[PATCH v4 0/7] efi_loader: secure boot: support intermediate certificates in signature

AKASHI Takahiro takahiro.akashi at linaro.org
Fri Jul 17 09:16:23 CEST 2020


Summary
=======
under the current implementation of secure boot merged in v2020.07,
UEFI subsystem verifies a signature using certificates that are coming
from signature dtabase, i.e. "db."

In real world, an image is signed by a signer, but its certificate
can also be signed by another CA and, if it is not self-signed, the latter
will be signed by yet another CA and so on. This is called a certificate
chain and any certificates in the middle of chain is called "intermediate"
certificates.

With this patch set applied on top of the current implementation,
UEFI subsystem will get capable of verifying intermediate certificates
being contained in a signature and authenticating an image in a chain
of trusted certificates.

Please note that we don't support RFC6131, or timestamp protocol, and so
if any certificate in the chain is found in the revocation list, i.e. dbx,
the image will unconditionally be disqualified from being loaded or run.

Patch structure
===============
Patch#1-#5: preparatory patches
Patch#6: main part
Patch#7: pytest

Prerequisite
============
All the required patches have been merged.
You can fetch the whole workable repository from here[1].

One patch[2] to sbsigntools must also be applied so that we wil be able
to sign an image with intermediate certificates. It is required here for
testing.

Test
====
- The added new pytest (test_signed_intca.py) passed locally.
- Travis CI passed, except the new pytest added here due to a new
  feature in sbsigntools as mentioned above.
  (the latest vesion is still running though.)

Misc
====
- checkpatch.pl makes several warnings against pkcs7_verify.c, but
  we will ignore them as it is a file imported from linux code.

[1] https://git.linaro.org/people/takahiro.akashi/u-boot.git efi/secboot
[2] https://groups.io/g/sbsigntools/message/23

v4 (July 17, 2020)
* rebased to Heinrich's efi-2020-10-rc4
* remove a already-merged patch
* (no functional change)
* modify conftest.py to align it with recent changes Heinrich made
  (patch#7)

v3 (Jul 10, 2020)
* rebased to Heinrich's (current) efi-2020-10-rc1 along with
  my follow-up patches
* add sanity checks in public_key_verify_signature() (Patch#2)
* smplify include headers in pkcs7_verify.c (Patch#4)
* fix timestamp issues in Test Case 2 and 3 (Patch#8)

v2 (June 16, 2020)
* add function descriptions (Patch#2, #6 and #7)
* pylint and autopep8 against pytest (Patch#8)

v1 (June 9, 2020)
* initial release
* on top of v2020.07-rc4

AKASHI Takahiro (7):
  lib: crypto: add public_key_verify_signature()
  lib: crypto: enable x509_check_for_self_signed()
  lib: crypto: import pkcs7_verify.c from linux
  lib: crypto: add pkcs7_digest()
  lib: crypto: export and enhance pkcs7_verify_one()
  efi_loader: signature: rework for intermediate certificates support
  test/py: efi_secboot: add test for intermediate certificates

 include/crypto/pkcs7.h                        |   9 +-
 include/crypto/public_key.h                   |   2 +-
 include/efi_loader.h                          |   8 +-
 lib/crypto/Kconfig                            |   3 +
 lib/crypto/Makefile                           |   1 +
 lib/crypto/pkcs7_verify.c                     | 654 ++++++++++++++++++
 lib/crypto/public_key.c                       |  70 +-
 lib/crypto/x509_cert_parser.c                 |   2 -
 lib/crypto/x509_public_key.c                  |  33 +-
 lib/efi_loader/Kconfig                        |   1 +
 lib/efi_loader/efi_image_loader.c             |   2 +-
 lib/efi_loader/efi_signature.c                | 385 +++++------
 lib/efi_loader/efi_variable.c                 |   5 +-
 test/py/tests/test_efi_secboot/conftest.py    | 134 +++-
 test/py/tests/test_efi_secboot/defs.py        |   8 +-
 test/py/tests/test_efi_secboot/openssl.cnf    |  48 ++
 .../test_efi_secboot/test_signed_intca.py     | 135 ++++
 17 files changed, 1266 insertions(+), 234 deletions(-)
 create mode 100644 lib/crypto/pkcs7_verify.c
 create mode 100644 test/py/tests/test_efi_secboot/openssl.cnf
 create mode 100644 test/py/tests/test_efi_secboot/test_signed_intca.py

-- 
2.27.0



More information about the U-Boot mailing list