Skip to content

Commit 993c2a8

Browse files
mkannwischerhanno-becker
authored andcommitted
keypair_derand: *coins -> coins[2 * MLKEM_SYMBYTES]
keypair requires 2 * MLKEM_SYMBYTES bytes of randomness. So far the function signature took a const uint8_t *coins. This commit changfes the function signature to make the size explicit: const uint8_t coins[2 * MLKEM_SYMBYTES]. This is in line with the enc_derand function and should reduce the risk of misuse. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
1 parent 672064f commit 993c2a8

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

mlkem/kem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ static int mlk_check_pct(uint8_t const pk[MLKEM_INDCCA_PUBLICKEYBYTES],
189189
MLK_EXTERNAL_API
190190
int crypto_kem_keypair_derand(uint8_t pk[MLKEM_INDCCA_PUBLICKEYBYTES],
191191
uint8_t sk[MLKEM_INDCCA_SECRETKEYBYTES],
192-
const uint8_t *coins)
192+
const uint8_t coins[2 * MLKEM_SYMBYTES])
193193
{
194194
mlk_indcpa_keypair_derand(pk, sk, coins);
195195
memcpy(sk + MLKEM_INDCPA_SECRETKEYBYTES, pk, MLKEM_INDCCA_PUBLICKEYBYTES);

mlkem/kem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ MLK_EXTERNAL_API
6363
MLK_MUST_CHECK_RETURN_VALUE
6464
int crypto_kem_keypair_derand(uint8_t pk[MLKEM_INDCCA_PUBLICKEYBYTES],
6565
uint8_t sk[MLKEM_INDCCA_SECRETKEYBYTES],
66-
const uint8_t *coins)
66+
const uint8_t coins[2 * MLKEM_SYMBYTES])
6767
__contract__(
6868
requires(memory_no_alias(pk, MLKEM_INDCCA_PUBLICKEYBYTES))
6969
requires(memory_no_alias(sk, MLKEM_INDCCA_SECRETKEYBYTES))

mlkem/mlkem_native.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ MLK_API_MUST_CHECK_RETURN_VALUE
137137
int MLK_API_NAMESPACE(keypair_derand)(
138138
uint8_t pk[MLKEM_PUBLICKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)],
139139
uint8_t sk[MLKEM_SECRETKEYBYTES(MLK_CONFIG_API_PARAMETER_SET)],
140-
const uint8_t *coins);
140+
const uint8_t coins[2 * MLKEM_SYMBYTES]);
141141

142142
/*************************************************
143143
* Name: crypto_kem_keypair

0 commit comments

Comments
 (0)