diff --git a/crypto/dilithium/ml_dsa.c b/crypto/dilithium/ml_dsa.c index 96be7a035f..4aa5fe6683 100644 --- a/crypto/dilithium/ml_dsa.c +++ b/crypto/dilithium/ml_dsa.c @@ -47,8 +47,8 @@ int ml_dsa_44_sign(const uint8_t *private_key /* IN */, size_t ctx_string_len /* IN */) { ml_dsa_params params; ml_dsa_44_params_init(¶ms); - return ml_dsa_signature(¶ms, sig, sig_len, message, message_len, - ctx_string, ctx_string_len, private_key) == 0; + return ml_dsa_sign(¶ms, sig, sig_len, message, message_len, + ctx_string, ctx_string_len, private_key) == 0; } int ml_dsa_44_sign_internal(const uint8_t *private_key /* IN */, @@ -61,8 +61,8 @@ int ml_dsa_44_sign_internal(const uint8_t *private_key /* IN */, uint8_t *rnd /* IN */) { ml_dsa_params params; ml_dsa_44_params_init(¶ms); - return ml_dsa_signature_internal(¶ms, sig, sig_len, message, message_len, - pre, pre_len, rnd, private_key) == 0; + return ml_dsa_sign_internal(¶ms, sig, sig_len, message, message_len, + pre, pre_len, rnd, private_key) == 0; } int ml_dsa_44_verify(const uint8_t *public_key /* IN */, @@ -115,8 +115,8 @@ int ml_dsa_65_sign(const uint8_t *private_key /* IN */, size_t ctx_string_len /* IN */) { ml_dsa_params params; ml_dsa_65_params_init(¶ms); - return ml_dsa_signature(¶ms, sig, sig_len, message, message_len, - ctx_string, ctx_string_len, private_key) == 0; + return ml_dsa_sign(¶ms, sig, sig_len, message, message_len, + ctx_string, ctx_string_len, private_key) == 0; } int ml_dsa_65_sign_internal(const uint8_t *private_key /* IN */, @@ -129,8 +129,8 @@ int ml_dsa_65_sign_internal(const uint8_t *private_key /* IN */, uint8_t *rnd /* IN */) { ml_dsa_params params; ml_dsa_65_params_init(¶ms); - return ml_dsa_signature_internal(¶ms, sig, sig_len, message, message_len, - pre, pre_len, rnd, private_key) == 0; + return ml_dsa_sign_internal(¶ms, sig, sig_len, message, message_len, + pre, pre_len, rnd, private_key) == 0; } int ml_dsa_65_verify(const uint8_t *public_key /* IN */, @@ -183,8 +183,8 @@ int ml_dsa_87_sign(const uint8_t *private_key /* IN */, size_t ctx_string_len /* IN */) { ml_dsa_params params; ml_dsa_87_params_init(¶ms); - return ml_dsa_signature(¶ms, sig, sig_len, message, message_len, - ctx_string, ctx_string_len, private_key) == 0; + return ml_dsa_sign(¶ms, sig, sig_len, message, message_len, + ctx_string, ctx_string_len, private_key) == 0; } int ml_dsa_87_sign_internal(const uint8_t *private_key /* IN */, @@ -197,8 +197,8 @@ int ml_dsa_87_sign_internal(const uint8_t *private_key /* IN */, uint8_t *rnd /* IN */) { ml_dsa_params params; ml_dsa_87_params_init(¶ms); - return ml_dsa_signature_internal(¶ms, sig, sig_len, message, message_len, - pre, pre_len, rnd, private_key) == 0; + return ml_dsa_sign_internal(¶ms, sig, sig_len, message, message_len, + pre, pre_len, rnd, private_key) == 0; } int ml_dsa_87_verify(const uint8_t *public_key /* IN */, diff --git a/crypto/dilithium/pqcrystals_dilithium_ref_common/sign.c b/crypto/dilithium/pqcrystals_dilithium_ref_common/sign.c index 1d31c58340..cdc772f72a 100644 --- a/crypto/dilithium/pqcrystals_dilithium_ref_common/sign.c +++ b/crypto/dilithium/pqcrystals_dilithium_ref_common/sign.c @@ -107,7 +107,7 @@ int ml_dsa_keypair(ml_dsa_params *params, uint8_t *pk, uint8_t *sk) { } /************************************************* -* Name: ml_dsa_signature_internal +* Name: ml_dsa_sign_internal * * Description: FIPS 204: Algorithm 7 ML-DSA.Sign_internal. * Computes signature. Internal API. @@ -124,15 +124,15 @@ int ml_dsa_keypair(ml_dsa_params *params, uint8_t *pk, uint8_t *sk) { * * Returns 0 (success) or -1 (context string too long) **************************************************/ -int ml_dsa_signature_internal(ml_dsa_params *params, - uint8_t *sig, - size_t *siglen, - const uint8_t *m, - size_t mlen, - const uint8_t *pre, - size_t prelen, - const uint8_t *rnd, - const uint8_t *sk) +int ml_dsa_sign_internal(ml_dsa_params *params, + uint8_t *sig, + size_t *siglen, + const uint8_t *m, + size_t mlen, + const uint8_t *pre, + size_t prelen, + const uint8_t *rnd, + const uint8_t *sk) { unsigned int n; uint8_t seedbuf[2*ML_DSA_SEEDBYTES + ML_DSA_TRBYTES + 2*ML_DSA_CRHBYTES]; @@ -253,7 +253,7 @@ int ml_dsa_signature_internal(ml_dsa_params *params, } /************************************************* -* Name: ml_dsa_signature +* Name: ml_dsa_sign * * Description: FIPS 204: Algorithm 2 ML-DSA.Sign. * Computes signature in hedged mode. @@ -268,14 +268,14 @@ int ml_dsa_signature_internal(ml_dsa_params *params, * * Returns 0 (success) or -1 (context string too long) **************************************************/ -int ml_dsa_signature(ml_dsa_params *params, - uint8_t *sig, - size_t *siglen, - const uint8_t *m, - size_t mlen, - const uint8_t *ctx, - size_t ctxlen, - const uint8_t *sk) +int ml_dsa_sign(ml_dsa_params *params, + uint8_t *sig, + size_t *siglen, + const uint8_t *m, + size_t mlen, + const uint8_t *ctx, + size_t ctxlen, + const uint8_t *sk) { uint8_t pre[257]; uint8_t rnd[ML_DSA_RNDBYTES]; @@ -291,7 +291,7 @@ int ml_dsa_signature(ml_dsa_params *params, if (!RAND_bytes(rnd, ML_DSA_RNDBYTES)) { return -1; } - ml_dsa_signature_internal(params, sig, siglen, m, mlen, pre, 2 + ctxlen, rnd, sk); + ml_dsa_sign_internal(params, sig, siglen, m, mlen, pre, 2 + ctxlen, rnd, sk); /* FIPS 204. Section 3.6.3 Destruction of intermediate values. */ OPENSSL_cleanse(pre, sizeof(pre)); @@ -333,7 +333,7 @@ int ml_dsa_sign_message(ml_dsa_params *params, for(i = 0; i < mlen; ++i) { sm[params->bytes + mlen - 1 - i] = m[mlen - 1 - i]; } - ret = ml_dsa_signature(params, sm, smlen, sm + params->bytes, mlen, ctx, ctxlen, sk); + ret = ml_dsa_sign(params, sm, smlen, sm + params->bytes, mlen, ctx, ctxlen, sk); *smlen += mlen; return ret; } diff --git a/crypto/dilithium/pqcrystals_dilithium_ref_common/sign.h b/crypto/dilithium/pqcrystals_dilithium_ref_common/sign.h index bc21a45bd1..fc32be0dd7 100644 --- a/crypto/dilithium/pqcrystals_dilithium_ref_common/sign.h +++ b/crypto/dilithium/pqcrystals_dilithium_ref_common/sign.h @@ -12,18 +12,18 @@ int ml_dsa_keypair_internal(ml_dsa_params *params, uint8_t *sk, const uint8_t *seed); -int ml_dsa_signature(ml_dsa_params *params, - uint8_t *sig, size_t *siglen, - const uint8_t *m, size_t mlen, - const uint8_t *ctx, size_t ctxlen, - const uint8_t *sk); - -int ml_dsa_signature_internal(ml_dsa_params *params, - uint8_t *sig, size_t *siglen, - const uint8_t *m, size_t mlen, - const uint8_t *pre, size_t prelen, - const uint8_t *rnd, - const uint8_t *sk); +int ml_dsa_sign(ml_dsa_params *params, + uint8_t *sig, size_t *siglen, + const uint8_t *m, size_t mlen, + const uint8_t *ctx, size_t ctxlen, + const uint8_t *sk); + +int ml_dsa_sign_internal(ml_dsa_params *params, + uint8_t *sig, size_t *siglen, + const uint8_t *m, size_t mlen, + const uint8_t *pre, size_t prelen, + const uint8_t *rnd, + const uint8_t *sk); int ml_dsa_sign_message(ml_dsa_params *params, uint8_t *sm, size_t *smlen,