Skip to content

Commit

Permalink
openssl, refactor: fix bug in ossl_sm2_compute_z_digest function.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Jul 23, 2024
1 parent c8149f1 commit 4717116
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion openssl/src/crypto/sm2/sm2_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
int ossl_sm2_compute_z_digest(uint8_t *out,
const EVP_MD *digest,
const uint8_t *id,
const size_t id_len,
size_t id_len,
const EC_KEY *key)
{
int rc = 0;
Expand Down Expand Up @@ -80,6 +80,11 @@ int ossl_sm2_compute_z_digest(uint8_t *out,

/* Z = h(ENTL || ID || a || b || xG || yG || xA || yA) */

if (id == NULL) {
id = (const uint8_t *)SM2_DEFAULT_USERID;
id_len = strlen(SM2_DEFAULT_USERID);
}

if (id_len >= (UINT16_MAX / 8)) {
/* too large */
ERR_raise(ERR_LIB_SM2, SM2_R_ID_TOO_LARGE);
Expand Down

0 comments on commit 4717116

Please sign in to comment.