Commit Graph

1500 Commits

Author SHA1 Message Date
Mathieu Trudel-Lapierre
ac05ece820 New upstream version 12+1502324945.478f9bb 2017-08-09 20:39:01 -04:00
Mathieu Trudel-Lapierre
33da8726b4 Fix typo for DEFAULT_LOADER: missing a backslash, also needs quoting. 2017-08-07 17:43:53 -04:00
Mathieu Trudel-Lapierre
5ca483b97b debian/patches/0001-shim-fix-the-mirroring-MokSBState-fail.patch: dropped, included upstream. 2017-08-07 17:43:08 -04:00
Mathieu Trudel-Lapierre
5d42729fe3 Define an EFI_ARCH variable, and use that for paths to shim. This makes it possible to build a shim for other architectures than amd64. 2017-08-07 17:42:42 -04:00
Mathieu Trudel-Lapierre
ea54c7675f debian/patches/sbsigntool-no-pesign: refreshed. 2017-08-07 17:42:12 -04:00
Mathieu Trudel-Lapierre
94190a1cd8 Set DEFAULT_LOADER; this makes second-stage-path unnecessary. 2017-08-07 17:39:45 -04:00
Mathieu Trudel-Lapierre
62a4fa2d31 * debian/rules:
- Update dh_auto_build/dh_auto_clean for new upstream options: set
    MAKELEVEL.
2017-08-07 17:39:07 -04:00
Mathieu Trudel-Lapierre
ba899c3d3c debian/control: add a Build-Depends on libnss3-tools for pk12-util. 2017-08-07 17:38:30 -04:00
Mathieu Trudel-Lapierre
11c5b79d30 New upstream snapshot: 12+1501864225.b586175. 2017-08-07 17:37:56 -04:00
Mathieu Trudel-Lapierre
25f7fd1fb3 New upstream version 12+1501864225.b586175 2017-08-07 17:35:43 -04:00
Mathieu Trudel-Lapierre
cd6457d07d Merge tag 'upstream/12+1501864225.b586175' into cyphermox/mokmanager
Upstream version 12+1501864225.b586175
2017-08-07 17:35:43 -04:00
Mathieu Trudel-Lapierre
f4173af1ad New upstream version 12+1501864225.b586175 2017-08-07 17:34:45 -04:00
Mathieu Trudel-Lapierre
f51c03c05b Merge branch 'master' into cyphermox/mokmanager
Update changelog entries/changes from Debian for 0.9+1474479173.6c180c6-1.
2017-08-07 17:28:51 -04:00
Mathieu Trudel-Lapierre
bd98c8fd1c Update changelog/changes for released 0.9+1474479173.6c180c6-1ubuntu1 2017-08-07 17:24:36 -04:00
Mathieu Trudel-Lapierre
3b43f33d71 Update changelog for released 0.9+1474479173.6c180c6-0ubuntu1 2017-08-07 17:21:03 -04:00
Julien Cristau
c117735c20 Import Debian changes 0.9+1474479173.6c180c6-1
shim (0.9+1474479173.6c180c6-1) unstable; urgency=medium

  [ Steve Langasek ]
  * Initial Debian upload.  Closes: #820052.
  * Update Standards-Version.
  * Embed the newly-minted Debian CA certificate.
  * Vendorize debian/rules so that the same package can be used in both
    Debian and Ubuntu without modification.
  * Fix debian/copyright to match the spec (last match wins, not first)
  * Fix shim.efi to not be executable.
  * Add watchfile.
  * Support parallel builds, because eh why not
  * Update Vcs-Bzr.
  * Resync with Ubuntu, including patch to fix debian/copyright.

  [ Julien Cristau ]
  * Add some missing copyright holders in d/copyright, update
    Upstream-Contact.  Thanks to Helen Koike for the help.

shim (0.9+1474479173.6c180c6-0ubuntu1) UNRELEASED; urgency=medium

  [ Helen Koike ]
  * debian/copyright: add OpenSSL license 

  [ Mathieu Trudel-Lapierre ]
  * New upstream release.
  * debian/copyright: patches should be BSD, like the rest of the upstream
    code.
  * debian/patches/unused-variable: dropped; applied upstream.
  * debian/patches/binutils-version-matching: dropped, fixed upstream.
  * debian/shim.install: built EFI binaries were renamed; update our install
    file to properly pick up shim (shim$arch), MokManager (mm$arch), and
    fallback (fb$arch).

