Skip to content

Commit 4991eab

Browse files
committed
Peer review fixes. Default to ML-DSA level 2.
1 parent 35b98e7 commit 4991eab

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

include/wolfboot/wolfboot.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,18 @@ extern "C" {
140140
#define ML_DSA_L3_PUBKEY_SIZE 1952
141141
#define ML_DSA_L5_PUBKEY_SIZE 2592
142142

143-
/* Configure using ML_DSA_LEVEL: Default is security category 5. */
144-
#if defined(WOLFBOOT_SIGN_ML_DSA) && !defined(ML_DSA_LEVEL)
145-
#define ML_DSA_LEVEL 5
143+
/* Configure using ML_DSA_LEVEL: Default is security category 2. */
144+
#ifndef ML_DSA_LEVEL
145+
#define ML_DSA_LEVEL 2
146+
#endif
147+
148+
#if ML_DSA_LEVEL == 2
149+
#define KEYSTORE_PUBKEY_SIZE_ML_DSA ML_DSA_L2_PUBKEY_SIZE
150+
#elif ML_DSA_LEVEL == 3
151+
#define KEYSTORE_PUBKEY_SIZE_ML_DSA ML_DSA_L3_PUBKEY_SIZE
152+
#elif ML_DSA_LEVEL == 5
153+
#define KEYSTORE_PUBKEY_SIZE_ML_DSA ML_DSA_L5_PUBKEY_SIZE
146154
#endif
147-
/* Default to max size for keystore */
148-
#define KEYSTORE_PUBKEY_SIZE_ML_DSA 2592
149155

150156
/* Mask for key permissions */
151157
#define KEY_VERIFY_ALL (0xFFFFFFFFU)

tools/keytools/keygen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static WC_RNG rng;
124124
static int noLocalKeys = 0;
125125

126126
/* ML-DSA pub keys are big. */
127-
#define KEYSLOT_MAX_PUBKEY_SIZE KEYSTORE_PUBKEY_SIZE_ML_DSA
127+
#define KEYSLOT_MAX_PUBKEY_SIZE ML_DSA_L5_PUBKEY_SIZE
128128

129129
struct keystore_slot {
130130
uint32_t slot_id;

tools/keytools/sign.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include <delta.h>
4646

4747
#include "wolfboot/version.h"
48-
//#include "wolfboot/wolfboot.h"
4948

5049
#ifdef DEBUG_SIGNTOOL
5150
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
@@ -319,15 +318,15 @@ static uint16_t sign_tool_find_header(uint8_t *haystack, uint16_t type, uint8_t
319318
len = p[2] | (p[3] << 8);
320319
/* check len */
321320
if ((4 + len) > (uint16_t)(CMD.header_sz - IMAGE_HEADER_OFFSET)) {
322-
fprintf(stderr, "This field is too large (bigger than the space available "
323-
"in the current header)\n");
324-
//fprintf(stderr, "%d %d %d\n", len, CMD.header_sz, IMAGE_HEADER_OFFSET);
321+
fprintf(stderr, "This field too large to fit into header "
322+
"(%d > %d)\n",
323+
(int)(4 + len), (int)(CMD.header_sz - IMAGE_HEADER_OFFSET));
325324
break;
326325
}
327326
/* check max pointer */
328327
if (p + 4 + len > max_p) {
329-
fprintf(stderr, "This field is too large and would overflow the image "
330-
"header\n");
328+
fprintf(stderr, "This field is too large and would overflow the "
329+
"image header pointer\n");
331330
break;
332331
}
333332

@@ -2116,7 +2115,7 @@ static void set_signature_sizes(int secondary)
21162115

21172116
if (!lms_levels_str)
21182117
lms_levels = LMS_LEVELS;
2119-
else
2118+
else
21202119
lms_levels = atoi(lms_levels_str);
21212120
if (!lms_height_str)
21222121
lms_height = LMS_HEIGHT;

0 commit comments

Comments
 (0)