mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Add little endian export to Bignum
The function `mbedtls_mpi_write_binary()` writes big endian byte order, but we need to be able to write little endian in some caseses. (For example when handling keys corresponding to Montgomery curves.) Used `echo xx | tac -rs ..` to transform the test data to little endian.
This commit is contained in:
@ -378,6 +378,37 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_mpi_write_binary_le( int radix_X, char * input_X,
|
||||
data_t * input_A, int output_size,
|
||||
int result )
|
||||
{
|
||||
mbedtls_mpi X;
|
||||
unsigned char buf[1000];
|
||||
size_t buflen;
|
||||
|
||||
memset( buf, 0x00, 1000 );
|
||||
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &X, radix_X, input_X ) == 0 );
|
||||
|
||||
buflen = mbedtls_mpi_size( &X );
|
||||
if( buflen > (size_t) output_size )
|
||||
buflen = (size_t) output_size;
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_write_binary_le( &X, buf, buflen ) == result );
|
||||
if( result == 0)
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
mbedtls_mpi_free( &X );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO */
|
||||
void mbedtls_mpi_read_file( int radix_X, char * input_file,
|
||||
data_t * input_A, int result )
|
||||
|
Reference in New Issue
Block a user