3636 * This is to facilitate building multiple instances
3737 * of mlkem-native (e.g. with varying security levels)
3838 * within a single compilation unit. */
39- #define mlk_check_pk MLK_ADD_PARAM_SET(mlk_check_pk)
40- #define mlk_check_sk MLK_ADD_PARAM_SET(mlk_check_sk)
4139#define mlk_check_pct MLK_ADD_PARAM_SET(mlk_check_pct)
4240/* End of parameter set namespacing */
4341
@@ -50,26 +48,11 @@ __contract__(
5048);
5149#endif /* CBMC */
5250
53- /*************************************************
54- * Name: mlk_check_pk
55- *
56- * Description: Implements modulus check mandated by FIPS 203,
57- * i.e., ensures that coefficients are in [0,q-1].
58- *
59- * Arguments: - const uint8_t *pk: pointer to input public key
60- * (an already allocated array of MLKEM_INDCCA_PUBLICKEYBYTES
61- * bytes)
62- *
63- * Returns: - 0 on success
64- * - -1 on failure
65- *
66- * Specification: Implements @[FIPS203, Section 7.2, 'modulus check']
67- *
68- **************************************************/
6951
7052/* Reference: Not implemented in the reference implementation @[REF]. */
53+ MLK_INTERNAL_API
7154MLK_MUST_CHECK_RETURN_VALUE
72- static int mlk_check_pk (const uint8_t pk [MLKEM_INDCCA_PUBLICKEYBYTES ])
55+ int crypto_kem_check_pk (const uint8_t pk [MLKEM_INDCCA_PUBLICKEYBYTES ])
7356{
7457 int res ;
7558 mlk_polyvec p ;
@@ -90,27 +73,11 @@ static int mlk_check_pk(const uint8_t pk[MLKEM_INDCCA_PUBLICKEYBYTES])
9073 return res ;
9174}
9275
93- /*************************************************
94- * Name: mlk_check_sk
95- *
96- * Description: Implements public key hash check mandated by FIPS 203,
97- * i.e., ensures that
98- * sk[768𝑘+32 ∶ 768𝑘+64] = H(pk)= H(sk[384𝑘 : 768𝑘+32])
99- *
100- * Arguments: - const uint8_t *sk: pointer to input private key
101- * (an already allocated array of MLKEM_INDCCA_SECRETKEYBYTES
102- * bytes)
103- *
104- * Returns: - 0 on success
105- * - -1 on failure
106- *
107- * Specification: Implements @[FIPS203, Section 7.3, 'hash check']
108- *
109- **************************************************/
11076
11177/* Reference: Not implemented in the reference implementation @[REF]. */
78+ MLK_INTERNAL_API
11279MLK_MUST_CHECK_RETURN_VALUE
113- static int mlk_check_sk (const uint8_t sk [MLKEM_INDCCA_SECRETKEYBYTES ])
80+ int crypto_kem_check_sk (const uint8_t sk [MLKEM_INDCCA_SECRETKEYBYTES ])
11481{
11582 int res ;
11683 MLK_ALIGN uint8_t test [MLKEM_SYMBYTES ];
@@ -267,7 +234,7 @@ int crypto_kem_enc_derand(uint8_t ct[MLKEM_INDCCA_CIPHERTEXTBYTES],
267234 MLK_ALIGN uint8_t kr [2 * MLKEM_SYMBYTES ];
268235
269236 /* Specification: Implements @[FIPS203, Section 7.2, Modulus check] */
270- if (mlk_check_pk (pk ))
237+ if (crypto_kem_check_pk (pk ))
271238 {
272239 return -1 ;
273240 }
@@ -329,7 +296,7 @@ int crypto_kem_dec(uint8_t ss[MLKEM_SSBYTES],
329296 const uint8_t * pk = sk + MLKEM_INDCPA_SECRETKEYBYTES ;
330297
331298 /* Specification: Implements @[FIPS203, Section 7.3, Hash check] */
332- if (mlk_check_sk (sk ))
299+ if (crypto_kem_check_sk (sk ))
333300 {
334301 return -1 ;
335302 }
@@ -367,6 +334,4 @@ int crypto_kem_dec(uint8_t ss[MLKEM_SSBYTES],
367334
368335/* To facilitate single-compilation-unit (SCU) builds, undefine all macros.
369336 * Don't modify by hand -- this is auto-generated by scripts/autogen. */
370- #undef mlk_check_pk
371- #undef mlk_check_sk
372337#undef mlk_check_pct
0 commit comments