fix verify_mok()

() Fix the return value semantics. If the MokList doesn't
exist, we are OK. If the MokList was compromised but we
were able to erase it, that is OK too. Only if the list
can't be nuked do we return an error.

() Fix use of potentially uninitialized attribute variable

() Actually use the return value when called from verify_buffer.

Change-Id: If16df21d79c52a1726928df96d133390cde4cb7e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
netboot.h: fix build error on 32-bit systems

Function prototype/implementation mismatch.

Change-Id: I89aaae1b49d0372d3aed76fc21c194e0ae55f72e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
add VerifyBlob to shim_lock protocol

Implement a generic binary verification function that doesn't assume
PE/COFF format. The binary data and the signature are passed
separately. A SHA256 hash is taken and the digest is verified using
the built-in shim and the vendor key.

shim has some functions to check black/white lists for
Authenticode-signed PE/COFF images. Introduce a layer of
abstraction so that we can choose what authentication function
we use. For blobs we're only checking SHA256 hashes for now.

OpenSSL errors are only printed if the entire verification
fails, as some errors may be expected when checking the
databases.

Change-Id: I46430bd9a598b93c1cc53ebcf650f12ae71fe494
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
shim.c: Add support for hashing/relocation of 32-bit binaries

Change-Id: Ib93305f7f1691d1b142567507df1058de62dde06
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
properly compile OpenSSL in 32-bit mode

Change-Id: Iff3ee5ae0f0b95b282b99a23e465723b4e9f6104
Signed-off-by: Andrey Petrov <andrey.petrov@intel.com>
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
fallback.c: fix 32-bit compilation

fh->Read expects pointer to 32-bit int, use UINTN

Change-Id: If1a728efd51a9a24dfcd8123e84bf4c0713491fe
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
fix fallback.so build dependency

Exposed during parallel builds

Change-Id: I9867858166dcafd69438f37ee5da14a267ace8f4
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
propagate some path variables

If these are overridden on the command line, pass them along to
the sub-makes.

Change-Id: I531ccb5d2f5e4be8e99d4892cdcfffffc1ad9877
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
allow 32-bit compilation with 64-bit compiler

Also removed unused LIB_PATH from some Makefiles.

Change-Id: I7d28d18f7531b51b6121a2ffb88bcaedec57c467
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
shim: improve error messages

%r when used in Print() will show a string representation of
an EFI_STATUS code.

Change-Id: I6db47f5213454603bd66177aca378ad01e9f0bd4
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
shim: load_image(): use relative and absolute paths

shim currently tries to load 2nd-stage from a path relative
to its own location. However, in an installed system we could
be using /shim.efi or /EFI/BOOT/BOOT{X64|IA32}.EFI. Rather
than have 2 copies of the other EFI binaries, also check
absolute paths.

This situation happens on very broken devices that do not
use the EFI Boot Manager and rely entirely on the presence
of EFI\BOOT\BOOT{X64|IA32}.EFI files; the shim stage loader
is copied to this location, but we shouldn't need to copy
all the other loaders in the root directory to EFI\BOOT.

Issue: ADEV-306
Change-Id: I6f245cce6abd154244a07c90a1e6380a5f406f3f
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>