Skip to content

Commit c3fe505

Browse files
committed
Fix check on ML_DSA pubkey size at runtime
1 parent 51eff3e commit c3fe505

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

config/examples/sim-ml-dsa.config

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
ARCH=sim
2727
TARGET=sim
28-
SIGN?=ML_DSA
29-
HASH?=SHA256
28+
SIGN=ML_DSA
29+
HASH=SHA256
3030
WOLFBOOT_SMALL_STACK=0
3131
SPI_FLASH=0
3232
DEBUG=0
@@ -38,17 +38,17 @@ DELTA_UPDATES=0
3838
# Category 2:
3939
ML_DSA_LEVEL=2
4040
IMAGE_SIGNATURE_SIZE=2420
41-
IMAGE_HEADER_SIZE?=8192
41+
IMAGE_HEADER_SIZE=8192
4242
#
4343
# Category 3:
4444
# ML_DSA_LEVEL=3
4545
# IMAGE_SIGNATURE_SIZE=3309
46-
# IMAGE_HEADER_SIZE?=8192
46+
# IMAGE_HEADER_SIZE=8192
4747
#
4848
# Category 5:
4949
# ML_DSA_LEVEL=5
5050
# IMAGE_SIGNATURE_SIZE=4627
51-
# IMAGE_HEADER_SIZE?=12288
51+
# IMAGE_HEADER_SIZE=12288
5252
# This example needsd larger sector size.
5353
# WOLFBOOT_SECTOR_SIZE=0x3000
5454
#

src/image.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ static void wolfBoot_verify_signature_xmss(uint8_t key_slot,
593593

594594
#ifdef WOLFBOOT_SIGN_ML_DSA
595595
#include <wolfssl/wolfcrypt/dilithium.h>
596+
596597
static void wolfBoot_verify_signature_ml_dsa(uint8_t key_slot,
597598
struct wolfBoot_image *img, uint8_t *sig)
598599
{
@@ -636,9 +637,9 @@ static void wolfBoot_verify_signature_ml_dsa(uint8_t key_slot,
636637
wolfBoot_printf("error: wc_MlDsaKey_GetPubLen returned %d\n", ret);
637638
ret = -1;
638639
}
639-
else if (pub_len != KEYSTORE_PUBKEY_SIZE_ML_DSA) {
640+
else if (pub_len > KEYSTORE_PUBKEY_SIZE) {
640641
wolfBoot_printf("error: ML-DSA pub key mismatch: got %d bytes " \
641-
"expected %d\n", pub_len, KEYSTORE_PUBKEY_SIZE_ML_DSA);
642+
"max %d\n", pub_len, KEYSTORE_PUBKEY_SIZE);
642643
ret = -1;
643644
}
644645
}

0 commit comments

Comments
 (0)