Skip to content

Commit a5f28c1

Browse files
taltenbachd3zd3z
authored andcommitted
bootutil: Add SHA-512 support to Ed25519
When Ed25519 signatures are used, the bootutil_verify_sig responsible for verifying a signature was expecting as argument the SHA-256 digest of the firmware image. This commit slightly modifies this routine to make possible to use Ed25519 with SHA-512 digests. Signed-off-by: Thomas Altenbach <[email protected]>
1 parent 601463d commit a5f28c1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: boot/bootutil/src/image_ed25519.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "bootutil_priv.h"
1919
#include "bootutil/crypto/common.h"
20+
#include "bootutil/crypto/sha.h"
2021

2122
static const uint8_t ed25519_pubkey_oid[] = MBEDTLS_OID_ISO_IDENTIFIED_ORG "\x65\x70";
2223
#define NUM_ED25519_BYTES 32
@@ -73,7 +74,7 @@ bootutil_verify_sig(uint8_t *hash, uint32_t hlen, uint8_t *sig, size_t slen,
7374
uint8_t *pubkey;
7475
uint8_t *end;
7576

76-
if (hlen != 32 || slen != 64) {
77+
if (hlen != IMAGE_HASH_SIZE || slen != 64) {
7778
FIH_SET(fih_rc, FIH_FAILURE);
7879
goto out;
7980
}
@@ -87,7 +88,7 @@ bootutil_verify_sig(uint8_t *hash, uint32_t hlen, uint8_t *sig, size_t slen,
8788
goto out;
8889
}
8990

90-
rc = ED25519_verify(hash, 32, sig, pubkey);
91+
rc = ED25519_verify(hash, IMAGE_HASH_SIZE, sig, pubkey);
9192

9293
if (rc == 0) {
9394
/* if verify returns 0, there was an error. */

0 commit comments

Comments
 (0)