29 cx_shake256_hash(in, inlen, out, outlen);
34 cx_shake128_hash(in, inlen, out, outlen);
44 uint8_t buf[256] = {0};
45 size_t total = in1len + in2len;
48 if (total <=
sizeof(buf)) {
49 (void) memcpy(buf, in1, in1len);
50 (void) memcpy(buf + in1len, in2, in2len);
51 error = cx_shake256_hash(buf, total, out, outlen);
52 explicit_bzero(buf, total);
56 error = cx_shake256_init_no_throw(&ctx, outlen * 8U);
60 error = cx_hash_no_throw((cx_hash_t *) &ctx, 0, in1, in1len, NULL, 0);
64 error = cx_hash_no_throw((cx_hash_t *) &ctx,
CX_LAST, in2, in2len, out, outlen);
81 error = cx_shake256_init_no_throw(&ctx, outlen * 8U);
85 error = cx_hash_no_throw((cx_hash_t *) &ctx, 0, in1, in1len, NULL, 0);
89 error = cx_hash_no_throw((cx_hash_t *) &ctx, 0, in2, in2len, NULL, 0);
93 return cx_hash_no_throw((cx_hash_t *) &ctx,
CX_LAST, in3, in3len, out, outlen);
106 memcpy(buf, seed, seedlen);
107 buf[seedlen] = (uint8_t) (nonce & 0xFFU);
108 buf[seedlen + 1U] = (uint8_t) (nonce >> 8U);
109 cx_shake128_hash(buf, seedlen + 2U, out, outlen);
110 explicit_bzero(buf,
sizeof(buf));
123 memcpy(buf, seed, seedlen);
124 buf[seedlen] = (uint8_t) (nonce & 0xFFU);
125 buf[seedlen + 1U] = (uint8_t) (nonce >> 8U);
126 cx_shake256_hash(buf, seedlen + 2U, out, outlen);
127 explicit_bzero(buf,
sizeof(buf));
void MLDSA_UTIL_shake256(uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen)
SHAKE256 hash wrapper.
cx_err_t MLDSA_UTIL_shake256_three(uint8_t *out, size_t outlen, const uint8_t *in1, size_t in1len, const uint8_t *in2, size_t in2len, const uint8_t *in3, size_t in3len)
SHAKE256 with three inputs concatenated.
void MLDSA_UTIL_shake128(uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen)
SHAKE128 hash wrapper.
void MLDSA_UTIL_shake256_seed_nonce(uint8_t *out, size_t outlen, const uint8_t *seed, size_t seedlen, uint16_t nonce)
SHAKE256 with seed || uint16_t nonce.
void MLDSA_UTIL_shake128_seed_nonce(uint8_t *out, size_t outlen, const uint8_t *seed, size_t seedlen, uint16_t nonce)
SHAKE128 with seed || uint16_t nonce.
cx_err_t MLDSA_UTIL_shake256_two(uint8_t *out, size_t outlen, const uint8_t *in1, size_t in1len, const uint8_t *in2, size_t in2len)
SHAKE256 with two inputs concatenated.
ML-DSA (Module-Lattice Digital Signature Algorithm) public API.
SHA-3 (Secure Hash Algorithm 3)