mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 04:25:32 +00:00
mbedtls: Update to 2.6.0 release (without IDF-specific patches)
This commit is contained in:

committed by
Angus Gratton

parent
63e1e4e502
commit
ae382b3bfa
@@ -58,8 +58,6 @@
|
||||
#define mbedtls_free free
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_BIGNUM_ALT)
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void mbedtls_mpi_zeroize( mbedtls_mpi_uint *v, size_t n ) {
|
||||
volatile mbedtls_mpi_uint *p = v; while( n-- ) *p++ = 0;
|
||||
@@ -536,7 +534,12 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix,
|
||||
n = mbedtls_mpi_bitlen( X );
|
||||
if( radix >= 4 ) n >>= 1;
|
||||
if( radix >= 16 ) n >>= 1;
|
||||
n += 3;
|
||||
/*
|
||||
* Round up the buffer length to an even value to ensure that there is
|
||||
* enough room for hexadecimal values that can be represented in an odd
|
||||
* number of digits.
|
||||
*/
|
||||
n += 3 + ( ( n + 1 ) & 1 );
|
||||
|
||||
if( buflen < n )
|
||||
{
|
||||
@@ -613,11 +616,11 @@ int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin )
|
||||
if( slen == sizeof( s ) - 2 )
|
||||
return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL );
|
||||
|
||||
if( s[slen - 1] == '\n' ) { slen--; s[slen] = '\0'; }
|
||||
if( s[slen - 1] == '\r' ) { slen--; s[slen] = '\0'; }
|
||||
if( slen > 0 && s[slen - 1] == '\n' ) { slen--; s[slen] = '\0'; }
|
||||
if( slen > 0 && s[slen - 1] == '\r' ) { slen--; s[slen] = '\0'; }
|
||||
|
||||
p = s + slen;
|
||||
while( --p >= s )
|
||||
while( p-- > s )
|
||||
if( mpi_get_digit( &d, radix, *p ) != 0 )
|
||||
break;
|
||||
|
||||
@@ -1092,8 +1095,6 @@ int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint
|
||||
return( mbedtls_mpi_sub_mpi( X, A, &_B ) );
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_MPI_MUL_MPI_ALT) || !defined(MBEDTLS_MPI_EXP_MOD_ALT)
|
||||
|
||||
/*
|
||||
* Helper for mbedtls_mpi multiplication
|
||||
*/
|
||||
@@ -1105,7 +1106,6 @@ static
|
||||
*/
|
||||
__attribute__ ((noinline))
|
||||
#endif
|
||||
|
||||
void mpi_mul_hlp( size_t i, mbedtls_mpi_uint *s, mbedtls_mpi_uint *d, mbedtls_mpi_uint b )
|
||||
{
|
||||
mbedtls_mpi_uint c = 0, t = 0;
|
||||
@@ -1167,9 +1167,6 @@ void mpi_mul_hlp( size_t i, mbedtls_mpi_uint *s, mbedtls_mpi_uint *d, mbedtls_mp
|
||||
while( c != 0 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_MPI_MUL_MPI_ALT)
|
||||
/*
|
||||
* Baseline multiplication: X = A * B (HAC 14.12)
|
||||
*/
|
||||
@@ -1206,7 +1203,6 @@ cleanup:
|
||||
|
||||
return( ret );
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Baseline multiplication: X = A * b
|
||||
@@ -1531,8 +1527,6 @@ int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_MPI_EXP_MOD_ALT)
|
||||
|
||||
/*
|
||||
* Fast Montgomery initialization (thanks to Tom St Denis)
|
||||
*/
|
||||
@@ -1796,7 +1790,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi
|
||||
*/
|
||||
MBEDTLS_MPI_CHK( mpi_montred( X, N, mm, &T ) );
|
||||
|
||||
if( neg )
|
||||
if( neg && E->n != 0 && ( E->p[0] & 1 ) != 0 )
|
||||
{
|
||||
X->s = -1;
|
||||
MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( X, N, X ) );
|
||||
@@ -1814,7 +1808,6 @@ cleanup:
|
||||
|
||||
return( ret );
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Greatest common divisor: G = gcd(A, B) (HAC 14.54)
|
||||
@@ -1900,7 +1893,7 @@ int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi
|
||||
int ret;
|
||||
mbedtls_mpi G, TA, TU, U1, U2, TB, TV, V1, V2;
|
||||
|
||||
if( mbedtls_mpi_cmp_int( N, 0 ) <= 0 )
|
||||
if( mbedtls_mpi_cmp_int( N, 1 ) <= 0 )
|
||||
return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
|
||||
|
||||
mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TU ); mbedtls_mpi_init( &U1 ); mbedtls_mpi_init( &U2 );
|
||||
@@ -2276,7 +2269,6 @@ cleanup:
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_GENPRIME */
|
||||
#endif /* MBEDTLS_BIGNUM_ALT */
|
||||
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
|
||||
|
Reference in New Issue
Block a user