42 const uint8_t *publicseed = NULL;
43 const uint8_t *noiseseed = NULL;
49 if ((pk == NULL) || (sk == NULL) || (coins == NULL) || (p == NULL)) {
50 return CX_INVALID_PARAMETER;
53 if ((pk_len < p->indcpa_pk_bytes) || (sk_len < p->indcpa_sk_bytes)) {
54 return CX_INVALID_PARAMETER_SIZE;
64 for (uint32_t i = 0U; i < p->
k; i++) {
68 for (uint32_t i = 0U; i < p->
k; i++) {
76 for (uint32_t i = 0U; i < p->
k; i++) {
90 explicit_bzero(buf,
sizeof(buf));
91 explicit_bzero(coins_with_k,
sizeof(coins_with_k));
92 explicit_bzero(&a_row,
sizeof(a_row));
93 explicit_bzero(&e,
sizeof(e));
94 explicit_bzero(&skpv,
sizeof(skpv));
118 if ((c == NULL) || (m == NULL) || (pk == NULL) || (coins == NULL) || (p == NULL)) {
119 return CX_INVALID_PARAMETER;
122 if ((m_len <
MLKEM_SYMBYTES) || (pk_len < p->indcpa_pk_bytes) || (c_len < p->indcpa_ct_bytes)) {
123 return CX_INVALID_PARAMETER_SIZE;
131 for (uint32_t i = 0U; i < p->
k; i++) {
135 for (uint32_t i = 0U; i < p->
k; i++) {
144 for (uint32_t i = 0U; i < p->
k; i++) {
168 explicit_bzero(&at_row,
sizeof(at_row));
169 explicit_bzero(&sp,
sizeof(sp));
170 explicit_bzero(&ep,
sizeof(ep));
171 explicit_bzero(&b,
sizeof(b));
172 explicit_bzero(&v,
sizeof(v));
173 explicit_bzero(&epp,
sizeof(epp));
174 explicit_bzero(&k,
sizeof(k));
192 if ((m == NULL) || (c == NULL) || (sk == NULL) || (p == NULL)) {
193 return CX_INVALID_PARAMETER;
196 if ((m_len <
MLKEM_SYMBYTES) || (c_len < p->indcpa_ct_bytes) || (sk_len < p->indcpa_sk_bytes)) {
197 return CX_INVALID_PARAMETER_SIZE;
218 explicit_bzero(&skpv,
sizeof(skpv));
219 explicit_bzero(&sb,
sizeof(sb));
220 explicit_bzero(&v,
sizeof(v));
cx_err_t MLKEM_INDCPA_keypair_derand(uint8_t *pk, size_t pk_len, uint8_t *sk, size_t sk_len, const uint8_t coins[2 *MLKEM_SYMBYTES], const MLKEM_param_info_t *p)
cx_err_t MLKEM_INDCPA_enc(uint8_t *c, size_t c_len, const uint8_t *m, size_t m_len, const uint8_t *pk, size_t pk_len, const uint8_t coins[2 *MLKEM_SYMBYTES], const MLKEM_param_info_t *p)
cx_err_t MLKEM_INDCPA_dec(uint8_t *m, size_t m_len, const uint8_t *c, size_t c_len, const uint8_t *sk, size_t sk_len, const MLKEM_param_info_t *p)
void MLKEM_POLY_sub(poly *r, const poly *b)
Subtracts polynomial b from polynomial r in place.
void MLKEM_POLY_decompress_d5(poly *r, const uint8_t *a)
Decompresses a polynomial from bytes with dv=5.
void MLKEM_POLY_decompress_d4(poly *r, const uint8_t *a)
Decompresses a polynomial from bytes with dv=4.
void MLKEM_POLY_reduce(poly *r)
Applies Barrett reduction to all coefficients and map to [0, q-1].
void MLKEM_POLY_compress_d5(uint8_t *r, const poly *a)
Compresses a polynomial with dv=5 and serialize to bytes.
void MLKEM_POLY_tomsg(uint8_t *msg, const poly *a)
Encodes a polynomial into a 32-byte message.
void MLKEM_POLY_invntt_tomont(poly *p)
Computes the inverse NTT and multiply by Montgomery factor.
void MLKEM_POLY_add(poly *r, const poly *b)
Adds polynomial b to polynomial r in place.
void MLKEM_POLY_frommsg(poly *r, const uint8_t *msg)
Decodes a 32-byte message into a polynomial.
void MLKEM_POLY_compress_d4(uint8_t *r, const poly *a)
Compresses a polynomial with dv=4 and serialize to bytes.
void MLKEM_POLYMAT_gen_matrix_row(polyvec *row, const uint8_t *seed, int32_t transposed, uint8_t i, uint8_t k)
void MLKEM_POLYVEC_decompress(polyvec *r, const uint8_t *a, uint8_t k, uint8_t du)
Decompresses and deserializes a polynomial vector.
void MLKEM_POLYVEC_invntt_tomont(polyvec *r, uint8_t k)
Applies the inverse NTT to each polynomial in a vector.
void MLKEM_POLYVEC_reduce(polyvec *r, uint8_t k)
Reduces all coefficients of each polynomial in a vector.
void MLKEM_POLYVEC_compress(uint8_t *r, const polyvec *a, uint8_t k, uint8_t du)
Compresses and serializes a polynomial vector.
void MLKEM_POLYVEC_tomont(polyvec *r, uint8_t k)
Converts each polynomial in a vector to Montgomery domain.
void MLKEM_POLYVEC_frombytes(polyvec *r, const uint8_t *a, uint8_t k)
Deserializes a polynomial vector from bytes.
void MLKEM_POLYVEC_tobytes(uint8_t *r, const polyvec *a, uint8_t k)
Serializes a polynomial vector to bytes.
void MLKEM_POLYVEC_add(polyvec *r, const polyvec *b, uint8_t k)
Adds polynomial vector b to r in place.
void MLKEM_POLYVEC_basemul_acc_montgomery(poly *r, const polyvec *a, const polyvec *b, uint8_t k)
Accumulated pointwise multiplication of two polynomial vectors in the NTT domain.
void MLKEM_POLYVEC_ntt(polyvec *r, uint8_t k)
Applies the NTT to each polynomial in a vector.
void MLKEM_SAMPLE_getnoise(poly *r, const uint8_t *seed, uint8_t nonce, uint8_t eta)
Samples a noise polynomial using PRF and CBD.
void MLKEM_UTIL_hash_g(uint8_t *out, const uint8_t *in, size_t in_len)
Computes the G hash function (SHA3-512) as defined in FIPS 203.
ML-KEM parameter set descriptor holding all derived sizes.
uint16_t polyvec_compressed_bytes
Polynomial with MLKEM_N coefficients.
Vector of polynomials with up to MLKEM_MAX_K elements.