@@ -67,12 +67,14 @@ extern "C" {
6767#define HDR_IMG_DELTA_BASE 0x05
6868#define HDR_IMG_DELTA_SIZE 0x06
6969#define HDR_PUBKEY 0x10
70+ #define HDR_SECONDARY_PUBKEY 0x12
7071#define HDR_SHA3_384 0x13
7172#define HDR_SHA384 0x14
7273#define HDR_IMG_DELTA_INVERSE 0x15
7374#define HDR_IMG_DELTA_INVERSE_SIZE 0x16
7475#define HDR_SIGNATURE 0x20
7576#define HDR_POLICY_SIGNATURE 0x21
77+ #define HDR_SECONDARY_SIGNATURE 0x22
7678#define HDR_PADDING 0xFF
7779
7880/* Auth Key types */
@@ -118,72 +120,71 @@ extern "C" {
118120#define HDR_IMG_TYPE_APP 0x0001
119121#endif
120122
121- #define KEYSTORE_PUBKEY_SIZE_NONE 0
122- #define KEYSTORE_PUBKEY_SIZE_ED25519 32
123- #define KEYSTORE_PUBKEY_SIZE_ED448 57
124- #define KEYSTORE_PUBKEY_SIZE_ECC256 64
125- #define KEYSTORE_PUBKEY_SIZE_ECC384 96
126- #define KEYSTORE_PUBKEY_SIZE_ECC521 132
127- #define KEYSTORE_PUBKEY_SIZE_RSA2048 320
128- #define KEYSTORE_PUBKEY_SIZE_RSA3072 448
129- #define KEYSTORE_PUBKEY_SIZE_RSA4096 576
130- #define KEYSTORE_PUBKEY_SIZE_LMS 60
131- #define KEYSTORE_PUBKEY_SIZE_XMSS 68
132- /* ML-DSA pub key size is a function of parameters.
133- * This needs to be configurable. Default to security
134- * category 2. */
135- #ifdef ML_DSA_LEVEL
136- #if ML_DSA_LEVEL == 2
137- #define KEYSTORE_PUBKEY_SIZE_ML_DSA 1312
138- #elif ML_DSA_LEVEL == 3
139- #define KEYSTORE_PUBKEY_SIZE_ML_DSA 1952
140- #elif ML_DSA_LEVEL == 5
141- #define KEYSTORE_PUBKEY_SIZE_ML_DSA 2592
142- #else
143- #error "Invalid ML_DSA_LEVEL!"
144- #endif
145- #else
146- #define KEYSTORE_PUBKEY_SIZE_ML_DSA 1312
147- #endif /* ML_DSA_LEVEL */
123+ #define KEYSTORE_PUBKEY_SIZE_NONE 0
124+ #define KEYSTORE_PUBKEY_SIZE_ED25519 32
125+ #define KEYSTORE_PUBKEY_SIZE_ED448 57
126+ #define KEYSTORE_PUBKEY_SIZE_ECC256 64
127+ #define KEYSTORE_PUBKEY_SIZE_ECC384 96
128+ #define KEYSTORE_PUBKEY_SIZE_ECC521 132
129+ #define KEYSTORE_PUBKEY_SIZE_RSA2048 320
130+ #define KEYSTORE_PUBKEY_SIZE_RSA3072 448
131+ #define KEYSTORE_PUBKEY_SIZE_RSA4096 576
132+ #define KEYSTORE_PUBKEY_SIZE_LMS 60
133+ #define KEYSTORE_PUBKEY_SIZE_XMSS 68
134+
135+ /* ML-DSA pub key size is a function of parameters.
136+ * This needs to be configurable. Default to security
137+ * category 2. */
138+ #ifdef ML_DSA_LEVEL
139+ #if ML_DSA_LEVEL == 2
140+ #define KEYSTORE_PUBKEY_SIZE_ML_DSA 1312
141+ #elif ML_DSA_LEVEL == 3
142+ #define KEYSTORE_PUBKEY_SIZE_ML_DSA 1952
143+ #elif ML_DSA_LEVEL == 5
144+ #define KEYSTORE_PUBKEY_SIZE_ML_DSA 2592
145+ #else
146+ #error "Invalid ML_DSA_LEVEL!"
147+ #endif
148+ #endif /* ML_DSA_LEVEL */
148149
149150/* Mask for key permissions */
150- #define KEY_VERIFY_ALL (0xFFFFFFFFU)
151- #define KEY_VERIFY_ONLY_ID (X ) (1U << X)
152- #define KEY_VERIFY_SELF_ONLY KEY_VERIFY_ONLY_ID(0)
153- #define KEY_VERIFY_APP_ONLY KEY_VERIFY_ONLY_ID(1)
151+ #define KEY_VERIFY_ALL (0xFFFFFFFFU)
152+ #define KEY_VERIFY_ONLY_ID (X ) (1U << X)
153+ #define KEY_VERIFY_SELF_ONLY KEY_VERIFY_ONLY_ID(0)
154+ #define KEY_VERIFY_APP_ONLY KEY_VERIFY_ONLY_ID(1)
154155
155156#if defined(__WOLFBOOT ) || defined(UNIT_TEST_AUTH )
156157
157- /* Hashing configuration */
158- #if defined(WOLFBOOT_HASH_SHA256 )
159- # ifndef WOLFBOOT_SHA_BLOCK_SIZE
160- # define WOLFBOOT_SHA_BLOCK_SIZE (256)
161- # endif
162- # define WOLFBOOT_SHA_HDR HDR_SHA256
163- # define WOLFBOOT_SHA_DIGEST_SIZE (32)
164- # define image_hash image_sha256
165- # define key_hash key_sha256
166- # define self_hash self_sha256
167- #elif defined(WOLFBOOT_HASH_SHA384 )
168- # ifndef WOLFBOOT_SHA_BLOCK_SIZE
169- # define WOLFBOOT_SHA_BLOCK_SIZE (256)
170- # endif
171- # define WOLFBOOT_SHA_HDR HDR_SHA384
172- # define WOLFBOOT_SHA_DIGEST_SIZE (48)
173- # define image_hash image_sha384
174- # define key_hash key_sha384
175- # define self_hash self_sha384
176- #elif defined(WOLFBOOT_HASH_SHA3_384 )
177- # ifndef WOLFBOOT_SHA_BLOCK_SIZE
178- # define WOLFBOOT_SHA_BLOCK_SIZE (128)
179- # endif
180- # define WOLFBOOT_SHA_HDR HDR_SHA3_384
181- # define WOLFBOOT_SHA_DIGEST_SIZE (48)
182- # define image_hash image_sha3_384
183- # define key_hash key_sha3_384
184- #else
185- # error "No valid hash algorithm defined!"
186- #endif
158+ /* Hashing configuration */
159+ #if defined(WOLFBOOT_HASH_SHA256 )
160+ # ifndef WOLFBOOT_SHA_BLOCK_SIZE
161+ # define WOLFBOOT_SHA_BLOCK_SIZE (256)
162+ # endif
163+ # define WOLFBOOT_SHA_HDR HDR_SHA256
164+ # define WOLFBOOT_SHA_DIGEST_SIZE (32)
165+ # define image_hash image_sha256
166+ # define key_hash key_sha256
167+ # define self_hash self_sha256
168+ #elif defined(WOLFBOOT_HASH_SHA384 )
169+ # ifndef WOLFBOOT_SHA_BLOCK_SIZE
170+ # define WOLFBOOT_SHA_BLOCK_SIZE (256)
171+ # endif
172+ # define WOLFBOOT_SHA_HDR HDR_SHA384
173+ # define WOLFBOOT_SHA_DIGEST_SIZE (48)
174+ # define image_hash image_sha384
175+ # define key_hash key_sha384
176+ # define self_hash self_sha384
177+ #elif defined(WOLFBOOT_HASH_SHA3_384 )
178+ # ifndef WOLFBOOT_SHA_BLOCK_SIZE
179+ # define WOLFBOOT_SHA_BLOCK_SIZE (128)
180+ # endif
181+ # define WOLFBOOT_SHA_HDR HDR_SHA3_384
182+ # define WOLFBOOT_SHA_DIGEST_SIZE (48)
183+ # define image_hash image_sha3_384
184+ # define key_hash key_sha3_384
185+ #else
186+ # error "No valid hash algorithm defined!"
187+ #endif
187188
188189#ifdef WOLFBOOT_TPM
189190 #if defined(WOLFBOOT_HASH_SHA256 )
0 commit comments