blob: 07040e5904d5e29fb5cdc9fff81ecd54894c3ac7 [file] [log] [blame]
Paul Bakker33b43f12013-08-20 11:48:36 +02001/* BEGIN_HEADER */
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +00002#include "mbedtls/aes.h"
Paul Bakker33b43f12013-08-20 11:48:36 +02003/* END_HEADER */
Paul Bakker367dae42009-06-28 21:50:27 +00004
Paul Bakker33b43f12013-08-20 11:48:36 +02005/* BEGIN_DEPENDENCIES
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006 * depends_on:MBEDTLS_AES_C
Paul Bakker33b43f12013-08-20 11:48:36 +02007 * END_DEPENDENCIES
8 */
Paul Bakker5690efc2011-05-26 13:16:06 +00009
Paul Bakker33b43f12013-08-20 11:48:36 +020010/* BEGIN_CASE */
Azim Khan5fcca462018-06-29 11:05:32 +010011void aes_encrypt_ecb( data_t * key_str, data_t * src_str,
12 data_t * hex_dst_string, int setkey_result )
Paul Bakker367dae42009-06-28 21:50:27 +000013{
Paul Bakker367dae42009-06-28 21:50:27 +000014 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020015 mbedtls_aes_context ctx;
Paul Bakker367dae42009-06-28 21:50:27 +000016
Paul Bakker367dae42009-06-28 21:50:27 +000017 memset(output, 0x00, 100);
18
Simon Butcher249b3d62018-12-09 22:18:46 +000019 mbedtls_aes_init( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +000020
Azim Khand30ca132017-06-09 04:32:58 +010021 TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ) == setkey_result );
Paul Bakker33b43f12013-08-20 11:48:36 +020022 if( setkey_result == 0 )
Paul Bakker2b222c82009-07-27 21:03:45 +000023 {
Azim Khand30ca132017-06-09 04:32:58 +010024 TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx, MBEDTLS_AES_ENCRYPT, src_str->x, output ) == 0 );
Paul Bakker367dae42009-06-28 21:50:27 +000025
Azim Khand30ca132017-06-09 04:32:58 +010026 TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
Paul Bakker2b222c82009-07-27 21:03:45 +000027 }
Paul Bakker8cfd9d82014-06-18 11:16:11 +020028
Paul Bakkerbd51b262014-07-10 15:26:12 +020029exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020030 mbedtls_aes_free( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +000031}
Paul Bakker33b43f12013-08-20 11:48:36 +020032/* END_CASE */
Paul Bakker367dae42009-06-28 21:50:27 +000033
Paul Bakker33b43f12013-08-20 11:48:36 +020034/* BEGIN_CASE */
Azim Khan5fcca462018-06-29 11:05:32 +010035void aes_decrypt_ecb( data_t * key_str, data_t * src_str,
36 data_t * hex_dst_string, int setkey_result )
Paul Bakker367dae42009-06-28 21:50:27 +000037{
Paul Bakker367dae42009-06-28 21:50:27 +000038 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020039 mbedtls_aes_context ctx;
Paul Bakker367dae42009-06-28 21:50:27 +000040
Paul Bakker367dae42009-06-28 21:50:27 +000041 memset(output, 0x00, 100);
42
Simon Butcher249b3d62018-12-09 22:18:46 +000043 mbedtls_aes_init( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +000044
Azim Khand30ca132017-06-09 04:32:58 +010045 TEST_ASSERT( mbedtls_aes_setkey_dec( &ctx, key_str->x, key_str->len * 8 ) == setkey_result );
Paul Bakker33b43f12013-08-20 11:48:36 +020046 if( setkey_result == 0 )
Paul Bakker2b222c82009-07-27 21:03:45 +000047 {
Azim Khand30ca132017-06-09 04:32:58 +010048 TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx, MBEDTLS_AES_DECRYPT, src_str->x, output ) == 0 );
Paul Bakker367dae42009-06-28 21:50:27 +000049
Azim Khand30ca132017-06-09 04:32:58 +010050 TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
Paul Bakker2b222c82009-07-27 21:03:45 +000051 }
Paul Bakker8cfd9d82014-06-18 11:16:11 +020052
Paul Bakkerbd51b262014-07-10 15:26:12 +020053exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020054 mbedtls_aes_free( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +000055}
Paul Bakker33b43f12013-08-20 11:48:36 +020056/* END_CASE */
Paul Bakker367dae42009-06-28 21:50:27 +000057
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020058/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */
Azim Khan5fcca462018-06-29 11:05:32 +010059void aes_encrypt_cbc( data_t * key_str, data_t * iv_str,
60 data_t * src_str, data_t * hex_dst_string,
Azim Khand30ca132017-06-09 04:32:58 +010061 int cbc_result )
Paul Bakker367dae42009-06-28 21:50:27 +000062{
Paul Bakker367dae42009-06-28 21:50:27 +000063 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020064 mbedtls_aes_context ctx;
Paul Bakker367dae42009-06-28 21:50:27 +000065
Paul Bakker367dae42009-06-28 21:50:27 +000066 memset(output, 0x00, 100);
67
Simon Butcher249b3d62018-12-09 22:18:46 +000068 mbedtls_aes_init( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +000069
Azim Khand30ca132017-06-09 04:32:58 +010070 mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
71 TEST_ASSERT( mbedtls_aes_crypt_cbc( &ctx, MBEDTLS_AES_ENCRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result );
Paul Bakker33b43f12013-08-20 11:48:36 +020072 if( cbc_result == 0 )
Paul Bakkerf3ccc682010-03-18 21:21:02 +000073 {
Paul Bakker367dae42009-06-28 21:50:27 +000074
Azim Khand30ca132017-06-09 04:32:58 +010075 TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
Paul Bakkerf3ccc682010-03-18 21:21:02 +000076 }
Paul Bakker8cfd9d82014-06-18 11:16:11 +020077
Paul Bakkerbd51b262014-07-10 15:26:12 +020078exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020079 mbedtls_aes_free( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +000080}
Paul Bakker33b43f12013-08-20 11:48:36 +020081/* END_CASE */
Paul Bakker367dae42009-06-28 21:50:27 +000082
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020083/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */
Azim Khan5fcca462018-06-29 11:05:32 +010084void aes_decrypt_cbc( data_t * key_str, data_t * iv_str,
85 data_t * src_str, data_t * hex_dst_string,
Azim Khand30ca132017-06-09 04:32:58 +010086 int cbc_result )
Paul Bakker367dae42009-06-28 21:50:27 +000087{
Paul Bakker367dae42009-06-28 21:50:27 +000088 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020089 mbedtls_aes_context ctx;
Paul Bakker367dae42009-06-28 21:50:27 +000090
Paul Bakker367dae42009-06-28 21:50:27 +000091 memset(output, 0x00, 100);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020092 mbedtls_aes_init( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +000093
Azim Khand30ca132017-06-09 04:32:58 +010094 mbedtls_aes_setkey_dec( &ctx, key_str->x, key_str->len * 8 );
95 TEST_ASSERT( mbedtls_aes_crypt_cbc( &ctx, MBEDTLS_AES_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result );
Paul Bakker33b43f12013-08-20 11:48:36 +020096 if( cbc_result == 0)
Paul Bakkerf3ccc682010-03-18 21:21:02 +000097 {
Paul Bakker367dae42009-06-28 21:50:27 +000098
Azim Khand30ca132017-06-09 04:32:58 +010099 TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000100 }
Paul Bakker8cfd9d82014-06-18 11:16:11 +0200101
Paul Bakkerbd51b262014-07-10 15:26:12 +0200102exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200103 mbedtls_aes_free( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +0000104}
Paul Bakker33b43f12013-08-20 11:48:36 +0200105/* END_CASE */
Paul Bakker367dae42009-06-28 21:50:27 +0000106
Aorimn5f778012016-06-09 23:22:58 +0200107/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_XTS */
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100108void aes_encrypt_xts( char *hex_key_string, char *hex_data_unit_string,
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100109 char *hex_src_string, char *hex_dst_string )
Aorimn5f778012016-06-09 23:22:58 +0200110{
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100111 enum { AES_BLOCK_SIZE = 16 };
112 unsigned char *data_unit = NULL;
113 unsigned char *key = NULL;
114 unsigned char *src = NULL;
115 unsigned char *dst = NULL;
116 unsigned char *output = NULL;
Jaeden Amero9366feb2018-05-29 18:55:17 +0100117 mbedtls_aes_xts_context ctx;
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100118 size_t key_len, src_len, dst_len, data_unit_len;
Aorimn5f778012016-06-09 23:22:58 +0200119
Jaeden Amero9366feb2018-05-29 18:55:17 +0100120 mbedtls_aes_xts_init( &ctx );
Aorimn5f778012016-06-09 23:22:58 +0200121
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100122 data_unit = unhexify_alloc( hex_data_unit_string, &data_unit_len );
123 TEST_ASSERT( data_unit_len == AES_BLOCK_SIZE );
Aorimn5f778012016-06-09 23:22:58 +0200124
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100125 key = unhexify_alloc( hex_key_string, &key_len );
126 TEST_ASSERT( key_len % 2 == 0 );
Aorimn5f778012016-06-09 23:22:58 +0200127
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100128 src = unhexify_alloc( hex_src_string, &src_len );
129 dst = unhexify_alloc( hex_dst_string, &dst_len );
130 TEST_ASSERT( src_len == dst_len );
Aorimn5f778012016-06-09 23:22:58 +0200131
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100132 output = zero_alloc( dst_len );
133
134 TEST_ASSERT( mbedtls_aes_xts_setkey_enc( &ctx, key, key_len * 8 ) == 0 );
135 TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, src_len,
136 data_unit, src, output ) == 0 );
137
138 TEST_ASSERT( memcmp( output, dst, dst_len ) == 0 );
Aorimn5f778012016-06-09 23:22:58 +0200139
140exit:
Jaeden Amero9366feb2018-05-29 18:55:17 +0100141 mbedtls_aes_xts_free( &ctx );
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100142 mbedtls_free( data_unit );
143 mbedtls_free( key );
144 mbedtls_free( src );
145 mbedtls_free( dst );
146 mbedtls_free( output );
Aorimn5f778012016-06-09 23:22:58 +0200147}
148/* END_CASE */
149
150/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_XTS */
Jaeden Amerocd9fc5e2018-05-30 15:23:24 +0100151void aes_decrypt_xts( char *hex_key_string, char *hex_data_unit_string,
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100152 char *hex_dst_string, char *hex_src_string )
Aorimn5f778012016-06-09 23:22:58 +0200153{
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100154 enum { AES_BLOCK_SIZE = 16 };
155 unsigned char *data_unit = NULL;
156 unsigned char *key = NULL;
157 unsigned char *src = NULL;
158 unsigned char *dst = NULL;
159 unsigned char *output = NULL;
Jaeden Amero9366feb2018-05-29 18:55:17 +0100160 mbedtls_aes_xts_context ctx;
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100161 size_t key_len, src_len, dst_len, data_unit_len;
Aorimn5f778012016-06-09 23:22:58 +0200162
Jaeden Amero9366feb2018-05-29 18:55:17 +0100163 mbedtls_aes_xts_init( &ctx );
Aorimn5f778012016-06-09 23:22:58 +0200164
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100165 data_unit = unhexify_alloc( hex_data_unit_string, &data_unit_len );
166 TEST_ASSERT( data_unit_len == AES_BLOCK_SIZE );
Aorimn5f778012016-06-09 23:22:58 +0200167
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100168 key = unhexify_alloc( hex_key_string, &key_len );
169 TEST_ASSERT( key_len % 2 == 0 );
Aorimn5f778012016-06-09 23:22:58 +0200170
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100171 src = unhexify_alloc( hex_src_string, &src_len );
172 dst = unhexify_alloc( hex_dst_string, &dst_len );
173 TEST_ASSERT( src_len == dst_len );
Aorimn5f778012016-06-09 23:22:58 +0200174
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100175 output = zero_alloc( dst_len );
176
177 TEST_ASSERT( mbedtls_aes_xts_setkey_dec( &ctx, key, key_len * 8 ) == 0 );
178 TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_DECRYPT, src_len,
179 data_unit, src, output ) == 0 );
180
181 TEST_ASSERT( memcmp( output, dst, dst_len ) == 0 );
Aorimn5f778012016-06-09 23:22:58 +0200182
183exit:
Jaeden Amero9366feb2018-05-29 18:55:17 +0100184 mbedtls_aes_xts_free( &ctx );
Jaeden Ameroe5c4b072018-04-28 17:26:25 +0100185 mbedtls_free( data_unit );
186 mbedtls_free( key );
187 mbedtls_free( src );
188 mbedtls_free( dst );
189 mbedtls_free( output );
Aorimn5f778012016-06-09 23:22:58 +0200190}
191/* END_CASE */
192
Jaeden Amero425382d2018-04-28 17:26:25 +0100193/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_XTS */
194void aes_crypt_xts_size( int size, int retval )
195{
196 mbedtls_aes_xts_context ctx;
Manuel Pégourié-Gonnard191af132018-12-13 10:15:30 +0100197 const unsigned char src[16] = { 0 };
198 unsigned char output[16];
Jaeden Amero425382d2018-04-28 17:26:25 +0100199 unsigned char data_unit[16];
200 size_t length = size;
201
202 mbedtls_aes_xts_init( &ctx );
203 memset( data_unit, 0x00, sizeof( data_unit ) );
204
205
Manuel Pégourié-Gonnard191af132018-12-13 10:15:30 +0100206 /* Valid pointers are passed for builds with MBEDTLS_CHECK_PARAMS, as
207 * otherwise we wouldn't get to the size check we're interested in. */
Jaeden Amero425382d2018-04-28 17:26:25 +0100208 TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, length, data_unit, src, output ) == retval );
209}
210/* END_CASE */
211
Jaeden Amero142383e2018-05-31 10:40:34 +0100212/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_XTS */
213void aes_crypt_xts_keysize( int size, int retval )
214{
215 mbedtls_aes_xts_context ctx;
Manuel Pégourié-Gonnard68e3dff2018-12-12 12:48:04 +0100216 const unsigned char key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
Jaeden Amero142383e2018-05-31 10:40:34 +0100217 size_t key_len = size;
218
219 mbedtls_aes_xts_init( &ctx );
220
221 TEST_ASSERT( mbedtls_aes_xts_setkey_enc( &ctx, key, key_len * 8 ) == retval );
222 TEST_ASSERT( mbedtls_aes_xts_setkey_dec( &ctx, key, key_len * 8 ) == retval );
223exit:
224 mbedtls_aes_xts_free( &ctx );
225}
226/* END_CASE */
Jaeden Amero425382d2018-04-28 17:26:25 +0100227
228
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200229/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */
Azim Khan5fcca462018-06-29 11:05:32 +0100230void aes_encrypt_cfb128( data_t * key_str, data_t * iv_str,
231 data_t * src_str, data_t * hex_dst_string )
Paul Bakker367dae42009-06-28 21:50:27 +0000232{
Paul Bakker367dae42009-06-28 21:50:27 +0000233 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200234 mbedtls_aes_context ctx;
Paul Bakkercd43a0b2011-06-09 13:55:44 +0000235 size_t iv_offset = 0;
Paul Bakker367dae42009-06-28 21:50:27 +0000236
Paul Bakker367dae42009-06-28 21:50:27 +0000237 memset(output, 0x00, 100);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200238 mbedtls_aes_init( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +0000239
Paul Bakker367dae42009-06-28 21:50:27 +0000240
Azim Khand30ca132017-06-09 04:32:58 +0100241 mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
242 TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_ENCRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
Paul Bakker367dae42009-06-28 21:50:27 +0000243
Azim Khand30ca132017-06-09 04:32:58 +0100244 TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
Paul Bakker8cfd9d82014-06-18 11:16:11 +0200245
Paul Bakkerbd51b262014-07-10 15:26:12 +0200246exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200247 mbedtls_aes_free( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +0000248}
Paul Bakker33b43f12013-08-20 11:48:36 +0200249/* END_CASE */
Paul Bakker367dae42009-06-28 21:50:27 +0000250
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200251/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */
Azim Khan5fcca462018-06-29 11:05:32 +0100252void aes_decrypt_cfb128( data_t * key_str, data_t * iv_str,
253 data_t * src_str, data_t * hex_dst_string )
Paul Bakker367dae42009-06-28 21:50:27 +0000254{
Paul Bakker367dae42009-06-28 21:50:27 +0000255 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200256 mbedtls_aes_context ctx;
Paul Bakkercd43a0b2011-06-09 13:55:44 +0000257 size_t iv_offset = 0;
Paul Bakker367dae42009-06-28 21:50:27 +0000258
Paul Bakker367dae42009-06-28 21:50:27 +0000259 memset(output, 0x00, 100);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200260 mbedtls_aes_init( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +0000261
Paul Bakker367dae42009-06-28 21:50:27 +0000262
Azim Khand30ca132017-06-09 04:32:58 +0100263 mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
264 TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_DECRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
Paul Bakker367dae42009-06-28 21:50:27 +0000265
Azim Khand30ca132017-06-09 04:32:58 +0100266 TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
Paul Bakker8cfd9d82014-06-18 11:16:11 +0200267
Paul Bakkerbd51b262014-07-10 15:26:12 +0200268exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200269 mbedtls_aes_free( &ctx );
Paul Bakker367dae42009-06-28 21:50:27 +0000270}
Paul Bakker33b43f12013-08-20 11:48:36 +0200271/* END_CASE */
Paul Bakker367dae42009-06-28 21:50:27 +0000272
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200273/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */
Azim Khan5fcca462018-06-29 11:05:32 +0100274void aes_encrypt_cfb8( data_t * key_str, data_t * iv_str,
275 data_t * src_str, data_t * hex_dst_string )
Paul Bakker556efba2014-01-24 15:38:12 +0100276{
Paul Bakker556efba2014-01-24 15:38:12 +0100277 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200278 mbedtls_aes_context ctx;
Paul Bakker556efba2014-01-24 15:38:12 +0100279
Paul Bakker556efba2014-01-24 15:38:12 +0100280 memset(output, 0x00, 100);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200281 mbedtls_aes_init( &ctx );
Paul Bakker556efba2014-01-24 15:38:12 +0100282
Paul Bakker556efba2014-01-24 15:38:12 +0100283
Azim Khand30ca132017-06-09 04:32:58 +0100284 mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
285 TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_ENCRYPT, src_str->len, iv_str->x, src_str->x, output ) == 0 );
Paul Bakker556efba2014-01-24 15:38:12 +0100286
Azim Khand30ca132017-06-09 04:32:58 +0100287 TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
Paul Bakker8cfd9d82014-06-18 11:16:11 +0200288
Paul Bakkerbd51b262014-07-10 15:26:12 +0200289exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200290 mbedtls_aes_free( &ctx );
Paul Bakker556efba2014-01-24 15:38:12 +0100291}
292/* END_CASE */
293
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200294/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */
Azim Khan5fcca462018-06-29 11:05:32 +0100295void aes_decrypt_cfb8( data_t * key_str, data_t * iv_str,
296 data_t * src_str, data_t * hex_dst_string )
Paul Bakker556efba2014-01-24 15:38:12 +0100297{
Paul Bakker556efba2014-01-24 15:38:12 +0100298 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200299 mbedtls_aes_context ctx;
Paul Bakker556efba2014-01-24 15:38:12 +0100300
Paul Bakker556efba2014-01-24 15:38:12 +0100301 memset(output, 0x00, 100);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200302 mbedtls_aes_init( &ctx );
Paul Bakker556efba2014-01-24 15:38:12 +0100303
Paul Bakker556efba2014-01-24 15:38:12 +0100304
Azim Khand30ca132017-06-09 04:32:58 +0100305 mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
306 TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == 0 );
Paul Bakker556efba2014-01-24 15:38:12 +0100307
Azim Khand30ca132017-06-09 04:32:58 +0100308 TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
Paul Bakker8cfd9d82014-06-18 11:16:11 +0200309
Paul Bakkerbd51b262014-07-10 15:26:12 +0200310exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200311 mbedtls_aes_free( &ctx );
Paul Bakker556efba2014-01-24 15:38:12 +0100312}
313/* END_CASE */
314
Simon Butcher03018842018-04-22 22:57:58 +0100315/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_OFB */
316void aes_encrypt_ofb( int fragment_size, char *hex_key_string,
Simon Butcher00131442018-05-22 22:40:36 +0100317 char *hex_iv_string, char *hex_src_string,
318 char *hex_dst_string )
Simon Butcher03018842018-04-22 22:57:58 +0100319{
Simon Butchere416bf92018-06-02 18:28:32 +0100320 unsigned char key_str[32];
321 unsigned char iv_str[16];
322 unsigned char src_str[64];
323 unsigned char dst_str[64];
324 unsigned char output[32];
Simon Butcher03018842018-04-22 22:57:58 +0100325 mbedtls_aes_context ctx;
326 size_t iv_offset = 0;
327 int in_buffer_len;
328 unsigned char* src_str_next;
Simon Butcherdbe7fbf2018-04-29 14:51:35 +0100329 int key_len;
Simon Butcher03018842018-04-22 22:57:58 +0100330
Simon Butcherb7836e12018-06-02 18:36:49 +0100331 memset( key_str, 0x00, sizeof( key_str ) );
332 memset( iv_str, 0x00, sizeof( iv_str ) );
333 memset( src_str, 0x00, sizeof( src_str ) );
334 memset( dst_str, 0x00, sizeof( dst_str ) );
335 memset( output, 0x00, sizeof( output ) );
Simon Butcher03018842018-04-22 22:57:58 +0100336 mbedtls_aes_init( &ctx );
337
Simon Butchere416bf92018-06-02 18:28:32 +0100338 TEST_ASSERT( strlen( hex_key_string ) <= ( 32 * 2 ) );
339 TEST_ASSERT( strlen( hex_iv_string ) <= ( 16 * 2 ) );
340 TEST_ASSERT( strlen( hex_src_string ) <= ( 64 * 2 ) );
341 TEST_ASSERT( strlen( hex_dst_string ) <= ( 64 * 2 ) );
342
Simon Butcher03018842018-04-22 22:57:58 +0100343 key_len = unhexify( key_str, hex_key_string );
Simon Butcherdbe7fbf2018-04-29 14:51:35 +0100344 unhexify( iv_str, hex_iv_string );
Simon Butcher03018842018-04-22 22:57:58 +0100345 in_buffer_len = unhexify( src_str, hex_src_string );
346
Simon Butcherad4e4932018-04-29 00:43:47 +0100347 TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
Simon Butcher03018842018-04-22 22:57:58 +0100348 src_str_next = src_str;
349
350 while( in_buffer_len > 0 )
351 {
352 TEST_ASSERT( mbedtls_aes_crypt_ofb( &ctx, fragment_size, &iv_offset,
353 iv_str, src_str_next, output ) == 0 );
354
355 hexify( dst_str, output, fragment_size );
356 TEST_ASSERT( strncmp( (char *) dst_str, hex_dst_string,
Simon Butcher00131442018-05-22 22:40:36 +0100357 ( 2 * fragment_size ) ) == 0 );
Simon Butcher03018842018-04-22 22:57:58 +0100358
359 in_buffer_len -= fragment_size;
360 hex_dst_string += ( fragment_size * 2 );
361 src_str_next += fragment_size;
362
363 if( in_buffer_len < fragment_size )
364 fragment_size = in_buffer_len;
365 }
366
367exit:
368 mbedtls_aes_free( &ctx );
369}
370/* END_CASE */
371
Manuel Pégourié-Gonnarda2b0e272018-12-10 15:23:58 +0100372/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
Manuel Pégourié-Gonnard3178d1a2018-12-12 13:05:00 +0100373void aes_check_params( )
Simon Butchera6463452018-12-06 17:41:56 +0000374{
Manuel Pégourié-Gonnard68e3dff2018-12-12 12:48:04 +0100375 mbedtls_aes_context aes_ctx;
376#if defined(MBEDTLS_CIPHER_MODE_XTS)
377 mbedtls_aes_xts_context xts_ctx;
378#endif
Simon Butchera6463452018-12-06 17:41:56 +0000379 const unsigned char key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
Manuel Pégourié-Gonnard1aca2602018-12-12 12:56:55 +0100380 const unsigned char in[16] = { 0 };
381 unsigned char out[16];
Manuel Pégourié-Gonnard1677cca2018-12-13 10:27:13 +0100382 size_t size;
Simon Butchera6463452018-12-06 17:41:56 +0000383
384 TEST_INVALID_PARAM( mbedtls_aes_init( NULL ) );
Manuel Pégourié-Gonnard68e3dff2018-12-12 12:48:04 +0100385#if defined(MBEDTLS_CIPHER_MODE_XTS)
Manuel Pégourié-Gonnard44c5d582018-12-10 16:56:14 +0100386 TEST_INVALID_PARAM( mbedtls_aes_xts_init( NULL ) );
Manuel Pégourié-Gonnard68e3dff2018-12-12 12:48:04 +0100387#endif
Manuel Pégourié-Gonnard44c5d582018-12-10 16:56:14 +0100388
Simon Butchera6463452018-12-06 17:41:56 +0000389 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
390 mbedtls_aes_setkey_enc( NULL, key, 128 ) );
Simon Butchera6463452018-12-06 17:41:56 +0000391 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
Manuel Pégourié-Gonnard68e3dff2018-12-12 12:48:04 +0100392 mbedtls_aes_setkey_enc( &aes_ctx, NULL, 128 ) );
Simon Butchera6463452018-12-06 17:41:56 +0000393
Simon Butchera6463452018-12-06 17:41:56 +0000394 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
395 mbedtls_aes_setkey_dec( NULL, key, 128 ) );
Manuel Pégourié-Gonnard68e3dff2018-12-12 12:48:04 +0100396 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
397 mbedtls_aes_setkey_dec( &aes_ctx, NULL, 128 ) );
398
399#if defined(MBEDTLS_CIPHER_MODE_XTS)
400 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
401 mbedtls_aes_xts_setkey_enc( NULL, key, 128 ) );
402 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
403 mbedtls_aes_xts_setkey_enc( &xts_ctx, NULL, 128 ) );
Simon Butchera6463452018-12-06 17:41:56 +0000404
405 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
Manuel Pégourié-Gonnard68e3dff2018-12-12 12:48:04 +0100406 mbedtls_aes_xts_setkey_dec( NULL, key, 128 ) );
407 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
408 mbedtls_aes_xts_setkey_dec( &xts_ctx, NULL, 128 ) );
409#endif
Manuel Pégourié-Gonnard1aca2602018-12-12 12:56:55 +0100410
411
412 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
413 mbedtls_aes_crypt_ecb( NULL,
414 MBEDTLS_AES_ENCRYPT, in, out ) );
415 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
416 mbedtls_aes_crypt_ecb( &aes_ctx,
417 42, in, out ) );
418 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
419 mbedtls_aes_crypt_ecb( &aes_ctx,
420 MBEDTLS_AES_ENCRYPT, NULL, out ) );
421 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
422 mbedtls_aes_crypt_ecb( &aes_ctx,
423 MBEDTLS_AES_ENCRYPT, in, NULL ) );
Manuel Pégourié-Gonnard3178d1a2018-12-12 13:05:00 +0100424
425#if defined(MBEDTLS_CIPHER_MODE_CBC)
426 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
427 mbedtls_aes_crypt_cbc( NULL,
428 MBEDTLS_AES_ENCRYPT, 16,
429 out, in, out ) );
430 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
431 mbedtls_aes_crypt_cbc( &aes_ctx,
432 42, 16,
433 out, in, out ) );
434 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
435 mbedtls_aes_crypt_cbc( &aes_ctx,
436 MBEDTLS_AES_ENCRYPT, 16,
437 NULL, in, out ) );
438 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
439 mbedtls_aes_crypt_cbc( &aes_ctx,
440 MBEDTLS_AES_ENCRYPT, 16,
441 out, NULL, out ) );
442 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
443 mbedtls_aes_crypt_cbc( &aes_ctx,
444 MBEDTLS_AES_ENCRYPT, 16,
445 out, in, NULL ) );
446#endif /* MBEDTLS_CIPHER_MODE_CBC */
Manuel Pégourié-Gonnard191af132018-12-13 10:15:30 +0100447
448#if defined(MBEDTLS_CIPHER_MODE_XTS)
449 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
450 mbedtls_aes_crypt_xts( NULL,
451 MBEDTLS_AES_ENCRYPT, 16,
452 in, in, out ) );
453 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
454 mbedtls_aes_crypt_xts( &xts_ctx,
455 42, 16,
456 in, in, out ) );
457 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
458 mbedtls_aes_crypt_xts( &xts_ctx,
459 MBEDTLS_AES_ENCRYPT, 16,
460 NULL, in, out ) );
461 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
462 mbedtls_aes_crypt_xts( &xts_ctx,
463 MBEDTLS_AES_ENCRYPT, 16,
464 in, NULL, out ) );
465 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
466 mbedtls_aes_crypt_xts( &xts_ctx,
467 MBEDTLS_AES_ENCRYPT, 16,
468 in, in, NULL ) );
469#endif /* MBEDTLS_CIPHER_MODE_XTS */
Manuel Pégourié-Gonnard1677cca2018-12-13 10:27:13 +0100470
471#if defined(MBEDTLS_CIPHER_MODE_CFB)
472 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
473 mbedtls_aes_crypt_cfb128( NULL,
474 MBEDTLS_AES_ENCRYPT, 16,
475 &size, out, in, out ) );
476 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
477 mbedtls_aes_crypt_cfb128( &aes_ctx,
478 42, 16,
479 &size, out, in, out ) );
480 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
481 mbedtls_aes_crypt_cfb128( &aes_ctx,
482 MBEDTLS_AES_ENCRYPT, 16,
483 NULL, out, in, out ) );
484 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
485 mbedtls_aes_crypt_cfb128( &aes_ctx,
486 MBEDTLS_AES_ENCRYPT, 16,
487 &size, NULL, in, out ) );
488 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
489 mbedtls_aes_crypt_cfb128( &aes_ctx,
490 MBEDTLS_AES_ENCRYPT, 16,
491 &size, out, NULL, out ) );
492 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
493 mbedtls_aes_crypt_cfb128( &aes_ctx,
494 MBEDTLS_AES_ENCRYPT, 16,
495 &size, out, in, NULL ) );
496
497
498 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
499 mbedtls_aes_crypt_cfb8( NULL,
500 MBEDTLS_AES_ENCRYPT, 16,
501 out, in, out ) );
502 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
503 mbedtls_aes_crypt_cfb8( &aes_ctx,
504 42, 16,
505 out, in, out ) );
506 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
507 mbedtls_aes_crypt_cfb8( &aes_ctx,
508 MBEDTLS_AES_ENCRYPT, 16,
509 NULL, in, out ) );
510 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
511 mbedtls_aes_crypt_cfb8( &aes_ctx,
512 MBEDTLS_AES_ENCRYPT, 16,
513 out, NULL, out ) );
514 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
515 mbedtls_aes_crypt_cfb8( &aes_ctx,
516 MBEDTLS_AES_ENCRYPT, 16,
517 out, in, NULL ) );
518#endif /* MBEDTLS_CIPHER_MODE_CFB */
Manuel Pégourié-Gonnard8e41eb72018-12-13 11:00:56 +0100519
520#if defined(MBEDTLS_CIPHER_MODE_OFB)
521 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
522 mbedtls_aes_crypt_ofb( NULL, 16,
523 &size, out, in, out ) );
524 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
525 mbedtls_aes_crypt_ofb( &aes_ctx, 16,
526 NULL, out, in, out ) );
527 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
528 mbedtls_aes_crypt_ofb( &aes_ctx, 16,
529 &size, NULL, in, out ) );
530 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
531 mbedtls_aes_crypt_ofb( &aes_ctx, 16,
532 &size, out, NULL, out ) );
533 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
534 mbedtls_aes_crypt_ofb( &aes_ctx, 16,
535 &size, out, in, NULL ) );
536#endif /* MBEDTLS_CIPHER_MODE_OFB */
Manuel Pégourié-Gonnard2bc535b2018-12-13 11:08:36 +0100537
538#if defined(MBEDTLS_CIPHER_MODE_CTR)
539 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
540 mbedtls_aes_crypt_ctr( NULL, 16, &size, out,
541 out, in, out ) );
542 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
543 mbedtls_aes_crypt_ctr( &aes_ctx, 16, NULL, out,
544 out, in, out ) );
545 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
546 mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, NULL,
547 out, in, out ) );
548 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
549 mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, out,
550 NULL, in, out ) );
551 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
552 mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, out,
553 out, NULL, out ) );
554 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA,
555 mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, out,
556 out, in, NULL ) );
557#endif /* MBEDTLS_CIPHER_MODE_CTR */
Manuel Pégourié-Gonnarda4251f42018-12-12 12:04:51 +0100558}
559/* END_CASE */
Simon Butchera6463452018-12-06 17:41:56 +0000560
Manuel Pégourié-Gonnarda4251f42018-12-12 12:04:51 +0100561/* BEGIN_CASE */
Manuel Pégourié-Gonnard3178d1a2018-12-12 13:05:00 +0100562void aes_misc_params( )
Manuel Pégourié-Gonnarda4251f42018-12-12 12:04:51 +0100563{
Manuel Pégourié-Gonnard3178d1a2018-12-12 13:05:00 +0100564 mbedtls_aes_context aes_ctx;
Manuel Pégourié-Gonnard191af132018-12-13 10:15:30 +0100565#if defined(MBEDTLS_CIPHER_MODE_XTS)
566 mbedtls_aes_xts_context xts_ctx;
567#endif
Manuel Pégourié-Gonnard3178d1a2018-12-12 13:05:00 +0100568 const unsigned char in[16] = { 0 };
569 unsigned char out[16];
570
Manuel Pégourié-Gonnard44c5d582018-12-10 16:56:14 +0100571 /* These calls accept NULL */
572 TEST_VALID_PARAM( mbedtls_aes_free( NULL ) );
Manuel Pégourié-Gonnardaf0c6cb2018-12-18 12:02:52 +0100573#if defined(MBEDTLS_CIPHER_MODE_XTS)
Manuel Pégourié-Gonnard44c5d582018-12-10 16:56:14 +0100574 TEST_VALID_PARAM( mbedtls_aes_xts_free( NULL ) );
Manuel Pégourié-Gonnardaf0c6cb2018-12-18 12:02:52 +0100575#endif
Manuel Pégourié-Gonnard3178d1a2018-12-12 13:05:00 +0100576
577#if defined(MBEDTLS_CIPHER_MODE_CBC)
578 TEST_ASSERT( mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_ENCRYPT,
Manuel Pégourié-Gonnard191af132018-12-13 10:15:30 +0100579 15,
580 out, in, out )
Manuel Pégourié-Gonnard3178d1a2018-12-12 13:05:00 +0100581 == MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
582 TEST_ASSERT( mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_ENCRYPT,
Manuel Pégourié-Gonnard191af132018-12-13 10:15:30 +0100583 17,
584 out, in, out )
Manuel Pégourié-Gonnard3178d1a2018-12-12 13:05:00 +0100585 == MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
586#endif
587
Manuel Pégourié-Gonnard191af132018-12-13 10:15:30 +0100588#if defined(MBEDTLS_CIPHER_MODE_XTS)
589 TEST_ASSERT( mbedtls_aes_crypt_xts( &xts_ctx, MBEDTLS_AES_ENCRYPT,
590 15,
591 in, in, out )
592 == MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
593 TEST_ASSERT( mbedtls_aes_crypt_xts( &xts_ctx, MBEDTLS_AES_ENCRYPT,
594 (1 << 24) + 1,
595 in, in, out )
596 == MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
597#endif
Simon Butchera6463452018-12-06 17:41:56 +0000598}
599/* END_CASE */
600
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200601/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
Azim Khanf1aaec92017-05-30 14:23:15 +0100602void aes_selftest( )
Paul Bakker3d360822009-07-05 11:29:38 +0000603{
Andres AG93012e82016-09-09 09:10:28 +0100604 TEST_ASSERT( mbedtls_aes_self_test( 1 ) == 0 );
Paul Bakker3d360822009-07-05 11:29:38 +0000605}
Paul Bakker33b43f12013-08-20 11:48:36 +0200606/* END_CASE */