mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-01-12 12:12:13 +01:00
This adds a test that signs a FIT and verifies the signature with fit_check_sign. OpenSSL engines are typically for signing with external HW so it's not that straight-forward to simulate. For a simple RSA OpenSSL engine, a dummy engine with a hardcoded RSA 4096 private key is made available. It can be selected by setting the OpenSSL engine argument to dummy-rsa-engine. This can only be done if the engine is detected by OpenSSL, which works by setting the OPENSSL_ENGINES environment variable. I have no clue if dummy-rsa-engine is properly implementing what is expected from an RSA engine, but it seems to be enough for testing. For a simple PKCS11 engine, SoftHSMv2 is used, which allows to do PKCS11 without specific hardware. The keypairs and tokens are generated on the fly. The "prod" token is generated with a different PIN (1234 instead of 1111) to also test MKIMAGE_SIGN_PIN env variable while we're at it. Binman will not mess with the local SoftHSMv2 setup as it will only use tokens from a per-test temporary directory enforced via the temporary configuration file set via SOFTHSM2_CONF env variable in the tests. The files created in the input dir should NOT be named the same as it is shared between all tests in the same process (which is all tests when running binman with -P 1 or with -T). Once signed, it's checked with fit_check_sign with the associated certificate. Finally, a new softhsm2_util bintool is added so that we can initialize the token and import keypairs. On Debian, the package also brings libsofthsm2 which is required for OpenSSL to interact with SoftHSMv2. It is not the only package required though, as it also needs p11-kit and libengine-pkcs11-openssl (the latter bringing the former). We can detect if it's properly installed by running openssl engine dynamic -c pkcs11. If that fails, we simply skip the test. The package is installed in the CI container by default. Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
22 lines
647 B
Python
22 lines
647 B
Python
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
# Copyright 2025 Cherry Embedded Solutions GmbH
|
|
#
|
|
"""Bintool implementation for SoftHSMv2 (softhsm2-util)"""
|
|
|
|
from binman import bintool
|
|
|
|
|
|
class Bintoolsofthsm2_util(bintool.Bintool):
|
|
"""SoftHSMv2 -- support tool for libsofthsm2"""
|
|
def __init__(self, name):
|
|
super().__init__('softhsm2-util',
|
|
'SoftHSMv2 support tool for libsofthsm2',
|
|
version_args='-v')
|
|
|
|
def fetch(self, method):
|
|
"""Install softhsm2-util via APT """
|
|
if method != bintool.FETCH_BIN:
|
|
return None
|
|
|
|
return self.apt_install('softhsm2')
|