-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] MbedTLS integration (MbedTLS as a git submodule) #4
base: master
Are you sure you want to change the base?
Conversation
ed544cf
to
2a264df
Compare
Milestone 1: |
Add mbedtls as a submodule. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
25b0a46
to
7590093
Compare
EFI Secure Boot requires the MicroSoft Authenticate Code and Authenticate Attributes for verifying a signed PE image, while MbedTLS does not support these attributes naturally. |
7590093
to
5ba14fe
Compare
Milestone 2: |
7efa4ac
to
4d9a05d
Compare
Optimized target size by disabling unused features in MbedTLS config. |
919542d
to
c21d446
Compare
c21d446
to
2090f05
Compare
Fixed Makefile minor issue. |
2090f05
to
cd8f332
Compare
Fixed MbedTLS PKCS7 test suites failures: We are only supporting the Context Data format that is expected by EFI Loader. Other than that (e.g. "Inlined Content Info" that represented by Updated MbedTLS test suites to support PKCS7 with multiple certs. |
Take mbedtls LTS release from tag v3.6.0 Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Retrieve all git submodules before building Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
cd8f332
to
9c72561
Compare
Port mbedtls with dummy libc header files. Add mbedtls default config header file. Add mbedtls kbuild makefile. Add Kconfig and mbedtls config submenu. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Apply MbedTLS patch if any exist before building. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Add text section alignment to fix sbsign signing warning 'gaps in the section table may result in different checksums' which causes a failure of efi_image_verify_diges() Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Fix a permission issue when running virt-make-fs Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Remove the redundant includes of u-boot/md5.h, u-boot/sha1.h, u-boot/sha256.h and u-boot/sha512.h Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Remove the redundant includes of u-boot/sha1.h, u-boot/sha256.h and u-boot/sha512.h Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Create a hash shim layer on top of mbedtls crypto library. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Integrate common/hash.c on the hash shim layer so that hash APIs from mbedtls can be leveraged by boot/image and efi_loader. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Add the mbedtls include directories into the build system. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
When MBEDTLS_LIB_CRYPTO is enabled, use the APIs of sha256 from hash shim layer instead. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
When MBEDTLS_LIB_CRYPTO is enabled, use the APIs of sha256 from hash shim layer instead. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Added patches for MBedTLS PKCS7 parser to support MicroSoft Authenticate Code with Authenticate Attributes. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Add mbedtls patch to support multiple signer's certs in the signed data within a PKCS7 message. Update the related MbedTLS test suites. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Integrate function public_key_verify_signature on top of MbedTLS pk library. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Integrate x509_cert_parser on top of MbedTLS x509 library. Add API x509_populate_cert and x509_populate_pubkey for code reusability between x509 and pkcs7 parsers. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Integrate PKCS7 parser on top of MbedTLS PKCS7 library. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Integrate MicroSoft Authenticate Code parser on top of MbedTLS ASN.1 decoder. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
When building with MbedTLS, we are using MbedTLS to decode ASN1 data for x509, pkcs7 and mscode. So we can remove the dependence on ASN1 decoder when MBEDTLS_LIB_X509 is enabled. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Disable the unused features of MbedTLS to reduce the target size. Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Enable MbedTLS as default setting for qemu arm64 Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
a003176
to
f2deb7e
Compare
Rebased all patches on top of MbedTLS v3.6.0 LTS. |
This is the initial PR to integrate MbedTLS into U-Boot.
What are changed with this patch set:
CONFIG_MBEDTLS_LIB
as a main switch for enabling MbedTLS,CONFIG_MBEDTLS_LIB_CRYPTO
,CONFIG_MBEDTLS_LIB_X509
andCONFIG_MBEDTLS_LIB_TLS
for enabling the subset libraries Crypto, X509 and TLS respectively).common/hash
, which is used byboot/image
andefi_loader
, etc, whenCONFIG_MBEDTLS_LIB_CRYPTO
is enabled.efi_image_verify_digest()
.CONFIG_MBEDTLS_LIB_CRYPTO
is enabled, since they are widely being used by arch/platform/driver codes at the moment, but idealy all of them should be replaced eventually whenCONFIG_MBEDTLS_LIB_CRYPTO
is enabled.CONFIG_MBEDTLS_LIB_X509
is enabled (lib/crypto/rsa_helper, lib/rsa and lib/asn1_decoder are still being built for modules other than the EFI loader).Below MbedTLS configs are added into qemu_arm64_defconfig
To build:
Tested through below steps for EFI Secure Boot:
Sign a test EFI image (helloworld.efi)
sbsign --key db.key --cert db.crt --output helloworld-signed.efi helloworld.efi
Verify the signature:
sbverify --cert db.crt helloworld-signed.efi
Create a GPT image (test_efi_secboot.img) that contains the signed test EFI image (helloworld-signed.efi) and the UEFI certs
sudo virt-make-fs --partition=gpt --size=+1M --type=vfat <DIR_OF_CERTS_AND_EFI_IMAGE> test_efi_secboot.img
Launch QEMU with the GPT image (test_efi_secboot.img) mounted as a virtio device
qemu-system-aarch64 -bios u-boot.bin -machine virt -cpu cortex-a57 -smp 1 -m 4G -d unimp -nographic -serial mon:stdio -semihosting -drive if=none,file=test_efi_secboot.img,format=raw,id=hd0 -device virtio-blk-device,drive=hd0
Load PK from virtio device
load virtio 0:1 90000000 PK.auth && setenv -e -nv -bs -rt -at -i 90000000:$filesize PK
Load KEK/db/dbx from virtio device respectively and each of them should be verified successfully.
The signed EFI image should be verified and boot successfully.
Also tested through EFI Secure Boot sandbox test by: