Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
[nrf noup] mbedtls: Fix memory leak
Browse files Browse the repository at this point in the history
nrf-squash![nrf noup] mbedtls: Fix MbedTLS EC parameter A

The MPI bignum's were not freed after use.

Fixes SHEL-2851.

Signed-off-by: Chaitanya Tata <[email protected]>
  • Loading branch information
krish2718 committed Jun 7, 2024
1 parent 3ee1610 commit 6311fde
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/crypto/crypto_mbedtls-ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const struct crypto_bignum *crypto_ec_get_a(struct crypto_ec *e)
/* A = -3 mod P*/
MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod(&e->A, &minus_three, &one, &e->group.P, NULL));
cleanup:
mbedtls_mpi_free(&minus_three);
mbedtls_mpi_free(&one);
return (const struct crypto_bignum *)&e->A;
}

Expand Down Expand Up @@ -109,6 +111,7 @@ void crypto_ec_deinit(struct crypto_ec *e)
return;
}

mbedtls_mpi_free(&e->A);
mbedtls_ecp_group_free(&e->group);
os_free(e);
}
Expand Down

0 comments on commit 6311fde

Please sign in to comment.