rsa: add a more flexible way to support different hash algorithms (e.g. sha256)
PATCH v2 1/1 rsa: add a more flexible way to support different hash algorithms (e.g. sha256)
As proposed by Heiko I made some small changes and verified the patch with the checkpatch-script.
?
?
PATCH v2 1/1 rsa: add a more flexible way to support different hash algorithms (e.g. sha256)
Hello Andreas,
Am 27.11.2013 13:10, schrieb andreas at oetken.name:
Quoted 8 lines
As proposed by Heiko I made some small changes and verified the patch with the checkpatch-script.
Quoted 1 line
From
169f40e72fceb222bb15dd59c1337f42371e97a5Mon Sep 17 00:00:00 2001From: Andreas Oetken<[email protected]>
Date: Wed, 27 Nov 2013 13:09:19 +0100
Subject: [PATCH] Added rsa-sha256 support.
Could you fix your commit message?
Please write in the commit message why and what you have changed in your patch. After "---" you can write for example the changelog of your patch, see a detailed help for sending patches, here:
http://www.denx.de/wiki/U-Boot/Patches
Quoted 13 lines
Signed-off-by Andreas Oetken<[email protected]>--- common/image-sig.c | 33 +++++++++++++ include/image.h | 20 +++++++- include/rsa-checksum.h | 25 ++++++++++ include/rsa.h | 17 +++++++ lib/rsa/Makefile | 2 +- lib/rsa/rsa-checksum.c | 108 +++++++++++++++++++++++++++++++++++++++++++ lib/rsa/rsa-sign.c | 10 ++-- lib/rsa/rsa-verify.c | 80 +++++++++----------------------- test/vboot/sign-configs.its | 2 +- test/vboot/sign-images.its | 2 +- 10 files changed, 233 insertions(+), 66 deletions(-)
Quoted 2 lines
create mode 100644
include/rsa-checksum.h
create mode 100644lib/rsa/rsa-checksum.c
Hmm.. I tried to apply your patch, but I get:
pollux:u-boot hs [20131202] $ git am mbox
Wende an: rsa: add a more flexible way to support different hash algorithms (e.g. sha256)
fatal: fehlerhafter Patch bei Zeile 24
Anwendung des Patches fehlgeschlagen bei 0001 rsa: add a more flexible way to support different hash algorithms (e.g. sha256) Die Kopie des fehlgeschlagenen Patches befindet sich in:
/home/hs/ids/u-boot/.git/rebase-apply/patch
Wenn Sie das Problem gel?st haben, f?hren Sie "git am --resolved" aus.
Falls Sie diesen Patch auslassen m?chten, f?hren Sie stattdessen
"git am --skip" aus.
Um den urspr?nglichen Zweig wiederherzustellen und die Anwendung der
Patches abzubrechen, f?hren Sie "git am --abort" aus.
pollux:u-boot hs [20131202] $ git am --abort
pollux:u-boot hs [20131202] $ vi mbox
pollux:u-boot hs [20131202] $ patch -p1 < mbox
patching file common/image-sig.c
patch: **** malformed patch at line 49: #endif /* !USE_HOSTCC*/
pollux:u-boot hs [20131202] $
Can you have a look@this issue?
Beside of that, just some nitpicking comment:
[...]
Quoted 15 lines
include/rsa.h +7
-0@@ -15,6 +15,23 @@#include <errno.h> #include <image.h> +#define RSA2048_BYTES (2048 / 8) + +/** +* struct rsa_public_key - holder for a public key +* +* An RSA public key consists of a modulus (typically called N), the inverse +* and R^2, where R is 2^(# key bits).
include/rsa.h line 34
Quoted 10 lines
include/rsa.h +10
-0+*/ + +struct rsa_public_key { +uint len;/* Length of modulus[] in number of uint32_t */ +uint32_t n0inv;/* -1 / modulus[0] mod 2^32 */ +uint32_t *modulus;/* modulus as little endian array */ +uint32_t *rr;/* R^2 as little endian array */ +}; + +
only one empty line please.
Quoted 3 lines
include/rsa.h +0
-0#if IMAGE_ENABLE_SIGN /** * sign() - calculate and return signature for given input data
[...]
Quoted 12 lines
lib/rsa/rsa-checksum.c new file +6
-0@@ -0,0 +1,108 @@ +/* +* Copyright (c) 2013, Andreas Oetken. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +
lib/rsa/rsa-checksum.c line 16
Quoted 10 lines
lib/rsa/rsa-checksum.c new file +10
-0+#include <common.h> +#include <fdtdec.h> +#include <rsa.h> +#include <sha1.h> +#include <sha256.h> +#include <asm/byteorder.h> +#include <asm/errno.h> +#include <asm/unaligned.h> + +
only one empty line please.
lib/rsa/rsa-checksum.c line 19
Quoted 3 lines
lib/rsa/rsa-checksum.c new file +3
-0+/* PKCS 1.5 paddings as described in the RSA PKCS#1 v2.1 standard. */ + +
here too.. please fix globally.
[...]
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v2 1/1 rsa: add a more flexible way to support different hash algorithms (e.g. sha256)
Hi,
Quoted 7 lines · Heiko Schocher
Hello Andreas,
Am 27.11.2013 13:10, schrieb andreas at oetken.name:
Quoted 3 lines
As proposed by Heiko I made some small changes and verified the patch with the
checkpatch-script.
You can also use patman to generate, check and send your patch if you like.
I couldn't apply it due to the problems Heiko mentioned, but it looks promising. One I think I wonder if whether you could use the existing infrastructure in common/hash.c to select the hash algorithm?
Regards,
Simon
Quoted 144 lines
Quoted 7 lines
Quoted 3 lines
From
169f40e72fceb222bb15dd59c1337f42371e97a5Mon Sep 17 00:00:00 2001From: Andreas Oetken<[email protected]>
Date: Wed, 27 Nov 2013 13:09:19 +0100
Subject: [PATCH] Added rsa-sha256 support.Could you fix your commit message?
Please write in the commit message why and what you have changed in your patch. After "---" you can write for example the changelog of your patch, see a detailed help for sending patches, here:
http://www.denx.de/wiki/U-Boot/Patches
Quoted 14 lines
Signed-off-by Andreas Oetken<[email protected]>--- common/image-sig.c | 33 +++++++++++++ include/image.h | 20 +++++++- include/rsa-checksum.h | 25 ++++++++++ include/rsa.h | 17 +++++++ lib/rsa/Makefile | 2 +- lib/rsa/rsa-checksum.c | 108 +++++++++++++++++++++++++++++++++++++++++++ lib/rsa/rsa-sign.c | 10 ++-- lib/rsa/rsa-verify.c | 80 +++++++++----------------------- test/vboot/sign-configs.its | 2 +- test/vboot/sign-images.its | 2 +- 10 files changed, 233 insertions(+), 66 deletions(-)Quoted 2 lines
create mode 100644
include/rsa-checksum.h
create mode 100644lib/rsa/rsa-checksum.cHmm.. I tried to apply your patch, but I get:
pollux:u-boot hs [20131202] $ git am mbox
Wende an: rsa: add a more flexible way to support different hash algorithms (e.g. sha256)
fatal: fehlerhafter Patch bei Zeile 24
Anwendung des Patches fehlgeschlagen bei 0001 rsa: add a more flexible way to support different hash algorithms (e.g. sha256)
Die Kopie des fehlgeschlagenen Patches befindet sich in:
/home/hs/ids/u-boot/.git/rebase-apply/patch
Wenn Sie das Problem gel?st haben, f?hren Sie "git am --resolved" aus. Falls Sie diesen Patch auslassen m?chten, f?hren Sie stattdessen "git am --skip" aus.
Um den urspr?nglichen Zweig wiederherzustellen und die Anwendung der Patches abzubrechen, f?hren Sie "git am --abort" aus. pollux:u-boot hs [20131202] $ git am --abort
pollux:u-boot hs [20131202] $ vi mbox
pollux:u-boot hs [20131202] $ patch -p1 < mbox
patching filecommon/image-sig.c
patch: **** malformed patch at line 49: #endif /* !USE_HOSTCC*/pollux:u-boot hs [20131202] $
Can you have a look at this issue?
Beside of that, just some nitpicking comment:
[...]
Quoted 21 lines
include/rsa.h +6
-0@@ -15,6 +15,23 @@#include <errno.h> #include <image.h> +#define RSA2048_BYTES (2048 / 8) + +/** +* struct rsa_public_key - holder for a public key +* +* An RSA public key consists of a modulus (typically called N), the inverse
+ * and R^2, where R is 2^(# key bits).
+ */include/rsa.h +3
-0+ +struct rsa_public_key { +uint len;/* Length of modulus[] in number of
uint32_t*/include/rsa.h
Quoted 6 lines
include/rsa.h +6
-0+uint32_t n0inv;/* -1 / modulus[0] mod 2^32 */ +uint32_t *modulus;/* modulus as little endian array */ +uint32_t *rr;/* R^2 as little endian array */ +}; + +only one empty line please.
Quoted 3 lines
#if
IMAGE_ENABLE_SIGN
/**
*sign()- calculate and return signature for given input data[...]
Quoted 12 lines
lib/rsa/rsa-checksum.c new file +6
-0@@ -0,0 +1,108 @@ +/* +* Copyright (c) 2013, Andreas Oetken. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +lib/rsa/rsa-checksum.c line 16
Quoted 10 lines
lib/rsa/rsa-checksum.c new file +10
-0+#include <common.h> +#include <fdtdec.h> +#include <rsa.h> +#include <sha1.h> +#include <sha256.h> +#include <asm/byteorder.h> +#include <asm/errno.h> +#include <asm/unaligned.h> + +only one empty line please.
lib/rsa/rsa-checksum.c line 19
Quoted 3 lines
lib/rsa/rsa-checksum.c new file +3
-0+/* PKCS 1.5 paddings as described in the RSA PKCS#1 v2.1 standard. */ + +here too.. please fix globally.
[...]
bye,
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany