1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Internal function mbedtls_mpi_zeroize() can be mbedtls_mpi_zeroize_and_free()

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
This commit is contained in:
Tom Cosgrove
2023-07-18 16:44:14 +01:00
parent 3a11bb8213
commit 46259f670f

View File

@ -55,9 +55,9 @@
MBEDTLS_INTERNAL_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE(cond)
/* Implementation that should never be optimized out by the compiler */ /* Implementation that should never be optimized out by the compiler */
static void mbedtls_mpi_zeroize(mbedtls_mpi_uint *v, size_t n) static void mbedtls_mpi_zeroize_and_free(mbedtls_mpi_uint *v, size_t n)
{ {
mbedtls_platform_zeroize(v, ciL * n); mbedtls_zeroize_and_free(v, ciL * n);
} }
/* /*
@ -82,8 +82,7 @@ void mbedtls_mpi_free(mbedtls_mpi *X)
} }
if (X->p != NULL) { if (X->p != NULL) {
mbedtls_mpi_zeroize(X->p, X->n); mbedtls_mpi_zeroize_and_free(X->p, X->n);
mbedtls_free(X->p);
} }
X->s = 1; X->s = 1;
@ -110,8 +109,7 @@ int mbedtls_mpi_grow(mbedtls_mpi *X, size_t nblimbs)
if (X->p != NULL) { if (X->p != NULL) {
memcpy(p, X->p, X->n * ciL); memcpy(p, X->p, X->n * ciL);
mbedtls_mpi_zeroize(X->p, X->n); mbedtls_mpi_zeroize_and_free(X->p, X->n);
mbedtls_free(X->p);
} }
X->n = nblimbs; X->n = nblimbs;
@ -158,8 +156,7 @@ int mbedtls_mpi_shrink(mbedtls_mpi *X, size_t nblimbs)
if (X->p != NULL) { if (X->p != NULL) {
memcpy(p, X->p, i * ciL); memcpy(p, X->p, i * ciL);
mbedtls_mpi_zeroize(X->p, X->n); mbedtls_mpi_zeroize_and_free(X->p, X->n);
mbedtls_free(X->p);
} }
X->n = i; X->n = i;