Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3244DC433F5 for ; Fri, 14 Jan 2022 18:14:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B6EAD83420; Fri, 14 Jan 2022 19:14:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="OgH0tLWE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0B3FE8341A; Fri, 14 Jan 2022 19:14:08 +0100 (CET) Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 13ECC83457 for ; Fri, 14 Jan 2022 19:14:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x82b.google.com with SMTP id bb9so6049484qtb.5 for ; Fri, 14 Jan 2022 10:14:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ohfaI0g4DtBBSki/LgRHoz013rTKgAlWlTFNCTQRyOY=; b=OgH0tLWE7HF4xkLaXr8JN+h2jR3OztMZtnqlbnaw7HLST1s8qxm1sYNEewjEaaQVwZ Q3U30ouwd4dAw34W46Tcp1nWXtuYBKj7Cr1Tca+X8gftEhKoGh4T4cYW9LmOzEivC9j7 UKypUfWZQRAdcDK2EcwpAFBpiEI5FzSGPi/xw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ohfaI0g4DtBBSki/LgRHoz013rTKgAlWlTFNCTQRyOY=; b=BG7DWiecW6kjFbl0Xg4kPsueRQy/FO8LdnVEGqXXr4hDIKS512wJGmauSgAICaJ00F e50aOBI76qongPRgWW5Aw490NtfGlPQyXzEfjYOHG8PUiCHvo+w6hhl2XtzaEyNyxKsM D3a+V5CbinpbaoRF4D7C4fBzeml1Q8dikt1JiQQ6NauGmu/jPgMG31oJ5Xh3ZEmp4e1X EvsTSWKPB7ey9E+vhhI/WMx/WzYMgjPVM/BrtLegp1XmgjFIDVepPt/219AKsC6xV+FS N2VtznMveQuVtbfGio3yFbGGc6vKFziE0Hzyz42BizVoAXJD0OpVIyOQ+yprmEtKYa6i +Igg== X-Gm-Message-State: AOAM531xokKeoMp1eRY3KXAWkyaBC2FpqpR4f7ps6dCVcPWyP4iNPIAe 4Wz24GrniqhPq9dE3glT3HpCjg== X-Google-Smtp-Source: ABdhPJwHEoHrPP74NEglAz1zL5RvUgZETcQlWeuoWiVg9AC+30Cdf94LNz/hSNVdef4MJNDC2t5Fdg== X-Received: by 2002:ac8:5a01:: with SMTP id n1mr8751633qta.359.1642184042899; Fri, 14 Jan 2022 10:14:02 -0800 (PST) Received: from bill-the-cat (2603-6081-7b01-cbda-9533-0c51-a891-732b.res6.spectrum.com. [2603:6081:7b01:cbda:9533:c51:a891:732b]) by smtp.gmail.com with ESMTPSA id d77sm1947657qkg.11.2022.01.14.10.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 10:14:02 -0800 (PST) Date: Fri, 14 Jan 2022 13:14:00 -0500 From: Tom Rini To: Jamin Lin Cc: Alexandru Gagniuc , Simon Glass , Philippe Reynes , Sean Anderson , Thomas Perrot , open list , troy_lee@aspeedtech.com, steven_lee@aspeedtech.com Subject: Re: [PATCH v3 1/1] rsa: adds rsa3072 algorithm Message-ID: <20220114181400.GA1810710@bill-the-cat> References: <20211210060100.16521-1-jamin_lin@aspeedtech.com> <20211210060100.16521-2-jamin_lin@aspeedtech.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="HlL+5n6rz5pIUxbD" Content-Disposition: inline In-Reply-To: <20211210060100.16521-2-jamin_lin@aspeedtech.com> X-Clacks-Overhead: GNU Terry Pratchett X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 10, 2021 at 02:00:55PM +0800, Jamin Lin wrote: > 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. >=20 > Add test case in vboot for sha384 with rsa3072 algorithm testing. >=20 > Signed-off-by: Jamin Lin > --- > 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 ++++ > 6 files changed, 111 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 >=20 > diff --git a/include/u-boot/rsa.h b/include/u-boot/rsa.h > index 7556aa5b4b..bb56c2243c 100644 > --- a/include/u-boot/rsa.h > +++ b/include/u-boot/rsa.h > @@ -110,6 +110,7 @@ int padding_pss_verify(struct image_sign_info *info, > #define RSA_DEFAULT_PADDING_NAME "pkcs-1.5" > =20 > #define RSA2048_BYTES (2048 / 8) > +#define RSA3072_BYTES (3072 / 8) > #define RSA4096_BYTES (4096 / 8) > =20 > /* This is the minimum/maximum key size we support, in bits */ > diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c > index 83f7564101..4fe487d7e5 100644 > --- a/lib/rsa/rsa-verify.c > +++ b/lib/rsa/rsa-verify.c > @@ -588,6 +588,12 @@ U_BOOT_CRYPTO_ALGO(rsa2048) =3D { > .verify =3D rsa_verify, > }; > =20 > +U_BOOT_CRYPTO_ALGO(rsa3072) =3D { > + .name =3D "rsa3072", > + .key_len =3D RSA3072_BYTES, > + .verify =3D rsa_verify, > +}; > + > U_BOOT_CRYPTO_ALGO(rsa4096) =3D { > .name =3D "rsa4096", > .key_len =3D RSA4096_BYTES, > diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py > index 095e00cce3..b080d482af 100644 > --- a/test/py/tests/test_vboot.py > +++ b/test/py/tests/test_vboot.py > @@ -45,6 +45,8 @@ TESTDATA =3D [ > ['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], > ] > =20 > @pytest.mark.boardspec('sandbox') > @@ -180,10 +182,16 @@ def test_vboot(u_boot_console, name, sha_algo, padd= ing, sign_options, required, > name: Name of of the key (e.g. 'dev') > """ > public_exponent =3D 65537 > + > + if sha_algo =3D=3D "sha384": > + rsa_keygen_bits =3D 3072 > + else: > + rsa_keygen_bits =3D 2048 > + > util.run_and_log(cons, 'openssl genpkey -algorithm RSA -out %s%s= =2Ekey ' > - '-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)) > =20 > # Create a certificate containing the public key > util.run_and_log(cons, 'openssl req -batch -new -x509 -key %s%s.= key ' > diff --git a/test/py/tests/vboot/sign-configs-sha384.its b/test/py/tests/= vboot/sign-configs-sha384.its > new file mode 100644 > index 0000000000..2869401991 > --- /dev/null > +++ b/test/py/tests/vboot/sign-configs-sha384.its > @@ -0,0 +1,45 @@ > +/dts-v1/; > + > +/ { > + description =3D "Chrome OS kernel image with one or more FDT blobs"; > + #address-cells =3D <1>; > + > + images { > + kernel { > + data =3D /incbin/("test-kernel.bin"); > + type =3D "kernel_noload"; > + arch =3D "sandbox"; > + os =3D "linux"; > + compression =3D "none"; > + load =3D <0x4>; > + entry =3D <0x8>; > + kernel-version =3D <1>; > + hash-1 { > + algo =3D "sha384"; > + }; > + }; > + fdt-1 { > + description =3D "snow"; > + data =3D /incbin/("sandbox-kernel.dtb"); > + type =3D "flat_dt"; > + arch =3D "sandbox"; > + compression =3D "none"; > + fdt-version =3D <1>; > + hash-1 { > + algo =3D "sha384"; > + }; > + }; > + }; > + configurations { > + default =3D "conf-1"; > + conf-1 { > + kernel =3D "kernel"; > + fdt =3D "fdt-1"; > + signature { > + algo =3D "sha384,rsa3072"; > + key-name-hint =3D "dev"; > + sign-images =3D "fdt", "kernel"; > + }; > + }; > + }; > +}; > diff --git a/test/py/tests/vboot/sign-images-sha384.its b/test/py/tests/v= boot/sign-images-sha384.its > new file mode 100644 > index 0000000000..be1a9a653c > --- /dev/null > +++ b/test/py/tests/vboot/sign-images-sha384.its > @@ -0,0 +1,42 @@ > +/dts-v1/; > + > +/ { > + description =3D "Chrome OS kernel image with one or more FDT blobs"; > + #address-cells =3D <1>; > + > + images { > + kernel { > + data =3D /incbin/("test-kernel.bin"); > + type =3D "kernel_noload"; > + arch =3D "sandbox"; > + os =3D "linux"; > + compression =3D "none"; > + load =3D <0x4>; > + entry =3D <0x8>; > + kernel-version =3D <1>; > + signature { > + algo =3D "sha384,rsa3072"; > + key-name-hint =3D "dev"; > + }; > + }; > + fdt-1 { > + description =3D "snow"; > + data =3D /incbin/("sandbox-kernel.dtb"); > + type =3D "flat_dt"; > + arch =3D "sandbox"; > + compression =3D "none"; > + fdt-version =3D <1>; > + signature { > + algo =3D "sha384,rsa3072"; > + key-name-hint =3D "dev"; > + }; > + }; > + }; > + configurations { > + default =3D "conf-1"; > + conf-1 { > + kernel =3D "kernel"; > + fdt =3D "fdt-1"; > + }; > + }; > +}; > diff --git a/tools/image-sig-host.c b/tools/image-sig-host.c > index 8ed6998dab..d0133aec4c 100644 > --- a/tools/image-sig-host.c > +++ b/tools/image-sig-host.c > @@ -55,6 +55,13 @@ struct crypto_algo crypto_algos[] =3D { > .add_verify_data =3D rsa_add_verify_data, > .verify =3D rsa_verify, > }, > + { > + .name =3D "rsa3072", > + .key_len =3D RSA3072_BYTES, > + .sign =3D rsa_sign, > + .add_verify_data =3D rsa_add_verify_data, > + .verify =3D rsa_verify, > + }, > { > .name =3D "rsa4096", > .key_len =3D RSA4096_BYTES, With current master these tests run and fail: https://source.denx.de/u-boot/u-boot/-/jobs/376757 (and also fail for me when running locally), please re-check and resubmit, thanks. --=20 Tom --HlL+5n6rz5pIUxbD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmHhvWUACgkQFHw5/5Y0 tyy5IAv/Rt9erUE/DVLg4ENcBLhSPRE4Do2qOeDrMrWkI5waIm5rbESCZDYGNTJy m6FLAi/7NEDXRis4g5oB4YfRgX3KmyiOIH/QNsrkMsmwaMkM+kjqJpfCsgx2tbjB qA1Zdh3MLuR9XGx60XBhaxHGAZd2k5lQoSVK2tdV9W/EaiyGLvU4Pazf3oRdSJGN NK4DHk+Th3Mfxih4a/jGu3mpkfSiWnjh5+EXqW5/c1/OCaaD2GdNt/0yI4O8BIbf xR2E2gRSQWAicQa/IcZfvb9unI5pOKpEaDat/lU5UEI1fYquQ1H0c1XRkF3PsmGP QiB6NYb8i2uE1OJNshAXHXR6Ej4QSJFoarGkgBhEpy9R+N9LlG/YdFhKYjZZEL3g aRRsIoF5ydviEIIQ7lP155rpQvHTYCH8u7LB69t7SR2obexwZlkkLkrFUOnIgUg9 bSv9Y/mLPXhsSSGE3tub7Z2cynpCGsmLLCds1MJugvpWbtR4FZpwT1CGDBLLqjgZ D7RZZMxC =ABKb -----END PGP SIGNATURE----- --HlL+5n6rz5pIUxbD--