mirror of
https://github.com/cuberite/polarssl.git
synced 2025-10-05 03:24:17 -04:00
Update test to cover move-decrypt sequence
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
This commit is contained in:
parent
7656a373b6
commit
ec0193d019
@ -464,7 +464,7 @@ void aes_misc_params( )
|
|||||||
void aes_ecb_copy_context( data_t * key_str, data_t * src_str )
|
void aes_ecb_copy_context( data_t * key_str, data_t * src_str )
|
||||||
{
|
{
|
||||||
unsigned char output1[16], output2[16], plain[16];
|
unsigned char output1[16], output2[16], plain[16];
|
||||||
mbedtls_aes_context ctx1, ctx2;
|
mbedtls_aes_context ctx1, ctx2, ctx3;
|
||||||
|
|
||||||
// Set key and encrypt with original context
|
// Set key and encrypt with original context
|
||||||
mbedtls_aes_init( &ctx1 );
|
mbedtls_aes_init( &ctx1 );
|
||||||
@ -474,18 +474,19 @@ void aes_ecb_copy_context( data_t * key_str, data_t * src_str )
|
|||||||
src_str->x, output1 ) == 0 );
|
src_str->x, output1 ) == 0 );
|
||||||
|
|
||||||
ctx2 = ctx1;
|
ctx2 = ctx1;
|
||||||
|
TEST_ASSERT( mbedtls_aes_setkey_dec( &ctx1, key_str->x,
|
||||||
|
key_str->len * 8 ) == 0 );
|
||||||
|
ctx3 = ctx1;
|
||||||
memset( &ctx1, 0, sizeof( ctx1 ) );
|
memset( &ctx1, 0, sizeof( ctx1 ) );
|
||||||
|
|
||||||
// Encrypt with copied context and decrypt
|
// Encrypt and decrypt with copied context
|
||||||
TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx2, MBEDTLS_AES_ENCRYPT,
|
TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx2, MBEDTLS_AES_ENCRYPT,
|
||||||
src_str->x, output2 ) == 0 );
|
src_str->x, output2 ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_aes_setkey_dec( &ctx2, key_str->x,
|
TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx3, MBEDTLS_AES_DECRYPT,
|
||||||
key_str->len * 8) == 0 );
|
|
||||||
TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx2, MBEDTLS_AES_DECRYPT,
|
|
||||||
output1, plain ) == 0 );
|
output1, plain ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_test_hexcmp( output1, output2, 16, 16 ) == 0 );
|
TEST_ASSERT( mbedtls_test_hexcmp( output1, output2, 16, 16 ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_test_hexcmp( src_str->x, plain, src_str->len, 16) == 0 );
|
TEST_ASSERT( mbedtls_test_hexcmp( src_str->x, plain, src_str->len, 16 ) == 0 );
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user