PolarSSL v1.1.4
|
00001 #include "fct.h" 00002 00003 #include <polarssl/aes.h> 00004 00005 #include <polarssl/config.h> 00006 00007 #ifdef _MSC_VER 00008 #include <basetsd.h> 00009 typedef UINT32 uint32_t; 00010 #else 00011 #include <inttypes.h> 00012 #endif 00013 00014 /* 00015 * 32-bit integer manipulation macros (big endian) 00016 */ 00017 #ifndef GET_ULONG_BE 00018 #define GET_ULONG_BE(n,b,i) \ 00019 { \ 00020 (n) = ( (unsigned long) (b)[(i) ] << 24 ) \ 00021 | ( (unsigned long) (b)[(i) + 1] << 16 ) \ 00022 | ( (unsigned long) (b)[(i) + 2] << 8 ) \ 00023 | ( (unsigned long) (b)[(i) + 3] ); \ 00024 } 00025 #endif 00026 00027 #ifndef PUT_ULONG_BE 00028 #define PUT_ULONG_BE(n,b,i) \ 00029 { \ 00030 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ 00031 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ 00032 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ 00033 (b)[(i) + 3] = (unsigned char) ( (n) ); \ 00034 } 00035 #endif 00036 00037 int unhexify(unsigned char *obuf, const char *ibuf) 00038 { 00039 unsigned char c, c2; 00040 int len = strlen(ibuf) / 2; 00041 assert(!(strlen(ibuf) %1)); // must be even number of bytes 00042 00043 while (*ibuf != 0) 00044 { 00045 c = *ibuf++; 00046 if( c >= '0' && c <= '9' ) 00047 c -= '0'; 00048 else if( c >= 'a' && c <= 'f' ) 00049 c -= 'a' - 10; 00050 else if( c >= 'A' && c <= 'F' ) 00051 c -= 'A' - 10; 00052 else 00053 assert( 0 ); 00054 00055 c2 = *ibuf++; 00056 if( c2 >= '0' && c2 <= '9' ) 00057 c2 -= '0'; 00058 else if( c2 >= 'a' && c2 <= 'f' ) 00059 c2 -= 'a' - 10; 00060 else if( c2 >= 'A' && c2 <= 'F' ) 00061 c2 -= 'A' - 10; 00062 else 00063 assert( 0 ); 00064 00065 *obuf++ = ( c << 4 ) | c2; 00066 } 00067 00068 return len; 00069 } 00070 00071 void hexify(unsigned char *obuf, const unsigned char *ibuf, int len) 00072 { 00073 unsigned char l, h; 00074 00075 while (len != 0) 00076 { 00077 h = (*ibuf) / 16; 00078 l = (*ibuf) % 16; 00079 00080 if( h < 10 ) 00081 *obuf++ = '0' + h; 00082 else 00083 *obuf++ = 'a' + h - 10; 00084 00085 if( l < 10 ) 00086 *obuf++ = '0' + l; 00087 else 00088 *obuf++ = 'a' + l - 10; 00089 00090 ++ibuf; 00091 len--; 00092 } 00093 } 00094 00104 static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len ) 00105 { 00106 size_t i; 00107 00108 if( rng_state != NULL ) 00109 rng_state = NULL; 00110 00111 for( i = 0; i < len; ++i ) 00112 output[i] = rand(); 00113 00114 return( 0 ); 00115 } 00116 00122 static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len ) 00123 { 00124 if( rng_state != NULL ) 00125 rng_state = NULL; 00126 00127 memset( output, 0, len ); 00128 00129 return( 0 ); 00130 } 00131 00132 typedef struct 00133 { 00134 unsigned char *buf; 00135 size_t length; 00136 } rnd_buf_info; 00137 00149 static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len ) 00150 { 00151 rnd_buf_info *info = (rnd_buf_info *) rng_state; 00152 size_t use_len; 00153 00154 if( rng_state == NULL ) 00155 return( rnd_std_rand( NULL, output, len ) ); 00156 00157 use_len = len; 00158 if( len > info->length ) 00159 use_len = info->length; 00160 00161 if( use_len ) 00162 { 00163 memcpy( output, info->buf, use_len ); 00164 info->buf += use_len; 00165 info->length -= use_len; 00166 } 00167 00168 if( len - use_len > 0 ) 00169 return( rnd_std_rand( NULL, output + use_len, len - use_len ) ); 00170 00171 return( 0 ); 00172 } 00173 00181 typedef struct 00182 { 00183 uint32_t key[16]; 00184 uint32_t v0, v1; 00185 } rnd_pseudo_info; 00186 00195 static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len ) 00196 { 00197 rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state; 00198 uint32_t i, *k, sum, delta=0x9E3779B9; 00199 unsigned char result[4]; 00200 00201 if( rng_state == NULL ) 00202 return( rnd_std_rand( NULL, output, len ) ); 00203 00204 k = info->key; 00205 00206 while( len > 0 ) 00207 { 00208 size_t use_len = ( len > 4 ) ? 4 : len; 00209 sum = 0; 00210 00211 for( i = 0; i < 32; i++ ) 00212 { 00213 info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]); 00214 sum += delta; 00215 info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]); 00216 } 00217 00218 PUT_ULONG_BE( info->v0, result, 0 ); 00219 memcpy( output, result, use_len ); 00220 len -= use_len; 00221 } 00222 00223 return( 0 ); 00224 } 00225 00226 00227 FCT_BGN() 00228 { 00229 #ifdef POLARSSL_AES_C 00230 00231 00232 FCT_SUITE_BGN(test_suite_aes) 00233 { 00234 00235 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_1) 00236 { 00237 unsigned char key_str[100]; 00238 unsigned char src_str[100]; 00239 unsigned char dst_str[100]; 00240 unsigned char output[100]; 00241 aes_context ctx; 00242 int key_len; 00243 00244 memset(key_str, 0x00, 100); 00245 memset(src_str, 0x00, 100); 00246 memset(dst_str, 0x00, 100); 00247 memset(output, 0x00, 100); 00248 00249 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00250 unhexify( src_str, "f34481ec3cc627bacd5dc3fb08f273e6" ); 00251 00252 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00253 if( 0 == 0 ) 00254 { 00255 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00256 hexify( dst_str, output, 16 ); 00257 00258 fct_chk( strcmp( (char *) dst_str, "0336763e966d92595a567cc9ce537f5e" ) == 0 ); 00259 } 00260 } 00261 FCT_TEST_END(); 00262 00263 00264 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_2) 00265 { 00266 unsigned char key_str[100]; 00267 unsigned char src_str[100]; 00268 unsigned char dst_str[100]; 00269 unsigned char output[100]; 00270 aes_context ctx; 00271 int key_len; 00272 00273 memset(key_str, 0x00, 100); 00274 memset(src_str, 0x00, 100); 00275 memset(dst_str, 0x00, 100); 00276 memset(output, 0x00, 100); 00277 00278 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00279 unhexify( src_str, "9798c4640bad75c7c3227db910174e72" ); 00280 00281 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00282 if( 0 == 0 ) 00283 { 00284 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00285 hexify( dst_str, output, 16 ); 00286 00287 fct_chk( strcmp( (char *) dst_str, "a9a1631bf4996954ebc093957b234589" ) == 0 ); 00288 } 00289 } 00290 FCT_TEST_END(); 00291 00292 00293 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_3) 00294 { 00295 unsigned char key_str[100]; 00296 unsigned char src_str[100]; 00297 unsigned char dst_str[100]; 00298 unsigned char output[100]; 00299 aes_context ctx; 00300 int key_len; 00301 00302 memset(key_str, 0x00, 100); 00303 memset(src_str, 0x00, 100); 00304 memset(dst_str, 0x00, 100); 00305 memset(output, 0x00, 100); 00306 00307 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00308 unhexify( src_str, "96ab5c2ff612d9dfaae8c31f30c42168" ); 00309 00310 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00311 if( 0 == 0 ) 00312 { 00313 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00314 hexify( dst_str, output, 16 ); 00315 00316 fct_chk( strcmp( (char *) dst_str, "ff4f8391a6a40ca5b25d23bedd44a597" ) == 0 ); 00317 } 00318 } 00319 FCT_TEST_END(); 00320 00321 00322 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_4) 00323 { 00324 unsigned char key_str[100]; 00325 unsigned char src_str[100]; 00326 unsigned char dst_str[100]; 00327 unsigned char output[100]; 00328 aes_context ctx; 00329 int key_len; 00330 00331 memset(key_str, 0x00, 100); 00332 memset(src_str, 0x00, 100); 00333 memset(dst_str, 0x00, 100); 00334 memset(output, 0x00, 100); 00335 00336 key_len = unhexify( key_str, "e0000000000000000000000000000000" ); 00337 unhexify( src_str, "00000000000000000000000000000000" ); 00338 00339 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00340 if( 0 == 0 ) 00341 { 00342 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00343 hexify( dst_str, output, 16 ); 00344 00345 fct_chk( strcmp( (char *) dst_str, "72a1da770f5d7ac4c9ef94d822affd97" ) == 0 ); 00346 } 00347 } 00348 FCT_TEST_END(); 00349 00350 00351 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_5) 00352 { 00353 unsigned char key_str[100]; 00354 unsigned char src_str[100]; 00355 unsigned char dst_str[100]; 00356 unsigned char output[100]; 00357 aes_context ctx; 00358 int key_len; 00359 00360 memset(key_str, 0x00, 100); 00361 memset(src_str, 0x00, 100); 00362 memset(dst_str, 0x00, 100); 00363 memset(output, 0x00, 100); 00364 00365 key_len = unhexify( key_str, "f0000000000000000000000000000000" ); 00366 unhexify( src_str, "00000000000000000000000000000000" ); 00367 00368 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00369 if( 0 == 0 ) 00370 { 00371 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00372 hexify( dst_str, output, 16 ); 00373 00374 fct_chk( strcmp( (char *) dst_str, "970014d634e2b7650777e8e84d03ccd8" ) == 0 ); 00375 } 00376 } 00377 FCT_TEST_END(); 00378 00379 00380 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_6) 00381 { 00382 unsigned char key_str[100]; 00383 unsigned char src_str[100]; 00384 unsigned char dst_str[100]; 00385 unsigned char output[100]; 00386 aes_context ctx; 00387 int key_len; 00388 00389 memset(key_str, 0x00, 100); 00390 memset(src_str, 0x00, 100); 00391 memset(dst_str, 0x00, 100); 00392 memset(output, 0x00, 100); 00393 00394 key_len = unhexify( key_str, "f8000000000000000000000000000000" ); 00395 unhexify( src_str, "00000000000000000000000000000000" ); 00396 00397 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00398 if( 0 == 0 ) 00399 { 00400 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00401 hexify( dst_str, output, 16 ); 00402 00403 fct_chk( strcmp( (char *) dst_str, "f17e79aed0db7e279e955b5f493875a7" ) == 0 ); 00404 } 00405 } 00406 FCT_TEST_END(); 00407 00408 00409 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_7) 00410 { 00411 unsigned char key_str[100]; 00412 unsigned char src_str[100]; 00413 unsigned char dst_str[100]; 00414 unsigned char output[100]; 00415 aes_context ctx; 00416 int key_len; 00417 00418 memset(key_str, 0x00, 100); 00419 memset(src_str, 0x00, 100); 00420 memset(dst_str, 0x00, 100); 00421 memset(output, 0x00, 100); 00422 00423 key_len = unhexify( key_str, "fffffffffffff0000000000000000000" ); 00424 unhexify( src_str, "00000000000000000000000000000000" ); 00425 00426 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00427 if( 0 == 0 ) 00428 { 00429 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00430 hexify( dst_str, output, 16 ); 00431 00432 fct_chk( strcmp( (char *) dst_str, "7b90785125505fad59b13c186dd66ce3" ) == 0 ); 00433 } 00434 } 00435 FCT_TEST_END(); 00436 00437 00438 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_8) 00439 { 00440 unsigned char key_str[100]; 00441 unsigned char src_str[100]; 00442 unsigned char dst_str[100]; 00443 unsigned char output[100]; 00444 aes_context ctx; 00445 int key_len; 00446 00447 memset(key_str, 0x00, 100); 00448 memset(src_str, 0x00, 100); 00449 memset(dst_str, 0x00, 100); 00450 memset(output, 0x00, 100); 00451 00452 key_len = unhexify( key_str, "fffffffffffff8000000000000000000" ); 00453 unhexify( src_str, "00000000000000000000000000000000" ); 00454 00455 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00456 if( 0 == 0 ) 00457 { 00458 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00459 hexify( dst_str, output, 16 ); 00460 00461 fct_chk( strcmp( (char *) dst_str, "8b527a6aebdaec9eaef8eda2cb7783e5" ) == 0 ); 00462 } 00463 } 00464 FCT_TEST_END(); 00465 00466 00467 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_9) 00468 { 00469 unsigned char key_str[100]; 00470 unsigned char src_str[100]; 00471 unsigned char dst_str[100]; 00472 unsigned char output[100]; 00473 aes_context ctx; 00474 int key_len; 00475 00476 memset(key_str, 0x00, 100); 00477 memset(src_str, 0x00, 100); 00478 memset(dst_str, 0x00, 100); 00479 memset(output, 0x00, 100); 00480 00481 key_len = unhexify( key_str, "fffffffffffffc000000000000000000" ); 00482 unhexify( src_str, "00000000000000000000000000000000" ); 00483 00484 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00485 if( 0 == 0 ) 00486 { 00487 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00488 hexify( dst_str, output, 16 ); 00489 00490 fct_chk( strcmp( (char *) dst_str, "43fdaf53ebbc9880c228617d6a9b548b" ) == 0 ); 00491 } 00492 } 00493 FCT_TEST_END(); 00494 00495 00496 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_10) 00497 { 00498 unsigned char key_str[100]; 00499 unsigned char src_str[100]; 00500 unsigned char dst_str[100]; 00501 unsigned char output[100]; 00502 aes_context ctx; 00503 int key_len; 00504 00505 memset(key_str, 0x00, 100); 00506 memset(src_str, 0x00, 100); 00507 memset(dst_str, 0x00, 100); 00508 memset(output, 0x00, 100); 00509 00510 key_len = unhexify( key_str, "ffffffffffffffffffffffffffffc000" ); 00511 unhexify( src_str, "00000000000000000000000000000000" ); 00512 00513 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00514 if( 0 == 0 ) 00515 { 00516 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00517 hexify( dst_str, output, 16 ); 00518 00519 fct_chk( strcmp( (char *) dst_str, "70c46bb30692be657f7eaa93ebad9897" ) == 0 ); 00520 } 00521 } 00522 FCT_TEST_END(); 00523 00524 00525 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_11) 00526 { 00527 unsigned char key_str[100]; 00528 unsigned char src_str[100]; 00529 unsigned char dst_str[100]; 00530 unsigned char output[100]; 00531 aes_context ctx; 00532 int key_len; 00533 00534 memset(key_str, 0x00, 100); 00535 memset(src_str, 0x00, 100); 00536 memset(dst_str, 0x00, 100); 00537 memset(output, 0x00, 100); 00538 00539 key_len = unhexify( key_str, "ffffffffffffffffffffffffffffe000" ); 00540 unhexify( src_str, "00000000000000000000000000000000" ); 00541 00542 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00543 if( 0 == 0 ) 00544 { 00545 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00546 hexify( dst_str, output, 16 ); 00547 00548 fct_chk( strcmp( (char *) dst_str, "323994cfb9da285a5d9642e1759b224a" ) == 0 ); 00549 } 00550 } 00551 FCT_TEST_END(); 00552 00553 00554 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_12) 00555 { 00556 unsigned char key_str[100]; 00557 unsigned char src_str[100]; 00558 unsigned char dst_str[100]; 00559 unsigned char output[100]; 00560 aes_context ctx; 00561 int key_len; 00562 00563 memset(key_str, 0x00, 100); 00564 memset(src_str, 0x00, 100); 00565 memset(dst_str, 0x00, 100); 00566 memset(output, 0x00, 100); 00567 00568 key_len = unhexify( key_str, "fffffffffffffffffffffffffffff000" ); 00569 unhexify( src_str, "00000000000000000000000000000000" ); 00570 00571 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00572 if( 0 == 0 ) 00573 { 00574 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00575 hexify( dst_str, output, 16 ); 00576 00577 fct_chk( strcmp( (char *) dst_str, "1dbf57877b7b17385c85d0b54851e371" ) == 0 ); 00578 } 00579 } 00580 FCT_TEST_END(); 00581 00582 00583 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_13) 00584 { 00585 unsigned char key_str[100]; 00586 unsigned char src_str[100]; 00587 unsigned char dst_str[100]; 00588 unsigned char output[100]; 00589 aes_context ctx; 00590 int key_len; 00591 00592 memset(key_str, 0x00, 100); 00593 memset(src_str, 0x00, 100); 00594 memset(dst_str, 0x00, 100); 00595 memset(output, 0x00, 100); 00596 00597 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00598 unhexify( src_str, "ffffffffffffffc00000000000000000" ); 00599 00600 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00601 if( 0 == 0 ) 00602 { 00603 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00604 hexify( dst_str, output, 16 ); 00605 00606 fct_chk( strcmp( (char *) dst_str, "3a4d354f02bb5a5e47d39666867f246a" ) == 0 ); 00607 } 00608 } 00609 FCT_TEST_END(); 00610 00611 00612 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_14) 00613 { 00614 unsigned char key_str[100]; 00615 unsigned char src_str[100]; 00616 unsigned char dst_str[100]; 00617 unsigned char output[100]; 00618 aes_context ctx; 00619 int key_len; 00620 00621 memset(key_str, 0x00, 100); 00622 memset(src_str, 0x00, 100); 00623 memset(dst_str, 0x00, 100); 00624 memset(output, 0x00, 100); 00625 00626 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00627 unhexify( src_str, "ffffffffffffffe00000000000000000" ); 00628 00629 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00630 if( 0 == 0 ) 00631 { 00632 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00633 hexify( dst_str, output, 16 ); 00634 00635 fct_chk( strcmp( (char *) dst_str, "d451b8d6e1e1a0ebb155fbbf6e7b7dc3" ) == 0 ); 00636 } 00637 } 00638 FCT_TEST_END(); 00639 00640 00641 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_15) 00642 { 00643 unsigned char key_str[100]; 00644 unsigned char src_str[100]; 00645 unsigned char dst_str[100]; 00646 unsigned char output[100]; 00647 aes_context ctx; 00648 int key_len; 00649 00650 memset(key_str, 0x00, 100); 00651 memset(src_str, 0x00, 100); 00652 memset(dst_str, 0x00, 100); 00653 memset(output, 0x00, 100); 00654 00655 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00656 unhexify( src_str, "fffffffffffffff00000000000000000" ); 00657 00658 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00659 if( 0 == 0 ) 00660 { 00661 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00662 hexify( dst_str, output, 16 ); 00663 00664 fct_chk( strcmp( (char *) dst_str, "6898d4f42fa7ba6a10ac05e87b9f2080" ) == 0 ); 00665 } 00666 } 00667 FCT_TEST_END(); 00668 00669 00670 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_16) 00671 { 00672 unsigned char key_str[100]; 00673 unsigned char src_str[100]; 00674 unsigned char dst_str[100]; 00675 unsigned char output[100]; 00676 aes_context ctx; 00677 int key_len; 00678 00679 memset(key_str, 0x00, 100); 00680 memset(src_str, 0x00, 100); 00681 memset(dst_str, 0x00, 100); 00682 memset(output, 0x00, 100); 00683 00684 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00685 unhexify( src_str, "ffffffffffffffffffffffffe0000000" ); 00686 00687 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00688 if( 0 == 0 ) 00689 { 00690 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00691 hexify( dst_str, output, 16 ); 00692 00693 fct_chk( strcmp( (char *) dst_str, "082eb8be35f442fb52668e16a591d1d6" ) == 0 ); 00694 } 00695 } 00696 FCT_TEST_END(); 00697 00698 00699 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_17) 00700 { 00701 unsigned char key_str[100]; 00702 unsigned char src_str[100]; 00703 unsigned char dst_str[100]; 00704 unsigned char output[100]; 00705 aes_context ctx; 00706 int key_len; 00707 00708 memset(key_str, 0x00, 100); 00709 memset(src_str, 0x00, 100); 00710 memset(dst_str, 0x00, 100); 00711 memset(output, 0x00, 100); 00712 00713 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00714 unhexify( src_str, "fffffffffffffffffffffffff0000000" ); 00715 00716 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00717 if( 0 == 0 ) 00718 { 00719 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00720 hexify( dst_str, output, 16 ); 00721 00722 fct_chk( strcmp( (char *) dst_str, "e656f9ecf5fe27ec3e4a73d00c282fb3" ) == 0 ); 00723 } 00724 } 00725 FCT_TEST_END(); 00726 00727 00728 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_18) 00729 { 00730 unsigned char key_str[100]; 00731 unsigned char src_str[100]; 00732 unsigned char dst_str[100]; 00733 unsigned char output[100]; 00734 aes_context ctx; 00735 int key_len; 00736 00737 memset(key_str, 0x00, 100); 00738 memset(src_str, 0x00, 100); 00739 memset(dst_str, 0x00, 100); 00740 memset(output, 0x00, 100); 00741 00742 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00743 unhexify( src_str, "fffffffffffffffffffffffff8000000" ); 00744 00745 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 00746 if( 0 == 0 ) 00747 { 00748 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 00749 hexify( dst_str, output, 16 ); 00750 00751 fct_chk( strcmp( (char *) dst_str, "2ca8209d63274cd9a29bb74bcd77683a" ) == 0 ); 00752 } 00753 } 00754 FCT_TEST_END(); 00755 00756 00757 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_1) 00758 { 00759 unsigned char key_str[100]; 00760 unsigned char src_str[100]; 00761 unsigned char dst_str[100]; 00762 unsigned char output[100]; 00763 aes_context ctx; 00764 int key_len; 00765 00766 memset(key_str, 0x00, 100); 00767 memset(src_str, 0x00, 100); 00768 memset(dst_str, 0x00, 100); 00769 memset(output, 0x00, 100); 00770 00771 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00772 unhexify( src_str, "db4f1aa530967d6732ce4715eb0ee24b" ); 00773 00774 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 00775 if( 0 == 0 ) 00776 { 00777 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 00778 hexify( dst_str, output, 16 ); 00779 00780 fct_chk( strcmp( (char *) dst_str, "ff000000000000000000000000000000" ) == 0 ); 00781 } 00782 } 00783 FCT_TEST_END(); 00784 00785 00786 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_2) 00787 { 00788 unsigned char key_str[100]; 00789 unsigned char src_str[100]; 00790 unsigned char dst_str[100]; 00791 unsigned char output[100]; 00792 aes_context ctx; 00793 int key_len; 00794 00795 memset(key_str, 0x00, 100); 00796 memset(src_str, 0x00, 100); 00797 memset(dst_str, 0x00, 100); 00798 memset(output, 0x00, 100); 00799 00800 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00801 unhexify( src_str, "a81738252621dd180a34f3455b4baa2f" ); 00802 00803 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 00804 if( 0 == 0 ) 00805 { 00806 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 00807 hexify( dst_str, output, 16 ); 00808 00809 fct_chk( strcmp( (char *) dst_str, "ff800000000000000000000000000000" ) == 0 ); 00810 } 00811 } 00812 FCT_TEST_END(); 00813 00814 00815 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_3) 00816 { 00817 unsigned char key_str[100]; 00818 unsigned char src_str[100]; 00819 unsigned char dst_str[100]; 00820 unsigned char output[100]; 00821 aes_context ctx; 00822 int key_len; 00823 00824 memset(key_str, 0x00, 100); 00825 memset(src_str, 0x00, 100); 00826 memset(dst_str, 0x00, 100); 00827 memset(output, 0x00, 100); 00828 00829 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00830 unhexify( src_str, "77e2b508db7fd89234caf7939ee5621a" ); 00831 00832 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 00833 if( 0 == 0 ) 00834 { 00835 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 00836 hexify( dst_str, output, 16 ); 00837 00838 fct_chk( strcmp( (char *) dst_str, "ffc00000000000000000000000000000" ) == 0 ); 00839 } 00840 } 00841 FCT_TEST_END(); 00842 00843 00844 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_4) 00845 { 00846 unsigned char key_str[100]; 00847 unsigned char src_str[100]; 00848 unsigned char dst_str[100]; 00849 unsigned char output[100]; 00850 aes_context ctx; 00851 int key_len; 00852 00853 memset(key_str, 0x00, 100); 00854 memset(src_str, 0x00, 100); 00855 memset(dst_str, 0x00, 100); 00856 memset(output, 0x00, 100); 00857 00858 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00859 unhexify( src_str, "dc43be40be0e53712f7e2bf5ca707209" ); 00860 00861 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 00862 if( 0 == 0 ) 00863 { 00864 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 00865 hexify( dst_str, output, 16 ); 00866 00867 fct_chk( strcmp( (char *) dst_str, "6a118a874519e64e9963798a503f1d35" ) == 0 ); 00868 } 00869 } 00870 FCT_TEST_END(); 00871 00872 00873 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_5) 00874 { 00875 unsigned char key_str[100]; 00876 unsigned char src_str[100]; 00877 unsigned char dst_str[100]; 00878 unsigned char output[100]; 00879 aes_context ctx; 00880 int key_len; 00881 00882 memset(key_str, 0x00, 100); 00883 memset(src_str, 0x00, 100); 00884 memset(dst_str, 0x00, 100); 00885 memset(output, 0x00, 100); 00886 00887 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00888 unhexify( src_str, "92beedab1895a94faa69b632e5cc47ce" ); 00889 00890 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 00891 if( 0 == 0 ) 00892 { 00893 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 00894 hexify( dst_str, output, 16 ); 00895 00896 fct_chk( strcmp( (char *) dst_str, "cb9fceec81286ca3e989bd979b0cb284" ) == 0 ); 00897 } 00898 } 00899 FCT_TEST_END(); 00900 00901 00902 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_6) 00903 { 00904 unsigned char key_str[100]; 00905 unsigned char src_str[100]; 00906 unsigned char dst_str[100]; 00907 unsigned char output[100]; 00908 aes_context ctx; 00909 int key_len; 00910 00911 memset(key_str, 0x00, 100); 00912 memset(src_str, 0x00, 100); 00913 memset(dst_str, 0x00, 100); 00914 memset(output, 0x00, 100); 00915 00916 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 00917 unhexify( src_str, "459264f4798f6a78bacb89c15ed3d601" ); 00918 00919 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 00920 if( 0 == 0 ) 00921 { 00922 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 00923 hexify( dst_str, output, 16 ); 00924 00925 fct_chk( strcmp( (char *) dst_str, "b26aeb1874e47ca8358ff22378f09144" ) == 0 ); 00926 } 00927 } 00928 FCT_TEST_END(); 00929 00930 00931 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_7) 00932 { 00933 unsigned char key_str[100]; 00934 unsigned char src_str[100]; 00935 unsigned char dst_str[100]; 00936 unsigned char output[100]; 00937 aes_context ctx; 00938 int key_len; 00939 00940 memset(key_str, 0x00, 100); 00941 memset(src_str, 0x00, 100); 00942 memset(dst_str, 0x00, 100); 00943 memset(output, 0x00, 100); 00944 00945 key_len = unhexify( key_str, "b69418a85332240dc82492353956ae0c" ); 00946 unhexify( src_str, "a303d940ded8f0baff6f75414cac5243" ); 00947 00948 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 00949 if( 0 == 0 ) 00950 { 00951 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 00952 hexify( dst_str, output, 16 ); 00953 00954 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 00955 } 00956 } 00957 FCT_TEST_END(); 00958 00959 00960 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_8) 00961 { 00962 unsigned char key_str[100]; 00963 unsigned char src_str[100]; 00964 unsigned char dst_str[100]; 00965 unsigned char output[100]; 00966 aes_context ctx; 00967 int key_len; 00968 00969 memset(key_str, 0x00, 100); 00970 memset(src_str, 0x00, 100); 00971 memset(dst_str, 0x00, 100); 00972 memset(output, 0x00, 100); 00973 00974 key_len = unhexify( key_str, "71b5c08a1993e1362e4d0ce9b22b78d5" ); 00975 unhexify( src_str, "c2dabd117f8a3ecabfbb11d12194d9d0" ); 00976 00977 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 00978 if( 0 == 0 ) 00979 { 00980 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 00981 hexify( dst_str, output, 16 ); 00982 00983 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 00984 } 00985 } 00986 FCT_TEST_END(); 00987 00988 00989 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_9) 00990 { 00991 unsigned char key_str[100]; 00992 unsigned char src_str[100]; 00993 unsigned char dst_str[100]; 00994 unsigned char output[100]; 00995 aes_context ctx; 00996 int key_len; 00997 00998 memset(key_str, 0x00, 100); 00999 memset(src_str, 0x00, 100); 01000 memset(dst_str, 0x00, 100); 01001 memset(output, 0x00, 100); 01002 01003 key_len = unhexify( key_str, "e234cdca2606b81f29408d5f6da21206" ); 01004 unhexify( src_str, "fff60a4740086b3b9c56195b98d91a7b" ); 01005 01006 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01007 if( 0 == 0 ) 01008 { 01009 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01010 hexify( dst_str, output, 16 ); 01011 01012 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 01013 } 01014 } 01015 FCT_TEST_END(); 01016 01017 01018 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_10) 01019 { 01020 unsigned char key_str[100]; 01021 unsigned char src_str[100]; 01022 unsigned char dst_str[100]; 01023 unsigned char output[100]; 01024 aes_context ctx; 01025 int key_len; 01026 01027 memset(key_str, 0x00, 100); 01028 memset(src_str, 0x00, 100); 01029 memset(dst_str, 0x00, 100); 01030 memset(output, 0x00, 100); 01031 01032 key_len = unhexify( key_str, "ffffffffffffffff0000000000000000" ); 01033 unhexify( src_str, "84be19e053635f09f2665e7bae85b42d" ); 01034 01035 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01036 if( 0 == 0 ) 01037 { 01038 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01039 hexify( dst_str, output, 16 ); 01040 01041 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 01042 } 01043 } 01044 FCT_TEST_END(); 01045 01046 01047 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_11) 01048 { 01049 unsigned char key_str[100]; 01050 unsigned char src_str[100]; 01051 unsigned char dst_str[100]; 01052 unsigned char output[100]; 01053 aes_context ctx; 01054 int key_len; 01055 01056 memset(key_str, 0x00, 100); 01057 memset(src_str, 0x00, 100); 01058 memset(dst_str, 0x00, 100); 01059 memset(output, 0x00, 100); 01060 01061 key_len = unhexify( key_str, "ffffffffffffffff8000000000000000" ); 01062 unhexify( src_str, "32cd652842926aea4aa6137bb2be2b5e" ); 01063 01064 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01065 if( 0 == 0 ) 01066 { 01067 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01068 hexify( dst_str, output, 16 ); 01069 01070 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 01071 } 01072 } 01073 FCT_TEST_END(); 01074 01075 01076 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_1) 01077 { 01078 unsigned char key_str[100]; 01079 unsigned char src_str[100]; 01080 unsigned char dst_str[100]; 01081 unsigned char output[100]; 01082 aes_context ctx; 01083 int key_len; 01084 01085 memset(key_str, 0x00, 100); 01086 memset(src_str, 0x00, 100); 01087 memset(dst_str, 0x00, 100); 01088 memset(output, 0x00, 100); 01089 01090 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01091 unhexify( src_str, "fffffffffffffffffffff80000000000" ); 01092 01093 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01094 if( 0 == 0 ) 01095 { 01096 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01097 hexify( dst_str, output, 16 ); 01098 01099 fct_chk( strcmp( (char *) dst_str, "156f07767a85a4312321f63968338a01" ) == 0 ); 01100 } 01101 } 01102 FCT_TEST_END(); 01103 01104 01105 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_2) 01106 { 01107 unsigned char key_str[100]; 01108 unsigned char src_str[100]; 01109 unsigned char dst_str[100]; 01110 unsigned char output[100]; 01111 aes_context ctx; 01112 int key_len; 01113 01114 memset(key_str, 0x00, 100); 01115 memset(src_str, 0x00, 100); 01116 memset(dst_str, 0x00, 100); 01117 memset(output, 0x00, 100); 01118 01119 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01120 unhexify( src_str, "fffffffffffffffffffffc0000000000" ); 01121 01122 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01123 if( 0 == 0 ) 01124 { 01125 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01126 hexify( dst_str, output, 16 ); 01127 01128 fct_chk( strcmp( (char *) dst_str, "15eec9ebf42b9ca76897d2cd6c5a12e2" ) == 0 ); 01129 } 01130 } 01131 FCT_TEST_END(); 01132 01133 01134 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_3) 01135 { 01136 unsigned char key_str[100]; 01137 unsigned char src_str[100]; 01138 unsigned char dst_str[100]; 01139 unsigned char output[100]; 01140 aes_context ctx; 01141 int key_len; 01142 01143 memset(key_str, 0x00, 100); 01144 memset(src_str, 0x00, 100); 01145 memset(dst_str, 0x00, 100); 01146 memset(output, 0x00, 100); 01147 01148 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01149 unhexify( src_str, "fffffffffffffffffffffe0000000000" ); 01150 01151 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01152 if( 0 == 0 ) 01153 { 01154 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01155 hexify( dst_str, output, 16 ); 01156 01157 fct_chk( strcmp( (char *) dst_str, "db0d3a6fdcc13f915e2b302ceeb70fd8" ) == 0 ); 01158 } 01159 } 01160 FCT_TEST_END(); 01161 01162 01163 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_4) 01164 { 01165 unsigned char key_str[100]; 01166 unsigned char src_str[100]; 01167 unsigned char dst_str[100]; 01168 unsigned char output[100]; 01169 aes_context ctx; 01170 int key_len; 01171 01172 memset(key_str, 0x00, 100); 01173 memset(src_str, 0x00, 100); 01174 memset(dst_str, 0x00, 100); 01175 memset(output, 0x00, 100); 01176 01177 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01178 unhexify( src_str, "51719783d3185a535bd75adc65071ce1" ); 01179 01180 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01181 if( 0 == 0 ) 01182 { 01183 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01184 hexify( dst_str, output, 16 ); 01185 01186 fct_chk( strcmp( (char *) dst_str, "4f354592ff7c8847d2d0870ca9481b7c" ) == 0 ); 01187 } 01188 } 01189 FCT_TEST_END(); 01190 01191 01192 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_5) 01193 { 01194 unsigned char key_str[100]; 01195 unsigned char src_str[100]; 01196 unsigned char dst_str[100]; 01197 unsigned char output[100]; 01198 aes_context ctx; 01199 int key_len; 01200 01201 memset(key_str, 0x00, 100); 01202 memset(src_str, 0x00, 100); 01203 memset(dst_str, 0x00, 100); 01204 memset(output, 0x00, 100); 01205 01206 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01207 unhexify( src_str, "26aa49dcfe7629a8901a69a9914e6dfd" ); 01208 01209 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01210 if( 0 == 0 ) 01211 { 01212 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01213 hexify( dst_str, output, 16 ); 01214 01215 fct_chk( strcmp( (char *) dst_str, "d5e08bf9a182e857cf40b3a36ee248cc" ) == 0 ); 01216 } 01217 } 01218 FCT_TEST_END(); 01219 01220 01221 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_6) 01222 { 01223 unsigned char key_str[100]; 01224 unsigned char src_str[100]; 01225 unsigned char dst_str[100]; 01226 unsigned char output[100]; 01227 aes_context ctx; 01228 int key_len; 01229 01230 memset(key_str, 0x00, 100); 01231 memset(src_str, 0x00, 100); 01232 memset(dst_str, 0x00, 100); 01233 memset(output, 0x00, 100); 01234 01235 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01236 unhexify( src_str, "941a4773058224e1ef66d10e0a6ee782" ); 01237 01238 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01239 if( 0 == 0 ) 01240 { 01241 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01242 hexify( dst_str, output, 16 ); 01243 01244 fct_chk( strcmp( (char *) dst_str, "067cd9d3749207791841562507fa9626" ) == 0 ); 01245 } 01246 } 01247 FCT_TEST_END(); 01248 01249 01250 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_7) 01251 { 01252 unsigned char key_str[100]; 01253 unsigned char src_str[100]; 01254 unsigned char dst_str[100]; 01255 unsigned char output[100]; 01256 aes_context ctx; 01257 int key_len; 01258 01259 memset(key_str, 0x00, 100); 01260 memset(src_str, 0x00, 100); 01261 memset(dst_str, 0x00, 100); 01262 memset(output, 0x00, 100); 01263 01264 key_len = unhexify( key_str, "d2926527e0aa9f37b45e2ec2ade5853ef807576104c7ace3" ); 01265 unhexify( src_str, "00000000000000000000000000000000" ); 01266 01267 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01268 if( 0 == 0 ) 01269 { 01270 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01271 hexify( dst_str, output, 16 ); 01272 01273 fct_chk( strcmp( (char *) dst_str, "dd619e1cf204446112e0af2b9afa8f8c" ) == 0 ); 01274 } 01275 } 01276 FCT_TEST_END(); 01277 01278 01279 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_8) 01280 { 01281 unsigned char key_str[100]; 01282 unsigned char src_str[100]; 01283 unsigned char dst_str[100]; 01284 unsigned char output[100]; 01285 aes_context ctx; 01286 int key_len; 01287 01288 memset(key_str, 0x00, 100); 01289 memset(src_str, 0x00, 100); 01290 memset(dst_str, 0x00, 100); 01291 memset(output, 0x00, 100); 01292 01293 key_len = unhexify( key_str, "982215f4e173dfa0fcffe5d3da41c4812c7bcc8ed3540f93" ); 01294 unhexify( src_str, "00000000000000000000000000000000" ); 01295 01296 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01297 if( 0 == 0 ) 01298 { 01299 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01300 hexify( dst_str, output, 16 ); 01301 01302 fct_chk( strcmp( (char *) dst_str, "d4f0aae13c8fe9339fbf9e69ed0ad74d" ) == 0 ); 01303 } 01304 } 01305 FCT_TEST_END(); 01306 01307 01308 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_9) 01309 { 01310 unsigned char key_str[100]; 01311 unsigned char src_str[100]; 01312 unsigned char dst_str[100]; 01313 unsigned char output[100]; 01314 aes_context ctx; 01315 int key_len; 01316 01317 memset(key_str, 0x00, 100); 01318 memset(src_str, 0x00, 100); 01319 memset(dst_str, 0x00, 100); 01320 memset(output, 0x00, 100); 01321 01322 key_len = unhexify( key_str, "98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9" ); 01323 unhexify( src_str, "00000000000000000000000000000000" ); 01324 01325 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01326 if( 0 == 0 ) 01327 { 01328 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01329 hexify( dst_str, output, 16 ); 01330 01331 fct_chk( strcmp( (char *) dst_str, "19c80ec4a6deb7e5ed1033dda933498f" ) == 0 ); 01332 } 01333 } 01334 FCT_TEST_END(); 01335 01336 01337 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_10) 01338 { 01339 unsigned char key_str[100]; 01340 unsigned char src_str[100]; 01341 unsigned char dst_str[100]; 01342 unsigned char output[100]; 01343 aes_context ctx; 01344 int key_len; 01345 01346 memset(key_str, 0x00, 100); 01347 memset(src_str, 0x00, 100); 01348 memset(dst_str, 0x00, 100); 01349 memset(output, 0x00, 100); 01350 01351 key_len = unhexify( key_str, "fffffffffffffffffffffffffff800000000000000000000" ); 01352 unhexify( src_str, "00000000000000000000000000000000" ); 01353 01354 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01355 if( 0 == 0 ) 01356 { 01357 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01358 hexify( dst_str, output, 16 ); 01359 01360 fct_chk( strcmp( (char *) dst_str, "8dd274bd0f1b58ae345d9e7233f9b8f3" ) == 0 ); 01361 } 01362 } 01363 FCT_TEST_END(); 01364 01365 01366 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_11) 01367 { 01368 unsigned char key_str[100]; 01369 unsigned char src_str[100]; 01370 unsigned char dst_str[100]; 01371 unsigned char output[100]; 01372 aes_context ctx; 01373 int key_len; 01374 01375 memset(key_str, 0x00, 100); 01376 memset(src_str, 0x00, 100); 01377 memset(dst_str, 0x00, 100); 01378 memset(output, 0x00, 100); 01379 01380 key_len = unhexify( key_str, "fffffffffffffffffffffffffffc00000000000000000000" ); 01381 unhexify( src_str, "00000000000000000000000000000000" ); 01382 01383 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01384 if( 0 == 0 ) 01385 { 01386 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01387 hexify( dst_str, output, 16 ); 01388 01389 fct_chk( strcmp( (char *) dst_str, "9d6bdc8f4ce5feb0f3bed2e4b9a9bb0b" ) == 0 ); 01390 } 01391 } 01392 FCT_TEST_END(); 01393 01394 01395 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_12) 01396 { 01397 unsigned char key_str[100]; 01398 unsigned char src_str[100]; 01399 unsigned char dst_str[100]; 01400 unsigned char output[100]; 01401 aes_context ctx; 01402 int key_len; 01403 01404 memset(key_str, 0x00, 100); 01405 memset(src_str, 0x00, 100); 01406 memset(dst_str, 0x00, 100); 01407 memset(output, 0x00, 100); 01408 01409 key_len = unhexify( key_str, "fffffffffffffffffffffffffffe00000000000000000000" ); 01410 unhexify( src_str, "00000000000000000000000000000000" ); 01411 01412 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01413 if( 0 == 0 ) 01414 { 01415 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01416 hexify( dst_str, output, 16 ); 01417 01418 fct_chk( strcmp( (char *) dst_str, "fd5548bcf3f42565f7efa94562528d46" ) == 0 ); 01419 } 01420 } 01421 FCT_TEST_END(); 01422 01423 01424 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_1) 01425 { 01426 unsigned char key_str[100]; 01427 unsigned char src_str[100]; 01428 unsigned char dst_str[100]; 01429 unsigned char output[100]; 01430 aes_context ctx; 01431 int key_len; 01432 01433 memset(key_str, 0x00, 100); 01434 memset(src_str, 0x00, 100); 01435 memset(dst_str, 0x00, 100); 01436 memset(output, 0x00, 100); 01437 01438 key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffff000000000000000" ); 01439 unhexify( src_str, "bb2852c891c5947d2ed44032c421b85f" ); 01440 01441 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01442 if( 0 == 0 ) 01443 { 01444 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01445 hexify( dst_str, output, 16 ); 01446 01447 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 01448 } 01449 } 01450 FCT_TEST_END(); 01451 01452 01453 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_2) 01454 { 01455 unsigned char key_str[100]; 01456 unsigned char src_str[100]; 01457 unsigned char dst_str[100]; 01458 unsigned char output[100]; 01459 aes_context ctx; 01460 int key_len; 01461 01462 memset(key_str, 0x00, 100); 01463 memset(src_str, 0x00, 100); 01464 memset(dst_str, 0x00, 100); 01465 memset(output, 0x00, 100); 01466 01467 key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffff800000000000000" ); 01468 unhexify( src_str, "1b9f5fbd5e8a4264c0a85b80409afa5e" ); 01469 01470 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01471 if( 0 == 0 ) 01472 { 01473 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01474 hexify( dst_str, output, 16 ); 01475 01476 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 01477 } 01478 } 01479 FCT_TEST_END(); 01480 01481 01482 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_3) 01483 { 01484 unsigned char key_str[100]; 01485 unsigned char src_str[100]; 01486 unsigned char dst_str[100]; 01487 unsigned char output[100]; 01488 aes_context ctx; 01489 int key_len; 01490 01491 memset(key_str, 0x00, 100); 01492 memset(src_str, 0x00, 100); 01493 memset(dst_str, 0x00, 100); 01494 memset(output, 0x00, 100); 01495 01496 key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffc00000000000000" ); 01497 unhexify( src_str, "30dab809f85a917fe924733f424ac589" ); 01498 01499 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01500 if( 0 == 0 ) 01501 { 01502 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01503 hexify( dst_str, output, 16 ); 01504 01505 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 01506 } 01507 } 01508 FCT_TEST_END(); 01509 01510 01511 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_4) 01512 { 01513 unsigned char key_str[100]; 01514 unsigned char src_str[100]; 01515 unsigned char dst_str[100]; 01516 unsigned char output[100]; 01517 aes_context ctx; 01518 int key_len; 01519 01520 memset(key_str, 0x00, 100); 01521 memset(src_str, 0x00, 100); 01522 memset(dst_str, 0x00, 100); 01523 memset(output, 0x00, 100); 01524 01525 key_len = unhexify( key_str, "61257134a518a0d57d9d244d45f6498cbc32f2bafc522d79" ); 01526 unhexify( src_str, "cfe4d74002696ccf7d87b14a2f9cafc9" ); 01527 01528 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01529 if( 0 == 0 ) 01530 { 01531 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01532 hexify( dst_str, output, 16 ); 01533 01534 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 01535 } 01536 } 01537 FCT_TEST_END(); 01538 01539 01540 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_5) 01541 { 01542 unsigned char key_str[100]; 01543 unsigned char src_str[100]; 01544 unsigned char dst_str[100]; 01545 unsigned char output[100]; 01546 aes_context ctx; 01547 int key_len; 01548 01549 memset(key_str, 0x00, 100); 01550 memset(src_str, 0x00, 100); 01551 memset(dst_str, 0x00, 100); 01552 memset(output, 0x00, 100); 01553 01554 key_len = unhexify( key_str, "b0ab0a6a818baef2d11fa33eac947284fb7d748cfb75e570" ); 01555 unhexify( src_str, "d2eafd86f63b109b91f5dbb3a3fb7e13" ); 01556 01557 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01558 if( 0 == 0 ) 01559 { 01560 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01561 hexify( dst_str, output, 16 ); 01562 01563 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 01564 } 01565 } 01566 FCT_TEST_END(); 01567 01568 01569 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_6) 01570 { 01571 unsigned char key_str[100]; 01572 unsigned char src_str[100]; 01573 unsigned char dst_str[100]; 01574 unsigned char output[100]; 01575 aes_context ctx; 01576 int key_len; 01577 01578 memset(key_str, 0x00, 100); 01579 memset(src_str, 0x00, 100); 01580 memset(dst_str, 0x00, 100); 01581 memset(output, 0x00, 100); 01582 01583 key_len = unhexify( key_str, "ee053aa011c8b428cdcc3636313c54d6a03cac01c71579d6" ); 01584 unhexify( src_str, "9b9fdd1c5975655f539998b306a324af" ); 01585 01586 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01587 if( 0 == 0 ) 01588 { 01589 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01590 hexify( dst_str, output, 16 ); 01591 01592 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 01593 } 01594 } 01595 FCT_TEST_END(); 01596 01597 01598 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_7) 01599 { 01600 unsigned char key_str[100]; 01601 unsigned char src_str[100]; 01602 unsigned char dst_str[100]; 01603 unsigned char output[100]; 01604 aes_context ctx; 01605 int key_len; 01606 01607 memset(key_str, 0x00, 100); 01608 memset(src_str, 0x00, 100); 01609 memset(dst_str, 0x00, 100); 01610 memset(output, 0x00, 100); 01611 01612 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01613 unhexify( src_str, "275cfc0413d8ccb70513c3859b1d0f72" ); 01614 01615 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01616 if( 0 == 0 ) 01617 { 01618 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01619 hexify( dst_str, output, 16 ); 01620 01621 fct_chk( strcmp( (char *) dst_str, "1b077a6af4b7f98229de786d7516b639" ) == 0 ); 01622 } 01623 } 01624 FCT_TEST_END(); 01625 01626 01627 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_8) 01628 { 01629 unsigned char key_str[100]; 01630 unsigned char src_str[100]; 01631 unsigned char dst_str[100]; 01632 unsigned char output[100]; 01633 aes_context ctx; 01634 int key_len; 01635 01636 memset(key_str, 0x00, 100); 01637 memset(src_str, 0x00, 100); 01638 memset(dst_str, 0x00, 100); 01639 memset(output, 0x00, 100); 01640 01641 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01642 unhexify( src_str, "c9b8135ff1b5adc413dfd053b21bd96d" ); 01643 01644 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01645 if( 0 == 0 ) 01646 { 01647 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01648 hexify( dst_str, output, 16 ); 01649 01650 fct_chk( strcmp( (char *) dst_str, "9c2d8842e5f48f57648205d39a239af1" ) == 0 ); 01651 } 01652 } 01653 FCT_TEST_END(); 01654 01655 01656 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_9) 01657 { 01658 unsigned char key_str[100]; 01659 unsigned char src_str[100]; 01660 unsigned char dst_str[100]; 01661 unsigned char output[100]; 01662 aes_context ctx; 01663 int key_len; 01664 01665 memset(key_str, 0x00, 100); 01666 memset(src_str, 0x00, 100); 01667 memset(dst_str, 0x00, 100); 01668 memset(output, 0x00, 100); 01669 01670 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01671 unhexify( src_str, "4a3650c3371ce2eb35e389a171427440" ); 01672 01673 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01674 if( 0 == 0 ) 01675 { 01676 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01677 hexify( dst_str, output, 16 ); 01678 01679 fct_chk( strcmp( (char *) dst_str, "bff52510095f518ecca60af4205444bb" ) == 0 ); 01680 } 01681 } 01682 FCT_TEST_END(); 01683 01684 01685 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_10) 01686 { 01687 unsigned char key_str[100]; 01688 unsigned char src_str[100]; 01689 unsigned char dst_str[100]; 01690 unsigned char output[100]; 01691 aes_context ctx; 01692 int key_len; 01693 01694 memset(key_str, 0x00, 100); 01695 memset(src_str, 0x00, 100); 01696 memset(dst_str, 0x00, 100); 01697 memset(output, 0x00, 100); 01698 01699 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01700 unhexify( src_str, "b2099795e88cc158fd75ea133d7e7fbe" ); 01701 01702 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01703 if( 0 == 0 ) 01704 { 01705 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01706 hexify( dst_str, output, 16 ); 01707 01708 fct_chk( strcmp( (char *) dst_str, "ffffffffffffffffffffc00000000000" ) == 0 ); 01709 } 01710 } 01711 FCT_TEST_END(); 01712 01713 01714 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_11) 01715 { 01716 unsigned char key_str[100]; 01717 unsigned char src_str[100]; 01718 unsigned char dst_str[100]; 01719 unsigned char output[100]; 01720 aes_context ctx; 01721 int key_len; 01722 01723 memset(key_str, 0x00, 100); 01724 memset(src_str, 0x00, 100); 01725 memset(dst_str, 0x00, 100); 01726 memset(output, 0x00, 100); 01727 01728 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01729 unhexify( src_str, "a6cae46fb6fadfe7a2c302a34242817b" ); 01730 01731 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01732 if( 0 == 0 ) 01733 { 01734 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01735 hexify( dst_str, output, 16 ); 01736 01737 fct_chk( strcmp( (char *) dst_str, "ffffffffffffffffffffe00000000000" ) == 0 ); 01738 } 01739 } 01740 FCT_TEST_END(); 01741 01742 01743 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_12) 01744 { 01745 unsigned char key_str[100]; 01746 unsigned char src_str[100]; 01747 unsigned char dst_str[100]; 01748 unsigned char output[100]; 01749 aes_context ctx; 01750 int key_len; 01751 01752 memset(key_str, 0x00, 100); 01753 memset(src_str, 0x00, 100); 01754 memset(dst_str, 0x00, 100); 01755 memset(output, 0x00, 100); 01756 01757 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 01758 unhexify( src_str, "026a7024d6a902e0b3ffccbaa910cc3f" ); 01759 01760 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 01761 if( 0 == 0 ) 01762 { 01763 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 01764 hexify( dst_str, output, 16 ); 01765 01766 fct_chk( strcmp( (char *) dst_str, "fffffffffffffffffffff00000000000" ) == 0 ); 01767 } 01768 } 01769 FCT_TEST_END(); 01770 01771 01772 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_1) 01773 { 01774 unsigned char key_str[100]; 01775 unsigned char src_str[100]; 01776 unsigned char dst_str[100]; 01777 unsigned char output[100]; 01778 aes_context ctx; 01779 int key_len; 01780 01781 memset(key_str, 0x00, 100); 01782 memset(src_str, 0x00, 100); 01783 memset(dst_str, 0x00, 100); 01784 memset(output, 0x00, 100); 01785 01786 key_len = unhexify( key_str, "c1cc358b449909a19436cfbb3f852ef8bcb5ed12ac7058325f56e6099aab1a1c" ); 01787 unhexify( src_str, "00000000000000000000000000000000" ); 01788 01789 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01790 if( 0 == 0 ) 01791 { 01792 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01793 hexify( dst_str, output, 16 ); 01794 01795 fct_chk( strcmp( (char *) dst_str, "352065272169abf9856843927d0674fd" ) == 0 ); 01796 } 01797 } 01798 FCT_TEST_END(); 01799 01800 01801 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_2) 01802 { 01803 unsigned char key_str[100]; 01804 unsigned char src_str[100]; 01805 unsigned char dst_str[100]; 01806 unsigned char output[100]; 01807 aes_context ctx; 01808 int key_len; 01809 01810 memset(key_str, 0x00, 100); 01811 memset(src_str, 0x00, 100); 01812 memset(dst_str, 0x00, 100); 01813 memset(output, 0x00, 100); 01814 01815 key_len = unhexify( key_str, "984ca75f4ee8d706f46c2d98c0bf4a45f5b00d791c2dfeb191b5ed8e420fd627" ); 01816 unhexify( src_str, "00000000000000000000000000000000" ); 01817 01818 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01819 if( 0 == 0 ) 01820 { 01821 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01822 hexify( dst_str, output, 16 ); 01823 01824 fct_chk( strcmp( (char *) dst_str, "4307456a9e67813b452e15fa8fffe398" ) == 0 ); 01825 } 01826 } 01827 FCT_TEST_END(); 01828 01829 01830 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_3) 01831 { 01832 unsigned char key_str[100]; 01833 unsigned char src_str[100]; 01834 unsigned char dst_str[100]; 01835 unsigned char output[100]; 01836 aes_context ctx; 01837 int key_len; 01838 01839 memset(key_str, 0x00, 100); 01840 memset(src_str, 0x00, 100); 01841 memset(dst_str, 0x00, 100); 01842 memset(output, 0x00, 100); 01843 01844 key_len = unhexify( key_str, "b43d08a447ac8609baadae4ff12918b9f68fc1653f1269222f123981ded7a92f" ); 01845 unhexify( src_str, "00000000000000000000000000000000" ); 01846 01847 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01848 if( 0 == 0 ) 01849 { 01850 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01851 hexify( dst_str, output, 16 ); 01852 01853 fct_chk( strcmp( (char *) dst_str, "4663446607354989477a5c6f0f007ef4" ) == 0 ); 01854 } 01855 } 01856 FCT_TEST_END(); 01857 01858 01859 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_4) 01860 { 01861 unsigned char key_str[100]; 01862 unsigned char src_str[100]; 01863 unsigned char dst_str[100]; 01864 unsigned char output[100]; 01865 aes_context ctx; 01866 int key_len; 01867 01868 memset(key_str, 0x00, 100); 01869 memset(src_str, 0x00, 100); 01870 memset(dst_str, 0x00, 100); 01871 memset(output, 0x00, 100); 01872 01873 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 01874 unhexify( src_str, "0b24af36193ce4665f2825d7b4749c98" ); 01875 01876 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01877 if( 0 == 0 ) 01878 { 01879 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01880 hexify( dst_str, output, 16 ); 01881 01882 fct_chk( strcmp( (char *) dst_str, "a9ff75bd7cf6613d3731c77c3b6d0c04" ) == 0 ); 01883 } 01884 } 01885 FCT_TEST_END(); 01886 01887 01888 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_5) 01889 { 01890 unsigned char key_str[100]; 01891 unsigned char src_str[100]; 01892 unsigned char dst_str[100]; 01893 unsigned char output[100]; 01894 aes_context ctx; 01895 int key_len; 01896 01897 memset(key_str, 0x00, 100); 01898 memset(src_str, 0x00, 100); 01899 memset(dst_str, 0x00, 100); 01900 memset(output, 0x00, 100); 01901 01902 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 01903 unhexify( src_str, "761c1fe41a18acf20d241650611d90f1" ); 01904 01905 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01906 if( 0 == 0 ) 01907 { 01908 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01909 hexify( dst_str, output, 16 ); 01910 01911 fct_chk( strcmp( (char *) dst_str, "623a52fcea5d443e48d9181ab32c7421" ) == 0 ); 01912 } 01913 } 01914 FCT_TEST_END(); 01915 01916 01917 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_6) 01918 { 01919 unsigned char key_str[100]; 01920 unsigned char src_str[100]; 01921 unsigned char dst_str[100]; 01922 unsigned char output[100]; 01923 aes_context ctx; 01924 int key_len; 01925 01926 memset(key_str, 0x00, 100); 01927 memset(src_str, 0x00, 100); 01928 memset(dst_str, 0x00, 100); 01929 memset(output, 0x00, 100); 01930 01931 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 01932 unhexify( src_str, "8a560769d605868ad80d819bdba03771" ); 01933 01934 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01935 if( 0 == 0 ) 01936 { 01937 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01938 hexify( dst_str, output, 16 ); 01939 01940 fct_chk( strcmp( (char *) dst_str, "38f2c7ae10612415d27ca190d27da8b4" ) == 0 ); 01941 } 01942 } 01943 FCT_TEST_END(); 01944 01945 01946 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_7) 01947 { 01948 unsigned char key_str[100]; 01949 unsigned char src_str[100]; 01950 unsigned char dst_str[100]; 01951 unsigned char output[100]; 01952 aes_context ctx; 01953 int key_len; 01954 01955 memset(key_str, 0x00, 100); 01956 memset(src_str, 0x00, 100); 01957 memset(dst_str, 0x00, 100); 01958 memset(output, 0x00, 100); 01959 01960 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 01961 unhexify( src_str, "ffffff80000000000000000000000000" ); 01962 01963 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01964 if( 0 == 0 ) 01965 { 01966 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01967 hexify( dst_str, output, 16 ); 01968 01969 fct_chk( strcmp( (char *) dst_str, "36aff0ef7bf3280772cf4cac80a0d2b2" ) == 0 ); 01970 } 01971 } 01972 FCT_TEST_END(); 01973 01974 01975 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_8) 01976 { 01977 unsigned char key_str[100]; 01978 unsigned char src_str[100]; 01979 unsigned char dst_str[100]; 01980 unsigned char output[100]; 01981 aes_context ctx; 01982 int key_len; 01983 01984 memset(key_str, 0x00, 100); 01985 memset(src_str, 0x00, 100); 01986 memset(dst_str, 0x00, 100); 01987 memset(output, 0x00, 100); 01988 01989 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 01990 unhexify( src_str, "ffffffc0000000000000000000000000" ); 01991 01992 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 01993 if( 0 == 0 ) 01994 { 01995 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 01996 hexify( dst_str, output, 16 ); 01997 01998 fct_chk( strcmp( (char *) dst_str, "1f8eedea0f62a1406d58cfc3ecea72cf" ) == 0 ); 01999 } 02000 } 02001 FCT_TEST_END(); 02002 02003 02004 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_9) 02005 { 02006 unsigned char key_str[100]; 02007 unsigned char src_str[100]; 02008 unsigned char dst_str[100]; 02009 unsigned char output[100]; 02010 aes_context ctx; 02011 int key_len; 02012 02013 memset(key_str, 0x00, 100); 02014 memset(src_str, 0x00, 100); 02015 memset(dst_str, 0x00, 100); 02016 memset(output, 0x00, 100); 02017 02018 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 02019 unhexify( src_str, "ffffffe0000000000000000000000000" ); 02020 02021 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 02022 if( 0 == 0 ) 02023 { 02024 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 02025 hexify( dst_str, output, 16 ); 02026 02027 fct_chk( strcmp( (char *) dst_str, "abf4154a3375a1d3e6b1d454438f95a6" ) == 0 ); 02028 } 02029 } 02030 FCT_TEST_END(); 02031 02032 02033 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_10) 02034 { 02035 unsigned char key_str[100]; 02036 unsigned char src_str[100]; 02037 unsigned char dst_str[100]; 02038 unsigned char output[100]; 02039 aes_context ctx; 02040 int key_len; 02041 02042 memset(key_str, 0x00, 100); 02043 memset(src_str, 0x00, 100); 02044 memset(dst_str, 0x00, 100); 02045 memset(output, 0x00, 100); 02046 02047 key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffff8000000000000000000000000000" ); 02048 unhexify( src_str, "00000000000000000000000000000000" ); 02049 02050 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 02051 if( 0 == 0 ) 02052 { 02053 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 02054 hexify( dst_str, output, 16 ); 02055 02056 fct_chk( strcmp( (char *) dst_str, "45d089c36d5c5a4efc689e3b0de10dd5" ) == 0 ); 02057 } 02058 } 02059 FCT_TEST_END(); 02060 02061 02062 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_11) 02063 { 02064 unsigned char key_str[100]; 02065 unsigned char src_str[100]; 02066 unsigned char dst_str[100]; 02067 unsigned char output[100]; 02068 aes_context ctx; 02069 int key_len; 02070 02071 memset(key_str, 0x00, 100); 02072 memset(src_str, 0x00, 100); 02073 memset(dst_str, 0x00, 100); 02074 memset(output, 0x00, 100); 02075 02076 key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffc000000000000000000000000000" ); 02077 unhexify( src_str, "00000000000000000000000000000000" ); 02078 02079 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 02080 if( 0 == 0 ) 02081 { 02082 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 02083 hexify( dst_str, output, 16 ); 02084 02085 fct_chk( strcmp( (char *) dst_str, "b4da5df4becb5462e03a0ed00d295629" ) == 0 ); 02086 } 02087 } 02088 FCT_TEST_END(); 02089 02090 02091 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_12) 02092 { 02093 unsigned char key_str[100]; 02094 unsigned char src_str[100]; 02095 unsigned char dst_str[100]; 02096 unsigned char output[100]; 02097 aes_context ctx; 02098 int key_len; 02099 02100 memset(key_str, 0x00, 100); 02101 memset(src_str, 0x00, 100); 02102 memset(dst_str, 0x00, 100); 02103 memset(output, 0x00, 100); 02104 02105 key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffe000000000000000000000000000" ); 02106 unhexify( src_str, "00000000000000000000000000000000" ); 02107 02108 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); 02109 if( 0 == 0 ) 02110 { 02111 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 02112 hexify( dst_str, output, 16 ); 02113 02114 fct_chk( strcmp( (char *) dst_str, "dcf4e129136c1a4b7a0f38935cc34b2b" ) == 0 ); 02115 } 02116 } 02117 FCT_TEST_END(); 02118 02119 02120 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_1) 02121 { 02122 unsigned char key_str[100]; 02123 unsigned char src_str[100]; 02124 unsigned char dst_str[100]; 02125 unsigned char output[100]; 02126 aes_context ctx; 02127 int key_len; 02128 02129 memset(key_str, 0x00, 100); 02130 memset(src_str, 0x00, 100); 02131 memset(dst_str, 0x00, 100); 02132 memset(output, 0x00, 100); 02133 02134 key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffff00000000000000000" ); 02135 unhexify( src_str, "edf61ae362e882ddc0167474a7a77f3a" ); 02136 02137 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02138 if( 0 == 0 ) 02139 { 02140 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02141 hexify( dst_str, output, 16 ); 02142 02143 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 02144 } 02145 } 02146 FCT_TEST_END(); 02147 02148 02149 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_2) 02150 { 02151 unsigned char key_str[100]; 02152 unsigned char src_str[100]; 02153 unsigned char dst_str[100]; 02154 unsigned char output[100]; 02155 aes_context ctx; 02156 int key_len; 02157 02158 memset(key_str, 0x00, 100); 02159 memset(src_str, 0x00, 100); 02160 memset(dst_str, 0x00, 100); 02161 memset(output, 0x00, 100); 02162 02163 key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffff80000000000000000" ); 02164 unhexify( src_str, "6168b00ba7859e0970ecfd757efecf7c" ); 02165 02166 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02167 if( 0 == 0 ) 02168 { 02169 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02170 hexify( dst_str, output, 16 ); 02171 02172 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 02173 } 02174 } 02175 FCT_TEST_END(); 02176 02177 02178 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_3) 02179 { 02180 unsigned char key_str[100]; 02181 unsigned char src_str[100]; 02182 unsigned char dst_str[100]; 02183 unsigned char output[100]; 02184 aes_context ctx; 02185 int key_len; 02186 02187 memset(key_str, 0x00, 100); 02188 memset(src_str, 0x00, 100); 02189 memset(dst_str, 0x00, 100); 02190 memset(output, 0x00, 100); 02191 02192 key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffffc0000000000000000" ); 02193 unhexify( src_str, "d1415447866230d28bb1ea18a4cdfd02" ); 02194 02195 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02196 if( 0 == 0 ) 02197 { 02198 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02199 hexify( dst_str, output, 16 ); 02200 02201 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 02202 } 02203 } 02204 FCT_TEST_END(); 02205 02206 02207 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_4) 02208 { 02209 unsigned char key_str[100]; 02210 unsigned char src_str[100]; 02211 unsigned char dst_str[100]; 02212 unsigned char output[100]; 02213 aes_context ctx; 02214 int key_len; 02215 02216 memset(key_str, 0x00, 100); 02217 memset(src_str, 0x00, 100); 02218 memset(dst_str, 0x00, 100); 02219 memset(output, 0x00, 100); 02220 02221 key_len = unhexify( key_str, "f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9" ); 02222 unhexify( src_str, "a3944b95ca0b52043584ef02151926a8" ); 02223 02224 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02225 if( 0 == 0 ) 02226 { 02227 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02228 hexify( dst_str, output, 16 ); 02229 02230 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 02231 } 02232 } 02233 FCT_TEST_END(); 02234 02235 02236 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_5) 02237 { 02238 unsigned char key_str[100]; 02239 unsigned char src_str[100]; 02240 unsigned char dst_str[100]; 02241 unsigned char output[100]; 02242 aes_context ctx; 02243 int key_len; 02244 02245 memset(key_str, 0x00, 100); 02246 memset(src_str, 0x00, 100); 02247 memset(dst_str, 0x00, 100); 02248 memset(output, 0x00, 100); 02249 02250 key_len = unhexify( key_str, "797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e" ); 02251 unhexify( src_str, "a74289fe73a4c123ca189ea1e1b49ad5" ); 02252 02253 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02254 if( 0 == 0 ) 02255 { 02256 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02257 hexify( dst_str, output, 16 ); 02258 02259 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 02260 } 02261 } 02262 FCT_TEST_END(); 02263 02264 02265 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_6) 02266 { 02267 unsigned char key_str[100]; 02268 unsigned char src_str[100]; 02269 unsigned char dst_str[100]; 02270 unsigned char output[100]; 02271 aes_context ctx; 02272 int key_len; 02273 02274 memset(key_str, 0x00, 100); 02275 memset(src_str, 0x00, 100); 02276 memset(dst_str, 0x00, 100); 02277 memset(output, 0x00, 100); 02278 02279 key_len = unhexify( key_str, "6838d40caf927749c13f0329d331f448e202c73ef52c5f73a37ca635d4c47707" ); 02280 unhexify( src_str, "b91d4ea4488644b56cf0812fa7fcf5fc" ); 02281 02282 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02283 if( 0 == 0 ) 02284 { 02285 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02286 hexify( dst_str, output, 16 ); 02287 02288 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 02289 } 02290 } 02291 FCT_TEST_END(); 02292 02293 02294 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_7) 02295 { 02296 unsigned char key_str[100]; 02297 unsigned char src_str[100]; 02298 unsigned char dst_str[100]; 02299 unsigned char output[100]; 02300 aes_context ctx; 02301 int key_len; 02302 02303 memset(key_str, 0x00, 100); 02304 memset(src_str, 0x00, 100); 02305 memset(dst_str, 0x00, 100); 02306 memset(output, 0x00, 100); 02307 02308 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 02309 unhexify( src_str, "623a52fcea5d443e48d9181ab32c7421" ); 02310 02311 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02312 if( 0 == 0 ) 02313 { 02314 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02315 hexify( dst_str, output, 16 ); 02316 02317 fct_chk( strcmp( (char *) dst_str, "761c1fe41a18acf20d241650611d90f1" ) == 0 ); 02318 } 02319 } 02320 FCT_TEST_END(); 02321 02322 02323 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_8) 02324 { 02325 unsigned char key_str[100]; 02326 unsigned char src_str[100]; 02327 unsigned char dst_str[100]; 02328 unsigned char output[100]; 02329 aes_context ctx; 02330 int key_len; 02331 02332 memset(key_str, 0x00, 100); 02333 memset(src_str, 0x00, 100); 02334 memset(dst_str, 0x00, 100); 02335 memset(output, 0x00, 100); 02336 02337 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 02338 unhexify( src_str, "38f2c7ae10612415d27ca190d27da8b4" ); 02339 02340 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02341 if( 0 == 0 ) 02342 { 02343 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02344 hexify( dst_str, output, 16 ); 02345 02346 fct_chk( strcmp( (char *) dst_str, "8a560769d605868ad80d819bdba03771" ) == 0 ); 02347 } 02348 } 02349 FCT_TEST_END(); 02350 02351 02352 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_9) 02353 { 02354 unsigned char key_str[100]; 02355 unsigned char src_str[100]; 02356 unsigned char dst_str[100]; 02357 unsigned char output[100]; 02358 aes_context ctx; 02359 int key_len; 02360 02361 memset(key_str, 0x00, 100); 02362 memset(src_str, 0x00, 100); 02363 memset(dst_str, 0x00, 100); 02364 memset(output, 0x00, 100); 02365 02366 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 02367 unhexify( src_str, "1bc704f1bce135ceb810341b216d7abe" ); 02368 02369 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02370 if( 0 == 0 ) 02371 { 02372 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02373 hexify( dst_str, output, 16 ); 02374 02375 fct_chk( strcmp( (char *) dst_str, "91fbef2d15a97816060bee1feaa49afe" ) == 0 ); 02376 } 02377 } 02378 FCT_TEST_END(); 02379 02380 02381 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_10) 02382 { 02383 unsigned char key_str[100]; 02384 unsigned char src_str[100]; 02385 unsigned char dst_str[100]; 02386 unsigned char output[100]; 02387 aes_context ctx; 02388 int key_len; 02389 02390 memset(key_str, 0x00, 100); 02391 memset(src_str, 0x00, 100); 02392 memset(dst_str, 0x00, 100); 02393 memset(output, 0x00, 100); 02394 02395 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 02396 unhexify( src_str, "ddc6bf790c15760d8d9aeb6f9a75fd4e" ); 02397 02398 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02399 if( 0 == 0 ) 02400 { 02401 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02402 hexify( dst_str, output, 16 ); 02403 02404 fct_chk( strcmp( (char *) dst_str, "80000000000000000000000000000000" ) == 0 ); 02405 } 02406 } 02407 FCT_TEST_END(); 02408 02409 02410 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_11) 02411 { 02412 unsigned char key_str[100]; 02413 unsigned char src_str[100]; 02414 unsigned char dst_str[100]; 02415 unsigned char output[100]; 02416 aes_context ctx; 02417 int key_len; 02418 02419 memset(key_str, 0x00, 100); 02420 memset(src_str, 0x00, 100); 02421 memset(dst_str, 0x00, 100); 02422 memset(output, 0x00, 100); 02423 02424 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 02425 unhexify( src_str, "0a6bdc6d4c1e6280301fd8e97ddbe601" ); 02426 02427 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02428 if( 0 == 0 ) 02429 { 02430 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02431 hexify( dst_str, output, 16 ); 02432 02433 fct_chk( strcmp( (char *) dst_str, "c0000000000000000000000000000000" ) == 0 ); 02434 } 02435 } 02436 FCT_TEST_END(); 02437 02438 02439 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_12) 02440 { 02441 unsigned char key_str[100]; 02442 unsigned char src_str[100]; 02443 unsigned char dst_str[100]; 02444 unsigned char output[100]; 02445 aes_context ctx; 02446 int key_len; 02447 02448 memset(key_str, 0x00, 100); 02449 memset(src_str, 0x00, 100); 02450 memset(dst_str, 0x00, 100); 02451 memset(output, 0x00, 100); 02452 02453 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 02454 unhexify( src_str, "9b80eefb7ebe2d2b16247aa0efc72f5d" ); 02455 02456 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 ); 02457 if( 0 == 0 ) 02458 { 02459 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 02460 hexify( dst_str, output, 16 ); 02461 02462 fct_chk( strcmp( (char *) dst_str, "e0000000000000000000000000000000" ) == 0 ); 02463 } 02464 } 02465 FCT_TEST_END(); 02466 02467 02468 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_1) 02469 { 02470 unsigned char key_str[100]; 02471 unsigned char iv_str[100]; 02472 unsigned char src_str[100]; 02473 unsigned char dst_str[100]; 02474 unsigned char output[100]; 02475 aes_context ctx; 02476 int key_len, data_len; 02477 02478 memset(key_str, 0x00, 100); 02479 memset(iv_str, 0x00, 100); 02480 memset(src_str, 0x00, 100); 02481 memset(dst_str, 0x00, 100); 02482 memset(output, 0x00, 100); 02483 02484 key_len = unhexify( key_str, "fffffffffffff8000000000000000000" ); 02485 unhexify( iv_str, "00000000000000000000000000000000" ); 02486 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 02487 02488 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02489 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02490 if( 0 == 0 ) 02491 { 02492 hexify( dst_str, output, data_len ); 02493 02494 fct_chk( strcmp( (char *) dst_str, "8b527a6aebdaec9eaef8eda2cb7783e5" ) == 0 ); 02495 } 02496 } 02497 FCT_TEST_END(); 02498 02499 02500 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_2) 02501 { 02502 unsigned char key_str[100]; 02503 unsigned char iv_str[100]; 02504 unsigned char src_str[100]; 02505 unsigned char dst_str[100]; 02506 unsigned char output[100]; 02507 aes_context ctx; 02508 int key_len, data_len; 02509 02510 memset(key_str, 0x00, 100); 02511 memset(iv_str, 0x00, 100); 02512 memset(src_str, 0x00, 100); 02513 memset(dst_str, 0x00, 100); 02514 memset(output, 0x00, 100); 02515 02516 key_len = unhexify( key_str, "fffffffffffffc000000000000000000" ); 02517 unhexify( iv_str, "00000000000000000000000000000000" ); 02518 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 02519 02520 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02521 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02522 if( 0 == 0 ) 02523 { 02524 hexify( dst_str, output, data_len ); 02525 02526 fct_chk( strcmp( (char *) dst_str, "43fdaf53ebbc9880c228617d6a9b548b" ) == 0 ); 02527 } 02528 } 02529 FCT_TEST_END(); 02530 02531 02532 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_3) 02533 { 02534 unsigned char key_str[100]; 02535 unsigned char iv_str[100]; 02536 unsigned char src_str[100]; 02537 unsigned char dst_str[100]; 02538 unsigned char output[100]; 02539 aes_context ctx; 02540 int key_len, data_len; 02541 02542 memset(key_str, 0x00, 100); 02543 memset(iv_str, 0x00, 100); 02544 memset(src_str, 0x00, 100); 02545 memset(dst_str, 0x00, 100); 02546 memset(output, 0x00, 100); 02547 02548 key_len = unhexify( key_str, "fffffffffffffe000000000000000000" ); 02549 unhexify( iv_str, "00000000000000000000000000000000" ); 02550 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 02551 02552 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02553 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02554 if( 0 == 0 ) 02555 { 02556 hexify( dst_str, output, data_len ); 02557 02558 fct_chk( strcmp( (char *) dst_str, "53786104b9744b98f052c46f1c850d0b" ) == 0 ); 02559 } 02560 } 02561 FCT_TEST_END(); 02562 02563 02564 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_4) 02565 { 02566 unsigned char key_str[100]; 02567 unsigned char iv_str[100]; 02568 unsigned char src_str[100]; 02569 unsigned char dst_str[100]; 02570 unsigned char output[100]; 02571 aes_context ctx; 02572 int key_len, data_len; 02573 02574 memset(key_str, 0x00, 100); 02575 memset(iv_str, 0x00, 100); 02576 memset(src_str, 0x00, 100); 02577 memset(dst_str, 0x00, 100); 02578 memset(output, 0x00, 100); 02579 02580 key_len = unhexify( key_str, "e37b1c6aa2846f6fdb413f238b089f23" ); 02581 unhexify( iv_str, "00000000000000000000000000000000" ); 02582 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 02583 02584 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02585 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02586 if( 0 == 0 ) 02587 { 02588 hexify( dst_str, output, data_len ); 02589 02590 fct_chk( strcmp( (char *) dst_str, "43c9f7e62f5d288bb27aa40ef8fe1ea8" ) == 0 ); 02591 } 02592 } 02593 FCT_TEST_END(); 02594 02595 02596 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_5) 02597 { 02598 unsigned char key_str[100]; 02599 unsigned char iv_str[100]; 02600 unsigned char src_str[100]; 02601 unsigned char dst_str[100]; 02602 unsigned char output[100]; 02603 aes_context ctx; 02604 int key_len, data_len; 02605 02606 memset(key_str, 0x00, 100); 02607 memset(iv_str, 0x00, 100); 02608 memset(src_str, 0x00, 100); 02609 memset(dst_str, 0x00, 100); 02610 memset(output, 0x00, 100); 02611 02612 key_len = unhexify( key_str, "6c002b682483e0cabcc731c253be5674" ); 02613 unhexify( iv_str, "00000000000000000000000000000000" ); 02614 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 02615 02616 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02617 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02618 if( 0 == 0 ) 02619 { 02620 hexify( dst_str, output, data_len ); 02621 02622 fct_chk( strcmp( (char *) dst_str, "3580d19cff44f1014a7c966a69059de5" ) == 0 ); 02623 } 02624 } 02625 FCT_TEST_END(); 02626 02627 02628 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_6) 02629 { 02630 unsigned char key_str[100]; 02631 unsigned char iv_str[100]; 02632 unsigned char src_str[100]; 02633 unsigned char dst_str[100]; 02634 unsigned char output[100]; 02635 aes_context ctx; 02636 int key_len, data_len; 02637 02638 memset(key_str, 0x00, 100); 02639 memset(iv_str, 0x00, 100); 02640 memset(src_str, 0x00, 100); 02641 memset(dst_str, 0x00, 100); 02642 memset(output, 0x00, 100); 02643 02644 key_len = unhexify( key_str, "143ae8ed6555aba96110ab58893a8ae1" ); 02645 unhexify( iv_str, "00000000000000000000000000000000" ); 02646 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 02647 02648 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02649 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02650 if( 0 == 0 ) 02651 { 02652 hexify( dst_str, output, data_len ); 02653 02654 fct_chk( strcmp( (char *) dst_str, "806da864dd29d48deafbe764f8202aef" ) == 0 ); 02655 } 02656 } 02657 FCT_TEST_END(); 02658 02659 02660 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_7) 02661 { 02662 unsigned char key_str[100]; 02663 unsigned char iv_str[100]; 02664 unsigned char src_str[100]; 02665 unsigned char dst_str[100]; 02666 unsigned char output[100]; 02667 aes_context ctx; 02668 int key_len, data_len; 02669 02670 memset(key_str, 0x00, 100); 02671 memset(iv_str, 0x00, 100); 02672 memset(src_str, 0x00, 100); 02673 memset(dst_str, 0x00, 100); 02674 memset(output, 0x00, 100); 02675 02676 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 02677 unhexify( iv_str, "00000000000000000000000000000000" ); 02678 data_len = unhexify( src_str, "6a118a874519e64e9963798a503f1d35" ); 02679 02680 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02681 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02682 if( 0 == 0 ) 02683 { 02684 hexify( dst_str, output, data_len ); 02685 02686 fct_chk( strcmp( (char *) dst_str, "dc43be40be0e53712f7e2bf5ca707209" ) == 0 ); 02687 } 02688 } 02689 FCT_TEST_END(); 02690 02691 02692 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_8) 02693 { 02694 unsigned char key_str[100]; 02695 unsigned char iv_str[100]; 02696 unsigned char src_str[100]; 02697 unsigned char dst_str[100]; 02698 unsigned char output[100]; 02699 aes_context ctx; 02700 int key_len, data_len; 02701 02702 memset(key_str, 0x00, 100); 02703 memset(iv_str, 0x00, 100); 02704 memset(src_str, 0x00, 100); 02705 memset(dst_str, 0x00, 100); 02706 memset(output, 0x00, 100); 02707 02708 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 02709 unhexify( iv_str, "00000000000000000000000000000000" ); 02710 data_len = unhexify( src_str, "cb9fceec81286ca3e989bd979b0cb284" ); 02711 02712 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02713 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02714 if( 0 == 0 ) 02715 { 02716 hexify( dst_str, output, data_len ); 02717 02718 fct_chk( strcmp( (char *) dst_str, "92beedab1895a94faa69b632e5cc47ce" ) == 0 ); 02719 } 02720 } 02721 FCT_TEST_END(); 02722 02723 02724 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_9) 02725 { 02726 unsigned char key_str[100]; 02727 unsigned char iv_str[100]; 02728 unsigned char src_str[100]; 02729 unsigned char dst_str[100]; 02730 unsigned char output[100]; 02731 aes_context ctx; 02732 int key_len, data_len; 02733 02734 memset(key_str, 0x00, 100); 02735 memset(iv_str, 0x00, 100); 02736 memset(src_str, 0x00, 100); 02737 memset(dst_str, 0x00, 100); 02738 memset(output, 0x00, 100); 02739 02740 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 02741 unhexify( iv_str, "00000000000000000000000000000000" ); 02742 data_len = unhexify( src_str, "b26aeb1874e47ca8358ff22378f09144" ); 02743 02744 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02745 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02746 if( 0 == 0 ) 02747 { 02748 hexify( dst_str, output, data_len ); 02749 02750 fct_chk( strcmp( (char *) dst_str, "459264f4798f6a78bacb89c15ed3d601" ) == 0 ); 02751 } 02752 } 02753 FCT_TEST_END(); 02754 02755 02756 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_10) 02757 { 02758 unsigned char key_str[100]; 02759 unsigned char iv_str[100]; 02760 unsigned char src_str[100]; 02761 unsigned char dst_str[100]; 02762 unsigned char output[100]; 02763 aes_context ctx; 02764 int key_len, data_len; 02765 02766 memset(key_str, 0x00, 100); 02767 memset(iv_str, 0x00, 100); 02768 memset(src_str, 0x00, 100); 02769 memset(dst_str, 0x00, 100); 02770 memset(output, 0x00, 100); 02771 02772 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 02773 unhexify( iv_str, "00000000000000000000000000000000" ); 02774 data_len = unhexify( src_str, "ffffffffffffffffffffffc000000000" ); 02775 02776 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02777 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02778 if( 0 == 0 ) 02779 { 02780 hexify( dst_str, output, data_len ); 02781 02782 fct_chk( strcmp( (char *) dst_str, "90684a2ac55fe1ec2b8ebd5622520b73" ) == 0 ); 02783 } 02784 } 02785 FCT_TEST_END(); 02786 02787 02788 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_11) 02789 { 02790 unsigned char key_str[100]; 02791 unsigned char iv_str[100]; 02792 unsigned char src_str[100]; 02793 unsigned char dst_str[100]; 02794 unsigned char output[100]; 02795 aes_context ctx; 02796 int key_len, data_len; 02797 02798 memset(key_str, 0x00, 100); 02799 memset(iv_str, 0x00, 100); 02800 memset(src_str, 0x00, 100); 02801 memset(dst_str, 0x00, 100); 02802 memset(output, 0x00, 100); 02803 02804 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 02805 unhexify( iv_str, "00000000000000000000000000000000" ); 02806 data_len = unhexify( src_str, "ffffffffffffffffffffffe000000000" ); 02807 02808 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02809 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02810 if( 0 == 0 ) 02811 { 02812 hexify( dst_str, output, data_len ); 02813 02814 fct_chk( strcmp( (char *) dst_str, "7472f9a7988607ca79707795991035e6" ) == 0 ); 02815 } 02816 } 02817 FCT_TEST_END(); 02818 02819 02820 FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_12) 02821 { 02822 unsigned char key_str[100]; 02823 unsigned char iv_str[100]; 02824 unsigned char src_str[100]; 02825 unsigned char dst_str[100]; 02826 unsigned char output[100]; 02827 aes_context ctx; 02828 int key_len, data_len; 02829 02830 memset(key_str, 0x00, 100); 02831 memset(iv_str, 0x00, 100); 02832 memset(src_str, 0x00, 100); 02833 memset(dst_str, 0x00, 100); 02834 memset(output, 0x00, 100); 02835 02836 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 02837 unhexify( iv_str, "00000000000000000000000000000000" ); 02838 data_len = unhexify( src_str, "fffffffffffffffffffffff000000000" ); 02839 02840 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 02841 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 02842 if( 0 == 0 ) 02843 { 02844 hexify( dst_str, output, data_len ); 02845 02846 fct_chk( strcmp( (char *) dst_str, "56aff089878bf3352f8df172a3ae47d8" ) == 0 ); 02847 } 02848 } 02849 FCT_TEST_END(); 02850 02851 02852 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_1) 02853 { 02854 unsigned char key_str[100]; 02855 unsigned char iv_str[100]; 02856 unsigned char src_str[100]; 02857 unsigned char dst_str[100]; 02858 unsigned char output[100]; 02859 aes_context ctx; 02860 int key_len, data_len; 02861 02862 memset(key_str, 0x00, 100); 02863 memset(iv_str, 0x00, 100); 02864 memset(src_str, 0x00, 100); 02865 memset(dst_str, 0x00, 100); 02866 memset(output, 0x00, 100); 02867 02868 key_len = unhexify( key_str, "ffffffffe00000000000000000000000" ); 02869 unhexify( iv_str, "00000000000000000000000000000000" ); 02870 data_len = unhexify( src_str, "23f710842b9bb9c32f26648c786807ca" ); 02871 02872 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 02873 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 02874 if( 0 == 0) 02875 { 02876 hexify( dst_str, output, data_len ); 02877 02878 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 02879 } 02880 } 02881 FCT_TEST_END(); 02882 02883 02884 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_2) 02885 { 02886 unsigned char key_str[100]; 02887 unsigned char iv_str[100]; 02888 unsigned char src_str[100]; 02889 unsigned char dst_str[100]; 02890 unsigned char output[100]; 02891 aes_context ctx; 02892 int key_len, data_len; 02893 02894 memset(key_str, 0x00, 100); 02895 memset(iv_str, 0x00, 100); 02896 memset(src_str, 0x00, 100); 02897 memset(dst_str, 0x00, 100); 02898 memset(output, 0x00, 100); 02899 02900 key_len = unhexify( key_str, "fffffffff00000000000000000000000" ); 02901 unhexify( iv_str, "00000000000000000000000000000000" ); 02902 data_len = unhexify( src_str, "44a98bf11e163f632c47ec6a49683a89" ); 02903 02904 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 02905 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 02906 if( 0 == 0) 02907 { 02908 hexify( dst_str, output, data_len ); 02909 02910 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 02911 } 02912 } 02913 FCT_TEST_END(); 02914 02915 02916 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_3) 02917 { 02918 unsigned char key_str[100]; 02919 unsigned char iv_str[100]; 02920 unsigned char src_str[100]; 02921 unsigned char dst_str[100]; 02922 unsigned char output[100]; 02923 aes_context ctx; 02924 int key_len, data_len; 02925 02926 memset(key_str, 0x00, 100); 02927 memset(iv_str, 0x00, 100); 02928 memset(src_str, 0x00, 100); 02929 memset(dst_str, 0x00, 100); 02930 memset(output, 0x00, 100); 02931 02932 key_len = unhexify( key_str, "fffffffff80000000000000000000000" ); 02933 unhexify( iv_str, "00000000000000000000000000000000" ); 02934 data_len = unhexify( src_str, "0f18aff94274696d9b61848bd50ac5e5" ); 02935 02936 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 02937 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 02938 if( 0 == 0) 02939 { 02940 hexify( dst_str, output, data_len ); 02941 02942 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 02943 } 02944 } 02945 FCT_TEST_END(); 02946 02947 02948 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_4) 02949 { 02950 unsigned char key_str[100]; 02951 unsigned char iv_str[100]; 02952 unsigned char src_str[100]; 02953 unsigned char dst_str[100]; 02954 unsigned char output[100]; 02955 aes_context ctx; 02956 int key_len, data_len; 02957 02958 memset(key_str, 0x00, 100); 02959 memset(iv_str, 0x00, 100); 02960 memset(src_str, 0x00, 100); 02961 memset(dst_str, 0x00, 100); 02962 memset(output, 0x00, 100); 02963 02964 key_len = unhexify( key_str, "e234cdca2606b81f29408d5f6da21206" ); 02965 unhexify( iv_str, "00000000000000000000000000000000" ); 02966 data_len = unhexify( src_str, "fff60a4740086b3b9c56195b98d91a7b" ); 02967 02968 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 02969 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 02970 if( 0 == 0) 02971 { 02972 hexify( dst_str, output, data_len ); 02973 02974 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 02975 } 02976 } 02977 FCT_TEST_END(); 02978 02979 02980 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_5) 02981 { 02982 unsigned char key_str[100]; 02983 unsigned char iv_str[100]; 02984 unsigned char src_str[100]; 02985 unsigned char dst_str[100]; 02986 unsigned char output[100]; 02987 aes_context ctx; 02988 int key_len, data_len; 02989 02990 memset(key_str, 0x00, 100); 02991 memset(iv_str, 0x00, 100); 02992 memset(src_str, 0x00, 100); 02993 memset(dst_str, 0x00, 100); 02994 memset(output, 0x00, 100); 02995 02996 key_len = unhexify( key_str, "13237c49074a3da078dc1d828bb78c6f" ); 02997 unhexify( iv_str, "00000000000000000000000000000000" ); 02998 data_len = unhexify( src_str, "8146a08e2357f0caa30ca8c94d1a0544" ); 02999 03000 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03001 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03002 if( 0 == 0) 03003 { 03004 hexify( dst_str, output, data_len ); 03005 03006 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 03007 } 03008 } 03009 FCT_TEST_END(); 03010 03011 03012 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_6) 03013 { 03014 unsigned char key_str[100]; 03015 unsigned char iv_str[100]; 03016 unsigned char src_str[100]; 03017 unsigned char dst_str[100]; 03018 unsigned char output[100]; 03019 aes_context ctx; 03020 int key_len, data_len; 03021 03022 memset(key_str, 0x00, 100); 03023 memset(iv_str, 0x00, 100); 03024 memset(src_str, 0x00, 100); 03025 memset(dst_str, 0x00, 100); 03026 memset(output, 0x00, 100); 03027 03028 key_len = unhexify( key_str, "3071a2a48fe6cbd04f1a129098e308f8" ); 03029 unhexify( iv_str, "00000000000000000000000000000000" ); 03030 data_len = unhexify( src_str, "4b98e06d356deb07ebb824e5713f7be3" ); 03031 03032 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03033 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03034 if( 0 == 0) 03035 { 03036 hexify( dst_str, output, data_len ); 03037 03038 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 03039 } 03040 } 03041 FCT_TEST_END(); 03042 03043 03044 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_7) 03045 { 03046 unsigned char key_str[100]; 03047 unsigned char iv_str[100]; 03048 unsigned char src_str[100]; 03049 unsigned char dst_str[100]; 03050 unsigned char output[100]; 03051 aes_context ctx; 03052 int key_len, data_len; 03053 03054 memset(key_str, 0x00, 100); 03055 memset(iv_str, 0x00, 100); 03056 memset(src_str, 0x00, 100); 03057 memset(dst_str, 0x00, 100); 03058 memset(output, 0x00, 100); 03059 03060 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 03061 unhexify( iv_str, "00000000000000000000000000000000" ); 03062 data_len = unhexify( src_str, "0336763e966d92595a567cc9ce537f5e" ); 03063 03064 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03065 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03066 if( 0 == 0) 03067 { 03068 hexify( dst_str, output, data_len ); 03069 03070 fct_chk( strcmp( (char *) dst_str, "f34481ec3cc627bacd5dc3fb08f273e6" ) == 0 ); 03071 } 03072 } 03073 FCT_TEST_END(); 03074 03075 03076 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_8) 03077 { 03078 unsigned char key_str[100]; 03079 unsigned char iv_str[100]; 03080 unsigned char src_str[100]; 03081 unsigned char dst_str[100]; 03082 unsigned char output[100]; 03083 aes_context ctx; 03084 int key_len, data_len; 03085 03086 memset(key_str, 0x00, 100); 03087 memset(iv_str, 0x00, 100); 03088 memset(src_str, 0x00, 100); 03089 memset(dst_str, 0x00, 100); 03090 memset(output, 0x00, 100); 03091 03092 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 03093 unhexify( iv_str, "00000000000000000000000000000000" ); 03094 data_len = unhexify( src_str, "a9a1631bf4996954ebc093957b234589" ); 03095 03096 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03097 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03098 if( 0 == 0) 03099 { 03100 hexify( dst_str, output, data_len ); 03101 03102 fct_chk( strcmp( (char *) dst_str, "9798c4640bad75c7c3227db910174e72" ) == 0 ); 03103 } 03104 } 03105 FCT_TEST_END(); 03106 03107 03108 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_9) 03109 { 03110 unsigned char key_str[100]; 03111 unsigned char iv_str[100]; 03112 unsigned char src_str[100]; 03113 unsigned char dst_str[100]; 03114 unsigned char output[100]; 03115 aes_context ctx; 03116 int key_len, data_len; 03117 03118 memset(key_str, 0x00, 100); 03119 memset(iv_str, 0x00, 100); 03120 memset(src_str, 0x00, 100); 03121 memset(dst_str, 0x00, 100); 03122 memset(output, 0x00, 100); 03123 03124 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 03125 unhexify( iv_str, "00000000000000000000000000000000" ); 03126 data_len = unhexify( src_str, "ff4f8391a6a40ca5b25d23bedd44a597" ); 03127 03128 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03129 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03130 if( 0 == 0) 03131 { 03132 hexify( dst_str, output, data_len ); 03133 03134 fct_chk( strcmp( (char *) dst_str, "96ab5c2ff612d9dfaae8c31f30c42168" ) == 0 ); 03135 } 03136 } 03137 FCT_TEST_END(); 03138 03139 03140 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_10) 03141 { 03142 unsigned char key_str[100]; 03143 unsigned char iv_str[100]; 03144 unsigned char src_str[100]; 03145 unsigned char dst_str[100]; 03146 unsigned char output[100]; 03147 aes_context ctx; 03148 int key_len, data_len; 03149 03150 memset(key_str, 0x00, 100); 03151 memset(iv_str, 0x00, 100); 03152 memset(src_str, 0x00, 100); 03153 memset(dst_str, 0x00, 100); 03154 memset(output, 0x00, 100); 03155 03156 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 03157 unhexify( iv_str, "00000000000000000000000000000000" ); 03158 data_len = unhexify( src_str, "f9b0fda0c4a898f5b9e6f661c4ce4d07" ); 03159 03160 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03161 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03162 if( 0 == 0) 03163 { 03164 hexify( dst_str, output, data_len ); 03165 03166 fct_chk( strcmp( (char *) dst_str, "fffffffffffffffffffffffffffffff0" ) == 0 ); 03167 } 03168 } 03169 FCT_TEST_END(); 03170 03171 03172 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_11) 03173 { 03174 unsigned char key_str[100]; 03175 unsigned char iv_str[100]; 03176 unsigned char src_str[100]; 03177 unsigned char dst_str[100]; 03178 unsigned char output[100]; 03179 aes_context ctx; 03180 int key_len, data_len; 03181 03182 memset(key_str, 0x00, 100); 03183 memset(iv_str, 0x00, 100); 03184 memset(src_str, 0x00, 100); 03185 memset(dst_str, 0x00, 100); 03186 memset(output, 0x00, 100); 03187 03188 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 03189 unhexify( iv_str, "00000000000000000000000000000000" ); 03190 data_len = unhexify( src_str, "8ade895913685c67c5269f8aae42983e" ); 03191 03192 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03193 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03194 if( 0 == 0) 03195 { 03196 hexify( dst_str, output, data_len ); 03197 03198 fct_chk( strcmp( (char *) dst_str, "fffffffffffffffffffffffffffffff8" ) == 0 ); 03199 } 03200 } 03201 FCT_TEST_END(); 03202 03203 03204 FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_12) 03205 { 03206 unsigned char key_str[100]; 03207 unsigned char iv_str[100]; 03208 unsigned char src_str[100]; 03209 unsigned char dst_str[100]; 03210 unsigned char output[100]; 03211 aes_context ctx; 03212 int key_len, data_len; 03213 03214 memset(key_str, 0x00, 100); 03215 memset(iv_str, 0x00, 100); 03216 memset(src_str, 0x00, 100); 03217 memset(dst_str, 0x00, 100); 03218 memset(output, 0x00, 100); 03219 03220 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 03221 unhexify( iv_str, "00000000000000000000000000000000" ); 03222 data_len = unhexify( src_str, "39bde67d5c8ed8a8b1c37eb8fa9f5ac0" ); 03223 03224 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03225 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03226 if( 0 == 0) 03227 { 03228 hexify( dst_str, output, data_len ); 03229 03230 fct_chk( strcmp( (char *) dst_str, "fffffffffffffffffffffffffffffffc" ) == 0 ); 03231 } 03232 } 03233 FCT_TEST_END(); 03234 03235 03236 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_1) 03237 { 03238 unsigned char key_str[100]; 03239 unsigned char iv_str[100]; 03240 unsigned char src_str[100]; 03241 unsigned char dst_str[100]; 03242 unsigned char output[100]; 03243 aes_context ctx; 03244 int key_len, data_len; 03245 03246 memset(key_str, 0x00, 100); 03247 memset(iv_str, 0x00, 100); 03248 memset(src_str, 0x00, 100); 03249 memset(dst_str, 0x00, 100); 03250 memset(output, 0x00, 100); 03251 03252 key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffe00" ); 03253 unhexify( iv_str, "00000000000000000000000000000000" ); 03254 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 03255 03256 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03257 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03258 if( 0 == 0 ) 03259 { 03260 hexify( dst_str, output, data_len ); 03261 03262 fct_chk( strcmp( (char *) dst_str, "ddb505e6cc1384cbaec1df90b80beb20" ) == 0 ); 03263 } 03264 } 03265 FCT_TEST_END(); 03266 03267 03268 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_2) 03269 { 03270 unsigned char key_str[100]; 03271 unsigned char iv_str[100]; 03272 unsigned char src_str[100]; 03273 unsigned char dst_str[100]; 03274 unsigned char output[100]; 03275 aes_context ctx; 03276 int key_len, data_len; 03277 03278 memset(key_str, 0x00, 100); 03279 memset(iv_str, 0x00, 100); 03280 memset(src_str, 0x00, 100); 03281 memset(dst_str, 0x00, 100); 03282 memset(output, 0x00, 100); 03283 03284 key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffffffffffff00" ); 03285 unhexify( iv_str, "00000000000000000000000000000000" ); 03286 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 03287 03288 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03289 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03290 if( 0 == 0 ) 03291 { 03292 hexify( dst_str, output, data_len ); 03293 03294 fct_chk( strcmp( (char *) dst_str, "5674a3bed27bf4bd3622f9f5fe208306" ) == 0 ); 03295 } 03296 } 03297 FCT_TEST_END(); 03298 03299 03300 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_3) 03301 { 03302 unsigned char key_str[100]; 03303 unsigned char iv_str[100]; 03304 unsigned char src_str[100]; 03305 unsigned char dst_str[100]; 03306 unsigned char output[100]; 03307 aes_context ctx; 03308 int key_len, data_len; 03309 03310 memset(key_str, 0x00, 100); 03311 memset(iv_str, 0x00, 100); 03312 memset(src_str, 0x00, 100); 03313 memset(dst_str, 0x00, 100); 03314 memset(output, 0x00, 100); 03315 03316 key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffffffffffff80" ); 03317 unhexify( iv_str, "00000000000000000000000000000000" ); 03318 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 03319 03320 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03321 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03322 if( 0 == 0 ) 03323 { 03324 hexify( dst_str, output, data_len ); 03325 03326 fct_chk( strcmp( (char *) dst_str, "b687f26a89cfbfbb8e5eeac54055315e" ) == 0 ); 03327 } 03328 } 03329 FCT_TEST_END(); 03330 03331 03332 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_4) 03333 { 03334 unsigned char key_str[100]; 03335 unsigned char iv_str[100]; 03336 unsigned char src_str[100]; 03337 unsigned char dst_str[100]; 03338 unsigned char output[100]; 03339 aes_context ctx; 03340 int key_len, data_len; 03341 03342 memset(key_str, 0x00, 100); 03343 memset(iv_str, 0x00, 100); 03344 memset(src_str, 0x00, 100); 03345 memset(dst_str, 0x00, 100); 03346 memset(output, 0x00, 100); 03347 03348 key_len = unhexify( key_str, "25a39dbfd8034f71a81f9ceb55026e4037f8f6aa30ab44ce" ); 03349 unhexify( iv_str, "00000000000000000000000000000000" ); 03350 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 03351 03352 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03353 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03354 if( 0 == 0 ) 03355 { 03356 hexify( dst_str, output, data_len ); 03357 03358 fct_chk( strcmp( (char *) dst_str, "3608c344868e94555d23a120f8a5502d" ) == 0 ); 03359 } 03360 } 03361 FCT_TEST_END(); 03362 03363 03364 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_5) 03365 { 03366 unsigned char key_str[100]; 03367 unsigned char iv_str[100]; 03368 unsigned char src_str[100]; 03369 unsigned char dst_str[100]; 03370 unsigned char output[100]; 03371 aes_context ctx; 03372 int key_len, data_len; 03373 03374 memset(key_str, 0x00, 100); 03375 memset(iv_str, 0x00, 100); 03376 memset(src_str, 0x00, 100); 03377 memset(dst_str, 0x00, 100); 03378 memset(output, 0x00, 100); 03379 03380 key_len = unhexify( key_str, "e08c15411774ec4a908b64eadc6ac4199c7cd453f3aaef53" ); 03381 unhexify( iv_str, "00000000000000000000000000000000" ); 03382 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 03383 03384 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03385 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03386 if( 0 == 0 ) 03387 { 03388 hexify( dst_str, output, data_len ); 03389 03390 fct_chk( strcmp( (char *) dst_str, "77da2021935b840b7f5dcc39132da9e5" ) == 0 ); 03391 } 03392 } 03393 FCT_TEST_END(); 03394 03395 03396 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_6) 03397 { 03398 unsigned char key_str[100]; 03399 unsigned char iv_str[100]; 03400 unsigned char src_str[100]; 03401 unsigned char dst_str[100]; 03402 unsigned char output[100]; 03403 aes_context ctx; 03404 int key_len, data_len; 03405 03406 memset(key_str, 0x00, 100); 03407 memset(iv_str, 0x00, 100); 03408 memset(src_str, 0x00, 100); 03409 memset(dst_str, 0x00, 100); 03410 memset(output, 0x00, 100); 03411 03412 key_len = unhexify( key_str, "3b375a1ff7e8d44409696e6326ec9dec86138e2ae010b980" ); 03413 unhexify( iv_str, "00000000000000000000000000000000" ); 03414 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 03415 03416 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03417 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03418 if( 0 == 0 ) 03419 { 03420 hexify( dst_str, output, data_len ); 03421 03422 fct_chk( strcmp( (char *) dst_str, "3b7c24f825e3bf9873c9f14d39a0e6f4" ) == 0 ); 03423 } 03424 } 03425 FCT_TEST_END(); 03426 03427 03428 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_7) 03429 { 03430 unsigned char key_str[100]; 03431 unsigned char iv_str[100]; 03432 unsigned char src_str[100]; 03433 unsigned char dst_str[100]; 03434 unsigned char output[100]; 03435 aes_context ctx; 03436 int key_len, data_len; 03437 03438 memset(key_str, 0x00, 100); 03439 memset(iv_str, 0x00, 100); 03440 memset(src_str, 0x00, 100); 03441 memset(dst_str, 0x00, 100); 03442 memset(output, 0x00, 100); 03443 03444 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03445 unhexify( iv_str, "00000000000000000000000000000000" ); 03446 data_len = unhexify( src_str, "51719783d3185a535bd75adc65071ce1" ); 03447 03448 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03449 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03450 if( 0 == 0 ) 03451 { 03452 hexify( dst_str, output, data_len ); 03453 03454 fct_chk( strcmp( (char *) dst_str, "4f354592ff7c8847d2d0870ca9481b7c" ) == 0 ); 03455 } 03456 } 03457 FCT_TEST_END(); 03458 03459 03460 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_8) 03461 { 03462 unsigned char key_str[100]; 03463 unsigned char iv_str[100]; 03464 unsigned char src_str[100]; 03465 unsigned char dst_str[100]; 03466 unsigned char output[100]; 03467 aes_context ctx; 03468 int key_len, data_len; 03469 03470 memset(key_str, 0x00, 100); 03471 memset(iv_str, 0x00, 100); 03472 memset(src_str, 0x00, 100); 03473 memset(dst_str, 0x00, 100); 03474 memset(output, 0x00, 100); 03475 03476 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03477 unhexify( iv_str, "00000000000000000000000000000000" ); 03478 data_len = unhexify( src_str, "26aa49dcfe7629a8901a69a9914e6dfd" ); 03479 03480 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03481 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03482 if( 0 == 0 ) 03483 { 03484 hexify( dst_str, output, data_len ); 03485 03486 fct_chk( strcmp( (char *) dst_str, "d5e08bf9a182e857cf40b3a36ee248cc" ) == 0 ); 03487 } 03488 } 03489 FCT_TEST_END(); 03490 03491 03492 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_9) 03493 { 03494 unsigned char key_str[100]; 03495 unsigned char iv_str[100]; 03496 unsigned char src_str[100]; 03497 unsigned char dst_str[100]; 03498 unsigned char output[100]; 03499 aes_context ctx; 03500 int key_len, data_len; 03501 03502 memset(key_str, 0x00, 100); 03503 memset(iv_str, 0x00, 100); 03504 memset(src_str, 0x00, 100); 03505 memset(dst_str, 0x00, 100); 03506 memset(output, 0x00, 100); 03507 03508 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03509 unhexify( iv_str, "00000000000000000000000000000000" ); 03510 data_len = unhexify( src_str, "941a4773058224e1ef66d10e0a6ee782" ); 03511 03512 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03513 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03514 if( 0 == 0 ) 03515 { 03516 hexify( dst_str, output, data_len ); 03517 03518 fct_chk( strcmp( (char *) dst_str, "067cd9d3749207791841562507fa9626" ) == 0 ); 03519 } 03520 } 03521 FCT_TEST_END(); 03522 03523 03524 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_10) 03525 { 03526 unsigned char key_str[100]; 03527 unsigned char iv_str[100]; 03528 unsigned char src_str[100]; 03529 unsigned char dst_str[100]; 03530 unsigned char output[100]; 03531 aes_context ctx; 03532 int key_len, data_len; 03533 03534 memset(key_str, 0x00, 100); 03535 memset(iv_str, 0x00, 100); 03536 memset(src_str, 0x00, 100); 03537 memset(dst_str, 0x00, 100); 03538 memset(output, 0x00, 100); 03539 03540 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03541 unhexify( iv_str, "00000000000000000000000000000000" ); 03542 data_len = unhexify( src_str, "ffc00000000000000000000000000000" ); 03543 03544 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03545 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03546 if( 0 == 0 ) 03547 { 03548 hexify( dst_str, output, data_len ); 03549 03550 fct_chk( strcmp( (char *) dst_str, "030d7e5b64f380a7e4ea5387b5cd7f49" ) == 0 ); 03551 } 03552 } 03553 FCT_TEST_END(); 03554 03555 03556 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_11) 03557 { 03558 unsigned char key_str[100]; 03559 unsigned char iv_str[100]; 03560 unsigned char src_str[100]; 03561 unsigned char dst_str[100]; 03562 unsigned char output[100]; 03563 aes_context ctx; 03564 int key_len, data_len; 03565 03566 memset(key_str, 0x00, 100); 03567 memset(iv_str, 0x00, 100); 03568 memset(src_str, 0x00, 100); 03569 memset(dst_str, 0x00, 100); 03570 memset(output, 0x00, 100); 03571 03572 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03573 unhexify( iv_str, "00000000000000000000000000000000" ); 03574 data_len = unhexify( src_str, "ffe00000000000000000000000000000" ); 03575 03576 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03577 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03578 if( 0 == 0 ) 03579 { 03580 hexify( dst_str, output, data_len ); 03581 03582 fct_chk( strcmp( (char *) dst_str, "0dc9a2610037009b698f11bb7e86c83e" ) == 0 ); 03583 } 03584 } 03585 FCT_TEST_END(); 03586 03587 03588 FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_12) 03589 { 03590 unsigned char key_str[100]; 03591 unsigned char iv_str[100]; 03592 unsigned char src_str[100]; 03593 unsigned char dst_str[100]; 03594 unsigned char output[100]; 03595 aes_context ctx; 03596 int key_len, data_len; 03597 03598 memset(key_str, 0x00, 100); 03599 memset(iv_str, 0x00, 100); 03600 memset(src_str, 0x00, 100); 03601 memset(dst_str, 0x00, 100); 03602 memset(output, 0x00, 100); 03603 03604 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03605 unhexify( iv_str, "00000000000000000000000000000000" ); 03606 data_len = unhexify( src_str, "fff00000000000000000000000000000" ); 03607 03608 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 03609 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 03610 if( 0 == 0 ) 03611 { 03612 hexify( dst_str, output, data_len ); 03613 03614 fct_chk( strcmp( (char *) dst_str, "0046612c766d1840c226364f1fa7ed72" ) == 0 ); 03615 } 03616 } 03617 FCT_TEST_END(); 03618 03619 03620 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_1) 03621 { 03622 unsigned char key_str[100]; 03623 unsigned char iv_str[100]; 03624 unsigned char src_str[100]; 03625 unsigned char dst_str[100]; 03626 unsigned char output[100]; 03627 aes_context ctx; 03628 int key_len, data_len; 03629 03630 memset(key_str, 0x00, 100); 03631 memset(iv_str, 0x00, 100); 03632 memset(src_str, 0x00, 100); 03633 memset(dst_str, 0x00, 100); 03634 memset(output, 0x00, 100); 03635 03636 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03637 unhexify( iv_str, "00000000000000000000000000000000" ); 03638 data_len = unhexify( src_str, "902d88d13eae52089abd6143cfe394e9" ); 03639 03640 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03641 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03642 if( 0 == 0) 03643 { 03644 hexify( dst_str, output, data_len ); 03645 03646 fct_chk( strcmp( (char *) dst_str, "ffffffffe00000000000000000000000" ) == 0 ); 03647 } 03648 } 03649 FCT_TEST_END(); 03650 03651 03652 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_2) 03653 { 03654 unsigned char key_str[100]; 03655 unsigned char iv_str[100]; 03656 unsigned char src_str[100]; 03657 unsigned char dst_str[100]; 03658 unsigned char output[100]; 03659 aes_context ctx; 03660 int key_len, data_len; 03661 03662 memset(key_str, 0x00, 100); 03663 memset(iv_str, 0x00, 100); 03664 memset(src_str, 0x00, 100); 03665 memset(dst_str, 0x00, 100); 03666 memset(output, 0x00, 100); 03667 03668 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03669 unhexify( iv_str, "00000000000000000000000000000000" ); 03670 data_len = unhexify( src_str, "d49bceb3b823fedd602c305345734bd2" ); 03671 03672 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03673 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03674 if( 0 == 0) 03675 { 03676 hexify( dst_str, output, data_len ); 03677 03678 fct_chk( strcmp( (char *) dst_str, "fffffffff00000000000000000000000" ) == 0 ); 03679 } 03680 } 03681 FCT_TEST_END(); 03682 03683 03684 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_3) 03685 { 03686 unsigned char key_str[100]; 03687 unsigned char iv_str[100]; 03688 unsigned char src_str[100]; 03689 unsigned char dst_str[100]; 03690 unsigned char output[100]; 03691 aes_context ctx; 03692 int key_len, data_len; 03693 03694 memset(key_str, 0x00, 100); 03695 memset(iv_str, 0x00, 100); 03696 memset(src_str, 0x00, 100); 03697 memset(dst_str, 0x00, 100); 03698 memset(output, 0x00, 100); 03699 03700 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03701 unhexify( iv_str, "00000000000000000000000000000000" ); 03702 data_len = unhexify( src_str, "707b1dbb0ffa40ef7d95def421233fae" ); 03703 03704 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03705 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03706 if( 0 == 0) 03707 { 03708 hexify( dst_str, output, data_len ); 03709 03710 fct_chk( strcmp( (char *) dst_str, "fffffffff80000000000000000000000" ) == 0 ); 03711 } 03712 } 03713 FCT_TEST_END(); 03714 03715 03716 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_4) 03717 { 03718 unsigned char key_str[100]; 03719 unsigned char iv_str[100]; 03720 unsigned char src_str[100]; 03721 unsigned char dst_str[100]; 03722 unsigned char output[100]; 03723 aes_context ctx; 03724 int key_len, data_len; 03725 03726 memset(key_str, 0x00, 100); 03727 memset(iv_str, 0x00, 100); 03728 memset(src_str, 0x00, 100); 03729 memset(dst_str, 0x00, 100); 03730 memset(output, 0x00, 100); 03731 03732 key_len = unhexify( key_str, "fffffffffffffffffffc0000000000000000000000000000" ); 03733 unhexify( iv_str, "00000000000000000000000000000000" ); 03734 data_len = unhexify( src_str, "8dfd999be5d0cfa35732c0ddc88ff5a5" ); 03735 03736 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03737 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03738 if( 0 == 0) 03739 { 03740 hexify( dst_str, output, data_len ); 03741 03742 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 03743 } 03744 } 03745 FCT_TEST_END(); 03746 03747 03748 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_5) 03749 { 03750 unsigned char key_str[100]; 03751 unsigned char iv_str[100]; 03752 unsigned char src_str[100]; 03753 unsigned char dst_str[100]; 03754 unsigned char output[100]; 03755 aes_context ctx; 03756 int key_len, data_len; 03757 03758 memset(key_str, 0x00, 100); 03759 memset(iv_str, 0x00, 100); 03760 memset(src_str, 0x00, 100); 03761 memset(dst_str, 0x00, 100); 03762 memset(output, 0x00, 100); 03763 03764 key_len = unhexify( key_str, "fffffffffffffffffffe0000000000000000000000000000" ); 03765 unhexify( iv_str, "00000000000000000000000000000000" ); 03766 data_len = unhexify( src_str, "02647c76a300c3173b841487eb2bae9f" ); 03767 03768 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03769 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03770 if( 0 == 0) 03771 { 03772 hexify( dst_str, output, data_len ); 03773 03774 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 03775 } 03776 } 03777 FCT_TEST_END(); 03778 03779 03780 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_6) 03781 { 03782 unsigned char key_str[100]; 03783 unsigned char iv_str[100]; 03784 unsigned char src_str[100]; 03785 unsigned char dst_str[100]; 03786 unsigned char output[100]; 03787 aes_context ctx; 03788 int key_len, data_len; 03789 03790 memset(key_str, 0x00, 100); 03791 memset(iv_str, 0x00, 100); 03792 memset(src_str, 0x00, 100); 03793 memset(dst_str, 0x00, 100); 03794 memset(output, 0x00, 100); 03795 03796 key_len = unhexify( key_str, "ffffffffffffffffffff0000000000000000000000000000" ); 03797 unhexify( iv_str, "00000000000000000000000000000000" ); 03798 data_len = unhexify( src_str, "172df8b02f04b53adab028b4e01acd87" ); 03799 03800 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03801 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03802 if( 0 == 0) 03803 { 03804 hexify( dst_str, output, data_len ); 03805 03806 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 03807 } 03808 } 03809 FCT_TEST_END(); 03810 03811 03812 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_7) 03813 { 03814 unsigned char key_str[100]; 03815 unsigned char iv_str[100]; 03816 unsigned char src_str[100]; 03817 unsigned char dst_str[100]; 03818 unsigned char output[100]; 03819 aes_context ctx; 03820 int key_len, data_len; 03821 03822 memset(key_str, 0x00, 100); 03823 memset(iv_str, 0x00, 100); 03824 memset(src_str, 0x00, 100); 03825 memset(dst_str, 0x00, 100); 03826 memset(output, 0x00, 100); 03827 03828 key_len = unhexify( key_str, "b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35" ); 03829 unhexify( iv_str, "00000000000000000000000000000000" ); 03830 data_len = unhexify( src_str, "3cf5e1d21a17956d1dffad6a7c41c659" ); 03831 03832 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03833 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03834 if( 0 == 0) 03835 { 03836 hexify( dst_str, output, data_len ); 03837 03838 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 03839 } 03840 } 03841 FCT_TEST_END(); 03842 03843 03844 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_8) 03845 { 03846 unsigned char key_str[100]; 03847 unsigned char iv_str[100]; 03848 unsigned char src_str[100]; 03849 unsigned char dst_str[100]; 03850 unsigned char output[100]; 03851 aes_context ctx; 03852 int key_len, data_len; 03853 03854 memset(key_str, 0x00, 100); 03855 memset(iv_str, 0x00, 100); 03856 memset(src_str, 0x00, 100); 03857 memset(dst_str, 0x00, 100); 03858 memset(output, 0x00, 100); 03859 03860 key_len = unhexify( key_str, "45899367c3132849763073c435a9288a766c8b9ec2308516" ); 03861 unhexify( iv_str, "00000000000000000000000000000000" ); 03862 data_len = unhexify( src_str, "69fd12e8505f8ded2fdcb197a121b362" ); 03863 03864 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03865 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03866 if( 0 == 0) 03867 { 03868 hexify( dst_str, output, data_len ); 03869 03870 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 03871 } 03872 } 03873 FCT_TEST_END(); 03874 03875 03876 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_9) 03877 { 03878 unsigned char key_str[100]; 03879 unsigned char iv_str[100]; 03880 unsigned char src_str[100]; 03881 unsigned char dst_str[100]; 03882 unsigned char output[100]; 03883 aes_context ctx; 03884 int key_len, data_len; 03885 03886 memset(key_str, 0x00, 100); 03887 memset(iv_str, 0x00, 100); 03888 memset(src_str, 0x00, 100); 03889 memset(dst_str, 0x00, 100); 03890 memset(output, 0x00, 100); 03891 03892 key_len = unhexify( key_str, "ec250e04c3903f602647b85a401a1ae7ca2f02f67fa4253e" ); 03893 unhexify( iv_str, "00000000000000000000000000000000" ); 03894 data_len = unhexify( src_str, "8aa584e2cc4d17417a97cb9a28ba29c8" ); 03895 03896 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03897 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03898 if( 0 == 0) 03899 { 03900 hexify( dst_str, output, data_len ); 03901 03902 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 03903 } 03904 } 03905 FCT_TEST_END(); 03906 03907 03908 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_10) 03909 { 03910 unsigned char key_str[100]; 03911 unsigned char iv_str[100]; 03912 unsigned char src_str[100]; 03913 unsigned char dst_str[100]; 03914 unsigned char output[100]; 03915 aes_context ctx; 03916 int key_len, data_len; 03917 03918 memset(key_str, 0x00, 100); 03919 memset(iv_str, 0x00, 100); 03920 memset(src_str, 0x00, 100); 03921 memset(dst_str, 0x00, 100); 03922 memset(output, 0x00, 100); 03923 03924 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03925 unhexify( iv_str, "00000000000000000000000000000000" ); 03926 data_len = unhexify( src_str, "c9b8135ff1b5adc413dfd053b21bd96d" ); 03927 03928 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03929 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03930 if( 0 == 0) 03931 { 03932 hexify( dst_str, output, data_len ); 03933 03934 fct_chk( strcmp( (char *) dst_str, "9c2d8842e5f48f57648205d39a239af1" ) == 0 ); 03935 } 03936 } 03937 FCT_TEST_END(); 03938 03939 03940 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_11) 03941 { 03942 unsigned char key_str[100]; 03943 unsigned char iv_str[100]; 03944 unsigned char src_str[100]; 03945 unsigned char dst_str[100]; 03946 unsigned char output[100]; 03947 aes_context ctx; 03948 int key_len, data_len; 03949 03950 memset(key_str, 0x00, 100); 03951 memset(iv_str, 0x00, 100); 03952 memset(src_str, 0x00, 100); 03953 memset(dst_str, 0x00, 100); 03954 memset(output, 0x00, 100); 03955 03956 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03957 unhexify( iv_str, "00000000000000000000000000000000" ); 03958 data_len = unhexify( src_str, "4a3650c3371ce2eb35e389a171427440" ); 03959 03960 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03961 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03962 if( 0 == 0) 03963 { 03964 hexify( dst_str, output, data_len ); 03965 03966 fct_chk( strcmp( (char *) dst_str, "bff52510095f518ecca60af4205444bb" ) == 0 ); 03967 } 03968 } 03969 FCT_TEST_END(); 03970 03971 03972 FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_12) 03973 { 03974 unsigned char key_str[100]; 03975 unsigned char iv_str[100]; 03976 unsigned char src_str[100]; 03977 unsigned char dst_str[100]; 03978 unsigned char output[100]; 03979 aes_context ctx; 03980 int key_len, data_len; 03981 03982 memset(key_str, 0x00, 100); 03983 memset(iv_str, 0x00, 100); 03984 memset(src_str, 0x00, 100); 03985 memset(dst_str, 0x00, 100); 03986 memset(output, 0x00, 100); 03987 03988 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 03989 unhexify( iv_str, "00000000000000000000000000000000" ); 03990 data_len = unhexify( src_str, "4f354592ff7c8847d2d0870ca9481b7c" ); 03991 03992 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 03993 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 03994 if( 0 == 0) 03995 { 03996 hexify( dst_str, output, data_len ); 03997 03998 fct_chk( strcmp( (char *) dst_str, "51719783d3185a535bd75adc65071ce1" ) == 0 ); 03999 } 04000 } 04001 FCT_TEST_END(); 04002 04003 04004 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_1) 04005 { 04006 unsigned char key_str[100]; 04007 unsigned char iv_str[100]; 04008 unsigned char src_str[100]; 04009 unsigned char dst_str[100]; 04010 unsigned char output[100]; 04011 aes_context ctx; 04012 int key_len, data_len; 04013 04014 memset(key_str, 0x00, 100); 04015 memset(iv_str, 0x00, 100); 04016 memset(src_str, 0x00, 100); 04017 memset(dst_str, 0x00, 100); 04018 memset(output, 0x00, 100); 04019 04020 key_len = unhexify( key_str, "8000000000000000000000000000000000000000000000000000000000000000" ); 04021 unhexify( iv_str, "00000000000000000000000000000000" ); 04022 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 04023 04024 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04025 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04026 if( 0 == 0 ) 04027 { 04028 hexify( dst_str, output, data_len ); 04029 04030 fct_chk( strcmp( (char *) dst_str, "e35a6dcb19b201a01ebcfa8aa22b5759" ) == 0 ); 04031 } 04032 } 04033 FCT_TEST_END(); 04034 04035 04036 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_2) 04037 { 04038 unsigned char key_str[100]; 04039 unsigned char iv_str[100]; 04040 unsigned char src_str[100]; 04041 unsigned char dst_str[100]; 04042 unsigned char output[100]; 04043 aes_context ctx; 04044 int key_len, data_len; 04045 04046 memset(key_str, 0x00, 100); 04047 memset(iv_str, 0x00, 100); 04048 memset(src_str, 0x00, 100); 04049 memset(dst_str, 0x00, 100); 04050 memset(output, 0x00, 100); 04051 04052 key_len = unhexify( key_str, "c000000000000000000000000000000000000000000000000000000000000000" ); 04053 unhexify( iv_str, "00000000000000000000000000000000" ); 04054 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 04055 04056 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04057 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04058 if( 0 == 0 ) 04059 { 04060 hexify( dst_str, output, data_len ); 04061 04062 fct_chk( strcmp( (char *) dst_str, "b29169cdcf2d83e838125a12ee6aa400" ) == 0 ); 04063 } 04064 } 04065 FCT_TEST_END(); 04066 04067 04068 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_3) 04069 { 04070 unsigned char key_str[100]; 04071 unsigned char iv_str[100]; 04072 unsigned char src_str[100]; 04073 unsigned char dst_str[100]; 04074 unsigned char output[100]; 04075 aes_context ctx; 04076 int key_len, data_len; 04077 04078 memset(key_str, 0x00, 100); 04079 memset(iv_str, 0x00, 100); 04080 memset(src_str, 0x00, 100); 04081 memset(dst_str, 0x00, 100); 04082 memset(output, 0x00, 100); 04083 04084 key_len = unhexify( key_str, "e000000000000000000000000000000000000000000000000000000000000000" ); 04085 unhexify( iv_str, "00000000000000000000000000000000" ); 04086 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 04087 04088 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04089 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04090 if( 0 == 0 ) 04091 { 04092 hexify( dst_str, output, data_len ); 04093 04094 fct_chk( strcmp( (char *) dst_str, "d8f3a72fc3cdf74dfaf6c3e6b97b2fa6" ) == 0 ); 04095 } 04096 } 04097 FCT_TEST_END(); 04098 04099 04100 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_4) 04101 { 04102 unsigned char key_str[100]; 04103 unsigned char iv_str[100]; 04104 unsigned char src_str[100]; 04105 unsigned char dst_str[100]; 04106 unsigned char output[100]; 04107 aes_context ctx; 04108 int key_len, data_len; 04109 04110 memset(key_str, 0x00, 100); 04111 memset(iv_str, 0x00, 100); 04112 memset(src_str, 0x00, 100); 04113 memset(dst_str, 0x00, 100); 04114 memset(output, 0x00, 100); 04115 04116 key_len = unhexify( key_str, "dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf" ); 04117 unhexify( iv_str, "00000000000000000000000000000000" ); 04118 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 04119 04120 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04121 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04122 if( 0 == 0 ) 04123 { 04124 hexify( dst_str, output, data_len ); 04125 04126 fct_chk( strcmp( (char *) dst_str, "fc6aec906323480005c58e7e1ab004ad" ) == 0 ); 04127 } 04128 } 04129 FCT_TEST_END(); 04130 04131 04132 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_5) 04133 { 04134 unsigned char key_str[100]; 04135 unsigned char iv_str[100]; 04136 unsigned char src_str[100]; 04137 unsigned char dst_str[100]; 04138 unsigned char output[100]; 04139 aes_context ctx; 04140 int key_len, data_len; 04141 04142 memset(key_str, 0x00, 100); 04143 memset(iv_str, 0x00, 100); 04144 memset(src_str, 0x00, 100); 04145 memset(dst_str, 0x00, 100); 04146 memset(output, 0x00, 100); 04147 04148 key_len = unhexify( key_str, "f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9" ); 04149 unhexify( iv_str, "00000000000000000000000000000000" ); 04150 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 04151 04152 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04153 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04154 if( 0 == 0 ) 04155 { 04156 hexify( dst_str, output, data_len ); 04157 04158 fct_chk( strcmp( (char *) dst_str, "a3944b95ca0b52043584ef02151926a8" ) == 0 ); 04159 } 04160 } 04161 FCT_TEST_END(); 04162 04163 04164 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_6) 04165 { 04166 unsigned char key_str[100]; 04167 unsigned char iv_str[100]; 04168 unsigned char src_str[100]; 04169 unsigned char dst_str[100]; 04170 unsigned char output[100]; 04171 aes_context ctx; 04172 int key_len, data_len; 04173 04174 memset(key_str, 0x00, 100); 04175 memset(iv_str, 0x00, 100); 04176 memset(src_str, 0x00, 100); 04177 memset(dst_str, 0x00, 100); 04178 memset(output, 0x00, 100); 04179 04180 key_len = unhexify( key_str, "797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e" ); 04181 unhexify( iv_str, "00000000000000000000000000000000" ); 04182 data_len = unhexify( src_str, "00000000000000000000000000000000" ); 04183 04184 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04185 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04186 if( 0 == 0 ) 04187 { 04188 hexify( dst_str, output, data_len ); 04189 04190 fct_chk( strcmp( (char *) dst_str, "a74289fe73a4c123ca189ea1e1b49ad5" ) == 0 ); 04191 } 04192 } 04193 FCT_TEST_END(); 04194 04195 04196 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_7) 04197 { 04198 unsigned char key_str[100]; 04199 unsigned char iv_str[100]; 04200 unsigned char src_str[100]; 04201 unsigned char dst_str[100]; 04202 unsigned char output[100]; 04203 aes_context ctx; 04204 int key_len, data_len; 04205 04206 memset(key_str, 0x00, 100); 04207 memset(iv_str, 0x00, 100); 04208 memset(src_str, 0x00, 100); 04209 memset(dst_str, 0x00, 100); 04210 memset(output, 0x00, 100); 04211 04212 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04213 unhexify( iv_str, "00000000000000000000000000000000" ); 04214 data_len = unhexify( src_str, "761c1fe41a18acf20d241650611d90f1" ); 04215 04216 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04217 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04218 if( 0 == 0 ) 04219 { 04220 hexify( dst_str, output, data_len ); 04221 04222 fct_chk( strcmp( (char *) dst_str, "623a52fcea5d443e48d9181ab32c7421" ) == 0 ); 04223 } 04224 } 04225 FCT_TEST_END(); 04226 04227 04228 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_8) 04229 { 04230 unsigned char key_str[100]; 04231 unsigned char iv_str[100]; 04232 unsigned char src_str[100]; 04233 unsigned char dst_str[100]; 04234 unsigned char output[100]; 04235 aes_context ctx; 04236 int key_len, data_len; 04237 04238 memset(key_str, 0x00, 100); 04239 memset(iv_str, 0x00, 100); 04240 memset(src_str, 0x00, 100); 04241 memset(dst_str, 0x00, 100); 04242 memset(output, 0x00, 100); 04243 04244 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04245 unhexify( iv_str, "00000000000000000000000000000000" ); 04246 data_len = unhexify( src_str, "8a560769d605868ad80d819bdba03771" ); 04247 04248 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04249 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04250 if( 0 == 0 ) 04251 { 04252 hexify( dst_str, output, data_len ); 04253 04254 fct_chk( strcmp( (char *) dst_str, "38f2c7ae10612415d27ca190d27da8b4" ) == 0 ); 04255 } 04256 } 04257 FCT_TEST_END(); 04258 04259 04260 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_9) 04261 { 04262 unsigned char key_str[100]; 04263 unsigned char iv_str[100]; 04264 unsigned char src_str[100]; 04265 unsigned char dst_str[100]; 04266 unsigned char output[100]; 04267 aes_context ctx; 04268 int key_len, data_len; 04269 04270 memset(key_str, 0x00, 100); 04271 memset(iv_str, 0x00, 100); 04272 memset(src_str, 0x00, 100); 04273 memset(dst_str, 0x00, 100); 04274 memset(output, 0x00, 100); 04275 04276 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04277 unhexify( iv_str, "00000000000000000000000000000000" ); 04278 data_len = unhexify( src_str, "91fbef2d15a97816060bee1feaa49afe" ); 04279 04280 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04281 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04282 if( 0 == 0 ) 04283 { 04284 hexify( dst_str, output, data_len ); 04285 04286 fct_chk( strcmp( (char *) dst_str, "1bc704f1bce135ceb810341b216d7abe" ) == 0 ); 04287 } 04288 } 04289 FCT_TEST_END(); 04290 04291 04292 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_10) 04293 { 04294 unsigned char key_str[100]; 04295 unsigned char iv_str[100]; 04296 unsigned char src_str[100]; 04297 unsigned char dst_str[100]; 04298 unsigned char output[100]; 04299 aes_context ctx; 04300 int key_len, data_len; 04301 04302 memset(key_str, 0x00, 100); 04303 memset(iv_str, 0x00, 100); 04304 memset(src_str, 0x00, 100); 04305 memset(dst_str, 0x00, 100); 04306 memset(output, 0x00, 100); 04307 04308 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04309 unhexify( iv_str, "00000000000000000000000000000000" ); 04310 data_len = unhexify( src_str, "ffffffffffffff800000000000000000" ); 04311 04312 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04313 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04314 if( 0 == 0 ) 04315 { 04316 hexify( dst_str, output, data_len ); 04317 04318 fct_chk( strcmp( (char *) dst_str, "0d9ac756eb297695eed4d382eb126d26" ) == 0 ); 04319 } 04320 } 04321 FCT_TEST_END(); 04322 04323 04324 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_11) 04325 { 04326 unsigned char key_str[100]; 04327 unsigned char iv_str[100]; 04328 unsigned char src_str[100]; 04329 unsigned char dst_str[100]; 04330 unsigned char output[100]; 04331 aes_context ctx; 04332 int key_len, data_len; 04333 04334 memset(key_str, 0x00, 100); 04335 memset(iv_str, 0x00, 100); 04336 memset(src_str, 0x00, 100); 04337 memset(dst_str, 0x00, 100); 04338 memset(output, 0x00, 100); 04339 04340 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04341 unhexify( iv_str, "00000000000000000000000000000000" ); 04342 data_len = unhexify( src_str, "ffffffffffffffc00000000000000000" ); 04343 04344 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04345 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04346 if( 0 == 0 ) 04347 { 04348 hexify( dst_str, output, data_len ); 04349 04350 fct_chk( strcmp( (char *) dst_str, "56ede9dda3f6f141bff1757fa689c3e1" ) == 0 ); 04351 } 04352 } 04353 FCT_TEST_END(); 04354 04355 04356 FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_12) 04357 { 04358 unsigned char key_str[100]; 04359 unsigned char iv_str[100]; 04360 unsigned char src_str[100]; 04361 unsigned char dst_str[100]; 04362 unsigned char output[100]; 04363 aes_context ctx; 04364 int key_len, data_len; 04365 04366 memset(key_str, 0x00, 100); 04367 memset(iv_str, 0x00, 100); 04368 memset(src_str, 0x00, 100); 04369 memset(dst_str, 0x00, 100); 04370 memset(output, 0x00, 100); 04371 04372 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04373 unhexify( iv_str, "00000000000000000000000000000000" ); 04374 data_len = unhexify( src_str, "ffffffffffffffe00000000000000000" ); 04375 04376 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04377 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 ); 04378 if( 0 == 0 ) 04379 { 04380 hexify( dst_str, output, data_len ); 04381 04382 fct_chk( strcmp( (char *) dst_str, "768f520efe0f23e61d3ec8ad9ce91774" ) == 0 ); 04383 } 04384 } 04385 FCT_TEST_END(); 04386 04387 04388 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_1) 04389 { 04390 unsigned char key_str[100]; 04391 unsigned char iv_str[100]; 04392 unsigned char src_str[100]; 04393 unsigned char dst_str[100]; 04394 unsigned char output[100]; 04395 aes_context ctx; 04396 int key_len, data_len; 04397 04398 memset(key_str, 0x00, 100); 04399 memset(iv_str, 0x00, 100); 04400 memset(src_str, 0x00, 100); 04401 memset(dst_str, 0x00, 100); 04402 memset(output, 0x00, 100); 04403 04404 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04405 unhexify( iv_str, "00000000000000000000000000000000" ); 04406 data_len = unhexify( src_str, "49af6b372135acef10132e548f217b17" ); 04407 04408 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04409 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04410 if( 0 == 0) 04411 { 04412 hexify( dst_str, output, data_len ); 04413 04414 fct_chk( strcmp( (char *) dst_str, "ff000000000000000000000000000000" ) == 0 ); 04415 } 04416 } 04417 FCT_TEST_END(); 04418 04419 04420 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_2) 04421 { 04422 unsigned char key_str[100]; 04423 unsigned char iv_str[100]; 04424 unsigned char src_str[100]; 04425 unsigned char dst_str[100]; 04426 unsigned char output[100]; 04427 aes_context ctx; 04428 int key_len, data_len; 04429 04430 memset(key_str, 0x00, 100); 04431 memset(iv_str, 0x00, 100); 04432 memset(src_str, 0x00, 100); 04433 memset(dst_str, 0x00, 100); 04434 memset(output, 0x00, 100); 04435 04436 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04437 unhexify( iv_str, "00000000000000000000000000000000" ); 04438 data_len = unhexify( src_str, "8bcd40f94ebb63b9f7909676e667f1e7" ); 04439 04440 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04441 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04442 if( 0 == 0) 04443 { 04444 hexify( dst_str, output, data_len ); 04445 04446 fct_chk( strcmp( (char *) dst_str, "ff800000000000000000000000000000" ) == 0 ); 04447 } 04448 } 04449 FCT_TEST_END(); 04450 04451 04452 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_3) 04453 { 04454 unsigned char key_str[100]; 04455 unsigned char iv_str[100]; 04456 unsigned char src_str[100]; 04457 unsigned char dst_str[100]; 04458 unsigned char output[100]; 04459 aes_context ctx; 04460 int key_len, data_len; 04461 04462 memset(key_str, 0x00, 100); 04463 memset(iv_str, 0x00, 100); 04464 memset(src_str, 0x00, 100); 04465 memset(dst_str, 0x00, 100); 04466 memset(output, 0x00, 100); 04467 04468 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04469 unhexify( iv_str, "00000000000000000000000000000000" ); 04470 data_len = unhexify( src_str, "fe1cffb83f45dcfb38b29be438dbd3ab" ); 04471 04472 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04473 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04474 if( 0 == 0) 04475 { 04476 hexify( dst_str, output, data_len ); 04477 04478 fct_chk( strcmp( (char *) dst_str, "ffc00000000000000000000000000000" ) == 0 ); 04479 } 04480 } 04481 FCT_TEST_END(); 04482 04483 04484 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_4) 04485 { 04486 unsigned char key_str[100]; 04487 unsigned char iv_str[100]; 04488 unsigned char src_str[100]; 04489 unsigned char dst_str[100]; 04490 unsigned char output[100]; 04491 aes_context ctx; 04492 int key_len, data_len; 04493 04494 memset(key_str, 0x00, 100); 04495 memset(iv_str, 0x00, 100); 04496 memset(src_str, 0x00, 100); 04497 memset(dst_str, 0x00, 100); 04498 memset(output, 0x00, 100); 04499 04500 key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00" ); 04501 unhexify( iv_str, "00000000000000000000000000000000" ); 04502 data_len = unhexify( src_str, "cca7c3086f5f9511b31233da7cab9160" ); 04503 04504 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04505 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04506 if( 0 == 0) 04507 { 04508 hexify( dst_str, output, data_len ); 04509 04510 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 04511 } 04512 } 04513 FCT_TEST_END(); 04514 04515 04516 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_5) 04517 { 04518 unsigned char key_str[100]; 04519 unsigned char iv_str[100]; 04520 unsigned char src_str[100]; 04521 unsigned char dst_str[100]; 04522 unsigned char output[100]; 04523 aes_context ctx; 04524 int key_len, data_len; 04525 04526 memset(key_str, 0x00, 100); 04527 memset(iv_str, 0x00, 100); 04528 memset(src_str, 0x00, 100); 04529 memset(dst_str, 0x00, 100); 04530 memset(output, 0x00, 100); 04531 04532 key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00" ); 04533 unhexify( iv_str, "00000000000000000000000000000000" ); 04534 data_len = unhexify( src_str, "5b40ff4ec9be536ba23035fa4f06064c" ); 04535 04536 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04537 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04538 if( 0 == 0) 04539 { 04540 hexify( dst_str, output, data_len ); 04541 04542 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 04543 } 04544 } 04545 FCT_TEST_END(); 04546 04547 04548 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_6) 04549 { 04550 unsigned char key_str[100]; 04551 unsigned char iv_str[100]; 04552 unsigned char src_str[100]; 04553 unsigned char dst_str[100]; 04554 unsigned char output[100]; 04555 aes_context ctx; 04556 int key_len, data_len; 04557 04558 memset(key_str, 0x00, 100); 04559 memset(iv_str, 0x00, 100); 04560 memset(src_str, 0x00, 100); 04561 memset(dst_str, 0x00, 100); 04562 memset(output, 0x00, 100); 04563 04564 key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00" ); 04565 unhexify( iv_str, "00000000000000000000000000000000" ); 04566 data_len = unhexify( src_str, "60eb5af8416b257149372194e8b88749" ); 04567 04568 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04569 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04570 if( 0 == 0) 04571 { 04572 hexify( dst_str, output, data_len ); 04573 04574 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 04575 } 04576 } 04577 FCT_TEST_END(); 04578 04579 04580 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_7) 04581 { 04582 unsigned char key_str[100]; 04583 unsigned char iv_str[100]; 04584 unsigned char src_str[100]; 04585 unsigned char dst_str[100]; 04586 unsigned char output[100]; 04587 aes_context ctx; 04588 int key_len, data_len; 04589 04590 memset(key_str, 0x00, 100); 04591 memset(iv_str, 0x00, 100); 04592 memset(src_str, 0x00, 100); 04593 memset(dst_str, 0x00, 100); 04594 memset(output, 0x00, 100); 04595 04596 key_len = unhexify( key_str, "90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1" ); 04597 unhexify( iv_str, "00000000000000000000000000000000" ); 04598 data_len = unhexify( src_str, "798c7c005dee432b2c8ea5dfa381ecc3" ); 04599 04600 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04601 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04602 if( 0 == 0) 04603 { 04604 hexify( dst_str, output, data_len ); 04605 04606 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 04607 } 04608 } 04609 FCT_TEST_END(); 04610 04611 04612 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_8) 04613 { 04614 unsigned char key_str[100]; 04615 unsigned char iv_str[100]; 04616 unsigned char src_str[100]; 04617 unsigned char dst_str[100]; 04618 unsigned char output[100]; 04619 aes_context ctx; 04620 int key_len, data_len; 04621 04622 memset(key_str, 0x00, 100); 04623 memset(iv_str, 0x00, 100); 04624 memset(src_str, 0x00, 100); 04625 memset(dst_str, 0x00, 100); 04626 memset(output, 0x00, 100); 04627 04628 key_len = unhexify( key_str, "b7a5794d52737475d53d5a377200849be0260a67a2b22ced8bbef12882270d07" ); 04629 unhexify( iv_str, "00000000000000000000000000000000" ); 04630 data_len = unhexify( src_str, "637c31dc2591a07636f646b72daabbe7" ); 04631 04632 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04633 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04634 if( 0 == 0) 04635 { 04636 hexify( dst_str, output, data_len ); 04637 04638 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 04639 } 04640 } 04641 FCT_TEST_END(); 04642 04643 04644 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_9) 04645 { 04646 unsigned char key_str[100]; 04647 unsigned char iv_str[100]; 04648 unsigned char src_str[100]; 04649 unsigned char dst_str[100]; 04650 unsigned char output[100]; 04651 aes_context ctx; 04652 int key_len, data_len; 04653 04654 memset(key_str, 0x00, 100); 04655 memset(iv_str, 0x00, 100); 04656 memset(src_str, 0x00, 100); 04657 memset(dst_str, 0x00, 100); 04658 memset(output, 0x00, 100); 04659 04660 key_len = unhexify( key_str, "fca02f3d5011cfc5c1e23165d413a049d4526a991827424d896fe3435e0bf68e" ); 04661 unhexify( iv_str, "00000000000000000000000000000000" ); 04662 data_len = unhexify( src_str, "179a49c712154bbffbe6e7a84a18e220" ); 04663 04664 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04665 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04666 if( 0 == 0) 04667 { 04668 hexify( dst_str, output, data_len ); 04669 04670 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 04671 } 04672 } 04673 FCT_TEST_END(); 04674 04675 04676 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_10) 04677 { 04678 unsigned char key_str[100]; 04679 unsigned char iv_str[100]; 04680 unsigned char src_str[100]; 04681 unsigned char dst_str[100]; 04682 unsigned char output[100]; 04683 aes_context ctx; 04684 int key_len, data_len; 04685 04686 memset(key_str, 0x00, 100); 04687 memset(iv_str, 0x00, 100); 04688 memset(src_str, 0x00, 100); 04689 memset(dst_str, 0x00, 100); 04690 memset(output, 0x00, 100); 04691 04692 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04693 unhexify( iv_str, "00000000000000000000000000000000" ); 04694 data_len = unhexify( src_str, "5c9d844ed46f9885085e5d6a4f94c7d7" ); 04695 04696 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04697 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04698 if( 0 == 0) 04699 { 04700 hexify( dst_str, output, data_len ); 04701 04702 fct_chk( strcmp( (char *) dst_str, "014730f80ac625fe84f026c60bfd547d" ) == 0 ); 04703 } 04704 } 04705 FCT_TEST_END(); 04706 04707 04708 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_11) 04709 { 04710 unsigned char key_str[100]; 04711 unsigned char iv_str[100]; 04712 unsigned char src_str[100]; 04713 unsigned char dst_str[100]; 04714 unsigned char output[100]; 04715 aes_context ctx; 04716 int key_len, data_len; 04717 04718 memset(key_str, 0x00, 100); 04719 memset(iv_str, 0x00, 100); 04720 memset(src_str, 0x00, 100); 04721 memset(dst_str, 0x00, 100); 04722 memset(output, 0x00, 100); 04723 04724 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04725 unhexify( iv_str, "00000000000000000000000000000000" ); 04726 data_len = unhexify( src_str, "a9ff75bd7cf6613d3731c77c3b6d0c04" ); 04727 04728 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04729 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04730 if( 0 == 0) 04731 { 04732 hexify( dst_str, output, data_len ); 04733 04734 fct_chk( strcmp( (char *) dst_str, "0b24af36193ce4665f2825d7b4749c98" ) == 0 ); 04735 } 04736 } 04737 FCT_TEST_END(); 04738 04739 04740 FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_12) 04741 { 04742 unsigned char key_str[100]; 04743 unsigned char iv_str[100]; 04744 unsigned char src_str[100]; 04745 unsigned char dst_str[100]; 04746 unsigned char output[100]; 04747 aes_context ctx; 04748 int key_len, data_len; 04749 04750 memset(key_str, 0x00, 100); 04751 memset(iv_str, 0x00, 100); 04752 memset(src_str, 0x00, 100); 04753 memset(dst_str, 0x00, 100); 04754 memset(output, 0x00, 100); 04755 04756 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 04757 unhexify( iv_str, "00000000000000000000000000000000" ); 04758 data_len = unhexify( src_str, "623a52fcea5d443e48d9181ab32c7421" ); 04759 04760 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 04761 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 ); 04762 if( 0 == 0) 04763 { 04764 hexify( dst_str, output, data_len ); 04765 04766 fct_chk( strcmp( (char *) dst_str, "761c1fe41a18acf20d241650611d90f1" ) == 0 ); 04767 } 04768 } 04769 FCT_TEST_END(); 04770 04771 #ifdef POLARSSL_CIPHER_MODE_CFB 04772 04773 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_1) 04774 { 04775 unsigned char key_str[100]; 04776 unsigned char iv_str[100]; 04777 unsigned char src_str[100]; 04778 unsigned char dst_str[100]; 04779 unsigned char output[100]; 04780 aes_context ctx; 04781 size_t iv_offset = 0; 04782 int key_len; 04783 04784 memset(key_str, 0x00, 100); 04785 memset(iv_str, 0x00, 100); 04786 memset(src_str, 0x00, 100); 04787 memset(dst_str, 0x00, 100); 04788 memset(output, 0x00, 100); 04789 04790 key_len = unhexify( key_str, "f0000000000000000000000000000000" ); 04791 unhexify( iv_str, "00000000000000000000000000000000" ); 04792 unhexify( src_str, "00000000000000000000000000000000" ); 04793 04794 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04795 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 04796 hexify( dst_str, output, 16 ); 04797 04798 fct_chk( strcmp( (char *) dst_str, "970014d634e2b7650777e8e84d03ccd8" ) == 0 ); 04799 } 04800 FCT_TEST_END(); 04801 #endif /* POLARSSL_CIPHER_MODE_CFB */ 04802 04803 #ifdef POLARSSL_CIPHER_MODE_CFB 04804 04805 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_2) 04806 { 04807 unsigned char key_str[100]; 04808 unsigned char iv_str[100]; 04809 unsigned char src_str[100]; 04810 unsigned char dst_str[100]; 04811 unsigned char output[100]; 04812 aes_context ctx; 04813 size_t iv_offset = 0; 04814 int key_len; 04815 04816 memset(key_str, 0x00, 100); 04817 memset(iv_str, 0x00, 100); 04818 memset(src_str, 0x00, 100); 04819 memset(dst_str, 0x00, 100); 04820 memset(output, 0x00, 100); 04821 04822 key_len = unhexify( key_str, "f8000000000000000000000000000000" ); 04823 unhexify( iv_str, "00000000000000000000000000000000" ); 04824 unhexify( src_str, "00000000000000000000000000000000" ); 04825 04826 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04827 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 04828 hexify( dst_str, output, 16 ); 04829 04830 fct_chk( strcmp( (char *) dst_str, "f17e79aed0db7e279e955b5f493875a7" ) == 0 ); 04831 } 04832 FCT_TEST_END(); 04833 #endif /* POLARSSL_CIPHER_MODE_CFB */ 04834 04835 #ifdef POLARSSL_CIPHER_MODE_CFB 04836 04837 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_3) 04838 { 04839 unsigned char key_str[100]; 04840 unsigned char iv_str[100]; 04841 unsigned char src_str[100]; 04842 unsigned char dst_str[100]; 04843 unsigned char output[100]; 04844 aes_context ctx; 04845 size_t iv_offset = 0; 04846 int key_len; 04847 04848 memset(key_str, 0x00, 100); 04849 memset(iv_str, 0x00, 100); 04850 memset(src_str, 0x00, 100); 04851 memset(dst_str, 0x00, 100); 04852 memset(output, 0x00, 100); 04853 04854 key_len = unhexify( key_str, "fc000000000000000000000000000000" ); 04855 unhexify( iv_str, "00000000000000000000000000000000" ); 04856 unhexify( src_str, "00000000000000000000000000000000" ); 04857 04858 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04859 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 04860 hexify( dst_str, output, 16 ); 04861 04862 fct_chk( strcmp( (char *) dst_str, "9ed5a75136a940d0963da379db4af26a" ) == 0 ); 04863 } 04864 FCT_TEST_END(); 04865 #endif /* POLARSSL_CIPHER_MODE_CFB */ 04866 04867 #ifdef POLARSSL_CIPHER_MODE_CFB 04868 04869 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_4) 04870 { 04871 unsigned char key_str[100]; 04872 unsigned char iv_str[100]; 04873 unsigned char src_str[100]; 04874 unsigned char dst_str[100]; 04875 unsigned char output[100]; 04876 aes_context ctx; 04877 size_t iv_offset = 0; 04878 int key_len; 04879 04880 memset(key_str, 0x00, 100); 04881 memset(iv_str, 0x00, 100); 04882 memset(src_str, 0x00, 100); 04883 memset(dst_str, 0x00, 100); 04884 memset(output, 0x00, 100); 04885 04886 key_len = unhexify( key_str, "64cf9c7abc50b888af65f49d521944b2" ); 04887 unhexify( iv_str, "00000000000000000000000000000000" ); 04888 unhexify( src_str, "00000000000000000000000000000000" ); 04889 04890 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04891 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 04892 hexify( dst_str, output, 16 ); 04893 04894 fct_chk( strcmp( (char *) dst_str, "f7efc89d5dba578104016ce5ad659c05" ) == 0 ); 04895 } 04896 FCT_TEST_END(); 04897 #endif /* POLARSSL_CIPHER_MODE_CFB */ 04898 04899 #ifdef POLARSSL_CIPHER_MODE_CFB 04900 04901 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_5) 04902 { 04903 unsigned char key_str[100]; 04904 unsigned char iv_str[100]; 04905 unsigned char src_str[100]; 04906 unsigned char dst_str[100]; 04907 unsigned char output[100]; 04908 aes_context ctx; 04909 size_t iv_offset = 0; 04910 int key_len; 04911 04912 memset(key_str, 0x00, 100); 04913 memset(iv_str, 0x00, 100); 04914 memset(src_str, 0x00, 100); 04915 memset(dst_str, 0x00, 100); 04916 memset(output, 0x00, 100); 04917 04918 key_len = unhexify( key_str, "47d6742eefcc0465dc96355e851b64d9" ); 04919 unhexify( iv_str, "00000000000000000000000000000000" ); 04920 unhexify( src_str, "00000000000000000000000000000000" ); 04921 04922 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04923 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 04924 hexify( dst_str, output, 16 ); 04925 04926 fct_chk( strcmp( (char *) dst_str, "0306194f666d183624aa230a8b264ae7" ) == 0 ); 04927 } 04928 FCT_TEST_END(); 04929 #endif /* POLARSSL_CIPHER_MODE_CFB */ 04930 04931 #ifdef POLARSSL_CIPHER_MODE_CFB 04932 04933 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_6) 04934 { 04935 unsigned char key_str[100]; 04936 unsigned char iv_str[100]; 04937 unsigned char src_str[100]; 04938 unsigned char dst_str[100]; 04939 unsigned char output[100]; 04940 aes_context ctx; 04941 size_t iv_offset = 0; 04942 int key_len; 04943 04944 memset(key_str, 0x00, 100); 04945 memset(iv_str, 0x00, 100); 04946 memset(src_str, 0x00, 100); 04947 memset(dst_str, 0x00, 100); 04948 memset(output, 0x00, 100); 04949 04950 key_len = unhexify( key_str, "3eb39790678c56bee34bbcdeccf6cdb5" ); 04951 unhexify( iv_str, "00000000000000000000000000000000" ); 04952 unhexify( src_str, "00000000000000000000000000000000" ); 04953 04954 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04955 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 04956 hexify( dst_str, output, 16 ); 04957 04958 fct_chk( strcmp( (char *) dst_str, "858075d536d79ccee571f7d7204b1f67" ) == 0 ); 04959 } 04960 FCT_TEST_END(); 04961 #endif /* POLARSSL_CIPHER_MODE_CFB */ 04962 04963 #ifdef POLARSSL_CIPHER_MODE_CFB 04964 04965 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_7) 04966 { 04967 unsigned char key_str[100]; 04968 unsigned char iv_str[100]; 04969 unsigned char src_str[100]; 04970 unsigned char dst_str[100]; 04971 unsigned char output[100]; 04972 aes_context ctx; 04973 size_t iv_offset = 0; 04974 int key_len; 04975 04976 memset(key_str, 0x00, 100); 04977 memset(iv_str, 0x00, 100); 04978 memset(src_str, 0x00, 100); 04979 memset(dst_str, 0x00, 100); 04980 memset(output, 0x00, 100); 04981 04982 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 04983 unhexify( iv_str, "6a118a874519e64e9963798a503f1d35" ); 04984 unhexify( src_str, "00000000000000000000000000000000" ); 04985 04986 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 04987 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 04988 hexify( dst_str, output, 16 ); 04989 04990 fct_chk( strcmp( (char *) dst_str, "dc43be40be0e53712f7e2bf5ca707209" ) == 0 ); 04991 } 04992 FCT_TEST_END(); 04993 #endif /* POLARSSL_CIPHER_MODE_CFB */ 04994 04995 #ifdef POLARSSL_CIPHER_MODE_CFB 04996 04997 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_8) 04998 { 04999 unsigned char key_str[100]; 05000 unsigned char iv_str[100]; 05001 unsigned char src_str[100]; 05002 unsigned char dst_str[100]; 05003 unsigned char output[100]; 05004 aes_context ctx; 05005 size_t iv_offset = 0; 05006 int key_len; 05007 05008 memset(key_str, 0x00, 100); 05009 memset(iv_str, 0x00, 100); 05010 memset(src_str, 0x00, 100); 05011 memset(dst_str, 0x00, 100); 05012 memset(output, 0x00, 100); 05013 05014 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 05015 unhexify( iv_str, "cb9fceec81286ca3e989bd979b0cb284" ); 05016 unhexify( src_str, "00000000000000000000000000000000" ); 05017 05018 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05019 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05020 hexify( dst_str, output, 16 ); 05021 05022 fct_chk( strcmp( (char *) dst_str, "92beedab1895a94faa69b632e5cc47ce" ) == 0 ); 05023 } 05024 FCT_TEST_END(); 05025 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05026 05027 #ifdef POLARSSL_CIPHER_MODE_CFB 05028 05029 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_9) 05030 { 05031 unsigned char key_str[100]; 05032 unsigned char iv_str[100]; 05033 unsigned char src_str[100]; 05034 unsigned char dst_str[100]; 05035 unsigned char output[100]; 05036 aes_context ctx; 05037 size_t iv_offset = 0; 05038 int key_len; 05039 05040 memset(key_str, 0x00, 100); 05041 memset(iv_str, 0x00, 100); 05042 memset(src_str, 0x00, 100); 05043 memset(dst_str, 0x00, 100); 05044 memset(output, 0x00, 100); 05045 05046 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 05047 unhexify( iv_str, "b26aeb1874e47ca8358ff22378f09144" ); 05048 unhexify( src_str, "00000000000000000000000000000000" ); 05049 05050 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05051 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05052 hexify( dst_str, output, 16 ); 05053 05054 fct_chk( strcmp( (char *) dst_str, "459264f4798f6a78bacb89c15ed3d601" ) == 0 ); 05055 } 05056 FCT_TEST_END(); 05057 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05058 05059 #ifdef POLARSSL_CIPHER_MODE_CFB 05060 05061 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_10) 05062 { 05063 unsigned char key_str[100]; 05064 unsigned char iv_str[100]; 05065 unsigned char src_str[100]; 05066 unsigned char dst_str[100]; 05067 unsigned char output[100]; 05068 aes_context ctx; 05069 size_t iv_offset = 0; 05070 int key_len; 05071 05072 memset(key_str, 0x00, 100); 05073 memset(iv_str, 0x00, 100); 05074 memset(src_str, 0x00, 100); 05075 memset(dst_str, 0x00, 100); 05076 memset(output, 0x00, 100); 05077 05078 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 05079 unhexify( iv_str, "fffffffffffffffffffffffffffffff0" ); 05080 unhexify( src_str, "00000000000000000000000000000000" ); 05081 05082 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05083 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05084 hexify( dst_str, output, 16 ); 05085 05086 fct_chk( strcmp( (char *) dst_str, "f9b0fda0c4a898f5b9e6f661c4ce4d07" ) == 0 ); 05087 } 05088 FCT_TEST_END(); 05089 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05090 05091 #ifdef POLARSSL_CIPHER_MODE_CFB 05092 05093 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_11) 05094 { 05095 unsigned char key_str[100]; 05096 unsigned char iv_str[100]; 05097 unsigned char src_str[100]; 05098 unsigned char dst_str[100]; 05099 unsigned char output[100]; 05100 aes_context ctx; 05101 size_t iv_offset = 0; 05102 int key_len; 05103 05104 memset(key_str, 0x00, 100); 05105 memset(iv_str, 0x00, 100); 05106 memset(src_str, 0x00, 100); 05107 memset(dst_str, 0x00, 100); 05108 memset(output, 0x00, 100); 05109 05110 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 05111 unhexify( iv_str, "fffffffffffffffffffffffffffffff8" ); 05112 unhexify( src_str, "00000000000000000000000000000000" ); 05113 05114 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05115 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05116 hexify( dst_str, output, 16 ); 05117 05118 fct_chk( strcmp( (char *) dst_str, "8ade895913685c67c5269f8aae42983e" ) == 0 ); 05119 } 05120 FCT_TEST_END(); 05121 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05122 05123 #ifdef POLARSSL_CIPHER_MODE_CFB 05124 05125 FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_12) 05126 { 05127 unsigned char key_str[100]; 05128 unsigned char iv_str[100]; 05129 unsigned char src_str[100]; 05130 unsigned char dst_str[100]; 05131 unsigned char output[100]; 05132 aes_context ctx; 05133 size_t iv_offset = 0; 05134 int key_len; 05135 05136 memset(key_str, 0x00, 100); 05137 memset(iv_str, 0x00, 100); 05138 memset(src_str, 0x00, 100); 05139 memset(dst_str, 0x00, 100); 05140 memset(output, 0x00, 100); 05141 05142 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 05143 unhexify( iv_str, "fffffffffffffffffffffffffffffffc" ); 05144 unhexify( src_str, "00000000000000000000000000000000" ); 05145 05146 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05147 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05148 hexify( dst_str, output, 16 ); 05149 05150 fct_chk( strcmp( (char *) dst_str, "39bde67d5c8ed8a8b1c37eb8fa9f5ac0" ) == 0 ); 05151 } 05152 FCT_TEST_END(); 05153 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05154 05155 #ifdef POLARSSL_CIPHER_MODE_CFB 05156 05157 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_1) 05158 { 05159 unsigned char key_str[100]; 05160 unsigned char iv_str[100]; 05161 unsigned char src_str[100]; 05162 unsigned char dst_str[100]; 05163 unsigned char output[100]; 05164 aes_context ctx; 05165 size_t iv_offset = 0; 05166 int key_len; 05167 05168 memset(key_str, 0x00, 100); 05169 memset(iv_str, 0x00, 100); 05170 memset(src_str, 0x00, 100); 05171 memset(dst_str, 0x00, 100); 05172 memset(output, 0x00, 100); 05173 05174 key_len = unhexify( key_str, "fffffffe000000000000000000000000" ); 05175 unhexify( iv_str, "00000000000000000000000000000000" ); 05176 unhexify( src_str, "1114bc2028009b923f0b01915ce5e7c4" ); 05177 05178 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05179 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05180 hexify( dst_str, output, 16 ); 05181 05182 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05183 } 05184 FCT_TEST_END(); 05185 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05186 05187 #ifdef POLARSSL_CIPHER_MODE_CFB 05188 05189 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_2) 05190 { 05191 unsigned char key_str[100]; 05192 unsigned char iv_str[100]; 05193 unsigned char src_str[100]; 05194 unsigned char dst_str[100]; 05195 unsigned char output[100]; 05196 aes_context ctx; 05197 size_t iv_offset = 0; 05198 int key_len; 05199 05200 memset(key_str, 0x00, 100); 05201 memset(iv_str, 0x00, 100); 05202 memset(src_str, 0x00, 100); 05203 memset(dst_str, 0x00, 100); 05204 memset(output, 0x00, 100); 05205 05206 key_len = unhexify( key_str, "ffffffff000000000000000000000000" ); 05207 unhexify( iv_str, "00000000000000000000000000000000" ); 05208 unhexify( src_str, "9c28524a16a1e1c1452971caa8d13476" ); 05209 05210 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05211 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05212 hexify( dst_str, output, 16 ); 05213 05214 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05215 } 05216 FCT_TEST_END(); 05217 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05218 05219 #ifdef POLARSSL_CIPHER_MODE_CFB 05220 05221 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_3) 05222 { 05223 unsigned char key_str[100]; 05224 unsigned char iv_str[100]; 05225 unsigned char src_str[100]; 05226 unsigned char dst_str[100]; 05227 unsigned char output[100]; 05228 aes_context ctx; 05229 size_t iv_offset = 0; 05230 int key_len; 05231 05232 memset(key_str, 0x00, 100); 05233 memset(iv_str, 0x00, 100); 05234 memset(src_str, 0x00, 100); 05235 memset(dst_str, 0x00, 100); 05236 memset(output, 0x00, 100); 05237 05238 key_len = unhexify( key_str, "ffffffff800000000000000000000000" ); 05239 unhexify( iv_str, "00000000000000000000000000000000" ); 05240 unhexify( src_str, "ed62e16363638360fdd6ad62112794f0" ); 05241 05242 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05243 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05244 hexify( dst_str, output, 16 ); 05245 05246 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05247 } 05248 FCT_TEST_END(); 05249 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05250 05251 #ifdef POLARSSL_CIPHER_MODE_CFB 05252 05253 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_4) 05254 { 05255 unsigned char key_str[100]; 05256 unsigned char iv_str[100]; 05257 unsigned char src_str[100]; 05258 unsigned char dst_str[100]; 05259 unsigned char output[100]; 05260 aes_context ctx; 05261 size_t iv_offset = 0; 05262 int key_len; 05263 05264 memset(key_str, 0x00, 100); 05265 memset(iv_str, 0x00, 100); 05266 memset(src_str, 0x00, 100); 05267 memset(dst_str, 0x00, 100); 05268 memset(output, 0x00, 100); 05269 05270 key_len = unhexify( key_str, "3071a2a48fe6cbd04f1a129098e308f8" ); 05271 unhexify( iv_str, "00000000000000000000000000000000" ); 05272 unhexify( src_str, "4b98e06d356deb07ebb824e5713f7be3" ); 05273 05274 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05275 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05276 hexify( dst_str, output, 16 ); 05277 05278 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05279 } 05280 FCT_TEST_END(); 05281 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05282 05283 #ifdef POLARSSL_CIPHER_MODE_CFB 05284 05285 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_5) 05286 { 05287 unsigned char key_str[100]; 05288 unsigned char iv_str[100]; 05289 unsigned char src_str[100]; 05290 unsigned char dst_str[100]; 05291 unsigned char output[100]; 05292 aes_context ctx; 05293 size_t iv_offset = 0; 05294 int key_len; 05295 05296 memset(key_str, 0x00, 100); 05297 memset(iv_str, 0x00, 100); 05298 memset(src_str, 0x00, 100); 05299 memset(dst_str, 0x00, 100); 05300 memset(output, 0x00, 100); 05301 05302 key_len = unhexify( key_str, "90f42ec0f68385f2ffc5dfc03a654dce" ); 05303 unhexify( iv_str, "00000000000000000000000000000000" ); 05304 unhexify( src_str, "7a20a53d460fc9ce0423a7a0764c6cf2" ); 05305 05306 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05307 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05308 hexify( dst_str, output, 16 ); 05309 05310 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05311 } 05312 FCT_TEST_END(); 05313 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05314 05315 #ifdef POLARSSL_CIPHER_MODE_CFB 05316 05317 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_6) 05318 { 05319 unsigned char key_str[100]; 05320 unsigned char iv_str[100]; 05321 unsigned char src_str[100]; 05322 unsigned char dst_str[100]; 05323 unsigned char output[100]; 05324 aes_context ctx; 05325 size_t iv_offset = 0; 05326 int key_len; 05327 05328 memset(key_str, 0x00, 100); 05329 memset(iv_str, 0x00, 100); 05330 memset(src_str, 0x00, 100); 05331 memset(dst_str, 0x00, 100); 05332 memset(output, 0x00, 100); 05333 05334 key_len = unhexify( key_str, "febd9a24d8b65c1c787d50a4ed3619a9" ); 05335 unhexify( iv_str, "00000000000000000000000000000000" ); 05336 unhexify( src_str, "f4a70d8af877f9b02b4c40df57d45b17" ); 05337 05338 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05339 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05340 hexify( dst_str, output, 16 ); 05341 05342 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05343 } 05344 FCT_TEST_END(); 05345 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05346 05347 #ifdef POLARSSL_CIPHER_MODE_CFB 05348 05349 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_7) 05350 { 05351 unsigned char key_str[100]; 05352 unsigned char iv_str[100]; 05353 unsigned char src_str[100]; 05354 unsigned char dst_str[100]; 05355 unsigned char output[100]; 05356 aes_context ctx; 05357 size_t iv_offset = 0; 05358 int key_len; 05359 05360 memset(key_str, 0x00, 100); 05361 memset(iv_str, 0x00, 100); 05362 memset(src_str, 0x00, 100); 05363 memset(dst_str, 0x00, 100); 05364 memset(output, 0x00, 100); 05365 05366 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 05367 unhexify( iv_str, "f34481ec3cc627bacd5dc3fb08f273e6" ); 05368 unhexify( src_str, "0336763e966d92595a567cc9ce537f5e" ); 05369 05370 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05371 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05372 hexify( dst_str, output, 16 ); 05373 05374 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05375 } 05376 FCT_TEST_END(); 05377 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05378 05379 #ifdef POLARSSL_CIPHER_MODE_CFB 05380 05381 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_8) 05382 { 05383 unsigned char key_str[100]; 05384 unsigned char iv_str[100]; 05385 unsigned char src_str[100]; 05386 unsigned char dst_str[100]; 05387 unsigned char output[100]; 05388 aes_context ctx; 05389 size_t iv_offset = 0; 05390 int key_len; 05391 05392 memset(key_str, 0x00, 100); 05393 memset(iv_str, 0x00, 100); 05394 memset(src_str, 0x00, 100); 05395 memset(dst_str, 0x00, 100); 05396 memset(output, 0x00, 100); 05397 05398 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 05399 unhexify( iv_str, "9798c4640bad75c7c3227db910174e72" ); 05400 unhexify( src_str, "a9a1631bf4996954ebc093957b234589" ); 05401 05402 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05403 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05404 hexify( dst_str, output, 16 ); 05405 05406 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05407 } 05408 FCT_TEST_END(); 05409 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05410 05411 #ifdef POLARSSL_CIPHER_MODE_CFB 05412 05413 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_9) 05414 { 05415 unsigned char key_str[100]; 05416 unsigned char iv_str[100]; 05417 unsigned char src_str[100]; 05418 unsigned char dst_str[100]; 05419 unsigned char output[100]; 05420 aes_context ctx; 05421 size_t iv_offset = 0; 05422 int key_len; 05423 05424 memset(key_str, 0x00, 100); 05425 memset(iv_str, 0x00, 100); 05426 memset(src_str, 0x00, 100); 05427 memset(dst_str, 0x00, 100); 05428 memset(output, 0x00, 100); 05429 05430 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 05431 unhexify( iv_str, "96ab5c2ff612d9dfaae8c31f30c42168" ); 05432 unhexify( src_str, "ff4f8391a6a40ca5b25d23bedd44a597" ); 05433 05434 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05435 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05436 hexify( dst_str, output, 16 ); 05437 05438 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05439 } 05440 FCT_TEST_END(); 05441 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05442 05443 #ifdef POLARSSL_CIPHER_MODE_CFB 05444 05445 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_10) 05446 { 05447 unsigned char key_str[100]; 05448 unsigned char iv_str[100]; 05449 unsigned char src_str[100]; 05450 unsigned char dst_str[100]; 05451 unsigned char output[100]; 05452 aes_context ctx; 05453 size_t iv_offset = 0; 05454 int key_len; 05455 05456 memset(key_str, 0x00, 100); 05457 memset(iv_str, 0x00, 100); 05458 memset(src_str, 0x00, 100); 05459 memset(dst_str, 0x00, 100); 05460 memset(output, 0x00, 100); 05461 05462 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 05463 unhexify( iv_str, "ffffffffffffffff0000000000000000" ); 05464 unhexify( src_str, "f807c3e7985fe0f5a50e2cdb25c5109e" ); 05465 05466 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05467 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05468 hexify( dst_str, output, 16 ); 05469 05470 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05471 } 05472 FCT_TEST_END(); 05473 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05474 05475 #ifdef POLARSSL_CIPHER_MODE_CFB 05476 05477 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_11) 05478 { 05479 unsigned char key_str[100]; 05480 unsigned char iv_str[100]; 05481 unsigned char src_str[100]; 05482 unsigned char dst_str[100]; 05483 unsigned char output[100]; 05484 aes_context ctx; 05485 size_t iv_offset = 0; 05486 int key_len; 05487 05488 memset(key_str, 0x00, 100); 05489 memset(iv_str, 0x00, 100); 05490 memset(src_str, 0x00, 100); 05491 memset(dst_str, 0x00, 100); 05492 memset(output, 0x00, 100); 05493 05494 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 05495 unhexify( iv_str, "ffffffffffffffff8000000000000000" ); 05496 unhexify( src_str, "41f992a856fb278b389a62f5d274d7e9" ); 05497 05498 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05499 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05500 hexify( dst_str, output, 16 ); 05501 05502 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05503 } 05504 FCT_TEST_END(); 05505 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05506 05507 #ifdef POLARSSL_CIPHER_MODE_CFB 05508 05509 FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_12) 05510 { 05511 unsigned char key_str[100]; 05512 unsigned char iv_str[100]; 05513 unsigned char src_str[100]; 05514 unsigned char dst_str[100]; 05515 unsigned char output[100]; 05516 aes_context ctx; 05517 size_t iv_offset = 0; 05518 int key_len; 05519 05520 memset(key_str, 0x00, 100); 05521 memset(iv_str, 0x00, 100); 05522 memset(src_str, 0x00, 100); 05523 memset(dst_str, 0x00, 100); 05524 memset(output, 0x00, 100); 05525 05526 key_len = unhexify( key_str, "00000000000000000000000000000000" ); 05527 unhexify( iv_str, "ffffffffffffffffc000000000000000" ); 05528 unhexify( src_str, "10d3ed7a6fe15ab4d91acbc7d0767ab1" ); 05529 05530 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05531 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05532 hexify( dst_str, output, 16 ); 05533 05534 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05535 } 05536 FCT_TEST_END(); 05537 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05538 05539 #ifdef POLARSSL_CIPHER_MODE_CFB 05540 05541 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_1) 05542 { 05543 unsigned char key_str[100]; 05544 unsigned char iv_str[100]; 05545 unsigned char src_str[100]; 05546 unsigned char dst_str[100]; 05547 unsigned char output[100]; 05548 aes_context ctx; 05549 size_t iv_offset = 0; 05550 int key_len; 05551 05552 memset(key_str, 0x00, 100); 05553 memset(iv_str, 0x00, 100); 05554 memset(src_str, 0x00, 100); 05555 memset(dst_str, 0x00, 100); 05556 memset(output, 0x00, 100); 05557 05558 key_len = unhexify( key_str, "fffffffffffffffffffc0000000000000000000000000000" ); 05559 unhexify( iv_str, "00000000000000000000000000000000" ); 05560 unhexify( src_str, "00000000000000000000000000000000" ); 05561 05562 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05563 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05564 hexify( dst_str, output, 16 ); 05565 05566 fct_chk( strcmp( (char *) dst_str, "8dfd999be5d0cfa35732c0ddc88ff5a5" ) == 0 ); 05567 } 05568 FCT_TEST_END(); 05569 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05570 05571 #ifdef POLARSSL_CIPHER_MODE_CFB 05572 05573 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_2) 05574 { 05575 unsigned char key_str[100]; 05576 unsigned char iv_str[100]; 05577 unsigned char src_str[100]; 05578 unsigned char dst_str[100]; 05579 unsigned char output[100]; 05580 aes_context ctx; 05581 size_t iv_offset = 0; 05582 int key_len; 05583 05584 memset(key_str, 0x00, 100); 05585 memset(iv_str, 0x00, 100); 05586 memset(src_str, 0x00, 100); 05587 memset(dst_str, 0x00, 100); 05588 memset(output, 0x00, 100); 05589 05590 key_len = unhexify( key_str, "fffffffffffffffffffe0000000000000000000000000000" ); 05591 unhexify( iv_str, "00000000000000000000000000000000" ); 05592 unhexify( src_str, "00000000000000000000000000000000" ); 05593 05594 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05595 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05596 hexify( dst_str, output, 16 ); 05597 05598 fct_chk( strcmp( (char *) dst_str, "02647c76a300c3173b841487eb2bae9f" ) == 0 ); 05599 } 05600 FCT_TEST_END(); 05601 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05602 05603 #ifdef POLARSSL_CIPHER_MODE_CFB 05604 05605 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_3) 05606 { 05607 unsigned char key_str[100]; 05608 unsigned char iv_str[100]; 05609 unsigned char src_str[100]; 05610 unsigned char dst_str[100]; 05611 unsigned char output[100]; 05612 aes_context ctx; 05613 size_t iv_offset = 0; 05614 int key_len; 05615 05616 memset(key_str, 0x00, 100); 05617 memset(iv_str, 0x00, 100); 05618 memset(src_str, 0x00, 100); 05619 memset(dst_str, 0x00, 100); 05620 memset(output, 0x00, 100); 05621 05622 key_len = unhexify( key_str, "ffffffffffffffffffff0000000000000000000000000000" ); 05623 unhexify( iv_str, "00000000000000000000000000000000" ); 05624 unhexify( src_str, "00000000000000000000000000000000" ); 05625 05626 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05627 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05628 hexify( dst_str, output, 16 ); 05629 05630 fct_chk( strcmp( (char *) dst_str, "172df8b02f04b53adab028b4e01acd87" ) == 0 ); 05631 } 05632 FCT_TEST_END(); 05633 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05634 05635 #ifdef POLARSSL_CIPHER_MODE_CFB 05636 05637 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_4) 05638 { 05639 unsigned char key_str[100]; 05640 unsigned char iv_str[100]; 05641 unsigned char src_str[100]; 05642 unsigned char dst_str[100]; 05643 unsigned char output[100]; 05644 aes_context ctx; 05645 size_t iv_offset = 0; 05646 int key_len; 05647 05648 memset(key_str, 0x00, 100); 05649 memset(iv_str, 0x00, 100); 05650 memset(src_str, 0x00, 100); 05651 memset(dst_str, 0x00, 100); 05652 memset(output, 0x00, 100); 05653 05654 key_len = unhexify( key_str, "d184c36cf0dddfec39e654195006022237871a47c33d3198" ); 05655 unhexify( iv_str, "00000000000000000000000000000000" ); 05656 unhexify( src_str, "00000000000000000000000000000000" ); 05657 05658 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05659 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05660 hexify( dst_str, output, 16 ); 05661 05662 fct_chk( strcmp( (char *) dst_str, "2e19fb60a3e1de0166f483c97824a978" ) == 0 ); 05663 } 05664 FCT_TEST_END(); 05665 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05666 05667 #ifdef POLARSSL_CIPHER_MODE_CFB 05668 05669 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_5) 05670 { 05671 unsigned char key_str[100]; 05672 unsigned char iv_str[100]; 05673 unsigned char src_str[100]; 05674 unsigned char dst_str[100]; 05675 unsigned char output[100]; 05676 aes_context ctx; 05677 size_t iv_offset = 0; 05678 int key_len; 05679 05680 memset(key_str, 0x00, 100); 05681 memset(iv_str, 0x00, 100); 05682 memset(src_str, 0x00, 100); 05683 memset(dst_str, 0x00, 100); 05684 memset(output, 0x00, 100); 05685 05686 key_len = unhexify( key_str, "4c6994ffa9dcdc805b60c2c0095334c42d95a8fc0ca5b080" ); 05687 unhexify( iv_str, "00000000000000000000000000000000" ); 05688 unhexify( src_str, "00000000000000000000000000000000" ); 05689 05690 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05691 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05692 hexify( dst_str, output, 16 ); 05693 05694 fct_chk( strcmp( (char *) dst_str, "7656709538dd5fec41e0ce6a0f8e207d" ) == 0 ); 05695 } 05696 FCT_TEST_END(); 05697 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05698 05699 #ifdef POLARSSL_CIPHER_MODE_CFB 05700 05701 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_6) 05702 { 05703 unsigned char key_str[100]; 05704 unsigned char iv_str[100]; 05705 unsigned char src_str[100]; 05706 unsigned char dst_str[100]; 05707 unsigned char output[100]; 05708 aes_context ctx; 05709 size_t iv_offset = 0; 05710 int key_len; 05711 05712 memset(key_str, 0x00, 100); 05713 memset(iv_str, 0x00, 100); 05714 memset(src_str, 0x00, 100); 05715 memset(dst_str, 0x00, 100); 05716 memset(output, 0x00, 100); 05717 05718 key_len = unhexify( key_str, "c88f5b00a4ef9a6840e2acaf33f00a3bdc4e25895303fa72" ); 05719 unhexify( iv_str, "00000000000000000000000000000000" ); 05720 unhexify( src_str, "00000000000000000000000000000000" ); 05721 05722 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05723 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05724 hexify( dst_str, output, 16 ); 05725 05726 fct_chk( strcmp( (char *) dst_str, "a67cf333b314d411d3c0ae6e1cfcd8f5" ) == 0 ); 05727 } 05728 FCT_TEST_END(); 05729 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05730 05731 #ifdef POLARSSL_CIPHER_MODE_CFB 05732 05733 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_7) 05734 { 05735 unsigned char key_str[100]; 05736 unsigned char iv_str[100]; 05737 unsigned char src_str[100]; 05738 unsigned char dst_str[100]; 05739 unsigned char output[100]; 05740 aes_context ctx; 05741 size_t iv_offset = 0; 05742 int key_len; 05743 05744 memset(key_str, 0x00, 100); 05745 memset(iv_str, 0x00, 100); 05746 memset(src_str, 0x00, 100); 05747 memset(dst_str, 0x00, 100); 05748 memset(output, 0x00, 100); 05749 05750 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 05751 unhexify( iv_str, "9c2d8842e5f48f57648205d39a239af1" ); 05752 unhexify( src_str, "00000000000000000000000000000000" ); 05753 05754 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05755 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05756 hexify( dst_str, output, 16 ); 05757 05758 fct_chk( strcmp( (char *) dst_str, "c9b8135ff1b5adc413dfd053b21bd96d" ) == 0 ); 05759 } 05760 FCT_TEST_END(); 05761 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05762 05763 #ifdef POLARSSL_CIPHER_MODE_CFB 05764 05765 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_8) 05766 { 05767 unsigned char key_str[100]; 05768 unsigned char iv_str[100]; 05769 unsigned char src_str[100]; 05770 unsigned char dst_str[100]; 05771 unsigned char output[100]; 05772 aes_context ctx; 05773 size_t iv_offset = 0; 05774 int key_len; 05775 05776 memset(key_str, 0x00, 100); 05777 memset(iv_str, 0x00, 100); 05778 memset(src_str, 0x00, 100); 05779 memset(dst_str, 0x00, 100); 05780 memset(output, 0x00, 100); 05781 05782 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 05783 unhexify( iv_str, "bff52510095f518ecca60af4205444bb" ); 05784 unhexify( src_str, "00000000000000000000000000000000" ); 05785 05786 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05787 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05788 hexify( dst_str, output, 16 ); 05789 05790 fct_chk( strcmp( (char *) dst_str, "4a3650c3371ce2eb35e389a171427440" ) == 0 ); 05791 } 05792 FCT_TEST_END(); 05793 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05794 05795 #ifdef POLARSSL_CIPHER_MODE_CFB 05796 05797 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_9) 05798 { 05799 unsigned char key_str[100]; 05800 unsigned char iv_str[100]; 05801 unsigned char src_str[100]; 05802 unsigned char dst_str[100]; 05803 unsigned char output[100]; 05804 aes_context ctx; 05805 size_t iv_offset = 0; 05806 int key_len; 05807 05808 memset(key_str, 0x00, 100); 05809 memset(iv_str, 0x00, 100); 05810 memset(src_str, 0x00, 100); 05811 memset(dst_str, 0x00, 100); 05812 memset(output, 0x00, 100); 05813 05814 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 05815 unhexify( iv_str, "51719783d3185a535bd75adc65071ce1" ); 05816 unhexify( src_str, "00000000000000000000000000000000" ); 05817 05818 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05819 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05820 hexify( dst_str, output, 16 ); 05821 05822 fct_chk( strcmp( (char *) dst_str, "4f354592ff7c8847d2d0870ca9481b7c" ) == 0 ); 05823 } 05824 FCT_TEST_END(); 05825 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05826 05827 #ifdef POLARSSL_CIPHER_MODE_CFB 05828 05829 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_10) 05830 { 05831 unsigned char key_str[100]; 05832 unsigned char iv_str[100]; 05833 unsigned char src_str[100]; 05834 unsigned char dst_str[100]; 05835 unsigned char output[100]; 05836 aes_context ctx; 05837 size_t iv_offset = 0; 05838 int key_len; 05839 05840 memset(key_str, 0x00, 100); 05841 memset(iv_str, 0x00, 100); 05842 memset(src_str, 0x00, 100); 05843 memset(dst_str, 0x00, 100); 05844 memset(output, 0x00, 100); 05845 05846 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 05847 unhexify( iv_str, "ffffffffffffffe00000000000000000" ); 05848 unhexify( src_str, "00000000000000000000000000000000" ); 05849 05850 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05851 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05852 hexify( dst_str, output, 16 ); 05853 05854 fct_chk( strcmp( (char *) dst_str, "f34e4a6324ea4a5c39a661c8fe5ada8f" ) == 0 ); 05855 } 05856 FCT_TEST_END(); 05857 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05858 05859 #ifdef POLARSSL_CIPHER_MODE_CFB 05860 05861 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_11) 05862 { 05863 unsigned char key_str[100]; 05864 unsigned char iv_str[100]; 05865 unsigned char src_str[100]; 05866 unsigned char dst_str[100]; 05867 unsigned char output[100]; 05868 aes_context ctx; 05869 size_t iv_offset = 0; 05870 int key_len; 05871 05872 memset(key_str, 0x00, 100); 05873 memset(iv_str, 0x00, 100); 05874 memset(src_str, 0x00, 100); 05875 memset(dst_str, 0x00, 100); 05876 memset(output, 0x00, 100); 05877 05878 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 05879 unhexify( iv_str, "fffffffffffffff00000000000000000" ); 05880 unhexify( src_str, "00000000000000000000000000000000" ); 05881 05882 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05883 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05884 hexify( dst_str, output, 16 ); 05885 05886 fct_chk( strcmp( (char *) dst_str, "0882a16f44088d42447a29ac090ec17e" ) == 0 ); 05887 } 05888 FCT_TEST_END(); 05889 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05890 05891 #ifdef POLARSSL_CIPHER_MODE_CFB 05892 05893 FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_12) 05894 { 05895 unsigned char key_str[100]; 05896 unsigned char iv_str[100]; 05897 unsigned char src_str[100]; 05898 unsigned char dst_str[100]; 05899 unsigned char output[100]; 05900 aes_context ctx; 05901 size_t iv_offset = 0; 05902 int key_len; 05903 05904 memset(key_str, 0x00, 100); 05905 memset(iv_str, 0x00, 100); 05906 memset(src_str, 0x00, 100); 05907 memset(dst_str, 0x00, 100); 05908 memset(output, 0x00, 100); 05909 05910 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 05911 unhexify( iv_str, "fffffffffffffff80000000000000000" ); 05912 unhexify( src_str, "00000000000000000000000000000000" ); 05913 05914 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05915 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05916 hexify( dst_str, output, 16 ); 05917 05918 fct_chk( strcmp( (char *) dst_str, "3a3c15bfc11a9537c130687004e136ee" ) == 0 ); 05919 } 05920 FCT_TEST_END(); 05921 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05922 05923 #ifdef POLARSSL_CIPHER_MODE_CFB 05924 05925 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_1) 05926 { 05927 unsigned char key_str[100]; 05928 unsigned char iv_str[100]; 05929 unsigned char src_str[100]; 05930 unsigned char dst_str[100]; 05931 unsigned char output[100]; 05932 aes_context ctx; 05933 size_t iv_offset = 0; 05934 int key_len; 05935 05936 memset(key_str, 0x00, 100); 05937 memset(iv_str, 0x00, 100); 05938 memset(src_str, 0x00, 100); 05939 memset(dst_str, 0x00, 100); 05940 memset(output, 0x00, 100); 05941 05942 key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffffffffe00000" ); 05943 unhexify( iv_str, "00000000000000000000000000000000" ); 05944 unhexify( src_str, "60136703374f64e860b48ce31f930716" ); 05945 05946 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05947 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05948 hexify( dst_str, output, 16 ); 05949 05950 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05951 } 05952 FCT_TEST_END(); 05953 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05954 05955 #ifdef POLARSSL_CIPHER_MODE_CFB 05956 05957 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_2) 05958 { 05959 unsigned char key_str[100]; 05960 unsigned char iv_str[100]; 05961 unsigned char src_str[100]; 05962 unsigned char dst_str[100]; 05963 unsigned char output[100]; 05964 aes_context ctx; 05965 size_t iv_offset = 0; 05966 int key_len; 05967 05968 memset(key_str, 0x00, 100); 05969 memset(iv_str, 0x00, 100); 05970 memset(src_str, 0x00, 100); 05971 memset(dst_str, 0x00, 100); 05972 memset(output, 0x00, 100); 05973 05974 key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffff00000" ); 05975 unhexify( iv_str, "00000000000000000000000000000000" ); 05976 unhexify( src_str, "8d63a269b14d506ccc401ab8a9f1b591" ); 05977 05978 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 05979 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 05980 hexify( dst_str, output, 16 ); 05981 05982 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 05983 } 05984 FCT_TEST_END(); 05985 #endif /* POLARSSL_CIPHER_MODE_CFB */ 05986 05987 #ifdef POLARSSL_CIPHER_MODE_CFB 05988 05989 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_3) 05990 { 05991 unsigned char key_str[100]; 05992 unsigned char iv_str[100]; 05993 unsigned char src_str[100]; 05994 unsigned char dst_str[100]; 05995 unsigned char output[100]; 05996 aes_context ctx; 05997 size_t iv_offset = 0; 05998 int key_len; 05999 06000 memset(key_str, 0x00, 100); 06001 memset(iv_str, 0x00, 100); 06002 memset(src_str, 0x00, 100); 06003 memset(dst_str, 0x00, 100); 06004 memset(output, 0x00, 100); 06005 06006 key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffff80000" ); 06007 unhexify( iv_str, "00000000000000000000000000000000" ); 06008 unhexify( src_str, "d317f81dc6aa454aee4bd4a5a5cff4bd" ); 06009 06010 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06011 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06012 hexify( dst_str, output, 16 ); 06013 06014 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06015 } 06016 FCT_TEST_END(); 06017 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06018 06019 #ifdef POLARSSL_CIPHER_MODE_CFB 06020 06021 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_4) 06022 { 06023 unsigned char key_str[100]; 06024 unsigned char iv_str[100]; 06025 unsigned char src_str[100]; 06026 unsigned char dst_str[100]; 06027 unsigned char output[100]; 06028 aes_context ctx; 06029 size_t iv_offset = 0; 06030 int key_len; 06031 06032 memset(key_str, 0x00, 100); 06033 memset(iv_str, 0x00, 100); 06034 memset(src_str, 0x00, 100); 06035 memset(dst_str, 0x00, 100); 06036 memset(output, 0x00, 100); 06037 06038 key_len = unhexify( key_str, "98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9" ); 06039 unhexify( iv_str, "00000000000000000000000000000000" ); 06040 unhexify( src_str, "19c80ec4a6deb7e5ed1033dda933498f" ); 06041 06042 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06043 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06044 hexify( dst_str, output, 16 ); 06045 06046 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06047 } 06048 FCT_TEST_END(); 06049 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06050 06051 #ifdef POLARSSL_CIPHER_MODE_CFB 06052 06053 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_5) 06054 { 06055 unsigned char key_str[100]; 06056 unsigned char iv_str[100]; 06057 unsigned char src_str[100]; 06058 unsigned char dst_str[100]; 06059 unsigned char output[100]; 06060 aes_context ctx; 06061 size_t iv_offset = 0; 06062 int key_len; 06063 06064 memset(key_str, 0x00, 100); 06065 memset(iv_str, 0x00, 100); 06066 memset(src_str, 0x00, 100); 06067 memset(dst_str, 0x00, 100); 06068 memset(output, 0x00, 100); 06069 06070 key_len = unhexify( key_str, "b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35" ); 06071 unhexify( iv_str, "00000000000000000000000000000000" ); 06072 unhexify( src_str, "3cf5e1d21a17956d1dffad6a7c41c659" ); 06073 06074 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06075 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06076 hexify( dst_str, output, 16 ); 06077 06078 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06079 } 06080 FCT_TEST_END(); 06081 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06082 06083 #ifdef POLARSSL_CIPHER_MODE_CFB 06084 06085 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_6) 06086 { 06087 unsigned char key_str[100]; 06088 unsigned char iv_str[100]; 06089 unsigned char src_str[100]; 06090 unsigned char dst_str[100]; 06091 unsigned char output[100]; 06092 aes_context ctx; 06093 size_t iv_offset = 0; 06094 int key_len; 06095 06096 memset(key_str, 0x00, 100); 06097 memset(iv_str, 0x00, 100); 06098 memset(src_str, 0x00, 100); 06099 memset(dst_str, 0x00, 100); 06100 memset(output, 0x00, 100); 06101 06102 key_len = unhexify( key_str, "45899367c3132849763073c435a9288a766c8b9ec2308516" ); 06103 unhexify( iv_str, "00000000000000000000000000000000" ); 06104 unhexify( src_str, "69fd12e8505f8ded2fdcb197a121b362" ); 06105 06106 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06107 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06108 hexify( dst_str, output, 16 ); 06109 06110 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06111 } 06112 FCT_TEST_END(); 06113 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06114 06115 #ifdef POLARSSL_CIPHER_MODE_CFB 06116 06117 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_7) 06118 { 06119 unsigned char key_str[100]; 06120 unsigned char iv_str[100]; 06121 unsigned char src_str[100]; 06122 unsigned char dst_str[100]; 06123 unsigned char output[100]; 06124 aes_context ctx; 06125 size_t iv_offset = 0; 06126 int key_len; 06127 06128 memset(key_str, 0x00, 100); 06129 memset(iv_str, 0x00, 100); 06130 memset(src_str, 0x00, 100); 06131 memset(dst_str, 0x00, 100); 06132 memset(output, 0x00, 100); 06133 06134 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 06135 unhexify( iv_str, "1b077a6af4b7f98229de786d7516b639" ); 06136 unhexify( src_str, "275cfc0413d8ccb70513c3859b1d0f72" ); 06137 06138 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06139 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06140 hexify( dst_str, output, 16 ); 06141 06142 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06143 } 06144 FCT_TEST_END(); 06145 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06146 06147 #ifdef POLARSSL_CIPHER_MODE_CFB 06148 06149 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_8) 06150 { 06151 unsigned char key_str[100]; 06152 unsigned char iv_str[100]; 06153 unsigned char src_str[100]; 06154 unsigned char dst_str[100]; 06155 unsigned char output[100]; 06156 aes_context ctx; 06157 size_t iv_offset = 0; 06158 int key_len; 06159 06160 memset(key_str, 0x00, 100); 06161 memset(iv_str, 0x00, 100); 06162 memset(src_str, 0x00, 100); 06163 memset(dst_str, 0x00, 100); 06164 memset(output, 0x00, 100); 06165 06166 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 06167 unhexify( iv_str, "9c2d8842e5f48f57648205d39a239af1" ); 06168 unhexify( src_str, "c9b8135ff1b5adc413dfd053b21bd96d" ); 06169 06170 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06171 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06172 hexify( dst_str, output, 16 ); 06173 06174 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06175 } 06176 FCT_TEST_END(); 06177 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06178 06179 #ifdef POLARSSL_CIPHER_MODE_CFB 06180 06181 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_9) 06182 { 06183 unsigned char key_str[100]; 06184 unsigned char iv_str[100]; 06185 unsigned char src_str[100]; 06186 unsigned char dst_str[100]; 06187 unsigned char output[100]; 06188 aes_context ctx; 06189 size_t iv_offset = 0; 06190 int key_len; 06191 06192 memset(key_str, 0x00, 100); 06193 memset(iv_str, 0x00, 100); 06194 memset(src_str, 0x00, 100); 06195 memset(dst_str, 0x00, 100); 06196 memset(output, 0x00, 100); 06197 06198 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 06199 unhexify( iv_str, "bff52510095f518ecca60af4205444bb" ); 06200 unhexify( src_str, "4a3650c3371ce2eb35e389a171427440" ); 06201 06202 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06203 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06204 hexify( dst_str, output, 16 ); 06205 06206 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06207 } 06208 FCT_TEST_END(); 06209 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06210 06211 #ifdef POLARSSL_CIPHER_MODE_CFB 06212 06213 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_10) 06214 { 06215 unsigned char key_str[100]; 06216 unsigned char iv_str[100]; 06217 unsigned char src_str[100]; 06218 unsigned char dst_str[100]; 06219 unsigned char output[100]; 06220 aes_context ctx; 06221 size_t iv_offset = 0; 06222 int key_len; 06223 06224 memset(key_str, 0x00, 100); 06225 memset(iv_str, 0x00, 100); 06226 memset(src_str, 0x00, 100); 06227 memset(dst_str, 0x00, 100); 06228 memset(output, 0x00, 100); 06229 06230 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 06231 unhexify( iv_str, "ffffffffffffffffffff000000000000" ); 06232 unhexify( src_str, "54d632d03aba0bd0f91877ebdd4d09cb" ); 06233 06234 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06235 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06236 hexify( dst_str, output, 16 ); 06237 06238 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06239 } 06240 FCT_TEST_END(); 06241 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06242 06243 #ifdef POLARSSL_CIPHER_MODE_CFB 06244 06245 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_11) 06246 { 06247 unsigned char key_str[100]; 06248 unsigned char iv_str[100]; 06249 unsigned char src_str[100]; 06250 unsigned char dst_str[100]; 06251 unsigned char output[100]; 06252 aes_context ctx; 06253 size_t iv_offset = 0; 06254 int key_len; 06255 06256 memset(key_str, 0x00, 100); 06257 memset(iv_str, 0x00, 100); 06258 memset(src_str, 0x00, 100); 06259 memset(dst_str, 0x00, 100); 06260 memset(output, 0x00, 100); 06261 06262 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 06263 unhexify( iv_str, "ffffffffffffffffffff800000000000" ); 06264 unhexify( src_str, "d3427be7e4d27cd54f5fe37b03cf0897" ); 06265 06266 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06267 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06268 hexify( dst_str, output, 16 ); 06269 06270 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06271 } 06272 FCT_TEST_END(); 06273 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06274 06275 #ifdef POLARSSL_CIPHER_MODE_CFB 06276 06277 FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_12) 06278 { 06279 unsigned char key_str[100]; 06280 unsigned char iv_str[100]; 06281 unsigned char src_str[100]; 06282 unsigned char dst_str[100]; 06283 unsigned char output[100]; 06284 aes_context ctx; 06285 size_t iv_offset = 0; 06286 int key_len; 06287 06288 memset(key_str, 0x00, 100); 06289 memset(iv_str, 0x00, 100); 06290 memset(src_str, 0x00, 100); 06291 memset(dst_str, 0x00, 100); 06292 memset(output, 0x00, 100); 06293 06294 key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" ); 06295 unhexify( iv_str, "ffffffffffffffffffffc00000000000" ); 06296 unhexify( src_str, "b2099795e88cc158fd75ea133d7e7fbe" ); 06297 06298 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06299 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06300 hexify( dst_str, output, 16 ); 06301 06302 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06303 } 06304 FCT_TEST_END(); 06305 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06306 06307 #ifdef POLARSSL_CIPHER_MODE_CFB 06308 06309 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_1) 06310 { 06311 unsigned char key_str[100]; 06312 unsigned char iv_str[100]; 06313 unsigned char src_str[100]; 06314 unsigned char dst_str[100]; 06315 unsigned char output[100]; 06316 aes_context ctx; 06317 size_t iv_offset = 0; 06318 int key_len; 06319 06320 memset(key_str, 0x00, 100); 06321 memset(iv_str, 0x00, 100); 06322 memset(src_str, 0x00, 100); 06323 memset(dst_str, 0x00, 100); 06324 memset(output, 0x00, 100); 06325 06326 key_len = unhexify( key_str, "ffffffe000000000000000000000000000000000000000000000000000000000" ); 06327 unhexify( iv_str, "00000000000000000000000000000000" ); 06328 unhexify( src_str, "00000000000000000000000000000000" ); 06329 06330 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06331 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06332 hexify( dst_str, output, 16 ); 06333 06334 fct_chk( strcmp( (char *) dst_str, "bbd1097a62433f79449fa97d4ee80dbf" ) == 0 ); 06335 } 06336 FCT_TEST_END(); 06337 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06338 06339 #ifdef POLARSSL_CIPHER_MODE_CFB 06340 06341 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_2) 06342 { 06343 unsigned char key_str[100]; 06344 unsigned char iv_str[100]; 06345 unsigned char src_str[100]; 06346 unsigned char dst_str[100]; 06347 unsigned char output[100]; 06348 aes_context ctx; 06349 size_t iv_offset = 0; 06350 int key_len; 06351 06352 memset(key_str, 0x00, 100); 06353 memset(iv_str, 0x00, 100); 06354 memset(src_str, 0x00, 100); 06355 memset(dst_str, 0x00, 100); 06356 memset(output, 0x00, 100); 06357 06358 key_len = unhexify( key_str, "fffffff000000000000000000000000000000000000000000000000000000000" ); 06359 unhexify( iv_str, "00000000000000000000000000000000" ); 06360 unhexify( src_str, "00000000000000000000000000000000" ); 06361 06362 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06363 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06364 hexify( dst_str, output, 16 ); 06365 06366 fct_chk( strcmp( (char *) dst_str, "07058e408f5b99b0e0f061a1761b5b3b" ) == 0 ); 06367 } 06368 FCT_TEST_END(); 06369 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06370 06371 #ifdef POLARSSL_CIPHER_MODE_CFB 06372 06373 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_3) 06374 { 06375 unsigned char key_str[100]; 06376 unsigned char iv_str[100]; 06377 unsigned char src_str[100]; 06378 unsigned char dst_str[100]; 06379 unsigned char output[100]; 06380 aes_context ctx; 06381 size_t iv_offset = 0; 06382 int key_len; 06383 06384 memset(key_str, 0x00, 100); 06385 memset(iv_str, 0x00, 100); 06386 memset(src_str, 0x00, 100); 06387 memset(dst_str, 0x00, 100); 06388 memset(output, 0x00, 100); 06389 06390 key_len = unhexify( key_str, "fffffff800000000000000000000000000000000000000000000000000000000" ); 06391 unhexify( iv_str, "00000000000000000000000000000000" ); 06392 unhexify( src_str, "00000000000000000000000000000000" ); 06393 06394 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06395 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06396 hexify( dst_str, output, 16 ); 06397 06398 fct_chk( strcmp( (char *) dst_str, "5fd1f13fa0f31e37fabde328f894eac2" ) == 0 ); 06399 } 06400 FCT_TEST_END(); 06401 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06402 06403 #ifdef POLARSSL_CIPHER_MODE_CFB 06404 06405 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_4) 06406 { 06407 unsigned char key_str[100]; 06408 unsigned char iv_str[100]; 06409 unsigned char src_str[100]; 06410 unsigned char dst_str[100]; 06411 unsigned char output[100]; 06412 aes_context ctx; 06413 size_t iv_offset = 0; 06414 int key_len; 06415 06416 memset(key_str, 0x00, 100); 06417 memset(iv_str, 0x00, 100); 06418 memset(src_str, 0x00, 100); 06419 memset(dst_str, 0x00, 100); 06420 memset(output, 0x00, 100); 06421 06422 key_len = unhexify( key_str, "13428b5e4c005e0636dd338405d173ab135dec2a25c22c5df0722d69dcc43887" ); 06423 unhexify( iv_str, "00000000000000000000000000000000" ); 06424 unhexify( src_str, "00000000000000000000000000000000" ); 06425 06426 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06427 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06428 hexify( dst_str, output, 16 ); 06429 06430 fct_chk( strcmp( (char *) dst_str, "649a71545378c783e368c9ade7114f6c" ) == 0 ); 06431 } 06432 FCT_TEST_END(); 06433 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06434 06435 #ifdef POLARSSL_CIPHER_MODE_CFB 06436 06437 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_5) 06438 { 06439 unsigned char key_str[100]; 06440 unsigned char iv_str[100]; 06441 unsigned char src_str[100]; 06442 unsigned char dst_str[100]; 06443 unsigned char output[100]; 06444 aes_context ctx; 06445 size_t iv_offset = 0; 06446 int key_len; 06447 06448 memset(key_str, 0x00, 100); 06449 memset(iv_str, 0x00, 100); 06450 memset(src_str, 0x00, 100); 06451 memset(dst_str, 0x00, 100); 06452 memset(output, 0x00, 100); 06453 06454 key_len = unhexify( key_str, "07eb03a08d291d1b07408bf3512ab40c91097ac77461aad4bb859647f74f00ee" ); 06455 unhexify( iv_str, "00000000000000000000000000000000" ); 06456 unhexify( src_str, "00000000000000000000000000000000" ); 06457 06458 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06459 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06460 hexify( dst_str, output, 16 ); 06461 06462 fct_chk( strcmp( (char *) dst_str, "47cb030da2ab051dfc6c4bf6910d12bb" ) == 0 ); 06463 } 06464 FCT_TEST_END(); 06465 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06466 06467 #ifdef POLARSSL_CIPHER_MODE_CFB 06468 06469 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_6) 06470 { 06471 unsigned char key_str[100]; 06472 unsigned char iv_str[100]; 06473 unsigned char src_str[100]; 06474 unsigned char dst_str[100]; 06475 unsigned char output[100]; 06476 aes_context ctx; 06477 size_t iv_offset = 0; 06478 int key_len; 06479 06480 memset(key_str, 0x00, 100); 06481 memset(iv_str, 0x00, 100); 06482 memset(src_str, 0x00, 100); 06483 memset(dst_str, 0x00, 100); 06484 memset(output, 0x00, 100); 06485 06486 key_len = unhexify( key_str, "90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1" ); 06487 unhexify( iv_str, "00000000000000000000000000000000" ); 06488 unhexify( src_str, "00000000000000000000000000000000" ); 06489 06490 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06491 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06492 hexify( dst_str, output, 16 ); 06493 06494 fct_chk( strcmp( (char *) dst_str, "798c7c005dee432b2c8ea5dfa381ecc3" ) == 0 ); 06495 } 06496 FCT_TEST_END(); 06497 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06498 06499 #ifdef POLARSSL_CIPHER_MODE_CFB 06500 06501 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_7) 06502 { 06503 unsigned char key_str[100]; 06504 unsigned char iv_str[100]; 06505 unsigned char src_str[100]; 06506 unsigned char dst_str[100]; 06507 unsigned char output[100]; 06508 aes_context ctx; 06509 size_t iv_offset = 0; 06510 int key_len; 06511 06512 memset(key_str, 0x00, 100); 06513 memset(iv_str, 0x00, 100); 06514 memset(src_str, 0x00, 100); 06515 memset(dst_str, 0x00, 100); 06516 memset(output, 0x00, 100); 06517 06518 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 06519 unhexify( iv_str, "0b24af36193ce4665f2825d7b4749c98" ); 06520 unhexify( src_str, "00000000000000000000000000000000" ); 06521 06522 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06523 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06524 hexify( dst_str, output, 16 ); 06525 06526 fct_chk( strcmp( (char *) dst_str, "a9ff75bd7cf6613d3731c77c3b6d0c04" ) == 0 ); 06527 } 06528 FCT_TEST_END(); 06529 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06530 06531 #ifdef POLARSSL_CIPHER_MODE_CFB 06532 06533 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_8) 06534 { 06535 unsigned char key_str[100]; 06536 unsigned char iv_str[100]; 06537 unsigned char src_str[100]; 06538 unsigned char dst_str[100]; 06539 unsigned char output[100]; 06540 aes_context ctx; 06541 size_t iv_offset = 0; 06542 int key_len; 06543 06544 memset(key_str, 0x00, 100); 06545 memset(iv_str, 0x00, 100); 06546 memset(src_str, 0x00, 100); 06547 memset(dst_str, 0x00, 100); 06548 memset(output, 0x00, 100); 06549 06550 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 06551 unhexify( iv_str, "761c1fe41a18acf20d241650611d90f1" ); 06552 unhexify( src_str, "00000000000000000000000000000000" ); 06553 06554 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06555 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06556 hexify( dst_str, output, 16 ); 06557 06558 fct_chk( strcmp( (char *) dst_str, "623a52fcea5d443e48d9181ab32c7421" ) == 0 ); 06559 } 06560 FCT_TEST_END(); 06561 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06562 06563 #ifdef POLARSSL_CIPHER_MODE_CFB 06564 06565 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_9) 06566 { 06567 unsigned char key_str[100]; 06568 unsigned char iv_str[100]; 06569 unsigned char src_str[100]; 06570 unsigned char dst_str[100]; 06571 unsigned char output[100]; 06572 aes_context ctx; 06573 size_t iv_offset = 0; 06574 int key_len; 06575 06576 memset(key_str, 0x00, 100); 06577 memset(iv_str, 0x00, 100); 06578 memset(src_str, 0x00, 100); 06579 memset(dst_str, 0x00, 100); 06580 memset(output, 0x00, 100); 06581 06582 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 06583 unhexify( iv_str, "8a560769d605868ad80d819bdba03771" ); 06584 unhexify( src_str, "00000000000000000000000000000000" ); 06585 06586 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06587 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06588 hexify( dst_str, output, 16 ); 06589 06590 fct_chk( strcmp( (char *) dst_str, "38f2c7ae10612415d27ca190d27da8b4" ) == 0 ); 06591 } 06592 FCT_TEST_END(); 06593 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06594 06595 #ifdef POLARSSL_CIPHER_MODE_CFB 06596 06597 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_10) 06598 { 06599 unsigned char key_str[100]; 06600 unsigned char iv_str[100]; 06601 unsigned char src_str[100]; 06602 unsigned char dst_str[100]; 06603 unsigned char output[100]; 06604 aes_context ctx; 06605 size_t iv_offset = 0; 06606 int key_len; 06607 06608 memset(key_str, 0x00, 100); 06609 memset(iv_str, 0x00, 100); 06610 memset(src_str, 0x00, 100); 06611 memset(dst_str, 0x00, 100); 06612 memset(output, 0x00, 100); 06613 06614 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 06615 unhexify( iv_str, "ffffffffffffffffffffffffe0000000" ); 06616 unhexify( src_str, "00000000000000000000000000000000" ); 06617 06618 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06619 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06620 hexify( dst_str, output, 16 ); 06621 06622 fct_chk( strcmp( (char *) dst_str, "2be1fae5048a25582a679ca10905eb80" ) == 0 ); 06623 } 06624 FCT_TEST_END(); 06625 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06626 06627 #ifdef POLARSSL_CIPHER_MODE_CFB 06628 06629 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_11) 06630 { 06631 unsigned char key_str[100]; 06632 unsigned char iv_str[100]; 06633 unsigned char src_str[100]; 06634 unsigned char dst_str[100]; 06635 unsigned char output[100]; 06636 aes_context ctx; 06637 size_t iv_offset = 0; 06638 int key_len; 06639 06640 memset(key_str, 0x00, 100); 06641 memset(iv_str, 0x00, 100); 06642 memset(src_str, 0x00, 100); 06643 memset(dst_str, 0x00, 100); 06644 memset(output, 0x00, 100); 06645 06646 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 06647 unhexify( iv_str, "fffffffffffffffffffffffff0000000" ); 06648 unhexify( src_str, "00000000000000000000000000000000" ); 06649 06650 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06651 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06652 hexify( dst_str, output, 16 ); 06653 06654 fct_chk( strcmp( (char *) dst_str, "da86f292c6f41ea34fb2068df75ecc29" ) == 0 ); 06655 } 06656 FCT_TEST_END(); 06657 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06658 06659 #ifdef POLARSSL_CIPHER_MODE_CFB 06660 06661 FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_12) 06662 { 06663 unsigned char key_str[100]; 06664 unsigned char iv_str[100]; 06665 unsigned char src_str[100]; 06666 unsigned char dst_str[100]; 06667 unsigned char output[100]; 06668 aes_context ctx; 06669 size_t iv_offset = 0; 06670 int key_len; 06671 06672 memset(key_str, 0x00, 100); 06673 memset(iv_str, 0x00, 100); 06674 memset(src_str, 0x00, 100); 06675 memset(dst_str, 0x00, 100); 06676 memset(output, 0x00, 100); 06677 06678 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 06679 unhexify( iv_str, "fffffffffffffffffffffffff8000000" ); 06680 unhexify( src_str, "00000000000000000000000000000000" ); 06681 06682 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06683 fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06684 hexify( dst_str, output, 16 ); 06685 06686 fct_chk( strcmp( (char *) dst_str, "220df19f85d69b1b562fa69a3c5beca5" ) == 0 ); 06687 } 06688 FCT_TEST_END(); 06689 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06690 06691 #ifdef POLARSSL_CIPHER_MODE_CFB 06692 06693 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_1) 06694 { 06695 unsigned char key_str[100]; 06696 unsigned char iv_str[100]; 06697 unsigned char src_str[100]; 06698 unsigned char dst_str[100]; 06699 unsigned char output[100]; 06700 aes_context ctx; 06701 size_t iv_offset = 0; 06702 int key_len; 06703 06704 memset(key_str, 0x00, 100); 06705 memset(iv_str, 0x00, 100); 06706 memset(src_str, 0x00, 100); 06707 memset(dst_str, 0x00, 100); 06708 memset(output, 0x00, 100); 06709 06710 key_len = unhexify( key_str, "ffffffffff800000000000000000000000000000000000000000000000000000" ); 06711 unhexify( iv_str, "00000000000000000000000000000000" ); 06712 unhexify( src_str, "be66cfea2fecd6bf0ec7b4352c99bcaa" ); 06713 06714 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06715 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06716 hexify( dst_str, output, 16 ); 06717 06718 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06719 } 06720 FCT_TEST_END(); 06721 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06722 06723 #ifdef POLARSSL_CIPHER_MODE_CFB 06724 06725 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_2) 06726 { 06727 unsigned char key_str[100]; 06728 unsigned char iv_str[100]; 06729 unsigned char src_str[100]; 06730 unsigned char dst_str[100]; 06731 unsigned char output[100]; 06732 aes_context ctx; 06733 size_t iv_offset = 0; 06734 int key_len; 06735 06736 memset(key_str, 0x00, 100); 06737 memset(iv_str, 0x00, 100); 06738 memset(src_str, 0x00, 100); 06739 memset(dst_str, 0x00, 100); 06740 memset(output, 0x00, 100); 06741 06742 key_len = unhexify( key_str, "ffffffffffc00000000000000000000000000000000000000000000000000000" ); 06743 unhexify( iv_str, "00000000000000000000000000000000" ); 06744 unhexify( src_str, "df31144f87a2ef523facdcf21a427804" ); 06745 06746 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06747 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06748 hexify( dst_str, output, 16 ); 06749 06750 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06751 } 06752 FCT_TEST_END(); 06753 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06754 06755 #ifdef POLARSSL_CIPHER_MODE_CFB 06756 06757 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_3) 06758 { 06759 unsigned char key_str[100]; 06760 unsigned char iv_str[100]; 06761 unsigned char src_str[100]; 06762 unsigned char dst_str[100]; 06763 unsigned char output[100]; 06764 aes_context ctx; 06765 size_t iv_offset = 0; 06766 int key_len; 06767 06768 memset(key_str, 0x00, 100); 06769 memset(iv_str, 0x00, 100); 06770 memset(src_str, 0x00, 100); 06771 memset(dst_str, 0x00, 100); 06772 memset(output, 0x00, 100); 06773 06774 key_len = unhexify( key_str, "ffffffffffe00000000000000000000000000000000000000000000000000000" ); 06775 unhexify( iv_str, "00000000000000000000000000000000" ); 06776 unhexify( src_str, "b5bb0f5629fb6aae5e1839a3c3625d63" ); 06777 06778 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06779 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06780 hexify( dst_str, output, 16 ); 06781 06782 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06783 } 06784 FCT_TEST_END(); 06785 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06786 06787 #ifdef POLARSSL_CIPHER_MODE_CFB 06788 06789 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_4) 06790 { 06791 unsigned char key_str[100]; 06792 unsigned char iv_str[100]; 06793 unsigned char src_str[100]; 06794 unsigned char dst_str[100]; 06795 unsigned char output[100]; 06796 aes_context ctx; 06797 size_t iv_offset = 0; 06798 int key_len; 06799 06800 memset(key_str, 0x00, 100); 06801 memset(iv_str, 0x00, 100); 06802 memset(src_str, 0x00, 100); 06803 memset(dst_str, 0x00, 100); 06804 memset(output, 0x00, 100); 06805 06806 key_len = unhexify( key_str, "1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9" ); 06807 unhexify( iv_str, "00000000000000000000000000000000" ); 06808 unhexify( src_str, "531c2c38344578b84d50b3c917bbb6e1" ); 06809 06810 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06811 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06812 hexify( dst_str, output, 16 ); 06813 06814 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06815 } 06816 FCT_TEST_END(); 06817 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06818 06819 #ifdef POLARSSL_CIPHER_MODE_CFB 06820 06821 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_5) 06822 { 06823 unsigned char key_str[100]; 06824 unsigned char iv_str[100]; 06825 unsigned char src_str[100]; 06826 unsigned char dst_str[100]; 06827 unsigned char output[100]; 06828 aes_context ctx; 06829 size_t iv_offset = 0; 06830 int key_len; 06831 06832 memset(key_str, 0x00, 100); 06833 memset(iv_str, 0x00, 100); 06834 memset(src_str, 0x00, 100); 06835 memset(dst_str, 0x00, 100); 06836 memset(output, 0x00, 100); 06837 06838 key_len = unhexify( key_str, "dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf" ); 06839 unhexify( iv_str, "00000000000000000000000000000000" ); 06840 unhexify( src_str, "fc6aec906323480005c58e7e1ab004ad" ); 06841 06842 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06843 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06844 hexify( dst_str, output, 16 ); 06845 06846 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06847 } 06848 FCT_TEST_END(); 06849 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06850 06851 #ifdef POLARSSL_CIPHER_MODE_CFB 06852 06853 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_6) 06854 { 06855 unsigned char key_str[100]; 06856 unsigned char iv_str[100]; 06857 unsigned char src_str[100]; 06858 unsigned char dst_str[100]; 06859 unsigned char output[100]; 06860 aes_context ctx; 06861 size_t iv_offset = 0; 06862 int key_len; 06863 06864 memset(key_str, 0x00, 100); 06865 memset(iv_str, 0x00, 100); 06866 memset(src_str, 0x00, 100); 06867 memset(dst_str, 0x00, 100); 06868 memset(output, 0x00, 100); 06869 06870 key_len = unhexify( key_str, "f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9" ); 06871 unhexify( iv_str, "00000000000000000000000000000000" ); 06872 unhexify( src_str, "a3944b95ca0b52043584ef02151926a8" ); 06873 06874 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06875 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06876 hexify( dst_str, output, 16 ); 06877 06878 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06879 } 06880 FCT_TEST_END(); 06881 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06882 06883 #ifdef POLARSSL_CIPHER_MODE_CFB 06884 06885 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_7) 06886 { 06887 unsigned char key_str[100]; 06888 unsigned char iv_str[100]; 06889 unsigned char src_str[100]; 06890 unsigned char dst_str[100]; 06891 unsigned char output[100]; 06892 aes_context ctx; 06893 size_t iv_offset = 0; 06894 int key_len; 06895 06896 memset(key_str, 0x00, 100); 06897 memset(iv_str, 0x00, 100); 06898 memset(src_str, 0x00, 100); 06899 memset(dst_str, 0x00, 100); 06900 memset(output, 0x00, 100); 06901 06902 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 06903 unhexify( iv_str, "761c1fe41a18acf20d241650611d90f1" ); 06904 unhexify( src_str, "623a52fcea5d443e48d9181ab32c7421" ); 06905 06906 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06907 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06908 hexify( dst_str, output, 16 ); 06909 06910 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06911 } 06912 FCT_TEST_END(); 06913 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06914 06915 #ifdef POLARSSL_CIPHER_MODE_CFB 06916 06917 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_8) 06918 { 06919 unsigned char key_str[100]; 06920 unsigned char iv_str[100]; 06921 unsigned char src_str[100]; 06922 unsigned char dst_str[100]; 06923 unsigned char output[100]; 06924 aes_context ctx; 06925 size_t iv_offset = 0; 06926 int key_len; 06927 06928 memset(key_str, 0x00, 100); 06929 memset(iv_str, 0x00, 100); 06930 memset(src_str, 0x00, 100); 06931 memset(dst_str, 0x00, 100); 06932 memset(output, 0x00, 100); 06933 06934 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 06935 unhexify( iv_str, "8a560769d605868ad80d819bdba03771" ); 06936 unhexify( src_str, "38f2c7ae10612415d27ca190d27da8b4" ); 06937 06938 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06939 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06940 hexify( dst_str, output, 16 ); 06941 06942 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06943 } 06944 FCT_TEST_END(); 06945 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06946 06947 #ifdef POLARSSL_CIPHER_MODE_CFB 06948 06949 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_9) 06950 { 06951 unsigned char key_str[100]; 06952 unsigned char iv_str[100]; 06953 unsigned char src_str[100]; 06954 unsigned char dst_str[100]; 06955 unsigned char output[100]; 06956 aes_context ctx; 06957 size_t iv_offset = 0; 06958 int key_len; 06959 06960 memset(key_str, 0x00, 100); 06961 memset(iv_str, 0x00, 100); 06962 memset(src_str, 0x00, 100); 06963 memset(dst_str, 0x00, 100); 06964 memset(output, 0x00, 100); 06965 06966 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 06967 unhexify( iv_str, "91fbef2d15a97816060bee1feaa49afe" ); 06968 unhexify( src_str, "1bc704f1bce135ceb810341b216d7abe" ); 06969 06970 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 06971 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 06972 hexify( dst_str, output, 16 ); 06973 06974 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 06975 } 06976 FCT_TEST_END(); 06977 #endif /* POLARSSL_CIPHER_MODE_CFB */ 06978 06979 #ifdef POLARSSL_CIPHER_MODE_CFB 06980 06981 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_10) 06982 { 06983 unsigned char key_str[100]; 06984 unsigned char iv_str[100]; 06985 unsigned char src_str[100]; 06986 unsigned char dst_str[100]; 06987 unsigned char output[100]; 06988 aes_context ctx; 06989 size_t iv_offset = 0; 06990 int key_len; 06991 06992 memset(key_str, 0x00, 100); 06993 memset(iv_str, 0x00, 100); 06994 memset(src_str, 0x00, 100); 06995 memset(dst_str, 0x00, 100); 06996 memset(output, 0x00, 100); 06997 06998 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 06999 unhexify( iv_str, "e0000000000000000000000000000000" ); 07000 unhexify( src_str, "9b80eefb7ebe2d2b16247aa0efc72f5d" ); 07001 07002 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 07003 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 07004 hexify( dst_str, output, 16 ); 07005 07006 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 07007 } 07008 FCT_TEST_END(); 07009 #endif /* POLARSSL_CIPHER_MODE_CFB */ 07010 07011 #ifdef POLARSSL_CIPHER_MODE_CFB 07012 07013 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_11) 07014 { 07015 unsigned char key_str[100]; 07016 unsigned char iv_str[100]; 07017 unsigned char src_str[100]; 07018 unsigned char dst_str[100]; 07019 unsigned char output[100]; 07020 aes_context ctx; 07021 size_t iv_offset = 0; 07022 int key_len; 07023 07024 memset(key_str, 0x00, 100); 07025 memset(iv_str, 0x00, 100); 07026 memset(src_str, 0x00, 100); 07027 memset(dst_str, 0x00, 100); 07028 memset(output, 0x00, 100); 07029 07030 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 07031 unhexify( iv_str, "f0000000000000000000000000000000" ); 07032 unhexify( src_str, "7f2c5ece07a98d8bee13c51177395ff7" ); 07033 07034 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 07035 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 07036 hexify( dst_str, output, 16 ); 07037 07038 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 07039 } 07040 FCT_TEST_END(); 07041 #endif /* POLARSSL_CIPHER_MODE_CFB */ 07042 07043 #ifdef POLARSSL_CIPHER_MODE_CFB 07044 07045 FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_12) 07046 { 07047 unsigned char key_str[100]; 07048 unsigned char iv_str[100]; 07049 unsigned char src_str[100]; 07050 unsigned char dst_str[100]; 07051 unsigned char output[100]; 07052 aes_context ctx; 07053 size_t iv_offset = 0; 07054 int key_len; 07055 07056 memset(key_str, 0x00, 100); 07057 memset(iv_str, 0x00, 100); 07058 memset(src_str, 0x00, 100); 07059 memset(dst_str, 0x00, 100); 07060 memset(output, 0x00, 100); 07061 07062 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 07063 unhexify( iv_str, "f8000000000000000000000000000000" ); 07064 unhexify( src_str, "7818d800dcf6f4be1e0e94f403d1e4c2" ); 07065 07066 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 07067 fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); 07068 hexify( dst_str, output, 16 ); 07069 07070 fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 ); 07071 } 07072 FCT_TEST_END(); 07073 #endif /* POLARSSL_CIPHER_MODE_CFB */ 07074 07075 07076 FCT_TEST_BGN(aes_ecb_encrypt_invalid_keylength) 07077 { 07078 unsigned char key_str[100]; 07079 unsigned char src_str[100]; 07080 unsigned char dst_str[100]; 07081 unsigned char output[100]; 07082 aes_context ctx; 07083 int key_len; 07084 07085 memset(key_str, 0x00, 100); 07086 memset(src_str, 0x00, 100); 07087 memset(dst_str, 0x00, 100); 07088 memset(output, 0x00, 100); 07089 07090 key_len = unhexify( key_str, "000000000000000000000000000000" ); 07091 unhexify( src_str, "f34481ec3cc627bacd5dc3fb08f273e6" ); 07092 07093 fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == POLARSSL_ERR_AES_INVALID_KEY_LENGTH ); 07094 if( POLARSSL_ERR_AES_INVALID_KEY_LENGTH == 0 ) 07095 { 07096 fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 ); 07097 hexify( dst_str, output, 16 ); 07098 07099 fct_chk( strcmp( (char *) dst_str, "0336763e966d92595a567cc9ce537f5e" ) == 0 ); 07100 } 07101 } 07102 FCT_TEST_END(); 07103 07104 07105 FCT_TEST_BGN(aes_ecb_decrypt_invalid_keylength) 07106 { 07107 unsigned char key_str[100]; 07108 unsigned char src_str[100]; 07109 unsigned char dst_str[100]; 07110 unsigned char output[100]; 07111 aes_context ctx; 07112 int key_len; 07113 07114 memset(key_str, 0x00, 100); 07115 memset(src_str, 0x00, 100); 07116 memset(dst_str, 0x00, 100); 07117 memset(output, 0x00, 100); 07118 07119 key_len = unhexify( key_str, "000000000000000000000000000000" ); 07120 unhexify( src_str, "f34481ec3cc627bacd5dc3fb08f273e6" ); 07121 07122 fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == POLARSSL_ERR_AES_INVALID_KEY_LENGTH ); 07123 if( POLARSSL_ERR_AES_INVALID_KEY_LENGTH == 0 ) 07124 { 07125 fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 ); 07126 hexify( dst_str, output, 16 ); 07127 07128 fct_chk( strcmp( (char *) dst_str, "0336763e966d92595a567cc9ce537f5e" ) == 0 ); 07129 } 07130 } 07131 FCT_TEST_END(); 07132 07133 07134 FCT_TEST_BGN(aes_256_cbc_encrypt_invalid_input_length) 07135 { 07136 unsigned char key_str[100]; 07137 unsigned char iv_str[100]; 07138 unsigned char src_str[100]; 07139 unsigned char dst_str[100]; 07140 unsigned char output[100]; 07141 aes_context ctx; 07142 int key_len, data_len; 07143 07144 memset(key_str, 0x00, 100); 07145 memset(iv_str, 0x00, 100); 07146 memset(src_str, 0x00, 100); 07147 memset(dst_str, 0x00, 100); 07148 memset(output, 0x00, 100); 07149 07150 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 07151 unhexify( iv_str, "00000000000000000000000000000000" ); 07152 data_len = unhexify( src_str, "ffffffffffffffe000000000000000" ); 07153 07154 aes_setkey_enc( &ctx, key_str, key_len * 8 ); 07155 fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == POLARSSL_ERR_AES_INVALID_INPUT_LENGTH ); 07156 if( POLARSSL_ERR_AES_INVALID_INPUT_LENGTH == 0 ) 07157 { 07158 hexify( dst_str, output, data_len ); 07159 07160 fct_chk( strcmp( (char *) dst_str, "" ) == 0 ); 07161 } 07162 } 07163 FCT_TEST_END(); 07164 07165 07166 FCT_TEST_BGN(aes_256_cbc_decrypt_invalid_input_length) 07167 { 07168 unsigned char key_str[100]; 07169 unsigned char iv_str[100]; 07170 unsigned char src_str[100]; 07171 unsigned char dst_str[100]; 07172 unsigned char output[100]; 07173 aes_context ctx; 07174 int key_len, data_len; 07175 07176 memset(key_str, 0x00, 100); 07177 memset(iv_str, 0x00, 100); 07178 memset(src_str, 0x00, 100); 07179 memset(dst_str, 0x00, 100); 07180 memset(output, 0x00, 100); 07181 07182 key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" ); 07183 unhexify( iv_str, "00000000000000000000000000000000" ); 07184 data_len = unhexify( src_str, "623a52fcea5d443e48d9181ab32c74" ); 07185 07186 aes_setkey_dec( &ctx, key_str, key_len * 8 ); 07187 fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == POLARSSL_ERR_AES_INVALID_INPUT_LENGTH ); 07188 if( POLARSSL_ERR_AES_INVALID_INPUT_LENGTH == 0) 07189 { 07190 hexify( dst_str, output, data_len ); 07191 07192 fct_chk( strcmp( (char *) dst_str, "" ) == 0 ); 07193 } 07194 } 07195 FCT_TEST_END(); 07196 07197 #ifdef POLARSSL_SELF_TEST 07198 07199 FCT_TEST_BGN(aes_selftest) 07200 { 07201 fct_chk( aes_self_test( 0 ) == 0 ); 07202 } 07203 FCT_TEST_END(); 07204 #endif /* POLARSSL_SELF_TEST */ 07205 07206 } 07207 FCT_SUITE_END(); 07208 07209 #endif /* POLARSSL_AES_C */ 07210 07211 } 07212 FCT_END(); 07213