mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-16 08:42:50 +00:00
bignum: Updated mbedtls_mpi_shift_l
to use the core method.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
parent
f0806bee66
commit
0144b35f7d
@ -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 mbedtls_mpi_shift_l(mbedtls_mpi *X, size_t count)
|
||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
size_t i, v0, t1;
|
size_t i;
|
||||||
mbedtls_mpi_uint r0 = 0, r1;
|
|
||||||
MPI_VALIDATE_RET(X != NULL);
|
MPI_VALIDATE_RET(X != NULL);
|
||||||
|
|
||||||
v0 = count / (biL);
|
|
||||||
t1 = count & (biL - 1);
|
|
||||||
|
|
||||||
i = mbedtls_mpi_bitlen(X) + count;
|
i = mbedtls_mpi_bitlen(X) + count;
|
||||||
|
|
||||||
if (X->n * biL < i) {
|
if (X->n * biL < i) {
|
||||||
@ -765,31 +761,7 @@ int mbedtls_mpi_shift_l(mbedtls_mpi *X, size_t count)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
/*
|
mbedtls_mpi_core_shift_l(X->p, X->n, count);
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user