rsa: adds rsa3072 algorithm
v4 cover rsa: adds rsa3072 algorithm
Add to support rsa 3072 bits algorithm in tools for make-image signing at host side and add rsa 3072 bits verification in the image binary.
v4:
- Fix vboot test failed for sha384 with rsa3072
v3:
- Fix typo
- Add test case in vboot for rsa3072 testing
v2:
- update to send a single patch
Jamin Lin (1):
rsa: adds rsa3072 algorithm
configs/sandbox_defconfig | 1 + include/u-boot/rsa.h | 1 + lib/rsa/rsa-verify.c | 6 +++ test/py/tests/test_vboot.py | 12 +++++- test/py/tests/vboot/sign-configs-sha384.its | 45 +++++++++++++++++++++ test/py/tests/vboot/sign-images-sha384.its | 42 +++++++++++++++++++ tools/image-sig-host.c | 7 ++++ 7 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 test/py/tests/vboot/sign-configs-sha384.its create mode 100644 test/py/tests/vboot/sign-images-sha384.its
Signature · 1 line
2.17.1
PATCH v4 1/1 rsa: adds rsa3072 algorithm
Add to support rsa 3072 bits algorithm in tools for image sign at host side and adds rsa 3072 bits verification in the image binary.
Add test case in vboot for sha384 with rsa3072 algorithm testing.
--- configs/sandbox_defconfig | 1 + include/u-boot/rsa.h | 1 + lib/rsa/rsa-verify.c | 6 +++ test/py/tests/test_vboot.py | 12 +++++- test/py/tests/vboot/sign-configs-sha384.its | 45 +++++++++++++++++++++ test/py/tests/vboot/sign-images-sha384.its | 42 +++++++++++++++++++ tools/image-sig-host.c | 7 ++++ 7 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 test/py/tests/vboot/sign-configs-sha384.its create mode 100644 test/py/tests/vboot/sign-images-sha384.its
configs/sandbox_defconfig +1 -0
@@ -312,3 +312,4 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_SHA384=y
include/u-boot/rsa.h +1 -0
@@ -110,6 +110,7 @@ int padding_pss_verify(struct image_sign_info *info,#define RSA_DEFAULT_PADDING_NAME "pkcs-1.5"#define RSA2048_BYTES (2048 / 8) +#define RSA3072_BYTES (3072 / 8)#define RSA4096_BYTES (4096 / 8)/* This is the minimum/maximum key size we support, in bits */
lib/rsa/rsa-verify.c +6 -0
@@ -588,6 +588,12 @@ U_BOOT_CRYPTO_ALGO(rsa2048) = { .verify = rsa_verify, }; +U_BOOT_CRYPTO_ALGO (rsa3072) = { + .name ="rsa3072" , + .key_len =RSA3072_BYTES , + .verify = rsa_verify, +}; +U_BOOT_CRYPTO_ALGO (rsa4096) = { .name ="rsa4096" , .key_len =RSA4096_BYTES ,
test/py/tests/test_vboot.py +10 -2
@@ -45,6 +45,8 @@ TESTDATA = [ ['sha256-pss-pad', 'sha256', '-pss', '-E -p 0x10000', False, False], ['sha256-pss-required', 'sha256', '-pss', None, True, False], ['sha256-pss-pad-required', 'sha256', '-pss', '-E -p 0x10000', True, True], + ['sha384-basic', 'sha384', '', None, False, False], + ['sha384-pad', 'sha384', '', '-E -p 0x10000', False, False], ] @pytest.mark.boardspec('sandbox')
@@ -180,10 +182,16 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, name: Name of of the key (e.g. 'dev') """ public_exponent = 65537 + + if sha_algo == "sha384": + rsa_keygen_bits = 3072 + else: + rsa_keygen_bits = 2048 + util.run_and_log(cons, 'openssl genpkey -algorithm RSA -out %s%s.key ' - '-pkeyopt rsa_keygen_bits:2048 ' + '-pkeyopt rsa_keygen_bits:%d ' '-pkeyopt rsa_keygen_pubexp:%d' % - (tmpdir, name, public_exponent)) + (tmpdir, name, rsa_keygen_bits, public_exponent)) # Create a certificate containing the public key util.run_and_log(cons, 'openssl req -batch -new -x509 -key %s%s.key '
test/py/tests/vboot/sign-configs-sha384.its new file +45 -0
45 lines not on this page · raw message
test/py/tests/vboot/sign-images-sha384.its new file +42 -0
42 lines not on this page · raw message
tools/image-sig-host.c +7 -0
@@ -55,6 +55,13 @@ struct crypto_algo crypto_algos[] = { .add_verify_data = rsa_add_verify_data, .verify = rsa_verify, }, + { + .name = "rsa3072", + .key_len = RSA3072_BYTES, + .sign = rsa_sign, + .add_verify_data = rsa_add_verify_data, + .verify = rsa_verify, + }, { .name = "rsa4096", .key_len = RSA4096_BYTES,
Signature · 1 line
2.17.1
Quoted 8 lines · Jamin Lin
Add to support rsa 3072 bits algorithm in tools for image sign at host side and adds rsa 3072 bits verification in the image binary.
Add test case in vboot for sha384 with rsa3072 algorithm testing.
Signed-off-by Jamin Lin <[email protected]>
Quoted 11 lines
--- configs/sandbox_defconfig | 1 + include/u-boot/rsa.h | 1 + lib/rsa/rsa-verify.c | 6 +++ test/py/tests/test_vboot.py | 12 +++++- test/py/tests/vboot/sign-configs-sha384.its | 45 +++++++++++++++++++++ test/py/tests/vboot/sign-images-sha384.its | 42 +++++++++++++++++++ tools/image-sig-host.c | 7 ++++ 7 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 test/py/tests/vboot/sign-configs-sha384.its create mode 100644 test/py/tests/vboot/sign-images-sha384.its
Quoted 8 lines · Jamin Lin
Add to support rsa 3072 bits algorithm in tools for image sign at host side and adds rsa 3072 bits verification in the image binary.
Add test case in vboot for sha384 with rsa3072 algorithm testing.
Signed-off-by Jamin Lin <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom