Skip to content

Commit

Permalink
renamed signature to sign
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemas committed Dec 24, 2024
1 parent 436dde3 commit 88d6602
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
24 changes: 12 additions & 12 deletions crypto/dilithium/ml_dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params);
return ml_dsa_signature(&params, sig, sig_len, message, message_len,
ctx_string, ctx_string_len, private_key) == 0;
return ml_dsa_sign(&params, 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 */,
Expand All @@ -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(&params);
return ml_dsa_signature_internal(&params, sig, sig_len, message, message_len,
pre, pre_len, rnd, private_key) == 0;
return ml_dsa_sign_internal(&params, sig, sig_len, message, message_len,
pre, pre_len, rnd, private_key) == 0;
}

int ml_dsa_44_verify(const uint8_t *public_key /* IN */,
Expand Down Expand Up @@ -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(&params);
return ml_dsa_signature(&params, sig, sig_len, message, message_len,
ctx_string, ctx_string_len, private_key) == 0;
return ml_dsa_sign(&params, 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 */,
Expand All @@ -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(&params);
return ml_dsa_signature_internal(&params, sig, sig_len, message, message_len,
pre, pre_len, rnd, private_key) == 0;
return ml_dsa_sign_internal(&params, sig, sig_len, message, message_len,
pre, pre_len, rnd, private_key) == 0;
}

int ml_dsa_65_verify(const uint8_t *public_key /* IN */,
Expand Down Expand Up @@ -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(&params);
return ml_dsa_signature(&params, sig, sig_len, message, message_len,
ctx_string, ctx_string_len, private_key) == 0;
return ml_dsa_sign(&params, 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 */,
Expand All @@ -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(&params);
return ml_dsa_signature_internal(&params, sig, sig_len, message, message_len,
pre, pre_len, rnd, private_key) == 0;
return ml_dsa_sign_internal(&params, sig, sig_len, message, message_len,
pre, pre_len, rnd, private_key) == 0;
}

int ml_dsa_87_verify(const uint8_t *public_key /* IN */,
Expand Down
42 changes: 21 additions & 21 deletions crypto/dilithium/pqcrystals_dilithium_ref_common/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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];
Expand Down Expand Up @@ -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.
Expand All @@ -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];
Expand All @@ -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));
Expand Down Expand Up @@ -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;
}
Expand Down
24 changes: 12 additions & 12 deletions crypto/dilithium/pqcrystals_dilithium_ref_common/sign.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 88d6602

Please sign in to comment.