blob: 5d70fa2c97a4ae43212c3a8337d82c5b634d3e5f [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/camellia.h"
Paul Bakker33b43f12013-08-20 11:48:36 +02003/* END_HEADER */
Paul Bakkere896fea2009-07-06 06:40:23 +00004
Paul Bakker33b43f12013-08-20 11:48:36 +02005/* BEGIN_DEPENDENCIES
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006 * depends_on:MBEDTLS_CAMELLIA_C
Paul Bakker33b43f12013-08-20 11:48:36 +02007 * END_DEPENDENCIES
8 */
Paul Bakker5690efc2011-05-26 13:16:06 +00009
Hanno Becker75788372018-12-12 18:02:18 +000010/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
11void camellia_invalid_param( )
12{
13 mbedtls_camellia_context ctx;
14 unsigned char buf[16] = { 0 };
Hanno Beckere939de72018-12-13 15:39:24 +000015 const size_t valid_keybits = 128;
Hanno Beckere939de72018-12-13 15:39:24 +000016 const int invalid_mode = 42;
17 const int valid_mode = MBEDTLS_CAMELLIA_ENCRYPT;
Hanno Becker75788372018-12-12 18:02:18 +000018 size_t off;
19 ((void) off);
20
21 TEST_INVALID_PARAM( mbedtls_camellia_init( NULL ) );
22 TEST_VALID_PARAM( mbedtls_camellia_free( NULL ) );
23
24 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
25 mbedtls_camellia_setkey_enc( NULL,
26 buf,
Hanno Beckere939de72018-12-13 15:39:24 +000027 valid_keybits ) );
Hanno Becker75788372018-12-12 18:02:18 +000028 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
29 mbedtls_camellia_setkey_enc( &ctx,
30 NULL,
Hanno Beckere939de72018-12-13 15:39:24 +000031 valid_keybits ) );
Hanno Becker75788372018-12-12 18:02:18 +000032
33 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
34 mbedtls_camellia_setkey_dec( NULL,
35 buf,
Hanno Beckere939de72018-12-13 15:39:24 +000036 valid_keybits ) );
Hanno Becker75788372018-12-12 18:02:18 +000037 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
38 mbedtls_camellia_setkey_dec( &ctx,
39 NULL,
Hanno Beckere939de72018-12-13 15:39:24 +000040 valid_keybits ) );
Hanno Becker75788372018-12-12 18:02:18 +000041
42 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
43 mbedtls_camellia_crypt_ecb( NULL,
Hanno Beckere939de72018-12-13 15:39:24 +000044 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +000045 buf, buf ) );
46 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
47 mbedtls_camellia_crypt_ecb( &ctx,
Hanno Beckere939de72018-12-13 15:39:24 +000048 invalid_mode,
49 buf, buf ) );
50 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
51 mbedtls_camellia_crypt_ecb( &ctx,
52 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +000053 NULL, buf ) );
54 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
55 mbedtls_camellia_crypt_ecb( &ctx,
Hanno Beckere939de72018-12-13 15:39:24 +000056 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +000057 buf, NULL ) );
58
59#if defined(MBEDTLS_CIPHER_MODE_CBC)
60 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
61 mbedtls_camellia_crypt_cbc( NULL,
Hanno Beckere939de72018-12-13 15:39:24 +000062 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +000063 sizeof( buf ),
64 buf, buf, buf ) );
65 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
66 mbedtls_camellia_crypt_cbc( &ctx,
Hanno Beckere939de72018-12-13 15:39:24 +000067 invalid_mode,
Hanno Becker75788372018-12-12 18:02:18 +000068 sizeof( buf ),
69 buf, buf, buf ) );
70 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
71 mbedtls_camellia_crypt_cbc( &ctx,
Hanno Beckere939de72018-12-13 15:39:24 +000072 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +000073 sizeof( buf ),
74 NULL, buf, buf ) );
75 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
76 mbedtls_camellia_crypt_cbc( &ctx,
Hanno Beckere939de72018-12-13 15:39:24 +000077 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +000078 sizeof( buf ),
79 buf, NULL, buf ) );
80 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
81 mbedtls_camellia_crypt_cbc( &ctx,
Hanno Beckere939de72018-12-13 15:39:24 +000082 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +000083 sizeof( buf ),
84 buf, buf, NULL ) );
85#endif /* MBEDTLS_CIPHER_MODE_CBC */
86
87#if defined(MBEDTLS_CIPHER_MODE_CFB)
88 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
89 mbedtls_camellia_crypt_cfb128( NULL,
Hanno Beckere939de72018-12-13 15:39:24 +000090 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +000091 sizeof( buf ),
92 &off, buf,
93 buf, buf ) );
94 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
95 mbedtls_camellia_crypt_cfb128( &ctx,
Hanno Beckere939de72018-12-13 15:39:24 +000096 invalid_mode,
Hanno Becker75788372018-12-12 18:02:18 +000097 sizeof( buf ),
98 &off, buf,
99 buf, buf ) );
100 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
101 mbedtls_camellia_crypt_cfb128( &ctx,
Hanno Beckere939de72018-12-13 15:39:24 +0000102 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +0000103 sizeof( buf ),
104 NULL, buf,
105 buf, buf ) );
106 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
107 mbedtls_camellia_crypt_cfb128( &ctx,
Hanno Beckere939de72018-12-13 15:39:24 +0000108 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +0000109 sizeof( buf ),
110 &off, NULL,
111 buf, buf ) );
112 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
113 mbedtls_camellia_crypt_cfb128( &ctx,
Hanno Beckere939de72018-12-13 15:39:24 +0000114 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +0000115 sizeof( buf ),
116 &off, buf,
117 NULL, buf ) );
118 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
119 mbedtls_camellia_crypt_cfb128( &ctx,
Hanno Beckere939de72018-12-13 15:39:24 +0000120 valid_mode,
Hanno Becker75788372018-12-12 18:02:18 +0000121 sizeof( buf ),
122 &off, buf,
123 buf, NULL ) );
124#endif /* MBEDTLS_CIPHER_MODE_CFB */
125
126#if defined(MBEDTLS_CIPHER_MODE_CTR)
127 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
128 mbedtls_camellia_crypt_ctr( NULL,
129 sizeof( buf ),
130 &off,
131 buf, buf,
132 buf, buf ) );
133 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
134 mbedtls_camellia_crypt_ctr( &ctx,
135 sizeof( buf ),
136 NULL,
137 buf, buf,
138 buf, buf ) );
139 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
140 mbedtls_camellia_crypt_ctr( &ctx,
141 sizeof( buf ),
142 &off,
143 NULL, buf,
144 buf, buf ) );
145 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
146 mbedtls_camellia_crypt_ctr( &ctx,
147 sizeof( buf ),
148 &off,
149 buf, NULL,
150 buf, buf ) );
151 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
152 mbedtls_camellia_crypt_ctr( &ctx,
153 sizeof( buf ),
154 &off,
155 buf, buf,
156 NULL, buf ) );
157 TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA,
158 mbedtls_camellia_crypt_ctr( &ctx,
159 sizeof( buf ),
160 &off,
161 buf, buf,
162 buf, NULL ) );
163#endif /* MBEDTLS_CIPHER_MODE_CTR */
164
165exit:
166 return;
167}
168/* END_CASE */
169
Paul Bakker33b43f12013-08-20 11:48:36 +0200170/* BEGIN_CASE */
Azim Khan5fcca462018-06-29 11:05:32 +0100171void camellia_encrypt_ecb( data_t * key_str, data_t * src_str,
172 data_t * hex_dst_string, int setkey_result )
Paul Bakkere896fea2009-07-06 06:40:23 +0000173{
Paul Bakkere896fea2009-07-06 06:40:23 +0000174 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200175 mbedtls_camellia_context ctx;
Paul Bakkere896fea2009-07-06 06:40:23 +0000176
Paul Bakkere896fea2009-07-06 06:40:23 +0000177 memset(output, 0x00, 100);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200178 mbedtls_camellia_init( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000179
Paul Bakkere896fea2009-07-06 06:40:23 +0000180
Azim Khand30ca132017-06-09 04:32:58 +0100181 TEST_ASSERT( mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 ) == setkey_result );
Paul Bakker33b43f12013-08-20 11:48:36 +0200182 if( setkey_result == 0 )
Paul Bakker2b222c82009-07-27 21:03:45 +0000183 {
Azim Khand30ca132017-06-09 04:32:58 +0100184 TEST_ASSERT( mbedtls_camellia_crypt_ecb( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, src_str->x, output ) == 0 );
Paul Bakkere896fea2009-07-06 06:40:23 +0000185
Azim Khand30ca132017-06-09 04:32:58 +0100186 TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
Paul Bakker2b222c82009-07-27 21:03:45 +0000187 }
Paul Bakker8cfd9d82014-06-18 11:16:11 +0200188
Paul Bakkerbd51b262014-07-10 15:26:12 +0200189exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200190 mbedtls_camellia_free( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000191}
Paul Bakker33b43f12013-08-20 11:48:36 +0200192/* END_CASE */
Paul Bakkere896fea2009-07-06 06:40:23 +0000193
Paul Bakker33b43f12013-08-20 11:48:36 +0200194/* BEGIN_CASE */
Azim Khan5fcca462018-06-29 11:05:32 +0100195void camellia_decrypt_ecb( data_t * key_str, data_t * src_str,
196 data_t * hex_dst_string, int setkey_result )
Paul Bakkere896fea2009-07-06 06:40:23 +0000197{
Paul Bakkere896fea2009-07-06 06:40:23 +0000198 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200199 mbedtls_camellia_context ctx;
Paul Bakkere896fea2009-07-06 06:40:23 +0000200
Paul Bakkere896fea2009-07-06 06:40:23 +0000201 memset(output, 0x00, 100);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200202 mbedtls_camellia_init( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000203
Paul Bakkere896fea2009-07-06 06:40:23 +0000204
Azim Khand30ca132017-06-09 04:32:58 +0100205 TEST_ASSERT( mbedtls_camellia_setkey_dec( &ctx, key_str->x, key_str->len * 8 ) == setkey_result );
Paul Bakker33b43f12013-08-20 11:48:36 +0200206 if( setkey_result == 0 )
Paul Bakker2b222c82009-07-27 21:03:45 +0000207 {
Azim Khand30ca132017-06-09 04:32:58 +0100208 TEST_ASSERT( mbedtls_camellia_crypt_ecb( &ctx, MBEDTLS_CAMELLIA_DECRYPT, src_str->x, output ) == 0 );
Paul Bakkere896fea2009-07-06 06:40:23 +0000209
Azim Khand30ca132017-06-09 04:32:58 +0100210 TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
Paul Bakker2b222c82009-07-27 21:03:45 +0000211 }
Paul Bakker8cfd9d82014-06-18 11:16:11 +0200212
Paul Bakkerbd51b262014-07-10 15:26:12 +0200213exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200214 mbedtls_camellia_free( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000215}
Paul Bakker33b43f12013-08-20 11:48:36 +0200216/* END_CASE */
Paul Bakkere896fea2009-07-06 06:40:23 +0000217
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200218/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */
Azim Khan5fcca462018-06-29 11:05:32 +0100219void camellia_encrypt_cbc( data_t * key_str, data_t * iv_str,
220 data_t * src_str, data_t * hex_dst_string,
Azim Khand30ca132017-06-09 04:32:58 +0100221 int cbc_result )
Paul Bakkere896fea2009-07-06 06:40:23 +0000222{
Paul Bakkere896fea2009-07-06 06:40:23 +0000223 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200224 mbedtls_camellia_context ctx;
Paul Bakkere896fea2009-07-06 06:40:23 +0000225
Paul Bakkere896fea2009-07-06 06:40:23 +0000226 memset(output, 0x00, 100);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200227 mbedtls_camellia_init( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000228
Paul Bakkere896fea2009-07-06 06:40:23 +0000229
Azim Khand30ca132017-06-09 04:32:58 +0100230 mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
231 TEST_ASSERT( mbedtls_camellia_crypt_cbc( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, src_str->len, iv_str->x, src_str->x, output) == cbc_result );
Paul Bakker33b43f12013-08-20 11:48:36 +0200232 if( cbc_result == 0 )
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000233 {
Paul Bakkere896fea2009-07-06 06:40:23 +0000234
Azim Khand30ca132017-06-09 04:32:58 +0100235 TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000236 }
Paul Bakker8cfd9d82014-06-18 11:16:11 +0200237
Paul Bakkerbd51b262014-07-10 15:26:12 +0200238exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200239 mbedtls_camellia_free( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000240}
Paul Bakker33b43f12013-08-20 11:48:36 +0200241/* END_CASE */
Paul Bakkere896fea2009-07-06 06:40:23 +0000242
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200243/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */
Azim Khan5fcca462018-06-29 11:05:32 +0100244void camellia_decrypt_cbc( data_t * key_str, data_t * iv_str,
245 data_t * src_str, data_t * hex_dst_string,
Azim Khand30ca132017-06-09 04:32:58 +0100246 int cbc_result )
Paul Bakkere896fea2009-07-06 06:40:23 +0000247{
Paul Bakkere896fea2009-07-06 06:40:23 +0000248 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200249 mbedtls_camellia_context ctx;
Paul Bakkere896fea2009-07-06 06:40:23 +0000250
Paul Bakkere896fea2009-07-06 06:40:23 +0000251 memset(output, 0x00, 100);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200252 mbedtls_camellia_init( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000253
Paul Bakkere896fea2009-07-06 06:40:23 +0000254
Azim Khand30ca132017-06-09 04:32:58 +0100255 mbedtls_camellia_setkey_dec( &ctx, key_str->x, key_str->len * 8 );
256 TEST_ASSERT( mbedtls_camellia_crypt_cbc( &ctx, MBEDTLS_CAMELLIA_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result );
Paul Bakker33b43f12013-08-20 11:48:36 +0200257 if( cbc_result == 0 )
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000258 {
Paul Bakkere896fea2009-07-06 06:40:23 +0000259
Azim Khand30ca132017-06-09 04:32:58 +0100260 TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
Paul Bakkerf3ccc682010-03-18 21:21:02 +0000261 }
Paul Bakker8cfd9d82014-06-18 11:16:11 +0200262
Paul Bakkerbd51b262014-07-10 15:26:12 +0200263exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200264 mbedtls_camellia_free( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000265}
Paul Bakker33b43f12013-08-20 11:48:36 +0200266/* END_CASE */
Paul Bakkere896fea2009-07-06 06:40:23 +0000267
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200268/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */
Azim Khan5fcca462018-06-29 11:05:32 +0100269void camellia_encrypt_cfb128( data_t * key_str, data_t * iv_str,
270 data_t * src_str,
271 data_t * hex_dst_string )
Paul Bakkere896fea2009-07-06 06:40:23 +0000272{
Paul Bakkere896fea2009-07-06 06:40:23 +0000273 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200274 mbedtls_camellia_context ctx;
Paul Bakker1ef71df2011-06-09 14:14:58 +0000275 size_t iv_offset = 0;
Paul Bakkere896fea2009-07-06 06:40:23 +0000276
Paul Bakkere896fea2009-07-06 06:40:23 +0000277 memset(output, 0x00, 100);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200278 mbedtls_camellia_init( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000279
Paul Bakkere896fea2009-07-06 06:40:23 +0000280
Azim Khand30ca132017-06-09 04:32:58 +0100281 mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
282 TEST_ASSERT( mbedtls_camellia_crypt_cfb128( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
Paul Bakkere896fea2009-07-06 06:40:23 +0000283
Azim Khand30ca132017-06-09 04:32:58 +0100284 TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
Paul Bakker8cfd9d82014-06-18 11:16:11 +0200285
Paul Bakkerbd51b262014-07-10 15:26:12 +0200286exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200287 mbedtls_camellia_free( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000288}
Paul Bakker33b43f12013-08-20 11:48:36 +0200289/* END_CASE */
Paul Bakkere896fea2009-07-06 06:40:23 +0000290
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200291/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */
Azim Khan5fcca462018-06-29 11:05:32 +0100292void camellia_decrypt_cfb128( data_t * key_str, data_t * iv_str,
293 data_t * src_str,
294 data_t * hex_dst_string )
Paul Bakkere896fea2009-07-06 06:40:23 +0000295{
Paul Bakkere896fea2009-07-06 06:40:23 +0000296 unsigned char output[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200297 mbedtls_camellia_context ctx;
Paul Bakker1ef71df2011-06-09 14:14:58 +0000298 size_t iv_offset = 0;
Paul Bakkere896fea2009-07-06 06:40:23 +0000299
Paul Bakkere896fea2009-07-06 06:40:23 +0000300 memset(output, 0x00, 100);
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200301 mbedtls_camellia_init( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000302
Paul Bakkere896fea2009-07-06 06:40:23 +0000303
Azim Khand30ca132017-06-09 04:32:58 +0100304 mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
305 TEST_ASSERT( mbedtls_camellia_crypt_cfb128( &ctx, MBEDTLS_CAMELLIA_DECRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
Paul Bakkere896fea2009-07-06 06:40:23 +0000306
Azim Khand30ca132017-06-09 04:32:58 +0100307 TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
Paul Bakker8cfd9d82014-06-18 11:16:11 +0200308
Paul Bakkerbd51b262014-07-10 15:26:12 +0200309exit:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200310 mbedtls_camellia_free( &ctx );
Paul Bakkere896fea2009-07-06 06:40:23 +0000311}
Paul Bakker33b43f12013-08-20 11:48:36 +0200312/* END_CASE */
Paul Bakkere896fea2009-07-06 06:40:23 +0000313
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200314/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
Azim Khanf1aaec92017-05-30 14:23:15 +0100315void camellia_selftest( )
Paul Bakkere896fea2009-07-06 06:40:23 +0000316{
Andres AG93012e82016-09-09 09:10:28 +0100317 TEST_ASSERT( mbedtls_camellia_self_test( 1 ) == 0 );
Paul Bakkere896fea2009-07-06 06:40:23 +0000318}
Paul Bakker33b43f12013-08-20 11:48:36 +0200319/* END_CASE */