aes: xts: Add tests for invalid key sizes

Test that we get the error we expect when using various valid and invalid
keysizes with mbedtls_aes_xts_setkey_enc() and
mbedtls_aes_xts_setkey_dec().
This commit is contained in:
Jaeden Amero 2018-05-31 10:40:34 +01:00
parent 8cfc75f603
commit 142383e25b
2 changed files with 30 additions and 0 deletions

View file

@ -258,6 +258,21 @@ void aes_crypt_xts_size( int size, int retval )
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_XTS */
void aes_crypt_xts_keysize( int size, int retval )
{
mbedtls_aes_xts_context ctx;
const unsigned char *key = NULL;
size_t key_len = size;
mbedtls_aes_xts_init( &ctx );
TEST_ASSERT( mbedtls_aes_xts_setkey_enc( &ctx, key, key_len * 8 ) == retval );
TEST_ASSERT( mbedtls_aes_xts_setkey_dec( &ctx, key, key_len * 8 ) == retval );
exit:
mbedtls_aes_xts_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */