32 cx_sha3_256_hash(in, in_len, out);
37 cx_sha3_512_hash(in, in_len, out);
45void MLKEM_UTIL_prf(uint8_t *out,
size_t outlen,
const uint8_t *key, uint8_t nonce)
51 explicit_bzero(extkey,
sizeof(extkey));
65 uint8_t mask = (uint8_t) (-(int8_t) (b != 0U));
66 for (
size_t i = 0U; i < len; i++) {
67 dst[i] ^= mask & (dst[i] ^ src[i]);
73 if ((p == NULL) || (ek == NULL)) {
74 return CX_INVALID_PARAMETER;
76 for (uint32_t i = 0U; i < p->
k; i++) {
78 for (uint32_t j = 0U; j < (
MLKEM_N / 2U); j++) {
79 uint16_t c0 = (uint16_t) (a[3U * j] | (((uint16_t) a[(3U * j) + 1U] << 8U) & 0xFFFU));
81 = (uint16_t) ((a[(3U * j) + 1U] >> 4U) | ((uint16_t) a[(3U * j) + 2U] << 4U));
83 return CX_INVALID_PARAMETER;
void MLKEM_UTIL_hash_j(uint8_t *out, const uint8_t *in, size_t inlen)
void MLKEM_UTIL_ct_cmov(uint8_t *dst, const uint8_t *src, size_t len, uint8_t b)
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.
void MLKEM_UTIL_prf(uint8_t *out, size_t outlen, const uint8_t *key, uint8_t nonce)
Computes the PRF function (SHAKE256) as defined in FIPS 203.
void MLKEM_UTIL_xof_squeeze(uint8_t *out, size_t outlen, const uint8_t *seed, uint8_t x, uint8_t y)
Computes the XOF function (SHAKE128) as defined in FIPS 203.
void MLKEM_UTIL_hash_h(uint8_t out[CX_SHA3_256_SIZE], const uint8_t *in, size_t in_len)
Computes the H hash function (SHA3-256) as defined in FIPS 203.
cx_err_t MLKEM_UTIL_check_ek(const uint8_t *ek, const MLKEM_param_info_t *p)
Validates encapsulation key modulus (FIPS 203 ยง7.2).
ML-KEM (Module-Lattice Key Encapsulation Mechanism) public API.
SHA-3 (Secure Hash Algorithm 3)
ML-KEM parameter set descriptor holding all derived sizes.