From 2a892e8d4b5f2d0ad76d60ce5bdd670fcddd4102 Mon Sep 17 00:00:00 2001 From: jordan Date: Sun, 22 Sep 2024 00:28:24 -0500 Subject: [PATCH] configurable KEYSTORE_PUBKEY_SIZE_ML_DSA. --- config/examples/sim-ml-dsa.config | 18 +++++++++++++++++- include/wolfboot/wolfboot.h | 10 +++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/config/examples/sim-ml-dsa.config b/config/examples/sim-ml-dsa.config index ec0924b4f..5571eb5f0 100644 --- a/config/examples/sim-ml-dsa.config +++ b/config/examples/sim-ml-dsa.config @@ -27,13 +27,29 @@ ARCH=sim TARGET=sim SIGN?=ML_DSA HASH?=SHA256 -ML_DSA_LEVEL=2 WOLFBOOT_SMALL_STACK=0 SPI_FLASH=0 DEBUG=0 DELTA_UPDATES=0 + +# +# ML-DSA config examples: +# +# Category 2: +ML_DSA_LEVEL=2 IMAGE_SIGNATURE_SIZE=2420 IMAGE_HEADER_SIZE?=4840 +# +# Category 3: +# ML_DSA_LEVEL=3 +# IMAGE_SIGNATURE_SIZE=3309 +# IMAGE_HEADER_SIZE?=6618 +# +# Category 5: +# ML_DSA_LEVEL=5 +# IMAGE_SIGNATURE_SIZE=4627 +# IMAGE_HEADER_SIZE?=9254 +# # sizes should be multiple of system page size WOLFBOOT_PARTITION_SIZE=0x40000 diff --git a/include/wolfboot/wolfboot.h b/include/wolfboot/wolfboot.h index 464c55cd1..5cba91285 100644 --- a/include/wolfboot/wolfboot.h +++ b/include/wolfboot/wolfboot.h @@ -129,7 +129,15 @@ extern "C" { #define KEYSTORE_PUBKEY_SIZE_XMSS 68 /* ML-DSA pub key size is a function of parameters. * This needs to be configurable. */ - #define KEYSTORE_PUBKEY_SIZE_ML_DSA 1312 + #if ML_DSA_LEVEL == 2 + #define KEYSTORE_PUBKEY_SIZE_ML_DSA 1312 + #elif ML_DSA_LEVEL == 3 + #define KEYSTORE_PUBKEY_SIZE_ML_DSA 1952 + #elif ML_DSA_LEVEL == 5 + #define KEYSTORE_PUBKEY_SIZE_ML_DSA 2592 + #else + #error "Invalid ML_DSA_LEVEL!" + #endif /* Mask for key permissions */ #define KEY_VERIFY_ALL (0xFFFFFFFFU)