From 0144b35f7d8b637a7bf29c8d7883622bdab75620 Mon Sep 17 00:00:00 2001 From: Minos Galanakis Date: Tue, 2 May 2023 14:02:32 +0100 Subject: [PATCH] bignum: Updated `mbedtls_mpi_shift_l` to use the core method. Signed-off-by: Minos Galanakis --- library/bignum.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/library/bignum.c b/library/bignum.c index 2421c1a3e..e686a1ba2 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -750,13 +750,9 @@ int mbedtls_mpi_write_binary(const mbedtls_mpi *X, int mbedtls_mpi_shift_l(mbedtls_mpi *X, size_t count) { int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; - size_t i, v0, t1; - mbedtls_mpi_uint r0 = 0, r1; + size_t i; MPI_VALIDATE_RET(X != NULL); - v0 = count / (biL); - t1 = count & (biL - 1); - i = mbedtls_mpi_bitlen(X) + count; if (X->n * biL < i) { @@ -765,31 +761,7 @@ int mbedtls_mpi_shift_l(mbedtls_mpi *X, size_t count) ret = 0; - /* - * shift by count / limb_size - */ - if (v0 > 0) { - for (i = X->n; i > v0; i--) { - X->p[i - 1] = X->p[i - v0 - 1]; - } - - for (; i > 0; i--) { - X->p[i - 1] = 0; - } - } - - /* - * shift by count % limb_size - */ - if (t1 > 0) { - for (i = v0; i < X->n; i++) { - r1 = X->p[i] >> (biL - t1); - X->p[i] <<= t1; - X->p[i] |= r0; - r0 = r1; - } - } - + mbedtls_mpi_core_shift_l(X->p, X->n, count); cleanup: return ret;