diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-11-12 09:49:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-12 09:49:38 +0100 |
commit | f6e62f1147fee45a24900360c61b768f7f395794 (patch) | |
tree | a1e6d05eb6e4d4abca54cdcca2dbd99d50fb9e9d /thirdparty/mbedtls/library/bignum.c | |
parent | 94bf2f648ee239a2f8d86aec23a6c1a35bef9332 (diff) | |
parent | a3d77be53b066e87199d1f91047fa40cb062f77f (diff) |
Merge pull request #33560 from akien-mga/mbedtls-2.16.3
mbedtls: Update to upstream version 2.16.3
Diffstat (limited to 'thirdparty/mbedtls/library/bignum.c')
-rw-r--r-- | thirdparty/mbedtls/library/bignum.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/thirdparty/mbedtls/library/bignum.c b/thirdparty/mbedtls/library/bignum.c index 41946183c5..d1717e9435 100644 --- a/thirdparty/mbedtls/library/bignum.c +++ b/thirdparty/mbedtls/library/bignum.c @@ -742,10 +742,15 @@ cleanup: static mbedtls_mpi_uint mpi_uint_bigendian_to_host_c( mbedtls_mpi_uint x ) { uint8_t i; + unsigned char *x_ptr; mbedtls_mpi_uint tmp = 0; - /* This works regardless of the endianness. */ - for( i = 0; i < ciL; i++, x >>= 8 ) - tmp |= ( x & 0xFF ) << ( ( ciL - 1 - i ) << 3 ); + + for( i = 0, x_ptr = (unsigned char*) &x; i < ciL; i++, x_ptr++ ) + { + tmp <<= CHAR_BIT; + tmp |= (mbedtls_mpi_uint) *x_ptr; + } + return( tmp ); } @@ -2351,7 +2356,8 @@ static int mpi_miller_rabin( const mbedtls_mpi *X, size_t rounds, } if (count++ > 30) { - return MBEDTLS_ERR_MPI_NOT_ACCEPTABLE; + ret = MBEDTLS_ERR_MPI_NOT_ACCEPTABLE; + goto cleanup; } } while ( mbedtls_mpi_cmp_mpi( &A, &W ) >= 0 || |