56 cx_err_t error = CX_INTERNAL_ERROR;
65 if ((pk == NULL) || (sk == NULL) || (seed == NULL)) {
66 error = CX_INVALID_PARAMETER;
71 error = CX_INVALID_PARAMETER_VALUE;
77 if ((pk_len < p->pk_bytes) || (sk_len < p->sk_bytes)) {
78 error = CX_INVALID_PARAMETER_SIZE;
88 const uint8_t *rho = seedbuf;
102 for (uint8_t i = 0U; i < p->
k; i++) {
103 for (uint8_t j = 0U; j < p->
l; j++) {
112 uint16_t nonce = ((uint16_t) i << 8U) | (uint16_t) j;
140 explicit_bzero(seedbuf,
sizeof(seedbuf));
141 explicit_bzero(buf,
sizeof(buf));
142 explicit_bzero(&tA,
sizeof(tA));
143 explicit_bzero(&tB,
sizeof(tB));
144 explicit_bzero(&tC,
sizeof(tC));
145 explicit_bzero(tr,
sizeof(tr));
155 size_t *sig_actual_len,
164 return CX_INVALID_PARAMETER;
168 sig, sig_len, sig_actual_len, NULL, mu, rnd, rnd_len, sk, sk_len, param);
181 if ((sig == NULL) || (pk == NULL) || (mu == NULL)) {
182 return CX_INVALID_PARAMETER;
cx_err_t MLDSA_internal_verify_core(const uint8_t *sig, size_t sig_len, const MLDSA_formatted_message_t *formatted_mprime, const uint8_t *precomputed_mu, const uint8_t *pk, size_t pk_len, MLDSA_param_t param)
Core ML-DSA verification routine (FIPS 204, Algorithms 3 & 8).
cx_err_t MLDSA_internal_sign_core(uint8_t *sig, size_t sig_len, size_t *sig_actual_len, const MLDSA_formatted_message_t *formatted_mprime, const uint8_t *precomputed_mu, uint8_t *rnd, size_t rnd_len, const uint8_t *sk, size_t sk_len, MLDSA_param_t param)
Core ML-DSA signing routine (FIPS 204, Algorithms 2 & 7).
cx_err_t MLDSA_internal_verify(const uint8_t *sig, size_t sig_len, const uint8_t *mu, const uint8_t *pk, size_t pk_len, MLDSA_param_t param)
Internal ML-DSA signature verification (FIPS 204, Algorithms 3 & 8).
cx_err_t MLDSA_internal_keygen(uint8_t *pk, size_t pk_len, uint8_t *sk, size_t sk_len, const uint8_t seed[MLDSA_SEEDBYTES], MLDSA_param_t param)
Generates an ML-DSA key pair from a seed (deterministic).
cx_err_t MLDSA_internal_sign(uint8_t *sig, size_t sig_len, size_t *sig_actual_len, const uint8_t *mu, uint8_t *rnd, size_t rnd_len, const uint8_t *sk, size_t sk_len, MLDSA_param_t param)
Internal ML-DSA signature generation (FIPS 204, Algorithms 2 & 7).
void MLDSA_PACK_polyt1(uint8_t r[MLDSA_POLYT1_PACKEDBYTES], const mldsa_poly *a)
Bit-pack polynomial with coefficients a1 from power2round (10-bit values). Each coefficient uses 10 b...
void MLDSA_PACK_polyt0(uint8_t r[MLDSA_POLYT0_PACKEDBYTES], const mldsa_poly *a)
Bit-pack polynomial with coefficients a0 from power2round. Coefficients in (-(2^{D-1}-1),...
uint32_t MLDSA_PACK_polyeta(uint8_t *r, const mldsa_poly *a, uint8_t eta)
Bit-pack polynomial with coefficients in [-eta, eta].
void MLDSA_POLY_reduce(mldsa_poly *a)
Applies reduce32 to all coefficients of a polynomial.
void MLDSA_POLY_ntt(mldsa_poly *a)
Forward NTT in place.
void MLDSA_POLY_caddq_all(mldsa_poly *a)
Applies caddq to all coefficients of a polynomial.
void MLDSA_POLY_add(mldsa_poly *a, const mldsa_poly *b)
Adds polynomial b to polynomial a in place.
void MLDSA_POLY_invntt_tomont(mldsa_poly *a)
Inverse NTT and multiply by Montgomery factor.
void MLDSA_POLY_pointwise_montgomery(mldsa_poly *c, const mldsa_poly *a, const mldsa_poly *b, int first)
Pointwise multiplication (Montgomery) with accumulation.
void MLDSA_ROUNDING_poly_power2round(mldsa_poly *a1, mldsa_poly *a0, const mldsa_poly *a)
Applies power2round to all coefficients of a polynomial.
void MLDSA_SAMPLE_eta(mldsa_poly *a, const uint8_t seed[MLDSA_CRHBYTES], uint16_t nonce, uint8_t eta)
Sample polynomial with coefficients in [-eta, eta] from SHAKE256(seed||nonce).
void MLDSA_SAMPLE_uniform(mldsa_poly *a, const uint8_t seed[MLDSA_SEEDBYTES], uint16_t nonce)
Sample polynomial with uniformly random coefficients in [0, q-1] by performing rejection sampling on ...
void MLDSA_UTIL_shake256(uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen)
SHAKE256 hash wrapper.
#define MLDSA_POLYT0_PACKEDBYTES
#define MLDSA_POLYT1_PACKEDBYTES
ML-DSA (Module-Lattice Digital Signature Algorithm) public API.
const MLDSA_param_info_t MLDSA_PARAM[MLDSA_NUM_PARAM_SETS]
Lookup table of ML-DSA parameter sets indexed by MLDSA_param_t.
enum MLDSA_param_e MLDSA_param_t
ML-DSA parameter set selector.
#define MLDSA_NUM_PARAM_SETS
ML-DSA parameter set descriptor holding all derived sizes.
uint16_t polyeta_packed_bytes
Polynomial with MLDSA_N int32_t coefficients.