aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2023-03-19Version 0.9.5HEADv0.9.5masterJames Bottomley1-1/+1
Andreas Schwab (1): sbsigntool: add support for RISC-V 64-bit PE/COFF images Daniel Axtens (1): sbvarsign: do not include PKCS#7 attributes James Bottomley (1): Add support for openssl-3 Jeremi Piotrowski (1): Fix openssl-3.0 issue involving ASN1 xxx_it dann frazier (1): sbkeysync: Don't ignore errors from insert_new_keys() Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2022-06-13Fix openssl-3.0 issue involving ASN1 xxx_itJeremi Piotrowski1-1/+1
Use ASN1_ITEM_rptr() instead of taking the address of IDC_PEID_it. openssl-3.0 changed the type of TYPE_it from `const ASN1_ITEM TYPE_it` to `const ASN1_ITEM *TYPE_it(void)`. This was previously hidden behind OPENSSL_EXPORT_VAR_AS_FUNCTION but in 3.0 only the function version is available. This change should have been transparent to the application, but only if the `ASN1_ITEM_rptr()` macro is used. This change passes `make check` with both openssl 1.1 and 3.0. Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2022-06-13Add support for openssl-3James Bottomley2-3/+10
We're currently using a raft of APIs which trigger deprecation warnings, so add OPENSSL_API_COMPAT to the command line for openssl-3 to cause them not to break the build. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2022-03-04sbsigntool: add support for RISC-V 64-bit PE/COFF imagesnextAndreas Schwab3-1/+3
Signed-off-by: Andreas Schwab <schwab@suse.de> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2022-02-21sbvarsign: do not include PKCS#7 attributesDaniel Axtens1-1/+1
The UEFI spec (8.2.2 Using the EFI_VARIABLE_AUTHENTICATION_2 descriptor) includes the following information about constructing the PKCS#7 message for the authentication descriptor under point 4(g): SignedData.signerInfos shall be constructed as: ... - SignerInfo.authenticatedAttributes shall not be present. sbvarsign does not currently honour this, and generates a PKCS#7 message containing authenticated attributes. This is a snippet from OpenSSL's printout of a message I reconstructed from an auth file: signedAttrs: object: contentType (1.2.840.113549.1.9.3) set: OBJECT:pkcs7-data (1.2.840.113549.1.7.1) object: signingTime (1.2.840.113549.1.9.5) set: UTCTIME:Mar 2 11:20:21 2021 GMT object: messageDigest (1.2.840.113549.1.9.4) set: OCTET STRING: 0000 - 99 58 87 86 82 82 b6 4b-c4 6a e4 e5 6b .X.....K.j..k 000d - 51 39 ac c3 b8 21 24 30-0c 28 e6 e3 aa Q9...!$0.(... 001a - 5c 33 c1 80 3f d1 \3..?. Tell OpenSSL to stop adding attributes. This also brings sbvarsign in to line with sign-efi-sig-list. Signed-off-by: Daniel Axtens <dja@axtens.net> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-08-18sbkeysync: Don't ignore errors from insert_new_keys()dann frazier1-3/+5
If insert_new_keys() fails, say due to a full variable store, we currently still exit(0). This can make it difficult to know something is wrong. For example, Debian and Ubuntu implement a secureboot-db systemd service to update the DB and DBX, which calls: ExecStart=/usr/bin/sbkeysync --no-default-keystores --keystore /usr/share/secureboot/updates --verbose But although this seemed to succeed on my system, looking at the logs shows a different story: Inserting key update /usr/share/secureboot/updates/dbx/dbxupdate_x64.bin into dbx Error writing key update: Invalid argument Error syncing keystore file /usr/share/secureboot/updates/dbx/dbxupdate_x64.bin Signed-off-by: dann frazier <dann.frazier@canonical.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-06-11Version 0.9.4v0.9.4James Bottomley1-1/+1
AKASHI Takahiro (1): sbsign: allow for adding intermediate certificates James Bottomley (8): sbverify: fix verification with intermediate certificates Tests: Add intermediate certificate tests to the sign-verify cases Fix some openssl 1.1.0 deprecated functions sbvarsign: remove unused global variable sbverify: refer to unused function Fix errors on 32 bit Enable -Werror for builds docs: add man page for sbkeysync Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-06-06docs: add man page for sbkeysyncJames Bottomley2-2/+5
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-06-06Enable -Werror for buildsJames Bottomley1-1/+1
Now that all the build warnings are eliminated, make sure they don't come back Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-06-06Fix errors on 32 bitJames Bottomley2-3/+5
print format and signed conversion due to big hex types Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-06-06sbverify: refer to unused functionJames Bottomley1-4/+5
The function print_certificate_store_certs() is currently commented out leading to an unused function warning. Make verbose a level and call this function for levels > 1 (meaning you have to specify -v -v to see it). Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-06-06sbvarsign: remove unused global variableJames Bottomley1-1/+0
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-06-06Fix some openssl 1.1.0 deprecated functionsJames Bottomley6-0/+32
replace OPENSSL_config with OPENSSL_init_crypto and ASN1_STRING_data with ASN1_STRING_get0_data Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-06-05Tests: Add intermediate certificate tests to the sign-verify casesJames Bottomley5-13/+70
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-06-05sbverify: fix verification with intermediate certificatesJames Bottomley1-2/+2
sbverify is currently failing if an intermediate certificate is added on signing but the binary is verified with the singing certificate. It fails with X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY. This is happening because the x509_STORE only contains the signing certificate but the pkcs7 bundle in the binary contains the issuer certificate as well. Fix this by unconditionally approving any locally missing certificates on verify. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-06-05sbsign: allow for adding intermediate certificatesAKASHI Takahiro1-2/+48
SignedData can have multiple certificates, but the current implementation of sbsign only allows a single one (as a signer). With this patch, "-addcert" options will be available on command line to specify a file in which any number of intermediate certificates in PEM format can be concatenated. $ sign --key <key> --cert <cert> --addcert <morecerts> [...] image_file Background: I'm working on implementing UEFI secure boot on U-Boot and want to test my code against PE images with intermediate certificates in certificate chain. As far as I know, the only tool that supports it in signing is Microsoft's signtool.exe. So I'd like to have some corresponding tool on linux. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-01-09Version 0.9.3v0.9.3James Bottomley1-1/+1
James Bottomley (1): README: update git location and add mailing list information Laszlo Ersek (1): sbvarsign: fix "EFI_VARIABLE_AUTHENTICATION_2.TimeStamp.Year" assignment Steve McIntyre (1): Fix PE/COFF checksum calculation Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-01-09README: update git location and add mailing list informationJames Bottomley1-1/+15
Now that a Mailing list is set up, update the README to point to it and mention the new maintained git location for this fork. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2020-01-09sbvarsign: fix "EFI_VARIABLE_AUTHENTICATION_2.TimeStamp.Year" assignmentLaszlo Ersek1-1/+1
According to UEFI-2.8, section 8.3 "Time Services" / GetTime(), the "EFI_TIME.Year" field must be in the range [1900, 9999] (both bounds inclusive). It is not stated or even implied that "EFI_TIME.Year" would not be an absolute year number. According to POSIX, the "tm_year" field of "struct tm" is defined as "Years since 1900". In other words, "tm_year" is relative to 1900. In set_timestamp(), time() and gmtime() are suitable for populating "EFI_VARIABLE_AUTHENTICATION_2.TimeStamp", as the UEFI spec specifically requires a stamp expressed in the GMT (UTC) zone. But we still need to offset "tm->tm_year" by 1900 for filling in "timestamp->Year". So let's do that now. While this issue does not seem to affect upstream edk2, SetVariable() calls with payloads containing an invalid "EFI_VARIABLE_AUTHENTICATION_2.TimeStamp.Year" value do seem to be rejected at least on some Dell Inspiron machines (using a UEFI implementation from AMI). Reported-by: Eugene Khoruzhenko <ekhoruzhenko@absolute.com> Reported-by: Paulo Henrique Lacerda de Amorim <phlamorim@riseup.net> Ref: https://edk2.groups.io/g/devel/message/49402 Fixes: 953b00481f3957fc756a6dc7d10c570da32a08bc Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2019-07-27Fix PE/COFF checksum calculationSteve McIntyre1-5/+1
Only count the cert_table header once when performing the calculation and counting buffer sizes. The problem entered because of a mismerge of multiple signature support and "be1f3d8 Update the PE checksum field using the somewhat-underdocumented algorithm, so that we match the Microsoft implementation in our signature generation.". Originally image->cert_table held the full certificate table including the Microsoft _WINH_CERTIFICATE header and image->sigbuf pointed to the pkcs11 signature inside, so the two had to be checksummed separately. After multiple signature support, image->sigbuf points to the full certificate table because we now need the headers to decide where one signature ends and the next begins, so the correct checksum only needs to sum over the entire image->sigbuf. Signed-off-by: Steve McIntyre <93sam@debian.org> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2019-01-09Version 0.9.2v0.9.2James Bottomley1-1/+1
Fix fedora build Fix variable signing for current tianocore Fix image processing not to invalidate existing signatures Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2019-01-09src/image.c: remove alignment of regionsJames Bottomley1-2/+1
The old code forced region size to be aligned to the PECOFF file alignment parameter, which is correct according to the spec. However, the major UEFI platforms do not align up when checking the signature, so if the PECOFF binary being signed already contains a signature, realigning the sections will make the existing signature invalid. Fix this by relaxing the rule about aligning up (also eliminates complaints about some pecoff sections being misaligned). Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2019-01-09sbvarsign: use SignedData instead of PKCS7 for authenticated updatesJames Bottomley1-2/+2
The EFI standard is ambiguous about which one to use for variable updates (it is definite about using PKCS7 for signed binaries). Until recently, the reference platform, tianocore, accepted both. However after patch commit c035e37335ae43229d7e68de74a65f2c01ebc0af Author: Zhang Lubo <lubo.zhang@intel.com> Date: Thu Jan 5 14:58:05 2017 +0800 SecurityPkg: enhance secure boot Config Dxe & Time Based AuthVariable. The acceptance of PKCS7 got broken. This breakage seems to be propagating to the UEFI ecosystem, so update the variable signing tools to emit the SignedData type (which all previous EFI implementations accepted). Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2018-02-20Fix Fedora BuildGuy Lunardi2-2/+2
Of course, Fedora puts gnu-efi in yet another different, non-standard place Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2017-10-28Version 0.9.1v0.9.1James Bottomley1-1/+1
Add support for engine based keys Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2017-10-28sbsign, sbvarsign: support engine based private keysJames Bottomley4-6/+76
Add the ability to specify an engine to read the keyfile. For safety, we don't do the full dynamic engine support, but only use engines configured for use by the platform. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2017-10-19Version 0.9v0.9James Bottomley1-1/+1
This version builds correctly on openssl 1.1 and also includes functional autotests for every architecture. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2017-10-19Fix Debian 8 and Leap_42.1 buildsJames Bottomley1-0/+3
Older versions of openssl 1.0.0 don't have X509_STORE_CTX_get0_store so define that as well. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2017-10-19tests: Fix up to work on arbitrary architecturesJames Bottomley5-38/+56
The current test infrastructure is tied to x86/amd64. This means the tests always fail on a non-x86 architecture (like aarch64). Fix this by generating the efi binary directly from C code and removing the architectural restrictions in the Makefile.am. One of the consequences of this is that we no longer test ia32 on x86_64, but the difficulty of detecting which architectures can support 32 bit variants and generating them correctly from EFI c code is too great. We also need to exclude tests involving objdump from aarch64 since its bfd still doesn't have an efi_app_aarch64 target. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2017-10-19tests/detach-remove.sh: fix for i386 pecoff size problemsJames Bottomley1-1/+5
pecoff for i386 can be too short, so it gets padded for an accurate signature. Make sure the size comparison takes this into account to avoid spurious failures. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2017-10-19tests: fix up the generation of the test pecoff binary for gcc-7.2James Bottomley3-126/+7
newer versions of gcc have contained an efi target for a while so use it instead of hacking a linker script. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2017-10-19tests: fix signature resign/reattach test problemsJames Bottomley2-2/+10
The original tests to warn about overwriting signatures have never worked after the multiple signature code was added (because we add a new signature instead of overwriting the old one) update the tests to check instead for the signature addition. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2017-10-19Update OpenSSL API usage to support OpenSSL 1.1Ben Hutchings2-18/+41
Most structure definitions in OpenSSL are now opaque and we must call the appropriate accessor functions to get information from them. Not all the accessors are available in older versions, so define the missing accessors as macros. The X509_retrieve_match() function is no longer usable, as we cannot initialise an X509_OBJECT ourselves. Instead, iterate over the certificate store and use X509_OBJECT_get_type and X509_cmp to compare certificates.
2017-10-19make check: fix test environment problemJames Bottomley1-1/+2
autotest is very finicky. The environment can't be set up in SH_LOG_COMPILER, but have to be done in AM_TESTS_ENVIRONMENT instead, so fix this. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2017-10-19Add OPENSSL_config(NULL) to each binary to load openssl.cnfJames Bottomley5-0/+10
In the current framework for using engine based keys, the engine has to be loaded and initialised as part of the default engines. The only way this can happen for the TPM engine is if it is named in a config secion, so all the tools must read and act on the config file to be able to use TPM based keys. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2016-02-14Version: 0.8v0.8James Bottomley1-1/+1
This version works correctly on arm 32 and 64. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2016-02-12sbkeysync: don't include efi.hJames Bottomley1-2/+0
It causes the ARM build to crash (because of directives) and it's unnecessary in this file. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2016-02-12configure: build on armJames Bottomley1-1/+1
arm has a variety of uname -m forms, all beginning with arm, so use this to determine the EFI architecture Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2016-01-27sbverify: Clear out content for the signature we're buildingMathieu Trudel-Lapierre1-0/+4
OpenSSL 1.0.2e now actively checks for both data and contents being present for a certificate. Clear out contents so that we have only data, and run a chance of actually verifying the signature. Bug-Ubuntu: https://launchpad.net/bugs/1526959 Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2016-01-27Handle odd buffer lengths in checksumLinn Crosetto1-4/+7
Buffers of odd length can be passed to the checksum, for example signatures. csum_bytes uses a uint16_t so change the function to prevent overflowing the buffer, while taking the extra byte into account if the length is odd. Signed-off-by: Linn Crosetto <linn@hpe.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2016-01-27Support openssl 1.0.2b and aboveSteve Langasek1-0/+1
Newer versions of openssl return a different error with alternate certificate chains; update for compatibility. Signed-off-by: Marc Deslauriers <marc.deslauriers@canonical.com> Bug-Ubuntu: https://bugs.launchpad.net/bugs/1474541 Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2016-01-27sbsigntool: add support for ARM and Aarch64 PE/COFF imagesArd Biesheuvel2-5/+9
Note that for the ARM case, we are using IMAGE_FILE_MACHINE_THUMB (0x1c2) rather than IMAGE_FILE_MACHINE_ARM (0x1c0), as the latter refers to an older calling convention that is incompatible with Tianocore UEFI. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2016-01-27sbsigntool: fix handling of zero sized sectionsArd Biesheuvel1-17/+18
The loop that iterates over the PE/COFF sections correctly skips zero sized sections, but still increments the loop index 'i'. This results in subsequent iterations poking into unallocated memory. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2016-01-27sbsigntool: remove doubly defined IMAGE_FILE_MACHINE_AMD64Ard Biesheuvel1-1/+0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2016-01-27sbverify: add extra expiry errors to ignoreJames Bottomley1-1/+4
Original patch from: Steve Langasek <steve.langasek@canonical.com> The ubuntu version of the signature expiry patch ignores serveral more errors, so add them. Bug-Ubuntu: https://bugs.launchpad.net/bugs/1234649. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2016-01-27Update the PE checksum field using the somewhat-underdocumentedSteve Langasek2-1/+62
algorithm, so that we match the Microsoft implementation in our signature generation. [jejb: add endian to autogen.sh and fix for multi-sign] Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2015-01-06OBS add correcting definition of EFI_ARCHJames Bottomley1-1/+1
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-12-19Version 0.7v0.7James Bottomley1-1/+1
Change responsible person to James Bottomley Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-12-19sbsign, sbattach, sbverify: add multiple signature supportJames Bottomley5-125/+208
sbsign will sign an already signed binary (adding a signature at the end) sbverify has a new mode --list, for listing all the signatures and sbattach takes a --signum argument for --remove or --detach. Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-12-19sbverify: fix verificationJames Bottomley1-3/+6
no leaf is OK as is expired cert. Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-12-19Clear ssl errors after loading everytingJames Bottomley5-2/+26
This prevents a FIPS failure message if no FIPS module is loaded. Plus add -v as short form for --verbose in sbverify Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-12-19Fix for multi-signJames Bottomley1-1/+7
The new Tianocore multi-sign code fails now for images signed with sbsigntools. The reason is that we don't actually align the signature table, we just slap it straight after the binary data. Unfortunately, the new multi-signature code checks that our alignment offsets are correct and fails the signature for this reason. Fix by adding junk to the end of the image to align the signature section. Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2014-12-19image.c: clear image variableJames Bottomley1-0/+1
Not zeroing the image after talloc occasionally leads to a segfault because the programme thinks it has a signature when in reality it just has a junk pointer and segfaults. Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-11-14sbkeysync: add corrected efivars magicJeremy Kerr1-2/+3
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-10-11Version 0.6Jeremy Kerr1-1/+1
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-10-11sbverify: explicitly trust all certificates given in --cert argumentsJeremy Kerr1-0/+18
In line with the verification process in firmware, update our verify callback to explicitly trust all certificates that we load to our cert store. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-10-10sbverify: Add --verbose optionJeremy Kerr1-0/+67
Add an option to print the certificate & signature info while verifying a signed image. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-10-10Version 0.5Jeremy Kerr1-1/+1
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-10-08sbkeysync: change default efivarfs mountpoint to /sys/.../efivars/Jeremy Kerr2-1/+11
Proposed changes to the kernel will establish /sys/firmware/efi/efivars as the canonical mountpoint for the efivars filesystem. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-10-02Version 0.4Jeremy Kerr1-1/+1
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-10-02image: improve handling of unaligned section tablesJeremy Kerr1-0/+22
Rather than overrunning the heap, explicitly allocate the pad area for cases where we've aligned-up the section table sizes. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-10-02image: use data_size in cert table headerJeremy Kerr1-1/+1
Since we write the certificate table starting at data_size (not size), use this value when generating the cert table header. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-09-28image: improve section table parsingJeremy Kerr1-1/+10
Only add the endjunk region when we need to add data, and warn when we've got too much. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-09-28image: Allow variable sized data directoriesJeremy Kerr2-28/+44
The PE/COFF spec allows variable-sized data directories, which reduce the size of the optional header. While GNU ld always produces maximum-sized headers, the kernel's EFI_STUB code generates a smaller header size, which causes the image parsing code to abort. This change allows variable-sized optional headers, but checks for at least enough of an optional header to contain a CERT_TABLE data directory entry. We also rename struct image's aouthdr to opthdr, as it contains more than just the a.out fields. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-09-05sbvarsign: fix incorrect pointer in add_auth_descriptorJeremy Kerr1-1/+1
Brown paper bag time: we want to hash the variable data, not the stack. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-09-05sbvarsign: auth descriptor hash does not cover the \0 in the varnameJeremy Kerr1-4/+2
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: fix siglist iterationJeremy Kerr1-2/+2
We were updating siglist before incrementing i, and so aborting the siglist iteration earlier than necessary. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbvarsign: Improve default GUID choiceJeremy Kerr2-5/+22
For db and dbx, we want EFI_IMAGE_SECURITY_DATABASE. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24skkeysync: Add PK-handing codeJeremy Kerr1-8/+68
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Refactor signature database data structuresJeremy Kerr1-167/+137
Rather than having three sets of (firmware, filesystem) key databases, refactor into two sets of (kdk, db, dbx) databases. This allows us to add the PK later. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: fix invalid free in keystore_read_entryJeremy Kerr1-5/+3
We want to free path, not ke. We can also unify the error path. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Improve error handling in read_firmware_key_databaseJeremy Kerr1-3/+15
We should free filename, and buf on error. Also, check for the length of the file's data; we may be passed empty files, and end up with a negative len. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: insert new keysJeremy Kerr1-0/+92
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: print keystore before key databasesJeremy Kerr1-4/+5
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Find keys missing from firmware key databasesJeremy Kerr1-0/+92
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Rename struct keystore_entry->list to keystore_listJeremy Kerr1-5/+5
We want to collect keystore entries on a separate list, so rename the 'list' member to something more specific. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Generate and print key descriptionsJeremy Kerr1-13/+18
.. rather than printing the raw IDs. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: add comment to sigdb_iterateJeremy Kerr1-0/+8
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Change key_id to key_parseJeremy Kerr1-37/+25
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Print filesystem key databasesJeremy Kerr1-1/+13
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: read keystore into kdb->filesystem_keysJeremy Kerr1-13/+138
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Unify key_databaseJeremy Kerr1-71/+54
Use key_database as a generic container for both firmware & filesystem keys. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Add key_database->filesystem_keysJeremy Kerr1-4/+6
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: keystore -> fs_keystoreJeremy Kerr1-15/+15
To make it clear that these are key files. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: pass data buffer (instead of EFI_SIGNATURE_DATA) to key_idJeremy Kerr1-15/+14
We want to call key_id on file buffers too, which don't have the EFI_SIGNATURE_DATA encapsulation. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: add keystore_entry->rootJeremy Kerr1-4/+6
Helps to show where the keys are loaded from. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Add --keystore and --no-default-keystores optionsJeremy Kerr1-6/+40
Add a couple of options to configure the location we read keys from Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Add --verbose option and conditionally print debug outputJeremy Kerr1-11/+27
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Add keystore parsing functionsJeremy Kerr1-4/+124
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Add --efivars-dir option to specific different locations for var ↵Jeremy Kerr1-12/+24
files Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Add X509 key parsingJeremy Kerr1-0/+46
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: Add key ID data to print_key_database()Jeremy Kerr1-2/+7
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24sbkeysync: read & print signature databasesJeremy Kerr2-1/+403
Add some initial code to parse the EFI signature databases. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24Move EFI_CERT types to efivars.hJeremy Kerr2-10/+11
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-24fileio: Add fileio_read_file_noerror()Jeremy Kerr2-16/+27
We may want to read files which can be absent. In this case, we don't want to print an error. This change adds fileio_read_file_noerror(), which suppresses error output. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-23sbvarsign: Start with a default set of variable attributesJeremy Kerr1-5/+17
We're almost always going to want the attributes set to NON_VOLATILE | BOOTSERVICE_ACCESS | RUNTIME_ACCES | APPEND_WRITE, and TIME_BASED_AUTHENTICATED_WRITE is required. So, provide this as the default if no --attrs argument is specified. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-23efivars: Move EFI_VARIABLE_* attributes to efivars.hJeremy Kerr2-7/+26
Rather than making these private to sbvarsign, move the EFI_VARIABLE attribute defintions to efivars.h Since some of these are defined by gnu-efi, we need to protect the definitions with an #ifdef. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-22sbsiglist: fix signature size checkJeremy Kerr1-3/+2
Rather than checking the size with the EFI_SIGNATURE_DATA header, just check the data len. Also, fix the definition for the SHA256 size. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-22sbvarsign: WIN_CERTIFICATE.dwLength should include the header sizeJeremy Kerr1-1/+1
Despite what the Authenticode spec says ("dwLength is set to the length of bCertificate"), the MS var sign tool and EDK2 sources include the header in the dwLength size. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-22sbvarsign: Fix invalid sizeof() for zeroing timestamp dataJeremy Kerr1-1/+1
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-22sbsiglist: check for owner and type argumentsJeremy Kerr1-0/+12
..rather than segfaulting. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-14sbsiglist: Fix SignatureSizeJeremy Kerr1-1/+1
We need to allow for the GUID in EFI_SIGNATURE_DATA too. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-13image: use fileio_write_fileJeremy Kerr1-12/+1
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-13Remove unused gen-keyfiles sourceJeremy Kerr1-216/+0
gen-keyfiles isn't built, and has been replaced by sbsiglist. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-13docs: Create man pages for sbvarsign & sbsiglistJeremy Kerr3-2/+7
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-13Move sources to src/ subdirectoryJeremy Kerr22-46/+47
We have a number of source files now, so move them from the top level to src/ Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-13image: Use size of image data when writing imagesJeremy Kerr4-4/+26
When detaching a signature, we need to know the size of the non-signature data. So, add a data_size member to struct image, and populate it when we iterate through the section table. When writing the image, use data_size rather than size, so we don't unnecessarily add the (now unused) signature data. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-13image: always parse image regionsJeremy Kerr4-31/+30
Rather than only calling image_find_regions when we want to sign or verify image, call it when the image is loaded. We'll want to use the parse data later, which will require it to be present on all instances of an image. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-13Include efivars.h in automake infrastructureJeremy Kerr1-1/+2
make distcheck was failing due to a missing efivars.h in the dist tarball. Add it to common_SOURCES to include it. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-13tests: run tests for each archJeremy Kerr18-59/+136
Since we can sign i386 PE/COFF images, run the tests on both x86-64 and i386 binaries. We do this by moving test.pecoff to test-<arch>.pecoff, and using automake's parallel-test option to add a wrapper to each test execution. This wrapper calls each test once per arch (as defined in TEST_ARCHES), and checks for failures in any invocation. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-13image: Allow manipulation of i386 PE/COFF filesJeremy Kerr2-23/+89
Replace struct image->aouthdr with a union of the 32- and 64-bit a.out header definitions, and abstract the relevant parsing code into the image_pecoff_parse_{32,64} functions. We also move all references of data in the a.out header to these functions, so we don't need to lookup the machine types elsewhere. Based on a patch by Maxim Kammerer <mk@dee.su>. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-10Remove arch-specific coff headersJeremy Kerr5-134/+2
If we use IMAGE_FILE_MACHINE_AMD64 instead of AMD64MAGIC, we can avoid including the arch-specific coff/x86_64 header. Based on a patch from Maxim Kammerer <mk@dee.su>. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-10image: Prevent an uninitialized variable warningMaxim Kammerer1-0/+1
padlen variable in image_write() cannot be used uninitialized, but compiler is unable to determine that. Signed-off-by: Maxim Kammerer <mk@dee.su> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-10sbsiglist: Add utility for creating EFI_SIGNATURE_LISTsJeremy Kerr3-1/+295
KEK, db and dbx updates need to be written as EFI_SIGNATURE_LIST structures, so create a simple tool to create them. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-10fileio: Add fileio_write_fileJeremy Kerr2-0/+21
Add a convenience function for writing a single buffer to a file. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-10efivars: rename efi variable headerJeremy Kerr2-1/+1
We'd like to add some other definitions to this, so give it a more generic name. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-03fileio: Unify whole-file readsJeremy Kerr7-156/+88
We do whole-file reads in a few places, so unify to a fileio_read_file() function. To do this, we change the type of struct image->buf to a uint8_t *. Where we do pointer manipulation on the image buffer, we need a temporary void * variable. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-03fileio: Unify key & cert loadingJeremy Kerr6-88/+138
Rather than duplicating the key & certificate loading in each tool, unify it in a fileio object. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-03image: add functions to add and remove signaturesJeremy Kerr7-12/+56
Rather than setting ->sigbuf directly, add two functions to handle image signature addition and removal: image_add_signature(image, sig, sigsize); image_remove_signature(image); And warn when a signature is to be overwritten. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-02sbattach: fix --detachJeremy Kerr3-4/+31
sbattach --detach isn't working, as we're not properly setting sigbuf in image_pecoff parse. This change ensures we populate sigbuf when we find a valid cert table. Also, add a test case for this. Bug report & initial patch from from Steve Langasek. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-02sbattach: fix missing openssl/evp.h headerJeremy Kerr1-0/+1
sbattach.c was generating a warning on compile: ../sbattach.c: In function ‘main’: ../sbattach.c:247:2: warning: implicit declaration of function ‘OpenSSL_add_all_digests’ [-Wimplicit-function-declaration] OpenSSL_add_all_digests is defined in evp.h, so add the #include. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-08-02sbvarsign: First cut of a variable-signing toolJeremy Kerr5-3/+706
Add sbvarsign, to sign variables to be passed to the efivars filesystem. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-28Version 0.3Jeremy Kerr1-1/+1
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-28license: Add OpenSSL exception to GPLv3 termsJeremy Kerr9-621/+744
We're using OpenSSL, so need to grant binary distrbutors permission to link with it. Cleared with current contributors. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-28COPYING: remove non-license textJeremy Kerr1-53/+0
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-28image: fix signature calculation when there's junk at the end of the efi binaryJames Bottomley1-4/+17
The current gnu efi generation tools insist on leaving junk at the end of the binary. According to the authenticode spec, we have to include this in the hash otherwise signature verification fails, so add the end junk to the calculation of the hash. I've verified that with this fix (and another one to get objcopy to align the sections correctly) we can now sign gnu tools generated efi code with tianocore r13466 Signed-off-by: James Bottomley <JBottomley@Parallels.com> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-28tests: Add test for PE/COFF cert table header validityJeremy Kerr2-1/+73
Add a test to check the validity of the certificate table header, ensuring that parsing the header gives us the valid certificate. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-28image: fix incorrect assumption about signature headerJames Bottomley2-2/+3
The sbsign tools appear to assume that WIN_CERTIFICATE.dwLength is the length of the signature. It's not, it's the length of the signature plus the length of the WIN_CERTIFICATE header. UEFI Version 2.3.1, Errata A explicitly states this in section 27.2.5 (Code Definitions). I found this because I've been playing around with the tianocore secure boot UEFI images and I couldn't get efi binaries signed with your tools to verify. When you apply the fix, I've got the binaries to verify (at least with X509 KEK signatures). Signed-off-by: James Bottomley <JBottomley@Parallels.com> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-28sbsign: handle errors from PKCS7_sign_add_signer()Jeremy Kerr1-0/+5
Rather than causing a segfault (si == NULL), report an error and exit. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-27sbsign: fix failure to sign when key is password protectedJames Bottomley1-0/+1
The current incarnation of sbsign doesn't all all ciphers to OpenSSL meaning that if the private key is encrypted, it can't decrypt it and instead it returns the unhelpful error message error reading private key ../certs/PK.key Fix this by adding all ciphers before trying to read the private key. Signed-off-by: James Bottomley <JBottomley@Parallels.com> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-20configure: Add check for bfh.hIvan Hu1-0/+4
We need bfd.h for the image object, so add a check for it in configure.ac. Signed-off-by: Ivan Hu <ivanh.hu@canonical.com> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-19tests: Add a test to check invalid PKCS7 signature attachingIvan Hu2-1/+17
Add a test for the invalid PKCS7 signature attaching. This test generates 1K of zero bytes as an invalid signature to attach. Signed-off-by: Ivan Hu <ivan.hu@canonical.com> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-19sbattach: Check that attached signatures are valid PKCS7 dataIvan Hu1-0/+25
Check detached signatures to ensure that we're attaching a valid PKCS7 object. If no, show a warning message and skip the attach action. Signed-off-by: Ivan Hu <ivan.hu@canonical.com> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-14sbverify: Use a variable for image filenameJeremy Kerr1-4/+6
... rather than using argv[optind] multiple times. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-13image: Unconditionally parse PE/COFF dataJeremy Kerr5-52/+51
Rather than requiring an explicit image_pecoff_parse, do it unconditionally in image_load. We don't have any instances where we need to do this separately. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-13sbverify: Check for failed image loadJeremy Kerr1-0/+5
Currently, sbverify will segfault when it can't load an image file, as the image is used unconditionally. This change adds a check to ensure we continue with a valid image pointer. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-13tests: Add tests for missing image, cert & key filesJeremy Kerr6-1/+68
Currently causes a segfault in verify-missing-image.sh. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-13tests: Execute tests in a clean (temporary) directoryJeremy Kerr4-17/+22
Instead of executing in the current (build) directory, create a temporary directory and change into it before running any tests. This ensures that tests aren't relying on left-overs from previous test runs. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-13tests: Use COMPILE.S for assembing test objectJeremy Kerr1-1/+1
Currently, ASFLAGS is not used, as we call $(AS) directly. Use $(COMPILE.S) instead. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-13Version 0.2Jeremy Kerr1-1/+1
We have a new tool (sbattach) now, so bump to version 0.2. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-13docs: Add simple manpage for sbattachJeremy Kerr2-2/+4
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-13automake: Clean generated man filesJeremy Kerr1-0/+1
`make distcheck` fails with the following error: ERROR: files left in build directory after distclean: ./docs/sbverify.1 ./docs/sbsign.1 This change adds a CLEANFILES rule for the generated manpages. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-13tests: Add a few simple testsJeremy Kerr9-2/+158
Add a few tests for the sign, verify, attach and detach code. These require some additional infrastructure to create a sample PE/COFF executable, plus a key & cert for testing. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-13Remove unused test.c fileJeremy Kerr1-2/+0
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-12sbattach: Add too to manage detached signaturesJeremy Kerr2-1/+241
Add a third tool (`sbattach`) to attach and detach signatures from PE/COFF files. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-12image: Add facility to write unsigned imagesJeremy Kerr3-12/+23
Change image_write_signed to image_write, and conditionally write the signature if one is present. This will allow us to write unsigned images when detaching a sig from an image. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-11sbsign,sbverify: Update getopt_long optstringsJeremy Kerr2-2/+2
The optstrings for sbsign and sbverify are out of sync with the long options, this change brings them up to date. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-11sbverify: Add support for detached signaturesJeremy Kerr1-3/+64
Allow sbverify to read PKCS7 data from a separate file with the '--detached <file>' option. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-11sbverify: Split image signature table reading to separate functionJeremy Kerr1-8/+26
We'd like to read detached signatures too, so split the signature-buffer-reading code into a separate function. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-11Fix warnings from added -W flagsJeremy Kerr3-10/+40
Fix a few warnings: idc.c: In function ‘IDC_get’: idc.c:248:12: warning: ‘idclen’ may be used uninitialised in this function [-Wuninitialized] image.c: In function ‘image_load’: image.c:37:15: warning: unused variable ‘bytes_read’ [-Wunused-variable] Plus, a bunch of strict-aliasing warnings: image.c:101:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] [ similar warnings trimmed ] when compiling image.c. Since struct external_PEI_DOS_hdr uses char[] types for all members, we need to use accessors here. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-11automake: Add -Wall -Wextra CFLAGSJeremy Kerr1-2/+4
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-11sbsign: Add --detached option to create detached PKCS7 signaturesJeremy Kerr3-3/+37
Add an option (--detached) to sbsign, which creates a detached signature, rather than embedding it in the PE/COFF signature table. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-11sbsign: fix flag for verbose operationJeremy Kerr1-1/+1
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-06-11docs: Fix manpage creationJeremy Kerr2-2/+3
$(builddir) should be $(top_builddir), and we need a valid definition of MKDIR_P to create the docs. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-29autogen.sh: Fix ccan_module assignmentAdam Conrad1-1/+1
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-28image: use read_write_all from ccanJeremy Kerr2-38/+12
Rather than using our own functions for reading/writing an entire buffer, use ccan's. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-28image: Fix format specifier for 32-bit buildsJeremy Kerr1-2/+2
Use %t rather than assuming typeof(ptr - int) == unsigned long. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-28autoconfiscateJeremy Kerr7-112/+129
Add autoconf & automake metadata, plus required files for automake to run without complaint. Requires an update to ccan, to get the --build-type argument to create-ccan-tree. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-24docs: Add initial manpagesJeremy Kerr3-2/+17
Mostly generated from help2man output. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-24sbsign,sbverify: help2man-ize usage outputJeremy Kerr3-15/+47
Update the usage output of sbsign and sbverify so that it can be better parsed by help2man. Also, add --version and --help. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-24Makefile: Add dist targetsJeremy Kerr1-0/+24
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-24ccan: Add ccan import logicJeremy Kerr2-3/+32
Add make logic to import lib/ccan from lib/ccan.git. We need to set some dependencies on $(obj) to ensure the the ccan headers are available before starting the main build. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-24Move ccan submoduleJeremy Kerr3-3/+2
Move the ccan git submodule to lib/ccan.git, so we can use ccan's create-ccan-tree utility. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-15Remove unused headerJeremy Kerr1-12/+0
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-14Remove pkcs7-simple test fileJeremy Kerr1-59/+0
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-14Makefile: add install targetJeremy Kerr1-0/+12
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-14Makefile: Comment componentsJeremy Kerr1-2/+3
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-14sbverify: clean up openssl initJeremy Kerr1-3/+1
Remove a duplicate call to ERR_load_crypto_strings, and move the digest init earlier. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-14sbverify: add check for invalid PKCS7 dataJeremy Kerr1-2/+7
Make sure d2i_PKCS7 returned a PKCS7 structure. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-14sbverify: Add certificate chain verificationJeremy Kerr1-6/+100
Add an option (--cert <file>) to specify a root certificate (or certificates) to use as a trusted CA. Verification can be disabled with --no-verify. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-12verify: move idc-related parsing to idc.cJeremy Kerr3-27/+46
Extract the IDC-parsing code from IDC_check_hash, and use it to initialise a BIO. This BIO can then be used to perform the PKCS7 verification. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-12sbsign: fix incorrect check for certificate loadJeremy Kerr1-1/+1
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-12image: reformat gap warningsJeremy Kerr1-3/+13
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-12image: add cert table to image sizeJeremy Kerr1-1/+1
Don't warn when the certificate table is the only un-hashed data. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-12sbverify: Add check for image hashJeremy Kerr4-5/+77
Add a check to match the calculated image's hash against the one found in the PKCS7 IndirectDataContext Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-12sbverify: check for presence of signature tableJeremy Kerr1-0/+6
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-12Makefile: add $(tools) varJeremy Kerr1-2/+4
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-12sbsigntool -> sbsignJeremy Kerr2-4/+4
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-05-12image: open output file with O_TRUNCJeremy Kerr1-1/+1
Prevents weirdness when overwriting old files. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-04-24sbsigntooL: expand usage infoJeremy Kerr1-1/+10
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-04-24Add GPLv3 text in COPYINGJeremy Kerr1-0/+674
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-04-24coff: remove unneeded coff includesJeremy Kerr37-8435/+0
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-04-23Add copyright commentsJeremy Kerr7-2/+126
GPLv3; the sources include parts of binutils, include parts of ccan, and have been partially based of osslsigntool. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-04-23image: warn about potential checksum differencesJeremy Kerr1-1/+14
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-04-23idc: allocate using the image contextJeremy Kerr1-2/+2
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
2012-04-23Initial commitJeremy Kerr56-0/+11468
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>