mirror of
https://github.com/espressif/openthread.git
synced 2026-08-21 01:49:52 +00:00
[ecdsa] do not free mpi context before initializing it (#3366)
This commit is contained in:
committed by
Jonathan Hui
parent
c281f284ff
commit
d369956d42
@@ -61,6 +61,8 @@ otError Ecdsa::Sign(uint8_t * aOutput,
|
||||
|
||||
mbedtls_pk_init(&pkCtx);
|
||||
mbedtls_ecdsa_init(&ctx);
|
||||
mbedtls_mpi_init(&rMpi);
|
||||
mbedtls_mpi_init(&sMpi);
|
||||
|
||||
// Parse a private key in PEM format.
|
||||
VerifyOrExit(mbedtls_pk_parse_key(&pkCtx, aPrivateKey, aPrivateKeyLength, NULL, 0) == 0,
|
||||
@@ -72,9 +74,6 @@ otError Ecdsa::Sign(uint8_t * aOutput,
|
||||
|
||||
VerifyOrExit(mbedtls_ecdsa_from_keypair(&ctx, keypair) == 0, error = OT_ERROR_FAILED);
|
||||
|
||||
mbedtls_mpi_init(&rMpi);
|
||||
mbedtls_mpi_init(&sMpi);
|
||||
|
||||
// Sign using ECDSA.
|
||||
VerifyOrExit(mbedtls_ecdsa_sign(&ctx.grp, &rMpi, &sMpi, &ctx.d, aInputHash, aInputHashLength, FillRandom, NULL) ==
|
||||
0,
|
||||
|
||||
Reference in New Issue
Block a user