crypto: sm2 - Fix crash caused by uninitialized context
In sm2_compute_z_digest() function, the newly allocated structure
mpi_ec_ctx is used, but forget to initialize it, which will cause
a crash when performing subsequent operations.
Fixes: e5221fa6a3
("KEYS: asymmetric: Move sm2 code into x509_public_key")
Cc: stable@vger.kernel.org # v6.5
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
0bb80ecc33
commit
21155620fb
@ -278,10 +278,14 @@ int sm2_compute_z_digest(struct shash_desc *desc,
|
|||||||
if (!ec)
|
if (!ec)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
err = __sm2_set_pub_key(ec, key, keylen);
|
err = sm2_ec_ctx_init(ec);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_free_ec;
|
goto out_free_ec;
|
||||||
|
|
||||||
|
err = __sm2_set_pub_key(ec, key, keylen);
|
||||||
|
if (err)
|
||||||
|
goto out_deinit_ec;
|
||||||
|
|
||||||
bits_len = SM2_DEFAULT_USERID_LEN * 8;
|
bits_len = SM2_DEFAULT_USERID_LEN * 8;
|
||||||
entl[0] = bits_len >> 8;
|
entl[0] = bits_len >> 8;
|
||||||
entl[1] = bits_len & 0xff;
|
entl[1] = bits_len & 0xff;
|
||||||
|
Loading…
Reference in New Issue
Block a user