shim (0.9+1465500757.14a5905-0ubuntu1) yakkety; urgency=medium

  * New upstream release.
    - Better handle LoadOptions. (LP: #1581299)
    - Measure state and second stage in TPM.
    - Mirror MokSBState in runtime as MokSBStateRT.
    - Fix failure to build with GCC 5. (LP: #1429978)
    - Various bug fixes and other improvements.
  * Refreshed patches.
    - Remaining patches:
      + second-stage-path
      + sbsigntool-not-pesign 
  * debian/patches/unused-variable: remove unused variable size.
  * debian/patches/binutils-version-matching: revert d9a4c912 to correctly
    match objcopy's version on Ubuntu.
  * debian/copyright: update copyright for patches.

shim (0.8-0ubuntu2) wily; urgency=medium

  * No-change rebuild against gnu-efi 3.0v-5ubuntu1.

shim (0.8-0ubuntu1) wily; urgency=medium

  * New upstream release.
    - Clarify meaning of insecure_mode. (LP: #1384973)
  * debian/patches/CVE-2014-3675.patch, debian/patches/CVE-2014-3677.patch,
    debian/patches/0001-Update-openssl-to-0.9.8za.patch: dropped, included
    in the upstream release.
  * debian/patches/sbsigntool-not-pesign,debian/patches/second-stage-path:
    refreshed.

shim (0.7-0ubuntu4) utopic; urgency=medium

  * SECURITY UPDATE: heap overflow and out-of-bounds read access when
    parsing DHCPv6 information
    - debian/patches/CVE-2014-3675.patch: apply proper bounds checking
      when parsing data provided in DHCPv6 packets.
    - CVE-2014-3675
    - CVE-2014-3676
  * SECURITY UPDATE: memory corruption when processing user-provided key
    lists
    - debian/patches/CVE-2014-3677.patch: detect malformed machine owner
      key (MOK) lists and ignore them, avoiding possible memory corruption.
    - CVE-2014-3677

shim (0.7-0ubuntu2) utopic; urgency=medium

  * Restore debian/patches/prototypes, which still is needed on shim 0.7
    but only detected on the buildds.
  * Update debian/patches/prototypes with some new declarations needed for
    openssl 0.9.8za update.

shim (0.7-0ubuntu1) utopic; urgency=medium

  * New upstream release.
    - fix spurious error message when fallback.efi is not present, as will
      always be the case for removable media.  LP: #1297069.
    - drop most patches, included upstream.
  * debian/patches/0001-Update-openssl-to-0.9.8za.patch: cherry-pick
    openssl 0.9.8za in via upstream.

shim (0.4-0ubuntu5) utopic; urgency=low

  * Install fallback.efi.signed as well, to lay the groundwork for fallback
    handling (wanted when we have to move a drive between machines, or when
    the firmware loses its marbles^W nvram).

shim (0.4-0ubuntu4) saucy; urgency=low

  * debian/patches/fix-tftp-prototype: pass the right arguments to
    EFI_PXE_BASE_CODE_TFTP_READ_FILE.
  * debian/patches/build-with-Werror: Build with -Werror to catch future
    prototype mismatches.
  * debian/patches/fix-compiler-warnings: Fix remaining compiler
    warnings in netboot.c.
  * debian/patches/tftp-proper-nul-termination: fix nul termination
    errors in filenames passed to tftp.
  * debian/patches/netboot-cleanup: roll-up of miscellaneous fixes to
    the netboot code.

shim (0.4-0ubuntu3) saucy; urgency=low

  [ Steve Langasek ]
  * Install MokManager.efi.signed in the package.
  * debian/patches/no-output-by-default.patch: Don't print any
    informational messages.  Closes LP: #1074302.

  [ Stéphane Graber ]
  * debian/patches/no-print-on-unsigned: Don't print an error message when
    validating an unsigned binary as that tends to hang Lenovo machines.
    (LP: #1087501)

shim (0.4-0ubuntu2) saucy; urgency=low

  * Add missing build-dependency on openssl.

shim (0.4-0ubuntu1) saucy; urgency=low

  * New upstream release.
  * Drop debian/patches/shim-before-loadimage; upstream has changed this to
    not call loadimage at all.
  * debian/patches/sbsigntool-not-pesign: Sign MokManager with
    sbsigntool instead of pesign.
  * Add a versioned build-dependency on gnu-efi.

shim (0~20120906.bcd0a4e8-0ubuntu4) quantal-proposed; urgency=low

  * debian/patches/shim-before-loadimage: Use direct verification first
    before LoadImage.  Addresses an issue where Lenovo's SecureBoot
    implementation pops an error message on any verification failure - avoid
    calling LoadImage at all unless we have to.

shim (0~20120906.bcd0a4e8-0ubuntu3) quantal; urgency=low

  * debian/patches/second-stage-path: Chainload grubx64.efi, not
    grub.efi.

shim (0~20120906.bcd0a4e8-0ubuntu2) quantal; urgency=low

  * debian/patches/prototypes: Include missing prototypes, and disable
    use of BIO_new_file.
  * Only build the package for amd64; we're not signing an i386 shim at this
    stage so there's no point in building it.

shim (0~20120906.bcd0a4e8-0ubuntu1) quantal; urgency=low

  * Initial release.
  * Include the Canonical Secure Boot master CA.
2017-08-04 12:10:50 -04:00
Mathieu Trudel-Lapierre
bbfd2ab18f Import Upstream version 0.9+1474479173.6c180c6 2017-08-04 12:10:50 -04:00
Peter Jones
631265b7e9 Add README.tpm to explain which PCRs we extend things to.
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-03 11:24:56 -04:00
Peter Jones
9abedc47f5 Add MokListX to MokVars.txt
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-03 11:00:58 -04:00
Peter Jones
431b8a2e75 Make fallback aware of tpm measurements, and reboot if tpm is used.
Since booting the entry with fallback in the stack of things that got
measured will result in all the wrong PCR values, in the cases where TPM
is present and enabled, use ->Reset() instead of loading the Boot####
variable and executing its target.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-03 11:00:58 -04:00
Peter Jones
2d82a3899b Make tpm.c build right on 32-bit platforms.
EFI_PHYSICAL_ADDRESS is UINT64 everywhere, so you can't just copy a
32-bit pointer to it.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-03 11:00:58 -04:00
Peter Jones
bdc5d3ec9c Always measure all of MokSBState, MokList, and MokListX
Even if errors occurred, always try to measure all of our Mok entries.
This way we won't fail on e.g. MokList not being set.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-03 11:00:58 -04:00
Matthew Garrett
22f2737535 Measure stage 2 according to spec
We're currently measuring the raw second stage loader into PCR 9, but
we're closer to spec if we measure the semi-parsed PE into PCR 4. The
hash that's logged is the same as the hash used for the Authenticode
validation, so refactor shim.c a little to separate out the hash
generation.
2017-08-03 11:00:58 -04:00
Matthew Garrett
8af7c4caca Extend PCR 7
It's desirable to be able to use PCR 7 for all TPM policy on Secure Boot
systems, but right now Shim doesn't record any information about its
configuration or the signature used to launch the second stage loader. Add
support for that.
2017-08-01 12:54:49 -04:00
Peter Jones
a8f3dc82be fallback.c: be more correct with device path code.
Rob Clark noticed while, implementing a UEFI like backend on u-boot,
that if a File Handle actually returns a meaningful device path from
DevicePathFromHandle(), we wind up with a horribly wrong device path in
the boot variable.  He's right, normal UEFI doesn't return that, which
means FileDevicePath() in our code currently does nothing at all.

Instead of all that, pass in the device's handle, and it'll do what
we're doing after the fact there.

Here's the log from a current run:

FS0:\> \efi\BOOT\BOOTX64.EFI
System BootOrder not found.  Initializing defaults.
find_boot_options:778:Found directory named "fedora"
try_boot_csv:532:Found file "\EFI\fedora\BOOT.CSV"
try_boot_csv:544:File looks like:
?shim.efi,Fedora,,This is the boot entry for Fedora

populate_stanza:495:CSV data: "shim.efi,Fedora,,This is the boot entry for Fedora"
populate_stanza:501:filename: "shim.efi"
populate_stanza:508:label: "Fedora"
populate_stanza:514:arguments: ""
add_to_boot_list:430:file DP: PciRoot(0)/Pci(0x1F,0x2)/Sata(0x0,0x0,0x0)/HD(Part1,Sig6584272A-D7B9-442A-B8A4-19B5EC4566F4)/\EFI\fedora\shim.efi
FindSubDevicePath:78:input device path: "PciRoot(0)/Pci(0x1F,0x2)/Sata(0x0,0x0,0x0)/HD(Part1,Sig6584272A-D7B9-442A-B8A4-19B5EC4566F4)/\EFI\fedora\shim.efi"
FindSubDevicePath:86:sub-path (4,1): "HD(Part1,Sig6584272A-D7B9-442A-B8A4-19B5EC4566F4)/\EFI\fedora\shim.efi"
add_to_boot_list:452:04 01 2A 00 01 00 00 00 00 08 00 00 00 00 00 00
add_to_boot_list:452:00 40 06 00 00 00 00 00 2A 27 84 65 B9 D7 2A 44
add_to_boot_list:452:B8 A4 19 B5 EC 45 66 F4 02 02 04 04 2E 00 5C 00
add_to_boot_list:452:45 00 46 00 49 00 5C 00 66 00 65 00 64 00 6F 00
add_to_boot_list:452:72 00 61 00 5C 00 73 00 68 00 69 00 6D 00 2E 00
add_to_boot_list:452:65 00 66 00 69 00 00 00 7F FF 04 00
add_to_boot_list:459:device path: "HD(Part1,Sig6584272A-D7B9-442A-B8A4-19B5EC4566F4)/\EFI\fedora\shim.efi"
Creating boot entry "Boot0000" with label "Fedora" for file "\EFI\fedora\shim.efi"
AddOption - Boot0000, then CurrentCount = 0x00000008
update_boot_order:390:nbootorder: 7
BootOrder: 0000 0002 0001 0003 0005 0006 0004

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-01 10:17:07 -04:00
Peter Jones
c0f7d13074 Make fallback debug printing be dynamic at runtime.
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-01 10:17:07 -04:00
Peter Jones
87c8f07e98 fallback: Minor whitespace cleanup
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-07-31 11:07:06 -04:00
Peter Jones
8a6d270d70 Make it possible to build in a subdirectory.
This lets you do:

mkdir build-x64 build-ia32
cd build-x64
make TOPDIR=.. -f ../Makefile
cd ../build-ia32
setarch i686 -B make ARCH=ia32 TOPDIR=.. -f ../Makefile

And not worry about generated sources and headers mixing and matching.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-07-24 20:11:28 -04:00
Lans Zhang
a1170bb00a README.fallback: correct the path of BOOT.CSV in layout example
BOOT.CSV should be placed in fedora directory in order to locate the base
directory of files recorded in $FILENAME column.

Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2017-07-24 14:12:31 -04:00
Peter Jones
d89b722ef7 Exit our dir->Read() loop if it says there's 0 bytes of data to read.
When dir->Read() says bs=0, we shouldn't try to allocate a buffer and
read into it. On edk2 this works because there's an implicit (possibly
accidental) minimum size of one pool list entry that can be allocated,
so you wind up getting (I think) 8 bytes.

When Rob Clark tried to run this under uboot's emulated UEFI
environment, dir->Read() returned 0 and when we passed that to
AllocateZeroPool() less good things happened.

So just check for that case and exit appropriately.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-07-24 14:02:37 -04:00
Peter Jones
c4aa058c2b Make ARCH overridable
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-07-18 15:43:27 -04:00
Lans Zhang
7d745e49c0 httpboot: fix OVMF crash
This is a typical typo. The free operation should be done if uri
was allocated.

Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2017-07-17 13:13:00 -04:00
Peter Jones
919c17a45f tpm2_present(): remove unused tpm2 protocol argument.
Signed-off-by: Peter Jones <pjones@redhat.com>
2017-06-20 16:41:44 -04:00
Javier Martinez Canillas
55c65546e4 shim/tpm: Avoid passing an usupported event log format to GetEventLogs()
The TCG EFI Protocol Specification for family "2.0" mentions that not all
TPM2 chips may support the EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 (crypto agile)
log format. So instead of always use this log format, the GetCapability()
function should be used to determine which format is supported by the TPM.

For example, the Intel PTT firmware based TPM found in Lenovo Thinkapd X1
Carbon (4th gen), only supports SHA-1 (EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2)
log format. So a call to GetEventLog() using the crypto agile format was
returning EFI_INVALID_PARAMETER, making tpm_log_event() function to fail.

This was preventing shim to correctly measure the second stage bootloader:

$ tpm2_listpcrs -L 0x04:9

Bank/Algorithm: TPM_ALG_SHA1(0x0004)
PCR_09: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

After passing a supported log format to GetEventLog(), it succeeds and so
shim is able to call the HashLogExtendEvent() EFI function correctly:

$ tpm2_listpcrs -L 0x04:9

Bank/Algorithm: TPM_ALG_SHA1(0x0004)
PCR_09: 07 5a 7e d3 75 64 ad 91 1a 34 17 17 c2 34 10 2b 58 5b de b7

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2017-06-15 11:30:22 -04:00
Javier Martinez Canillas
0baa915056 shim/tpm: Take out GetCapability() call from tpm2_present() logic
The EFI_TCG2_PROTOCOL.GetCapability() function is used to learn if a TPM2
chip is present. But the protocol capability information is also needed
for other reasons, for example to determine what event log formats are
supported by the firmware.

Take out the GetCapability() call from the tpm2_present() logic and reduce
that function to just checking if a TPM2 chip is available or not, so the
capabilities can later be used to determine the supported TPM log formats.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2017-06-15 11:30:22 -04:00
Javier Martinez Canillas
9c40fb7c05 shim/tpm: Remove magic numbers
When measuring data into the TPM and generating events logs, the event
type is set to EV_IPL (0xd), and for TPM1.2 the algorithm will always
be set to SHA-1 (0x4).

So, add some macro-defined constants for these instead of having them
as magic numbers to make the code more readable.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2017-06-15 11:30:22 -04:00
Lans Zhang
6d4498fb3b update verification_method if the loaded image is signed by shim/vendor cert
Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2017-06-15 11:30:11 -04:00
Lans Zhang
3537d91c61 become more friendly for the cross compilation
Allow to overwrite certain settings from the external.

Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2017-06-15 11:30:05 -04:00
Lans Zhang
71d927270a skip the error message when creating MokListRT if vendor cert is empty
EFI_NOT_FOUND will be returned when creating MokListRT if vendor cert is
empty. This is harmless, meaningless and skippable.

Signed-off-by: Lans Zhang <jia.zhang@windriver.com>
2017-06-15 11:29:51 -04:00
Max Resch
047242c624 fix compilerer errors in security policy
When compiling with -Werror security policy can't be compiled because of
type errors. This commit fixes this problem.
2017-06-15 11:21:04 -04:00
Peter Jones
ea5f7e1597 Bump version number to 12.
Since 87060b2fc effectively means signing with signtool.exe simply does
not work correctly, and that's sort of the biggest goal for shim, make
this version 12.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-04-27 10:58:33 -04:00
John S. Gruber
f481019157 Fix buffer overrun / damaged options passed to second_stage.
start is a UCS-2 character pointer and loader_len is a number of bytes.
Adjust loader_len to count characters before adding to the start pointer.
2017-04-27 10:58:33 -04:00
Peter Jones
5c3bf32908 Don't allow anything with a small alignment in our PE files.
When I added 4990d3f I inadvertantly made .data.ident and .rela.got
sections appear in the top-level section headers at file offsets not
aligned with PE->OptionalHeader.FileAlignment.  This results in a
section table that looks like:

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .eh_frame     00018648  0000000000005000  0000000000005000  00000400  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .text         00093f45  000000000001e000  000000000001e000  00018c00  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 .reloc        0000000a  00000000000b2000  00000000000b2000  000acc00  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .data.ident   000000e4  00000000000b3040  00000000000b3040  000ace40  2**5
                  CONTENTS, ALLOC, LOAD, DATA
  4 .data         000291e8  00000000000b4000  00000000000b4000  000ad200  2**5
                  CONTENTS, ALLOC, LOAD, DATA
  5 .vendor_cert  000003e2  00000000000de000  00000000000de000  000d6400  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .dynamic      000000f0  00000000000df000  00000000000df000  000d6800  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  7 .rela         0001aef8  00000000000e0000  00000000000e0000  000d6a00  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 .rela.got     00000060  00000000000faef8  00000000000faef8  000f1af8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .dynsym       0000ecd0  00000000000fb000  00000000000fb000  000f1e00  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

rather than:

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .eh_frame     00018118  0000000000005000  0000000000005000  00000400  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .text         00091898  000000000001e000  000000000001e000  00018600  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 .reloc        0000000a  00000000000b0000  00000000000b0000  000aa000  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .data         00028848  00000000000b1000  00000000000b1000  000aa200  2**5
                  CONTENTS, ALLOC, LOAD, DATA
  4 .vendor_cert  00000449  00000000000da000  00000000000da000  000d2c00  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .dynamic      00000100  00000000000db000  00000000000db000  000d3200  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  6 .rela         0001ae50  00000000000dc000  00000000000dc000  000d3400  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .dynsym       0000ea78  00000000000f7000  00000000000f7000  000ee400  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

(Note "File off" on sections #3 and #8 on the top one.)

This seems to work fine with edk2's loader and shim's loader, as well as
their Authenticode implementation, and pesign's as well.

While PE loaders seem to be fine with sections with alignments smaller
than PE->OptionalHeader.FileAlignment, MS's signtool.exe does ...
something else with them.  I'm not sure what.  What it definitely does
*not* do is extend the digest based on their file offset and size.

So just don't allow anything that small, and don't allow anything
smaller than SectionAlignment either, just to be on the safe side.
Since most of our stuff gets stripped into the debuginfo anyway, and
shim has relatively few sections, this should not be a very large
burden.

So just to be clear:

If you have a binary with a section that's not aligned on
PE->OptionalHeader.FileAlignment:

- pesign hashes it to A
- tiano hashes it to A
- shim hashes it to A
- signtool.exe hashes it to B

Because that makes sense.

This patch works around the bug in signtool.exe .

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-04-26 21:52:23 -04:00
Gary Lin
513cbe2aea Cryptlib: replace CryptPem with the Null version
CryptPem only provides one function: RsaGetPrivateKeyFromPem(). Since we
don't need to retrieve any private key, it's safe to disable the
function.

Signed-off-by: Gary Lin <glin@suse.com>
2017-04-11 10:42:19 -04:00
Gary Lin
e9cc33d6f2 Cryptlib: remove DES
Disable DES completely since it's already old and insecure.
This makes MokManager not support the DES based password hash but
probably no one is using it.

Signed-off-by: Gary Lin <glin@suse.com>
2017-04-11 10:42:19 -04:00
Gary Lin
80d49f758e Cryptlib: Remove MD4
MD4 is known to be insecure and shim never uses it.

Signed-off-by: Gary Lin <glin@suse.com>
2017-04-11 10:42:19 -04:00
Gary Lin
9bc647e2b2 Cryptlib: implement strcmp() and strcasecmp()
strcmp() and strcasecmp() are widely used in openssl. Implement those
two functions to eliminate the gcc warnings and the potential crash.

Signed-off-by: Gary Lin <glin@suse.com>
2017-04-11 10:42:19 -04:00
Gary Lin
ae75df6232 MokManager: Update to new openssl API
X509_get_notBefore -> X509_getm_notBefore
X509_get_notAfter  -> X509_getm_notAfter

Signed-off-by: Gary Lin <glin@suse.com>
2017-04-11 10:42:19 -04:00
Gary Lin
e883479f35 Cryptlib: amend the headers and fix signness
- Declare some functions in the proper headers
  + We missed them for a long time...

- Cast offsetof to UINTN
  + The original casting triggers the gcc warning since int can not
    present the offset for the 64bit machines.

- Cast the "char" array to "CHAR8 *" to avoid the gcc warnings

- Implement atoi correctly

Signed-off-by: Gary Lin <glin@suse.com>
2017-04-11 10:42:19 -04:00
Gary Lin
97469449fd Cryptlib: Include stddef.h in CrtLibSupport.h
The changes in the openssl headers cause the inclusion of
CrtLibSupport.h eariler than the inclusion of stddef.h, so "offsetof"
was defined twice and this caused the followling build error:

In file included from Cryptlib/Include/openssl/buffer.h:23:0,
                 from Cryptlib/Include/openssl/x509.h:22,
                 from shim.c:56:
/usr/lib64/gcc/x86_64-suse-linux/6/include/stddef.h:417:0: error: "offsetof" redefined [-Werror]
 #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)

In file included from Cryptlib/Include/limits.h:15:0,
                 from Cryptlib/Include/openssl/ossl_typ.h:13,
                 from Cryptlib/Include/openssl/x509.h:20,
                 from shim.c:56:
Cryptlib/Include/CrtLibSupport.h:192:0: note: this is the location of the previous definition
 #define offsetof(type, member) ( (int) & ((type*)0) -> member )

We can lower the priority of the gcc include path or just remove the
path, but this might cause problem since the path was introduced on
purpose(*). Instead, including stddef.h first is more feasible.

(*) d51739a416

Signed-off-by: Gary Lin <glin@suse.com>
2017-04-11 10:42:19 -04:00