Skip to content

Commit fa4638f

Browse files
Use a symbolic name for the seed size
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
1 parent b607824 commit fa4638f

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

drivers/pqcp/src/psa_crypto_mldsa.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
#include "wrap_mldsa_native.h"
1414
#include <mbedtls/platform_util.h>
1515

16+
/* The size of an ML-DSA seed in bytes.
17+
* The PSA API uses the seed as the private key.
18+
* (Some other ML-DSA interfaces use the "expanded secret", which is
19+
* derived from the seed, as the private key.)
20+
*/
21+
#define SEED_SIZE 32
22+
1623
/* For now, hard-coded values for MLDSA-87 */
1724
#define TF_PSA_CRYPTO_MLDSA_EXPANDED_SECRET_MAX_SIZE MLDSA87_SECRETKEYBYTES
1825
#define TF_PSA_CRYPTO_MLDSA_PUBLIC_KEY_MAX_SIZE MLDSA87_PUBLICKEYBYTES
@@ -39,7 +46,7 @@ static psa_status_t seed_to_public_key(
3946
const uint8_t *key_buffer, size_t key_buffer_size,
4047
uint8_t *data, size_t data_size, size_t *data_length)
4148
{
42-
if (key_buffer_size != 32) {
49+
if (key_buffer_size != SEED_SIZE) {
4350
return PSA_ERROR_INVALID_ARGUMENT;
4451
}
4552

@@ -108,7 +115,7 @@ psa_status_t tf_psa_crypto_mldsa_sign_message(
108115
}
109116
size_t actual_signature_length = MLDSA87_BYTES;
110117

111-
if (key_buffer_size != 32) {
118+
if (key_buffer_size != SEED_SIZE) {
112119
return PSA_ERROR_INVALID_ARGUMENT;
113120
}
114121

0 commit comments

Comments
 (0)