diff options
| author | jsing <> | 2014-05-31 14:39:06 +0000 |
|---|---|---|
| committer | jsing <> | 2014-05-31 14:39:06 +0000 |
| commit | 2e095c059a16c4644dd1bba604bd92bcdb683046 (patch) | |
| tree | 5bde067d164b57e2512426ccb58393934b962a4a /src | |
| parent | b70f38e23f94798874942f0c46cde6f3d32aa5bc (diff) | |
| download | openbsd-2e095c059a16c4644dd1bba604bd92bcdb683046.tar.gz openbsd-2e095c059a16c4644dd1bba604bd92bcdb683046.tar.bz2 openbsd-2e095c059a16c4644dd1bba604bd92bcdb683046.zip | |
Move the cts128 and gcm128 tests to regress.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/modes/cts128.c | 152 | ||||
| -rw-r--r-- | src/lib/libcrypto/modes/gcm128.c | 307 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/modes/cts128.c | 152 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/modes/gcm128.c | 307 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/Makefile | 3 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/cts128/Makefile | 7 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/cts128/cts128test.c | 160 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/gcm128/Makefile | 8 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/gcm128/gcm128test.c | 358 |
9 files changed, 530 insertions, 924 deletions
diff --git a/src/lib/libcrypto/modes/cts128.c b/src/lib/libcrypto/modes/cts128.c index 2d583de6f6..37bd05ed29 100644 --- a/src/lib/libcrypto/modes/cts128.c +++ b/src/lib/libcrypto/modes/cts128.c | |||
| @@ -299,155 +299,3 @@ size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out, | |||
| 299 | #endif | 299 | #endif |
| 300 | return 16+len+residue; | 300 | return 16+len+residue; |
| 301 | } | 301 | } |
| 302 | |||
| 303 | #if defined(SELFTEST) | ||
| 304 | #include <stdio.h> | ||
| 305 | #include <openssl/aes.h> | ||
| 306 | |||
| 307 | /* test vectors from RFC 3962 */ | ||
| 308 | static const unsigned char test_key[16] = "chicken teriyaki"; | ||
| 309 | static const unsigned char test_input[64] = | ||
| 310 | "I would like the" " General Gau's C" | ||
| 311 | "hicken, please, " "and wonton soup."; | ||
| 312 | static const unsigned char test_iv[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | ||
| 313 | |||
| 314 | static const unsigned char vector_17[17] = | ||
| 315 | {0xc6,0x35,0x35,0x68,0xf2,0xbf,0x8c,0xb4, 0xd8,0xa5,0x80,0x36,0x2d,0xa7,0xff,0x7f, | ||
| 316 | 0x97}; | ||
| 317 | static const unsigned char vector_31[31] = | ||
| 318 | {0xfc,0x00,0x78,0x3e,0x0e,0xfd,0xb2,0xc1, 0xd4,0x45,0xd4,0xc8,0xef,0xf7,0xed,0x22, | ||
| 319 | 0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5}; | ||
| 320 | static const unsigned char vector_32[32] = | ||
| 321 | {0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8, | ||
| 322 | 0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84}; | ||
| 323 | static const unsigned char vector_47[47] = | ||
| 324 | {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, | ||
| 325 | 0xb3,0xff,0xfd,0x94,0x0c,0x16,0xa1,0x8c, 0x1b,0x55,0x49,0xd2,0xf8,0x38,0x02,0x9e, | ||
| 326 | 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5}; | ||
| 327 | static const unsigned char vector_48[48] = | ||
| 328 | {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, | ||
| 329 | 0x9d,0xad,0x8b,0xbb,0x96,0xc4,0xcd,0xc0, 0x3b,0xc1,0x03,0xe1,0xa1,0x94,0xbb,0xd8, | ||
| 330 | 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8}; | ||
| 331 | static const unsigned char vector_64[64] = | ||
| 332 | {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, | ||
| 333 | 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8, | ||
| 334 | 0x48,0x07,0xef,0xe8,0x36,0xee,0x89,0xa5, 0x26,0x73,0x0d,0xbc,0x2f,0x7b,0xc8,0x40, | ||
| 335 | 0x9d,0xad,0x8b,0xbb,0x96,0xc4,0xcd,0xc0, 0x3b,0xc1,0x03,0xe1,0xa1,0x94,0xbb,0xd8}; | ||
| 336 | |||
| 337 | static AES_KEY encks, decks; | ||
| 338 | |||
| 339 | void test_vector(const unsigned char *vector,size_t len) | ||
| 340 | { unsigned char iv[sizeof(test_iv)]; | ||
| 341 | unsigned char cleartext[64],ciphertext[64]; | ||
| 342 | size_t tail; | ||
| 343 | |||
| 344 | printf("vector_%d\n",len); fflush(stdout); | ||
| 345 | |||
| 346 | if ((tail=len%16) == 0) tail = 16; | ||
| 347 | tail += 16; | ||
| 348 | |||
| 349 | /* test block-based encryption */ | ||
| 350 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 351 | CRYPTO_cts128_encrypt_block(test_input,ciphertext,len,&encks,iv,(block128_f)AES_encrypt); | ||
| 352 | if (memcmp(ciphertext,vector,len)) | ||
| 353 | fprintf(stderr,"output_%d mismatch\n",len), exit(1); | ||
| 354 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 355 | fprintf(stderr,"iv_%d mismatch\n",len), exit(1); | ||
| 356 | |||
| 357 | /* test block-based decryption */ | ||
| 358 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 359 | CRYPTO_cts128_decrypt_block(ciphertext,cleartext,len,&decks,iv,(block128_f)AES_decrypt); | ||
| 360 | if (memcmp(cleartext,test_input,len)) | ||
| 361 | fprintf(stderr,"input_%d mismatch\n",len), exit(2); | ||
| 362 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 363 | fprintf(stderr,"iv_%d mismatch\n",len), exit(2); | ||
| 364 | |||
| 365 | /* test streamed encryption */ | ||
| 366 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 367 | CRYPTO_cts128_encrypt(test_input,ciphertext,len,&encks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 368 | if (memcmp(ciphertext,vector,len)) | ||
| 369 | fprintf(stderr,"output_%d mismatch\n",len), exit(3); | ||
| 370 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 371 | fprintf(stderr,"iv_%d mismatch\n",len), exit(3); | ||
| 372 | |||
| 373 | /* test streamed decryption */ | ||
| 374 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 375 | CRYPTO_cts128_decrypt(ciphertext,cleartext,len,&decks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 376 | if (memcmp(cleartext,test_input,len)) | ||
| 377 | fprintf(stderr,"input_%d mismatch\n",len), exit(4); | ||
| 378 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 379 | fprintf(stderr,"iv_%d mismatch\n",len), exit(4); | ||
| 380 | } | ||
| 381 | |||
| 382 | void test_nistvector(const unsigned char *vector,size_t len) | ||
| 383 | { unsigned char iv[sizeof(test_iv)]; | ||
| 384 | unsigned char cleartext[64],ciphertext[64],nistvector[64]; | ||
| 385 | size_t tail; | ||
| 386 | |||
| 387 | printf("nistvector_%d\n",len); fflush(stdout); | ||
| 388 | |||
| 389 | if ((tail=len%16) == 0) tail = 16; | ||
| 390 | |||
| 391 | len -= 16 + tail; | ||
| 392 | memcpy(nistvector,vector,len); | ||
| 393 | /* flip two last blocks */ | ||
| 394 | memcpy(nistvector+len,vector+len+16,tail); | ||
| 395 | memcpy(nistvector+len+tail,vector+len,16); | ||
| 396 | len += 16 + tail; | ||
| 397 | tail = 16; | ||
| 398 | |||
| 399 | /* test block-based encryption */ | ||
| 400 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 401 | CRYPTO_nistcts128_encrypt_block(test_input,ciphertext,len,&encks,iv,(block128_f)AES_encrypt); | ||
| 402 | if (memcmp(ciphertext,nistvector,len)) | ||
| 403 | fprintf(stderr,"output_%d mismatch\n",len), exit(1); | ||
| 404 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 405 | fprintf(stderr,"iv_%d mismatch\n",len), exit(1); | ||
| 406 | |||
| 407 | /* test block-based decryption */ | ||
| 408 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 409 | CRYPTO_nistcts128_decrypt_block(ciphertext,cleartext,len,&decks,iv,(block128_f)AES_decrypt); | ||
| 410 | if (memcmp(cleartext,test_input,len)) | ||
| 411 | fprintf(stderr,"input_%d mismatch\n",len), exit(2); | ||
| 412 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 413 | fprintf(stderr,"iv_%d mismatch\n",len), exit(2); | ||
| 414 | |||
| 415 | /* test streamed encryption */ | ||
| 416 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 417 | CRYPTO_nistcts128_encrypt(test_input,ciphertext,len,&encks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 418 | if (memcmp(ciphertext,nistvector,len)) | ||
| 419 | fprintf(stderr,"output_%d mismatch\n",len), exit(3); | ||
| 420 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 421 | fprintf(stderr,"iv_%d mismatch\n",len), exit(3); | ||
| 422 | |||
| 423 | /* test streamed decryption */ | ||
| 424 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 425 | CRYPTO_nistcts128_decrypt(ciphertext,cleartext,len,&decks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 426 | if (memcmp(cleartext,test_input,len)) | ||
| 427 | fprintf(stderr,"input_%d mismatch\n",len), exit(4); | ||
| 428 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 429 | fprintf(stderr,"iv_%d mismatch\n",len), exit(4); | ||
| 430 | } | ||
| 431 | |||
| 432 | int main() | ||
| 433 | { | ||
| 434 | AES_set_encrypt_key(test_key,128,&encks); | ||
| 435 | AES_set_decrypt_key(test_key,128,&decks); | ||
| 436 | |||
| 437 | test_vector(vector_17,sizeof(vector_17)); | ||
| 438 | test_vector(vector_31,sizeof(vector_31)); | ||
| 439 | test_vector(vector_32,sizeof(vector_32)); | ||
| 440 | test_vector(vector_47,sizeof(vector_47)); | ||
| 441 | test_vector(vector_48,sizeof(vector_48)); | ||
| 442 | test_vector(vector_64,sizeof(vector_64)); | ||
| 443 | |||
| 444 | test_nistvector(vector_17,sizeof(vector_17)); | ||
| 445 | test_nistvector(vector_31,sizeof(vector_31)); | ||
| 446 | test_nistvector(vector_32,sizeof(vector_32)); | ||
| 447 | test_nistvector(vector_47,sizeof(vector_47)); | ||
| 448 | test_nistvector(vector_48,sizeof(vector_48)); | ||
| 449 | test_nistvector(vector_64,sizeof(vector_64)); | ||
| 450 | |||
| 451 | return 0; | ||
| 452 | } | ||
| 453 | #endif | ||
diff --git a/src/lib/libcrypto/modes/gcm128.c b/src/lib/libcrypto/modes/gcm128.c index f3bcb7dd6e..25754ccd99 100644 --- a/src/lib/libcrypto/modes/gcm128.c +++ b/src/lib/libcrypto/modes/gcm128.c | |||
| @@ -1540,310 +1540,3 @@ void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx) | |||
| 1540 | free(ctx); | 1540 | free(ctx); |
| 1541 | } | 1541 | } |
| 1542 | } | 1542 | } |
| 1543 | |||
| 1544 | #if defined(SELFTEST) | ||
| 1545 | #include <stdio.h> | ||
| 1546 | #include <openssl/aes.h> | ||
| 1547 | |||
| 1548 | /* Test Case 1 */ | ||
| 1549 | static const u8 K1[16], | ||
| 1550 | *P1=NULL, | ||
| 1551 | *A1=NULL, | ||
| 1552 | IV1[12], | ||
| 1553 | *C1=NULL, | ||
| 1554 | T1[]= {0x58,0xe2,0xfc,0xce,0xfa,0x7e,0x30,0x61,0x36,0x7f,0x1d,0x57,0xa4,0xe7,0x45,0x5a}; | ||
| 1555 | |||
| 1556 | /* Test Case 2 */ | ||
| 1557 | #define K2 K1 | ||
| 1558 | #define A2 A1 | ||
| 1559 | #define IV2 IV1 | ||
| 1560 | static const u8 P2[16], | ||
| 1561 | C2[]= {0x03,0x88,0xda,0xce,0x60,0xb6,0xa3,0x92,0xf3,0x28,0xc2,0xb9,0x71,0xb2,0xfe,0x78}, | ||
| 1562 | T2[]= {0xab,0x6e,0x47,0xd4,0x2c,0xec,0x13,0xbd,0xf5,0x3a,0x67,0xb2,0x12,0x57,0xbd,0xdf}; | ||
| 1563 | |||
| 1564 | /* Test Case 3 */ | ||
| 1565 | #define A3 A2 | ||
| 1566 | static const u8 K3[]= {0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08}, | ||
| 1567 | P3[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1568 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1569 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1570 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55}, | ||
| 1571 | IV3[]= {0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad,0xde,0xca,0xf8,0x88}, | ||
| 1572 | C3[]= {0x42,0x83,0x1e,0xc2,0x21,0x77,0x74,0x24,0x4b,0x72,0x21,0xb7,0x84,0xd0,0xd4,0x9c, | ||
| 1573 | 0xe3,0xaa,0x21,0x2f,0x2c,0x02,0xa4,0xe0,0x35,0xc1,0x7e,0x23,0x29,0xac,0xa1,0x2e, | ||
| 1574 | 0x21,0xd5,0x14,0xb2,0x54,0x66,0x93,0x1c,0x7d,0x8f,0x6a,0x5a,0xac,0x84,0xaa,0x05, | ||
| 1575 | 0x1b,0xa3,0x0b,0x39,0x6a,0x0a,0xac,0x97,0x3d,0x58,0xe0,0x91,0x47,0x3f,0x59,0x85}, | ||
| 1576 | T3[]= {0x4d,0x5c,0x2a,0xf3,0x27,0xcd,0x64,0xa6,0x2c,0xf3,0x5a,0xbd,0x2b,0xa6,0xfa,0xb4}; | ||
| 1577 | |||
| 1578 | /* Test Case 4 */ | ||
| 1579 | #define K4 K3 | ||
| 1580 | #define IV4 IV3 | ||
| 1581 | static const u8 P4[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1582 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1583 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1584 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39}, | ||
| 1585 | A4[]= {0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef,0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef, | ||
| 1586 | 0xab,0xad,0xda,0xd2}, | ||
| 1587 | C4[]= {0x42,0x83,0x1e,0xc2,0x21,0x77,0x74,0x24,0x4b,0x72,0x21,0xb7,0x84,0xd0,0xd4,0x9c, | ||
| 1588 | 0xe3,0xaa,0x21,0x2f,0x2c,0x02,0xa4,0xe0,0x35,0xc1,0x7e,0x23,0x29,0xac,0xa1,0x2e, | ||
| 1589 | 0x21,0xd5,0x14,0xb2,0x54,0x66,0x93,0x1c,0x7d,0x8f,0x6a,0x5a,0xac,0x84,0xaa,0x05, | ||
| 1590 | 0x1b,0xa3,0x0b,0x39,0x6a,0x0a,0xac,0x97,0x3d,0x58,0xe0,0x91}, | ||
| 1591 | T4[]= {0x5b,0xc9,0x4f,0xbc,0x32,0x21,0xa5,0xdb,0x94,0xfa,0xe9,0x5a,0xe7,0x12,0x1a,0x47}; | ||
| 1592 | |||
| 1593 | /* Test Case 5 */ | ||
| 1594 | #define K5 K4 | ||
| 1595 | #define P5 P4 | ||
| 1596 | #define A5 A4 | ||
| 1597 | static const u8 IV5[]= {0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad}, | ||
| 1598 | C5[]= {0x61,0x35,0x3b,0x4c,0x28,0x06,0x93,0x4a,0x77,0x7f,0xf5,0x1f,0xa2,0x2a,0x47,0x55, | ||
| 1599 | 0x69,0x9b,0x2a,0x71,0x4f,0xcd,0xc6,0xf8,0x37,0x66,0xe5,0xf9,0x7b,0x6c,0x74,0x23, | ||
| 1600 | 0x73,0x80,0x69,0x00,0xe4,0x9f,0x24,0xb2,0x2b,0x09,0x75,0x44,0xd4,0x89,0x6b,0x42, | ||
| 1601 | 0x49,0x89,0xb5,0xe1,0xeb,0xac,0x0f,0x07,0xc2,0x3f,0x45,0x98}, | ||
| 1602 | T5[]= {0x36,0x12,0xd2,0xe7,0x9e,0x3b,0x07,0x85,0x56,0x1b,0xe1,0x4a,0xac,0xa2,0xfc,0xcb}; | ||
| 1603 | |||
| 1604 | /* Test Case 6 */ | ||
| 1605 | #define K6 K5 | ||
| 1606 | #define P6 P5 | ||
| 1607 | #define A6 A5 | ||
| 1608 | static const u8 IV6[]= {0x93,0x13,0x22,0x5d,0xf8,0x84,0x06,0xe5,0x55,0x90,0x9c,0x5a,0xff,0x52,0x69,0xaa, | ||
| 1609 | 0x6a,0x7a,0x95,0x38,0x53,0x4f,0x7d,0xa1,0xe4,0xc3,0x03,0xd2,0xa3,0x18,0xa7,0x28, | ||
| 1610 | 0xc3,0xc0,0xc9,0x51,0x56,0x80,0x95,0x39,0xfc,0xf0,0xe2,0x42,0x9a,0x6b,0x52,0x54, | ||
| 1611 | 0x16,0xae,0xdb,0xf5,0xa0,0xde,0x6a,0x57,0xa6,0x37,0xb3,0x9b}, | ||
| 1612 | C6[]= {0x8c,0xe2,0x49,0x98,0x62,0x56,0x15,0xb6,0x03,0xa0,0x33,0xac,0xa1,0x3f,0xb8,0x94, | ||
| 1613 | 0xbe,0x91,0x12,0xa5,0xc3,0xa2,0x11,0xa8,0xba,0x26,0x2a,0x3c,0xca,0x7e,0x2c,0xa7, | ||
| 1614 | 0x01,0xe4,0xa9,0xa4,0xfb,0xa4,0x3c,0x90,0xcc,0xdc,0xb2,0x81,0xd4,0x8c,0x7c,0x6f, | ||
| 1615 | 0xd6,0x28,0x75,0xd2,0xac,0xa4,0x17,0x03,0x4c,0x34,0xae,0xe5}, | ||
| 1616 | T6[]= {0x61,0x9c,0xc5,0xae,0xff,0xfe,0x0b,0xfa,0x46,0x2a,0xf4,0x3c,0x16,0x99,0xd0,0x50}; | ||
| 1617 | |||
| 1618 | /* Test Case 7 */ | ||
| 1619 | static const u8 K7[24], | ||
| 1620 | *P7=NULL, | ||
| 1621 | *A7=NULL, | ||
| 1622 | IV7[12], | ||
| 1623 | *C7=NULL, | ||
| 1624 | T7[]= {0xcd,0x33,0xb2,0x8a,0xc7,0x73,0xf7,0x4b,0xa0,0x0e,0xd1,0xf3,0x12,0x57,0x24,0x35}; | ||
| 1625 | |||
| 1626 | /* Test Case 8 */ | ||
| 1627 | #define K8 K7 | ||
| 1628 | #define IV8 IV7 | ||
| 1629 | #define A8 A7 | ||
| 1630 | static const u8 P8[16], | ||
| 1631 | C8[]= {0x98,0xe7,0x24,0x7c,0x07,0xf0,0xfe,0x41,0x1c,0x26,0x7e,0x43,0x84,0xb0,0xf6,0x00}, | ||
| 1632 | T8[]= {0x2f,0xf5,0x8d,0x80,0x03,0x39,0x27,0xab,0x8e,0xf4,0xd4,0x58,0x75,0x14,0xf0,0xfb}; | ||
| 1633 | |||
| 1634 | /* Test Case 9 */ | ||
| 1635 | #define A9 A8 | ||
| 1636 | static const u8 K9[]= {0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08, | ||
| 1637 | 0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c}, | ||
| 1638 | P9[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1639 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1640 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1641 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55}, | ||
| 1642 | IV9[]= {0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad,0xde,0xca,0xf8,0x88}, | ||
| 1643 | C9[]= {0x39,0x80,0xca,0x0b,0x3c,0x00,0xe8,0x41,0xeb,0x06,0xfa,0xc4,0x87,0x2a,0x27,0x57, | ||
| 1644 | 0x85,0x9e,0x1c,0xea,0xa6,0xef,0xd9,0x84,0x62,0x85,0x93,0xb4,0x0c,0xa1,0xe1,0x9c, | ||
| 1645 | 0x7d,0x77,0x3d,0x00,0xc1,0x44,0xc5,0x25,0xac,0x61,0x9d,0x18,0xc8,0x4a,0x3f,0x47, | ||
| 1646 | 0x18,0xe2,0x44,0x8b,0x2f,0xe3,0x24,0xd9,0xcc,0xda,0x27,0x10,0xac,0xad,0xe2,0x56}, | ||
| 1647 | T9[]= {0x99,0x24,0xa7,0xc8,0x58,0x73,0x36,0xbf,0xb1,0x18,0x02,0x4d,0xb8,0x67,0x4a,0x14}; | ||
| 1648 | |||
| 1649 | /* Test Case 10 */ | ||
| 1650 | #define K10 K9 | ||
| 1651 | #define IV10 IV9 | ||
| 1652 | static const u8 P10[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1653 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1654 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1655 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39}, | ||
| 1656 | A10[]= {0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef,0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef, | ||
| 1657 | 0xab,0xad,0xda,0xd2}, | ||
| 1658 | C10[]= {0x39,0x80,0xca,0x0b,0x3c,0x00,0xe8,0x41,0xeb,0x06,0xfa,0xc4,0x87,0x2a,0x27,0x57, | ||
| 1659 | 0x85,0x9e,0x1c,0xea,0xa6,0xef,0xd9,0x84,0x62,0x85,0x93,0xb4,0x0c,0xa1,0xe1,0x9c, | ||
| 1660 | 0x7d,0x77,0x3d,0x00,0xc1,0x44,0xc5,0x25,0xac,0x61,0x9d,0x18,0xc8,0x4a,0x3f,0x47, | ||
| 1661 | 0x18,0xe2,0x44,0x8b,0x2f,0xe3,0x24,0xd9,0xcc,0xda,0x27,0x10}, | ||
| 1662 | T10[]= {0x25,0x19,0x49,0x8e,0x80,0xf1,0x47,0x8f,0x37,0xba,0x55,0xbd,0x6d,0x27,0x61,0x8c}; | ||
| 1663 | |||
| 1664 | /* Test Case 11 */ | ||
| 1665 | #define K11 K10 | ||
| 1666 | #define P11 P10 | ||
| 1667 | #define A11 A10 | ||
| 1668 | static const u8 IV11[]={0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad}, | ||
| 1669 | C11[]= {0x0f,0x10,0xf5,0x99,0xae,0x14,0xa1,0x54,0xed,0x24,0xb3,0x6e,0x25,0x32,0x4d,0xb8, | ||
| 1670 | 0xc5,0x66,0x63,0x2e,0xf2,0xbb,0xb3,0x4f,0x83,0x47,0x28,0x0f,0xc4,0x50,0x70,0x57, | ||
| 1671 | 0xfd,0xdc,0x29,0xdf,0x9a,0x47,0x1f,0x75,0xc6,0x65,0x41,0xd4,0xd4,0xda,0xd1,0xc9, | ||
| 1672 | 0xe9,0x3a,0x19,0xa5,0x8e,0x8b,0x47,0x3f,0xa0,0xf0,0x62,0xf7}, | ||
| 1673 | T11[]= {0x65,0xdc,0xc5,0x7f,0xcf,0x62,0x3a,0x24,0x09,0x4f,0xcc,0xa4,0x0d,0x35,0x33,0xf8}; | ||
| 1674 | |||
| 1675 | /* Test Case 12 */ | ||
| 1676 | #define K12 K11 | ||
| 1677 | #define P12 P11 | ||
| 1678 | #define A12 A11 | ||
| 1679 | static const u8 IV12[]={0x93,0x13,0x22,0x5d,0xf8,0x84,0x06,0xe5,0x55,0x90,0x9c,0x5a,0xff,0x52,0x69,0xaa, | ||
| 1680 | 0x6a,0x7a,0x95,0x38,0x53,0x4f,0x7d,0xa1,0xe4,0xc3,0x03,0xd2,0xa3,0x18,0xa7,0x28, | ||
| 1681 | 0xc3,0xc0,0xc9,0x51,0x56,0x80,0x95,0x39,0xfc,0xf0,0xe2,0x42,0x9a,0x6b,0x52,0x54, | ||
| 1682 | 0x16,0xae,0xdb,0xf5,0xa0,0xde,0x6a,0x57,0xa6,0x37,0xb3,0x9b}, | ||
| 1683 | C12[]= {0xd2,0x7e,0x88,0x68,0x1c,0xe3,0x24,0x3c,0x48,0x30,0x16,0x5a,0x8f,0xdc,0xf9,0xff, | ||
| 1684 | 0x1d,0xe9,0xa1,0xd8,0xe6,0xb4,0x47,0xef,0x6e,0xf7,0xb7,0x98,0x28,0x66,0x6e,0x45, | ||
| 1685 | 0x81,0xe7,0x90,0x12,0xaf,0x34,0xdd,0xd9,0xe2,0xf0,0x37,0x58,0x9b,0x29,0x2d,0xb3, | ||
| 1686 | 0xe6,0x7c,0x03,0x67,0x45,0xfa,0x22,0xe7,0xe9,0xb7,0x37,0x3b}, | ||
| 1687 | T12[]= {0xdc,0xf5,0x66,0xff,0x29,0x1c,0x25,0xbb,0xb8,0x56,0x8f,0xc3,0xd3,0x76,0xa6,0xd9}; | ||
| 1688 | |||
| 1689 | /* Test Case 13 */ | ||
| 1690 | static const u8 K13[32], | ||
| 1691 | *P13=NULL, | ||
| 1692 | *A13=NULL, | ||
| 1693 | IV13[12], | ||
| 1694 | *C13=NULL, | ||
| 1695 | T13[]={0x53,0x0f,0x8a,0xfb,0xc7,0x45,0x36,0xb9,0xa9,0x63,0xb4,0xf1,0xc4,0xcb,0x73,0x8b}; | ||
| 1696 | |||
| 1697 | /* Test Case 14 */ | ||
| 1698 | #define K14 K13 | ||
| 1699 | #define A14 A13 | ||
| 1700 | static const u8 P14[16], | ||
| 1701 | IV14[12], | ||
| 1702 | C14[]= {0xce,0xa7,0x40,0x3d,0x4d,0x60,0x6b,0x6e,0x07,0x4e,0xc5,0xd3,0xba,0xf3,0x9d,0x18}, | ||
| 1703 | T14[]= {0xd0,0xd1,0xc8,0xa7,0x99,0x99,0x6b,0xf0,0x26,0x5b,0x98,0xb5,0xd4,0x8a,0xb9,0x19}; | ||
| 1704 | |||
| 1705 | /* Test Case 15 */ | ||
| 1706 | #define A15 A14 | ||
| 1707 | static const u8 K15[]= {0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08, | ||
| 1708 | 0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08}, | ||
| 1709 | P15[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1710 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1711 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1712 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55}, | ||
| 1713 | IV15[]={0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad,0xde,0xca,0xf8,0x88}, | ||
| 1714 | C15[]= {0x52,0x2d,0xc1,0xf0,0x99,0x56,0x7d,0x07,0xf4,0x7f,0x37,0xa3,0x2a,0x84,0x42,0x7d, | ||
| 1715 | 0x64,0x3a,0x8c,0xdc,0xbf,0xe5,0xc0,0xc9,0x75,0x98,0xa2,0xbd,0x25,0x55,0xd1,0xaa, | ||
| 1716 | 0x8c,0xb0,0x8e,0x48,0x59,0x0d,0xbb,0x3d,0xa7,0xb0,0x8b,0x10,0x56,0x82,0x88,0x38, | ||
| 1717 | 0xc5,0xf6,0x1e,0x63,0x93,0xba,0x7a,0x0a,0xbc,0xc9,0xf6,0x62,0x89,0x80,0x15,0xad}, | ||
| 1718 | T15[]= {0xb0,0x94,0xda,0xc5,0xd9,0x34,0x71,0xbd,0xec,0x1a,0x50,0x22,0x70,0xe3,0xcc,0x6c}; | ||
| 1719 | |||
| 1720 | /* Test Case 16 */ | ||
| 1721 | #define K16 K15 | ||
| 1722 | #define IV16 IV15 | ||
| 1723 | static const u8 P16[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1724 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1725 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1726 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39}, | ||
| 1727 | A16[]= {0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef,0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef, | ||
| 1728 | 0xab,0xad,0xda,0xd2}, | ||
| 1729 | C16[]= {0x52,0x2d,0xc1,0xf0,0x99,0x56,0x7d,0x07,0xf4,0x7f,0x37,0xa3,0x2a,0x84,0x42,0x7d, | ||
| 1730 | 0x64,0x3a,0x8c,0xdc,0xbf,0xe5,0xc0,0xc9,0x75,0x98,0xa2,0xbd,0x25,0x55,0xd1,0xaa, | ||
| 1731 | 0x8c,0xb0,0x8e,0x48,0x59,0x0d,0xbb,0x3d,0xa7,0xb0,0x8b,0x10,0x56,0x82,0x88,0x38, | ||
| 1732 | 0xc5,0xf6,0x1e,0x63,0x93,0xba,0x7a,0x0a,0xbc,0xc9,0xf6,0x62}, | ||
| 1733 | T16[]= {0x76,0xfc,0x6e,0xce,0x0f,0x4e,0x17,0x68,0xcd,0xdf,0x88,0x53,0xbb,0x2d,0x55,0x1b}; | ||
| 1734 | |||
| 1735 | /* Test Case 17 */ | ||
| 1736 | #define K17 K16 | ||
| 1737 | #define P17 P16 | ||
| 1738 | #define A17 A16 | ||
| 1739 | static const u8 IV17[]={0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad}, | ||
| 1740 | C17[]= {0xc3,0x76,0x2d,0xf1,0xca,0x78,0x7d,0x32,0xae,0x47,0xc1,0x3b,0xf1,0x98,0x44,0xcb, | ||
| 1741 | 0xaf,0x1a,0xe1,0x4d,0x0b,0x97,0x6a,0xfa,0xc5,0x2f,0xf7,0xd7,0x9b,0xba,0x9d,0xe0, | ||
| 1742 | 0xfe,0xb5,0x82,0xd3,0x39,0x34,0xa4,0xf0,0x95,0x4c,0xc2,0x36,0x3b,0xc7,0x3f,0x78, | ||
| 1743 | 0x62,0xac,0x43,0x0e,0x64,0xab,0xe4,0x99,0xf4,0x7c,0x9b,0x1f}, | ||
| 1744 | T17[]= {0x3a,0x33,0x7d,0xbf,0x46,0xa7,0x92,0xc4,0x5e,0x45,0x49,0x13,0xfe,0x2e,0xa8,0xf2}; | ||
| 1745 | |||
| 1746 | /* Test Case 18 */ | ||
| 1747 | #define K18 K17 | ||
| 1748 | #define P18 P17 | ||
| 1749 | #define A18 A17 | ||
| 1750 | static const u8 IV18[]={0x93,0x13,0x22,0x5d,0xf8,0x84,0x06,0xe5,0x55,0x90,0x9c,0x5a,0xff,0x52,0x69,0xaa, | ||
| 1751 | 0x6a,0x7a,0x95,0x38,0x53,0x4f,0x7d,0xa1,0xe4,0xc3,0x03,0xd2,0xa3,0x18,0xa7,0x28, | ||
| 1752 | 0xc3,0xc0,0xc9,0x51,0x56,0x80,0x95,0x39,0xfc,0xf0,0xe2,0x42,0x9a,0x6b,0x52,0x54, | ||
| 1753 | 0x16,0xae,0xdb,0xf5,0xa0,0xde,0x6a,0x57,0xa6,0x37,0xb3,0x9b}, | ||
| 1754 | C18[]= {0x5a,0x8d,0xef,0x2f,0x0c,0x9e,0x53,0xf1,0xf7,0x5d,0x78,0x53,0x65,0x9e,0x2a,0x20, | ||
| 1755 | 0xee,0xb2,0xb2,0x2a,0xaf,0xde,0x64,0x19,0xa0,0x58,0xab,0x4f,0x6f,0x74,0x6b,0xf4, | ||
| 1756 | 0x0f,0xc0,0xc3,0xb7,0x80,0xf2,0x44,0x45,0x2d,0xa3,0xeb,0xf1,0xc5,0xd8,0x2c,0xde, | ||
| 1757 | 0xa2,0x41,0x89,0x97,0x20,0x0e,0xf8,0x2e,0x44,0xae,0x7e,0x3f}, | ||
| 1758 | T18[]= {0xa4,0x4a,0x82,0x66,0xee,0x1c,0x8e,0xb0,0xc8,0xb5,0xd4,0xcf,0x5a,0xe9,0xf1,0x9a}; | ||
| 1759 | |||
| 1760 | /* Test Case 19 */ | ||
| 1761 | #define K19 K1 | ||
| 1762 | #define P19 P1 | ||
| 1763 | #define IV19 IV1 | ||
| 1764 | #define C19 C1 | ||
| 1765 | static const u8 A19[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1766 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1767 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1768 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55, | ||
| 1769 | 0x52,0x2d,0xc1,0xf0,0x99,0x56,0x7d,0x07,0xf4,0x7f,0x37,0xa3,0x2a,0x84,0x42,0x7d, | ||
| 1770 | 0x64,0x3a,0x8c,0xdc,0xbf,0xe5,0xc0,0xc9,0x75,0x98,0xa2,0xbd,0x25,0x55,0xd1,0xaa, | ||
| 1771 | 0x8c,0xb0,0x8e,0x48,0x59,0x0d,0xbb,0x3d,0xa7,0xb0,0x8b,0x10,0x56,0x82,0x88,0x38, | ||
| 1772 | 0xc5,0xf6,0x1e,0x63,0x93,0xba,0x7a,0x0a,0xbc,0xc9,0xf6,0x62,0x89,0x80,0x15,0xad}, | ||
| 1773 | T19[]= {0x5f,0xea,0x79,0x3a,0x2d,0x6f,0x97,0x4d,0x37,0xe6,0x8e,0x0c,0xb8,0xff,0x94,0x92}; | ||
| 1774 | |||
| 1775 | /* Test Case 20 */ | ||
| 1776 | #define K20 K1 | ||
| 1777 | #define A20 A1 | ||
| 1778 | static const u8 IV20[64]={0xff,0xff,0xff,0xff}, /* this results in 0xff in counter LSB */ | ||
| 1779 | P20[288], | ||
| 1780 | C20[]= {0x56,0xb3,0x37,0x3c,0xa9,0xef,0x6e,0x4a,0x2b,0x64,0xfe,0x1e,0x9a,0x17,0xb6,0x14, | ||
| 1781 | 0x25,0xf1,0x0d,0x47,0xa7,0x5a,0x5f,0xce,0x13,0xef,0xc6,0xbc,0x78,0x4a,0xf2,0x4f, | ||
| 1782 | 0x41,0x41,0xbd,0xd4,0x8c,0xf7,0xc7,0x70,0x88,0x7a,0xfd,0x57,0x3c,0xca,0x54,0x18, | ||
| 1783 | 0xa9,0xae,0xff,0xcd,0x7c,0x5c,0xed,0xdf,0xc6,0xa7,0x83,0x97,0xb9,0xa8,0x5b,0x49, | ||
| 1784 | 0x9d,0xa5,0x58,0x25,0x72,0x67,0xca,0xab,0x2a,0xd0,0xb2,0x3c,0xa4,0x76,0xa5,0x3c, | ||
| 1785 | 0xb1,0x7f,0xb4,0x1c,0x4b,0x8b,0x47,0x5c,0xb4,0xf3,0xf7,0x16,0x50,0x94,0xc2,0x29, | ||
| 1786 | 0xc9,0xe8,0xc4,0xdc,0x0a,0x2a,0x5f,0xf1,0x90,0x3e,0x50,0x15,0x11,0x22,0x13,0x76, | ||
| 1787 | 0xa1,0xcd,0xb8,0x36,0x4c,0x50,0x61,0xa2,0x0c,0xae,0x74,0xbc,0x4a,0xcd,0x76,0xce, | ||
| 1788 | 0xb0,0xab,0xc9,0xfd,0x32,0x17,0xef,0x9f,0x8c,0x90,0xbe,0x40,0x2d,0xdf,0x6d,0x86, | ||
| 1789 | 0x97,0xf4,0xf8,0x80,0xdf,0xf1,0x5b,0xfb,0x7a,0x6b,0x28,0x24,0x1e,0xc8,0xfe,0x18, | ||
| 1790 | 0x3c,0x2d,0x59,0xe3,0xf9,0xdf,0xff,0x65,0x3c,0x71,0x26,0xf0,0xac,0xb9,0xe6,0x42, | ||
| 1791 | 0x11,0xf4,0x2b,0xae,0x12,0xaf,0x46,0x2b,0x10,0x70,0xbe,0xf1,0xab,0x5e,0x36,0x06, | ||
| 1792 | 0x87,0x2c,0xa1,0x0d,0xee,0x15,0xb3,0x24,0x9b,0x1a,0x1b,0x95,0x8f,0x23,0x13,0x4c, | ||
| 1793 | 0x4b,0xcc,0xb7,0xd0,0x32,0x00,0xbc,0xe4,0x20,0xa2,0xf8,0xeb,0x66,0xdc,0xf3,0x64, | ||
| 1794 | 0x4d,0x14,0x23,0xc1,0xb5,0x69,0x90,0x03,0xc1,0x3e,0xce,0xf4,0xbf,0x38,0xa3,0xb6, | ||
| 1795 | 0x0e,0xed,0xc3,0x40,0x33,0xba,0xc1,0x90,0x27,0x83,0xdc,0x6d,0x89,0xe2,0xe7,0x74, | ||
| 1796 | 0x18,0x8a,0x43,0x9c,0x7e,0xbc,0xc0,0x67,0x2d,0xbd,0xa4,0xdd,0xcf,0xb2,0x79,0x46, | ||
| 1797 | 0x13,0xb0,0xbe,0x41,0x31,0x5e,0xf7,0x78,0x70,0x8a,0x70,0xee,0x7d,0x75,0x16,0x5c}, | ||
| 1798 | T20[]= {0x8b,0x30,0x7f,0x6b,0x33,0x28,0x6d,0x0a,0xb0,0x26,0xa9,0xed,0x3f,0xe1,0xe8,0x5f}; | ||
| 1799 | |||
| 1800 | #define TEST_CASE(n) do { \ | ||
| 1801 | u8 out[sizeof(P##n)]; \ | ||
| 1802 | AES_set_encrypt_key(K##n,sizeof(K##n)*8,&key); \ | ||
| 1803 | CRYPTO_gcm128_init(&ctx,&key,(block128_f)AES_encrypt); \ | ||
| 1804 | CRYPTO_gcm128_setiv(&ctx,IV##n,sizeof(IV##n)); \ | ||
| 1805 | memset(out,0,sizeof(out)); \ | ||
| 1806 | if (A##n) CRYPTO_gcm128_aad(&ctx,A##n,sizeof(A##n)); \ | ||
| 1807 | if (P##n) CRYPTO_gcm128_encrypt(&ctx,P##n,out,sizeof(out)); \ | ||
| 1808 | if (CRYPTO_gcm128_finish(&ctx,T##n,16) || \ | ||
| 1809 | (C##n && memcmp(out,C##n,sizeof(out)))) \ | ||
| 1810 | ret++, printf ("encrypt test#%d failed.\n",n); \ | ||
| 1811 | CRYPTO_gcm128_setiv(&ctx,IV##n,sizeof(IV##n)); \ | ||
| 1812 | memset(out,0,sizeof(out)); \ | ||
| 1813 | if (A##n) CRYPTO_gcm128_aad(&ctx,A##n,sizeof(A##n)); \ | ||
| 1814 | if (C##n) CRYPTO_gcm128_decrypt(&ctx,C##n,out,sizeof(out)); \ | ||
| 1815 | if (CRYPTO_gcm128_finish(&ctx,T##n,16) || \ | ||
| 1816 | (P##n && memcmp(out,P##n,sizeof(out)))) \ | ||
| 1817 | ret++, printf ("decrypt test#%d failed.\n",n); \ | ||
| 1818 | } while(0) | ||
| 1819 | |||
| 1820 | int main() | ||
| 1821 | { | ||
| 1822 | GCM128_CONTEXT ctx; | ||
| 1823 | AES_KEY key; | ||
| 1824 | int ret=0; | ||
| 1825 | |||
| 1826 | TEST_CASE(1); | ||
| 1827 | TEST_CASE(2); | ||
| 1828 | TEST_CASE(3); | ||
| 1829 | TEST_CASE(4); | ||
| 1830 | TEST_CASE(5); | ||
| 1831 | TEST_CASE(6); | ||
| 1832 | TEST_CASE(7); | ||
| 1833 | TEST_CASE(8); | ||
| 1834 | TEST_CASE(9); | ||
| 1835 | TEST_CASE(10); | ||
| 1836 | TEST_CASE(11); | ||
| 1837 | TEST_CASE(12); | ||
| 1838 | TEST_CASE(13); | ||
| 1839 | TEST_CASE(14); | ||
| 1840 | TEST_CASE(15); | ||
| 1841 | TEST_CASE(16); | ||
| 1842 | TEST_CASE(17); | ||
| 1843 | TEST_CASE(18); | ||
| 1844 | TEST_CASE(19); | ||
| 1845 | TEST_CASE(20); | ||
| 1846 | |||
| 1847 | return ret; | ||
| 1848 | } | ||
| 1849 | #endif | ||
diff --git a/src/lib/libssl/src/crypto/modes/cts128.c b/src/lib/libssl/src/crypto/modes/cts128.c index 2d583de6f6..37bd05ed29 100644 --- a/src/lib/libssl/src/crypto/modes/cts128.c +++ b/src/lib/libssl/src/crypto/modes/cts128.c | |||
| @@ -299,155 +299,3 @@ size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out, | |||
| 299 | #endif | 299 | #endif |
| 300 | return 16+len+residue; | 300 | return 16+len+residue; |
| 301 | } | 301 | } |
| 302 | |||
| 303 | #if defined(SELFTEST) | ||
| 304 | #include <stdio.h> | ||
| 305 | #include <openssl/aes.h> | ||
| 306 | |||
| 307 | /* test vectors from RFC 3962 */ | ||
| 308 | static const unsigned char test_key[16] = "chicken teriyaki"; | ||
| 309 | static const unsigned char test_input[64] = | ||
| 310 | "I would like the" " General Gau's C" | ||
| 311 | "hicken, please, " "and wonton soup."; | ||
| 312 | static const unsigned char test_iv[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | ||
| 313 | |||
| 314 | static const unsigned char vector_17[17] = | ||
| 315 | {0xc6,0x35,0x35,0x68,0xf2,0xbf,0x8c,0xb4, 0xd8,0xa5,0x80,0x36,0x2d,0xa7,0xff,0x7f, | ||
| 316 | 0x97}; | ||
| 317 | static const unsigned char vector_31[31] = | ||
| 318 | {0xfc,0x00,0x78,0x3e,0x0e,0xfd,0xb2,0xc1, 0xd4,0x45,0xd4,0xc8,0xef,0xf7,0xed,0x22, | ||
| 319 | 0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5}; | ||
| 320 | static const unsigned char vector_32[32] = | ||
| 321 | {0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8, | ||
| 322 | 0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84}; | ||
| 323 | static const unsigned char vector_47[47] = | ||
| 324 | {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, | ||
| 325 | 0xb3,0xff,0xfd,0x94,0x0c,0x16,0xa1,0x8c, 0x1b,0x55,0x49,0xd2,0xf8,0x38,0x02,0x9e, | ||
| 326 | 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5}; | ||
| 327 | static const unsigned char vector_48[48] = | ||
| 328 | {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, | ||
| 329 | 0x9d,0xad,0x8b,0xbb,0x96,0xc4,0xcd,0xc0, 0x3b,0xc1,0x03,0xe1,0xa1,0x94,0xbb,0xd8, | ||
| 330 | 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8}; | ||
| 331 | static const unsigned char vector_64[64] = | ||
| 332 | {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, | ||
| 333 | 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8, | ||
| 334 | 0x48,0x07,0xef,0xe8,0x36,0xee,0x89,0xa5, 0x26,0x73,0x0d,0xbc,0x2f,0x7b,0xc8,0x40, | ||
| 335 | 0x9d,0xad,0x8b,0xbb,0x96,0xc4,0xcd,0xc0, 0x3b,0xc1,0x03,0xe1,0xa1,0x94,0xbb,0xd8}; | ||
| 336 | |||
| 337 | static AES_KEY encks, decks; | ||
| 338 | |||
| 339 | void test_vector(const unsigned char *vector,size_t len) | ||
| 340 | { unsigned char iv[sizeof(test_iv)]; | ||
| 341 | unsigned char cleartext[64],ciphertext[64]; | ||
| 342 | size_t tail; | ||
| 343 | |||
| 344 | printf("vector_%d\n",len); fflush(stdout); | ||
| 345 | |||
| 346 | if ((tail=len%16) == 0) tail = 16; | ||
| 347 | tail += 16; | ||
| 348 | |||
| 349 | /* test block-based encryption */ | ||
| 350 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 351 | CRYPTO_cts128_encrypt_block(test_input,ciphertext,len,&encks,iv,(block128_f)AES_encrypt); | ||
| 352 | if (memcmp(ciphertext,vector,len)) | ||
| 353 | fprintf(stderr,"output_%d mismatch\n",len), exit(1); | ||
| 354 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 355 | fprintf(stderr,"iv_%d mismatch\n",len), exit(1); | ||
| 356 | |||
| 357 | /* test block-based decryption */ | ||
| 358 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 359 | CRYPTO_cts128_decrypt_block(ciphertext,cleartext,len,&decks,iv,(block128_f)AES_decrypt); | ||
| 360 | if (memcmp(cleartext,test_input,len)) | ||
| 361 | fprintf(stderr,"input_%d mismatch\n",len), exit(2); | ||
| 362 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 363 | fprintf(stderr,"iv_%d mismatch\n",len), exit(2); | ||
| 364 | |||
| 365 | /* test streamed encryption */ | ||
| 366 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 367 | CRYPTO_cts128_encrypt(test_input,ciphertext,len,&encks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 368 | if (memcmp(ciphertext,vector,len)) | ||
| 369 | fprintf(stderr,"output_%d mismatch\n",len), exit(3); | ||
| 370 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 371 | fprintf(stderr,"iv_%d mismatch\n",len), exit(3); | ||
| 372 | |||
| 373 | /* test streamed decryption */ | ||
| 374 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 375 | CRYPTO_cts128_decrypt(ciphertext,cleartext,len,&decks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 376 | if (memcmp(cleartext,test_input,len)) | ||
| 377 | fprintf(stderr,"input_%d mismatch\n",len), exit(4); | ||
| 378 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 379 | fprintf(stderr,"iv_%d mismatch\n",len), exit(4); | ||
| 380 | } | ||
| 381 | |||
| 382 | void test_nistvector(const unsigned char *vector,size_t len) | ||
| 383 | { unsigned char iv[sizeof(test_iv)]; | ||
| 384 | unsigned char cleartext[64],ciphertext[64],nistvector[64]; | ||
| 385 | size_t tail; | ||
| 386 | |||
| 387 | printf("nistvector_%d\n",len); fflush(stdout); | ||
| 388 | |||
| 389 | if ((tail=len%16) == 0) tail = 16; | ||
| 390 | |||
| 391 | len -= 16 + tail; | ||
| 392 | memcpy(nistvector,vector,len); | ||
| 393 | /* flip two last blocks */ | ||
| 394 | memcpy(nistvector+len,vector+len+16,tail); | ||
| 395 | memcpy(nistvector+len+tail,vector+len,16); | ||
| 396 | len += 16 + tail; | ||
| 397 | tail = 16; | ||
| 398 | |||
| 399 | /* test block-based encryption */ | ||
| 400 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 401 | CRYPTO_nistcts128_encrypt_block(test_input,ciphertext,len,&encks,iv,(block128_f)AES_encrypt); | ||
| 402 | if (memcmp(ciphertext,nistvector,len)) | ||
| 403 | fprintf(stderr,"output_%d mismatch\n",len), exit(1); | ||
| 404 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 405 | fprintf(stderr,"iv_%d mismatch\n",len), exit(1); | ||
| 406 | |||
| 407 | /* test block-based decryption */ | ||
| 408 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 409 | CRYPTO_nistcts128_decrypt_block(ciphertext,cleartext,len,&decks,iv,(block128_f)AES_decrypt); | ||
| 410 | if (memcmp(cleartext,test_input,len)) | ||
| 411 | fprintf(stderr,"input_%d mismatch\n",len), exit(2); | ||
| 412 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 413 | fprintf(stderr,"iv_%d mismatch\n",len), exit(2); | ||
| 414 | |||
| 415 | /* test streamed encryption */ | ||
| 416 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 417 | CRYPTO_nistcts128_encrypt(test_input,ciphertext,len,&encks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 418 | if (memcmp(ciphertext,nistvector,len)) | ||
| 419 | fprintf(stderr,"output_%d mismatch\n",len), exit(3); | ||
| 420 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 421 | fprintf(stderr,"iv_%d mismatch\n",len), exit(3); | ||
| 422 | |||
| 423 | /* test streamed decryption */ | ||
| 424 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 425 | CRYPTO_nistcts128_decrypt(ciphertext,cleartext,len,&decks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 426 | if (memcmp(cleartext,test_input,len)) | ||
| 427 | fprintf(stderr,"input_%d mismatch\n",len), exit(4); | ||
| 428 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 429 | fprintf(stderr,"iv_%d mismatch\n",len), exit(4); | ||
| 430 | } | ||
| 431 | |||
| 432 | int main() | ||
| 433 | { | ||
| 434 | AES_set_encrypt_key(test_key,128,&encks); | ||
| 435 | AES_set_decrypt_key(test_key,128,&decks); | ||
| 436 | |||
| 437 | test_vector(vector_17,sizeof(vector_17)); | ||
| 438 | test_vector(vector_31,sizeof(vector_31)); | ||
| 439 | test_vector(vector_32,sizeof(vector_32)); | ||
| 440 | test_vector(vector_47,sizeof(vector_47)); | ||
| 441 | test_vector(vector_48,sizeof(vector_48)); | ||
| 442 | test_vector(vector_64,sizeof(vector_64)); | ||
| 443 | |||
| 444 | test_nistvector(vector_17,sizeof(vector_17)); | ||
| 445 | test_nistvector(vector_31,sizeof(vector_31)); | ||
| 446 | test_nistvector(vector_32,sizeof(vector_32)); | ||
| 447 | test_nistvector(vector_47,sizeof(vector_47)); | ||
| 448 | test_nistvector(vector_48,sizeof(vector_48)); | ||
| 449 | test_nistvector(vector_64,sizeof(vector_64)); | ||
| 450 | |||
| 451 | return 0; | ||
| 452 | } | ||
| 453 | #endif | ||
diff --git a/src/lib/libssl/src/crypto/modes/gcm128.c b/src/lib/libssl/src/crypto/modes/gcm128.c index f3bcb7dd6e..25754ccd99 100644 --- a/src/lib/libssl/src/crypto/modes/gcm128.c +++ b/src/lib/libssl/src/crypto/modes/gcm128.c | |||
| @@ -1540,310 +1540,3 @@ void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx) | |||
| 1540 | free(ctx); | 1540 | free(ctx); |
| 1541 | } | 1541 | } |
| 1542 | } | 1542 | } |
| 1543 | |||
| 1544 | #if defined(SELFTEST) | ||
| 1545 | #include <stdio.h> | ||
| 1546 | #include <openssl/aes.h> | ||
| 1547 | |||
| 1548 | /* Test Case 1 */ | ||
| 1549 | static const u8 K1[16], | ||
| 1550 | *P1=NULL, | ||
| 1551 | *A1=NULL, | ||
| 1552 | IV1[12], | ||
| 1553 | *C1=NULL, | ||
| 1554 | T1[]= {0x58,0xe2,0xfc,0xce,0xfa,0x7e,0x30,0x61,0x36,0x7f,0x1d,0x57,0xa4,0xe7,0x45,0x5a}; | ||
| 1555 | |||
| 1556 | /* Test Case 2 */ | ||
| 1557 | #define K2 K1 | ||
| 1558 | #define A2 A1 | ||
| 1559 | #define IV2 IV1 | ||
| 1560 | static const u8 P2[16], | ||
| 1561 | C2[]= {0x03,0x88,0xda,0xce,0x60,0xb6,0xa3,0x92,0xf3,0x28,0xc2,0xb9,0x71,0xb2,0xfe,0x78}, | ||
| 1562 | T2[]= {0xab,0x6e,0x47,0xd4,0x2c,0xec,0x13,0xbd,0xf5,0x3a,0x67,0xb2,0x12,0x57,0xbd,0xdf}; | ||
| 1563 | |||
| 1564 | /* Test Case 3 */ | ||
| 1565 | #define A3 A2 | ||
| 1566 | static const u8 K3[]= {0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08}, | ||
| 1567 | P3[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1568 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1569 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1570 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55}, | ||
| 1571 | IV3[]= {0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad,0xde,0xca,0xf8,0x88}, | ||
| 1572 | C3[]= {0x42,0x83,0x1e,0xc2,0x21,0x77,0x74,0x24,0x4b,0x72,0x21,0xb7,0x84,0xd0,0xd4,0x9c, | ||
| 1573 | 0xe3,0xaa,0x21,0x2f,0x2c,0x02,0xa4,0xe0,0x35,0xc1,0x7e,0x23,0x29,0xac,0xa1,0x2e, | ||
| 1574 | 0x21,0xd5,0x14,0xb2,0x54,0x66,0x93,0x1c,0x7d,0x8f,0x6a,0x5a,0xac,0x84,0xaa,0x05, | ||
| 1575 | 0x1b,0xa3,0x0b,0x39,0x6a,0x0a,0xac,0x97,0x3d,0x58,0xe0,0x91,0x47,0x3f,0x59,0x85}, | ||
| 1576 | T3[]= {0x4d,0x5c,0x2a,0xf3,0x27,0xcd,0x64,0xa6,0x2c,0xf3,0x5a,0xbd,0x2b,0xa6,0xfa,0xb4}; | ||
| 1577 | |||
| 1578 | /* Test Case 4 */ | ||
| 1579 | #define K4 K3 | ||
| 1580 | #define IV4 IV3 | ||
| 1581 | static const u8 P4[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1582 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1583 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1584 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39}, | ||
| 1585 | A4[]= {0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef,0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef, | ||
| 1586 | 0xab,0xad,0xda,0xd2}, | ||
| 1587 | C4[]= {0x42,0x83,0x1e,0xc2,0x21,0x77,0x74,0x24,0x4b,0x72,0x21,0xb7,0x84,0xd0,0xd4,0x9c, | ||
| 1588 | 0xe3,0xaa,0x21,0x2f,0x2c,0x02,0xa4,0xe0,0x35,0xc1,0x7e,0x23,0x29,0xac,0xa1,0x2e, | ||
| 1589 | 0x21,0xd5,0x14,0xb2,0x54,0x66,0x93,0x1c,0x7d,0x8f,0x6a,0x5a,0xac,0x84,0xaa,0x05, | ||
| 1590 | 0x1b,0xa3,0x0b,0x39,0x6a,0x0a,0xac,0x97,0x3d,0x58,0xe0,0x91}, | ||
| 1591 | T4[]= {0x5b,0xc9,0x4f,0xbc,0x32,0x21,0xa5,0xdb,0x94,0xfa,0xe9,0x5a,0xe7,0x12,0x1a,0x47}; | ||
| 1592 | |||
| 1593 | /* Test Case 5 */ | ||
| 1594 | #define K5 K4 | ||
| 1595 | #define P5 P4 | ||
| 1596 | #define A5 A4 | ||
| 1597 | static const u8 IV5[]= {0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad}, | ||
| 1598 | C5[]= {0x61,0x35,0x3b,0x4c,0x28,0x06,0x93,0x4a,0x77,0x7f,0xf5,0x1f,0xa2,0x2a,0x47,0x55, | ||
| 1599 | 0x69,0x9b,0x2a,0x71,0x4f,0xcd,0xc6,0xf8,0x37,0x66,0xe5,0xf9,0x7b,0x6c,0x74,0x23, | ||
| 1600 | 0x73,0x80,0x69,0x00,0xe4,0x9f,0x24,0xb2,0x2b,0x09,0x75,0x44,0xd4,0x89,0x6b,0x42, | ||
| 1601 | 0x49,0x89,0xb5,0xe1,0xeb,0xac,0x0f,0x07,0xc2,0x3f,0x45,0x98}, | ||
| 1602 | T5[]= {0x36,0x12,0xd2,0xe7,0x9e,0x3b,0x07,0x85,0x56,0x1b,0xe1,0x4a,0xac,0xa2,0xfc,0xcb}; | ||
| 1603 | |||
| 1604 | /* Test Case 6 */ | ||
| 1605 | #define K6 K5 | ||
| 1606 | #define P6 P5 | ||
| 1607 | #define A6 A5 | ||
| 1608 | static const u8 IV6[]= {0x93,0x13,0x22,0x5d,0xf8,0x84,0x06,0xe5,0x55,0x90,0x9c,0x5a,0xff,0x52,0x69,0xaa, | ||
| 1609 | 0x6a,0x7a,0x95,0x38,0x53,0x4f,0x7d,0xa1,0xe4,0xc3,0x03,0xd2,0xa3,0x18,0xa7,0x28, | ||
| 1610 | 0xc3,0xc0,0xc9,0x51,0x56,0x80,0x95,0x39,0xfc,0xf0,0xe2,0x42,0x9a,0x6b,0x52,0x54, | ||
| 1611 | 0x16,0xae,0xdb,0xf5,0xa0,0xde,0x6a,0x57,0xa6,0x37,0xb3,0x9b}, | ||
| 1612 | C6[]= {0x8c,0xe2,0x49,0x98,0x62,0x56,0x15,0xb6,0x03,0xa0,0x33,0xac,0xa1,0x3f,0xb8,0x94, | ||
| 1613 | 0xbe,0x91,0x12,0xa5,0xc3,0xa2,0x11,0xa8,0xba,0x26,0x2a,0x3c,0xca,0x7e,0x2c,0xa7, | ||
| 1614 | 0x01,0xe4,0xa9,0xa4,0xfb,0xa4,0x3c,0x90,0xcc,0xdc,0xb2,0x81,0xd4,0x8c,0x7c,0x6f, | ||
| 1615 | 0xd6,0x28,0x75,0xd2,0xac,0xa4,0x17,0x03,0x4c,0x34,0xae,0xe5}, | ||
| 1616 | T6[]= {0x61,0x9c,0xc5,0xae,0xff,0xfe,0x0b,0xfa,0x46,0x2a,0xf4,0x3c,0x16,0x99,0xd0,0x50}; | ||
| 1617 | |||
| 1618 | /* Test Case 7 */ | ||
| 1619 | static const u8 K7[24], | ||
| 1620 | *P7=NULL, | ||
| 1621 | *A7=NULL, | ||
| 1622 | IV7[12], | ||
| 1623 | *C7=NULL, | ||
| 1624 | T7[]= {0xcd,0x33,0xb2,0x8a,0xc7,0x73,0xf7,0x4b,0xa0,0x0e,0xd1,0xf3,0x12,0x57,0x24,0x35}; | ||
| 1625 | |||
| 1626 | /* Test Case 8 */ | ||
| 1627 | #define K8 K7 | ||
| 1628 | #define IV8 IV7 | ||
| 1629 | #define A8 A7 | ||
| 1630 | static const u8 P8[16], | ||
| 1631 | C8[]= {0x98,0xe7,0x24,0x7c,0x07,0xf0,0xfe,0x41,0x1c,0x26,0x7e,0x43,0x84,0xb0,0xf6,0x00}, | ||
| 1632 | T8[]= {0x2f,0xf5,0x8d,0x80,0x03,0x39,0x27,0xab,0x8e,0xf4,0xd4,0x58,0x75,0x14,0xf0,0xfb}; | ||
| 1633 | |||
| 1634 | /* Test Case 9 */ | ||
| 1635 | #define A9 A8 | ||
| 1636 | static const u8 K9[]= {0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08, | ||
| 1637 | 0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c}, | ||
| 1638 | P9[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1639 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1640 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1641 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55}, | ||
| 1642 | IV9[]= {0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad,0xde,0xca,0xf8,0x88}, | ||
| 1643 | C9[]= {0x39,0x80,0xca,0x0b,0x3c,0x00,0xe8,0x41,0xeb,0x06,0xfa,0xc4,0x87,0x2a,0x27,0x57, | ||
| 1644 | 0x85,0x9e,0x1c,0xea,0xa6,0xef,0xd9,0x84,0x62,0x85,0x93,0xb4,0x0c,0xa1,0xe1,0x9c, | ||
| 1645 | 0x7d,0x77,0x3d,0x00,0xc1,0x44,0xc5,0x25,0xac,0x61,0x9d,0x18,0xc8,0x4a,0x3f,0x47, | ||
| 1646 | 0x18,0xe2,0x44,0x8b,0x2f,0xe3,0x24,0xd9,0xcc,0xda,0x27,0x10,0xac,0xad,0xe2,0x56}, | ||
| 1647 | T9[]= {0x99,0x24,0xa7,0xc8,0x58,0x73,0x36,0xbf,0xb1,0x18,0x02,0x4d,0xb8,0x67,0x4a,0x14}; | ||
| 1648 | |||
| 1649 | /* Test Case 10 */ | ||
| 1650 | #define K10 K9 | ||
| 1651 | #define IV10 IV9 | ||
| 1652 | static const u8 P10[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1653 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1654 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1655 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39}, | ||
| 1656 | A10[]= {0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef,0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef, | ||
| 1657 | 0xab,0xad,0xda,0xd2}, | ||
| 1658 | C10[]= {0x39,0x80,0xca,0x0b,0x3c,0x00,0xe8,0x41,0xeb,0x06,0xfa,0xc4,0x87,0x2a,0x27,0x57, | ||
| 1659 | 0x85,0x9e,0x1c,0xea,0xa6,0xef,0xd9,0x84,0x62,0x85,0x93,0xb4,0x0c,0xa1,0xe1,0x9c, | ||
| 1660 | 0x7d,0x77,0x3d,0x00,0xc1,0x44,0xc5,0x25,0xac,0x61,0x9d,0x18,0xc8,0x4a,0x3f,0x47, | ||
| 1661 | 0x18,0xe2,0x44,0x8b,0x2f,0xe3,0x24,0xd9,0xcc,0xda,0x27,0x10}, | ||
| 1662 | T10[]= {0x25,0x19,0x49,0x8e,0x80,0xf1,0x47,0x8f,0x37,0xba,0x55,0xbd,0x6d,0x27,0x61,0x8c}; | ||
| 1663 | |||
| 1664 | /* Test Case 11 */ | ||
| 1665 | #define K11 K10 | ||
| 1666 | #define P11 P10 | ||
| 1667 | #define A11 A10 | ||
| 1668 | static const u8 IV11[]={0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad}, | ||
| 1669 | C11[]= {0x0f,0x10,0xf5,0x99,0xae,0x14,0xa1,0x54,0xed,0x24,0xb3,0x6e,0x25,0x32,0x4d,0xb8, | ||
| 1670 | 0xc5,0x66,0x63,0x2e,0xf2,0xbb,0xb3,0x4f,0x83,0x47,0x28,0x0f,0xc4,0x50,0x70,0x57, | ||
| 1671 | 0xfd,0xdc,0x29,0xdf,0x9a,0x47,0x1f,0x75,0xc6,0x65,0x41,0xd4,0xd4,0xda,0xd1,0xc9, | ||
| 1672 | 0xe9,0x3a,0x19,0xa5,0x8e,0x8b,0x47,0x3f,0xa0,0xf0,0x62,0xf7}, | ||
| 1673 | T11[]= {0x65,0xdc,0xc5,0x7f,0xcf,0x62,0x3a,0x24,0x09,0x4f,0xcc,0xa4,0x0d,0x35,0x33,0xf8}; | ||
| 1674 | |||
| 1675 | /* Test Case 12 */ | ||
| 1676 | #define K12 K11 | ||
| 1677 | #define P12 P11 | ||
| 1678 | #define A12 A11 | ||
| 1679 | static const u8 IV12[]={0x93,0x13,0x22,0x5d,0xf8,0x84,0x06,0xe5,0x55,0x90,0x9c,0x5a,0xff,0x52,0x69,0xaa, | ||
| 1680 | 0x6a,0x7a,0x95,0x38,0x53,0x4f,0x7d,0xa1,0xe4,0xc3,0x03,0xd2,0xa3,0x18,0xa7,0x28, | ||
| 1681 | 0xc3,0xc0,0xc9,0x51,0x56,0x80,0x95,0x39,0xfc,0xf0,0xe2,0x42,0x9a,0x6b,0x52,0x54, | ||
| 1682 | 0x16,0xae,0xdb,0xf5,0xa0,0xde,0x6a,0x57,0xa6,0x37,0xb3,0x9b}, | ||
| 1683 | C12[]= {0xd2,0x7e,0x88,0x68,0x1c,0xe3,0x24,0x3c,0x48,0x30,0x16,0x5a,0x8f,0xdc,0xf9,0xff, | ||
| 1684 | 0x1d,0xe9,0xa1,0xd8,0xe6,0xb4,0x47,0xef,0x6e,0xf7,0xb7,0x98,0x28,0x66,0x6e,0x45, | ||
| 1685 | 0x81,0xe7,0x90,0x12,0xaf,0x34,0xdd,0xd9,0xe2,0xf0,0x37,0x58,0x9b,0x29,0x2d,0xb3, | ||
| 1686 | 0xe6,0x7c,0x03,0x67,0x45,0xfa,0x22,0xe7,0xe9,0xb7,0x37,0x3b}, | ||
| 1687 | T12[]= {0xdc,0xf5,0x66,0xff,0x29,0x1c,0x25,0xbb,0xb8,0x56,0x8f,0xc3,0xd3,0x76,0xa6,0xd9}; | ||
| 1688 | |||
| 1689 | /* Test Case 13 */ | ||
| 1690 | static const u8 K13[32], | ||
| 1691 | *P13=NULL, | ||
| 1692 | *A13=NULL, | ||
| 1693 | IV13[12], | ||
| 1694 | *C13=NULL, | ||
| 1695 | T13[]={0x53,0x0f,0x8a,0xfb,0xc7,0x45,0x36,0xb9,0xa9,0x63,0xb4,0xf1,0xc4,0xcb,0x73,0x8b}; | ||
| 1696 | |||
| 1697 | /* Test Case 14 */ | ||
| 1698 | #define K14 K13 | ||
| 1699 | #define A14 A13 | ||
| 1700 | static const u8 P14[16], | ||
| 1701 | IV14[12], | ||
| 1702 | C14[]= {0xce,0xa7,0x40,0x3d,0x4d,0x60,0x6b,0x6e,0x07,0x4e,0xc5,0xd3,0xba,0xf3,0x9d,0x18}, | ||
| 1703 | T14[]= {0xd0,0xd1,0xc8,0xa7,0x99,0x99,0x6b,0xf0,0x26,0x5b,0x98,0xb5,0xd4,0x8a,0xb9,0x19}; | ||
| 1704 | |||
| 1705 | /* Test Case 15 */ | ||
| 1706 | #define A15 A14 | ||
| 1707 | static const u8 K15[]= {0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08, | ||
| 1708 | 0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08}, | ||
| 1709 | P15[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1710 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1711 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1712 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55}, | ||
| 1713 | IV15[]={0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad,0xde,0xca,0xf8,0x88}, | ||
| 1714 | C15[]= {0x52,0x2d,0xc1,0xf0,0x99,0x56,0x7d,0x07,0xf4,0x7f,0x37,0xa3,0x2a,0x84,0x42,0x7d, | ||
| 1715 | 0x64,0x3a,0x8c,0xdc,0xbf,0xe5,0xc0,0xc9,0x75,0x98,0xa2,0xbd,0x25,0x55,0xd1,0xaa, | ||
| 1716 | 0x8c,0xb0,0x8e,0x48,0x59,0x0d,0xbb,0x3d,0xa7,0xb0,0x8b,0x10,0x56,0x82,0x88,0x38, | ||
| 1717 | 0xc5,0xf6,0x1e,0x63,0x93,0xba,0x7a,0x0a,0xbc,0xc9,0xf6,0x62,0x89,0x80,0x15,0xad}, | ||
| 1718 | T15[]= {0xb0,0x94,0xda,0xc5,0xd9,0x34,0x71,0xbd,0xec,0x1a,0x50,0x22,0x70,0xe3,0xcc,0x6c}; | ||
| 1719 | |||
| 1720 | /* Test Case 16 */ | ||
| 1721 | #define K16 K15 | ||
| 1722 | #define IV16 IV15 | ||
| 1723 | static const u8 P16[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1724 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1725 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1726 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39}, | ||
| 1727 | A16[]= {0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef,0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef, | ||
| 1728 | 0xab,0xad,0xda,0xd2}, | ||
| 1729 | C16[]= {0x52,0x2d,0xc1,0xf0,0x99,0x56,0x7d,0x07,0xf4,0x7f,0x37,0xa3,0x2a,0x84,0x42,0x7d, | ||
| 1730 | 0x64,0x3a,0x8c,0xdc,0xbf,0xe5,0xc0,0xc9,0x75,0x98,0xa2,0xbd,0x25,0x55,0xd1,0xaa, | ||
| 1731 | 0x8c,0xb0,0x8e,0x48,0x59,0x0d,0xbb,0x3d,0xa7,0xb0,0x8b,0x10,0x56,0x82,0x88,0x38, | ||
| 1732 | 0xc5,0xf6,0x1e,0x63,0x93,0xba,0x7a,0x0a,0xbc,0xc9,0xf6,0x62}, | ||
| 1733 | T16[]= {0x76,0xfc,0x6e,0xce,0x0f,0x4e,0x17,0x68,0xcd,0xdf,0x88,0x53,0xbb,0x2d,0x55,0x1b}; | ||
| 1734 | |||
| 1735 | /* Test Case 17 */ | ||
| 1736 | #define K17 K16 | ||
| 1737 | #define P17 P16 | ||
| 1738 | #define A17 A16 | ||
| 1739 | static const u8 IV17[]={0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad}, | ||
| 1740 | C17[]= {0xc3,0x76,0x2d,0xf1,0xca,0x78,0x7d,0x32,0xae,0x47,0xc1,0x3b,0xf1,0x98,0x44,0xcb, | ||
| 1741 | 0xaf,0x1a,0xe1,0x4d,0x0b,0x97,0x6a,0xfa,0xc5,0x2f,0xf7,0xd7,0x9b,0xba,0x9d,0xe0, | ||
| 1742 | 0xfe,0xb5,0x82,0xd3,0x39,0x34,0xa4,0xf0,0x95,0x4c,0xc2,0x36,0x3b,0xc7,0x3f,0x78, | ||
| 1743 | 0x62,0xac,0x43,0x0e,0x64,0xab,0xe4,0x99,0xf4,0x7c,0x9b,0x1f}, | ||
| 1744 | T17[]= {0x3a,0x33,0x7d,0xbf,0x46,0xa7,0x92,0xc4,0x5e,0x45,0x49,0x13,0xfe,0x2e,0xa8,0xf2}; | ||
| 1745 | |||
| 1746 | /* Test Case 18 */ | ||
| 1747 | #define K18 K17 | ||
| 1748 | #define P18 P17 | ||
| 1749 | #define A18 A17 | ||
| 1750 | static const u8 IV18[]={0x93,0x13,0x22,0x5d,0xf8,0x84,0x06,0xe5,0x55,0x90,0x9c,0x5a,0xff,0x52,0x69,0xaa, | ||
| 1751 | 0x6a,0x7a,0x95,0x38,0x53,0x4f,0x7d,0xa1,0xe4,0xc3,0x03,0xd2,0xa3,0x18,0xa7,0x28, | ||
| 1752 | 0xc3,0xc0,0xc9,0x51,0x56,0x80,0x95,0x39,0xfc,0xf0,0xe2,0x42,0x9a,0x6b,0x52,0x54, | ||
| 1753 | 0x16,0xae,0xdb,0xf5,0xa0,0xde,0x6a,0x57,0xa6,0x37,0xb3,0x9b}, | ||
| 1754 | C18[]= {0x5a,0x8d,0xef,0x2f,0x0c,0x9e,0x53,0xf1,0xf7,0x5d,0x78,0x53,0x65,0x9e,0x2a,0x20, | ||
| 1755 | 0xee,0xb2,0xb2,0x2a,0xaf,0xde,0x64,0x19,0xa0,0x58,0xab,0x4f,0x6f,0x74,0x6b,0xf4, | ||
| 1756 | 0x0f,0xc0,0xc3,0xb7,0x80,0xf2,0x44,0x45,0x2d,0xa3,0xeb,0xf1,0xc5,0xd8,0x2c,0xde, | ||
| 1757 | 0xa2,0x41,0x89,0x97,0x20,0x0e,0xf8,0x2e,0x44,0xae,0x7e,0x3f}, | ||
| 1758 | T18[]= {0xa4,0x4a,0x82,0x66,0xee,0x1c,0x8e,0xb0,0xc8,0xb5,0xd4,0xcf,0x5a,0xe9,0xf1,0x9a}; | ||
| 1759 | |||
| 1760 | /* Test Case 19 */ | ||
| 1761 | #define K19 K1 | ||
| 1762 | #define P19 P1 | ||
| 1763 | #define IV19 IV1 | ||
| 1764 | #define C19 C1 | ||
| 1765 | static const u8 A19[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 1766 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 1767 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 1768 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55, | ||
| 1769 | 0x52,0x2d,0xc1,0xf0,0x99,0x56,0x7d,0x07,0xf4,0x7f,0x37,0xa3,0x2a,0x84,0x42,0x7d, | ||
| 1770 | 0x64,0x3a,0x8c,0xdc,0xbf,0xe5,0xc0,0xc9,0x75,0x98,0xa2,0xbd,0x25,0x55,0xd1,0xaa, | ||
| 1771 | 0x8c,0xb0,0x8e,0x48,0x59,0x0d,0xbb,0x3d,0xa7,0xb0,0x8b,0x10,0x56,0x82,0x88,0x38, | ||
| 1772 | 0xc5,0xf6,0x1e,0x63,0x93,0xba,0x7a,0x0a,0xbc,0xc9,0xf6,0x62,0x89,0x80,0x15,0xad}, | ||
| 1773 | T19[]= {0x5f,0xea,0x79,0x3a,0x2d,0x6f,0x97,0x4d,0x37,0xe6,0x8e,0x0c,0xb8,0xff,0x94,0x92}; | ||
| 1774 | |||
| 1775 | /* Test Case 20 */ | ||
| 1776 | #define K20 K1 | ||
| 1777 | #define A20 A1 | ||
| 1778 | static const u8 IV20[64]={0xff,0xff,0xff,0xff}, /* this results in 0xff in counter LSB */ | ||
| 1779 | P20[288], | ||
| 1780 | C20[]= {0x56,0xb3,0x37,0x3c,0xa9,0xef,0x6e,0x4a,0x2b,0x64,0xfe,0x1e,0x9a,0x17,0xb6,0x14, | ||
| 1781 | 0x25,0xf1,0x0d,0x47,0xa7,0x5a,0x5f,0xce,0x13,0xef,0xc6,0xbc,0x78,0x4a,0xf2,0x4f, | ||
| 1782 | 0x41,0x41,0xbd,0xd4,0x8c,0xf7,0xc7,0x70,0x88,0x7a,0xfd,0x57,0x3c,0xca,0x54,0x18, | ||
| 1783 | 0xa9,0xae,0xff,0xcd,0x7c,0x5c,0xed,0xdf,0xc6,0xa7,0x83,0x97,0xb9,0xa8,0x5b,0x49, | ||
| 1784 | 0x9d,0xa5,0x58,0x25,0x72,0x67,0xca,0xab,0x2a,0xd0,0xb2,0x3c,0xa4,0x76,0xa5,0x3c, | ||
| 1785 | 0xb1,0x7f,0xb4,0x1c,0x4b,0x8b,0x47,0x5c,0xb4,0xf3,0xf7,0x16,0x50,0x94,0xc2,0x29, | ||
| 1786 | 0xc9,0xe8,0xc4,0xdc,0x0a,0x2a,0x5f,0xf1,0x90,0x3e,0x50,0x15,0x11,0x22,0x13,0x76, | ||
| 1787 | 0xa1,0xcd,0xb8,0x36,0x4c,0x50,0x61,0xa2,0x0c,0xae,0x74,0xbc,0x4a,0xcd,0x76,0xce, | ||
| 1788 | 0xb0,0xab,0xc9,0xfd,0x32,0x17,0xef,0x9f,0x8c,0x90,0xbe,0x40,0x2d,0xdf,0x6d,0x86, | ||
| 1789 | 0x97,0xf4,0xf8,0x80,0xdf,0xf1,0x5b,0xfb,0x7a,0x6b,0x28,0x24,0x1e,0xc8,0xfe,0x18, | ||
| 1790 | 0x3c,0x2d,0x59,0xe3,0xf9,0xdf,0xff,0x65,0x3c,0x71,0x26,0xf0,0xac,0xb9,0xe6,0x42, | ||
| 1791 | 0x11,0xf4,0x2b,0xae,0x12,0xaf,0x46,0x2b,0x10,0x70,0xbe,0xf1,0xab,0x5e,0x36,0x06, | ||
| 1792 | 0x87,0x2c,0xa1,0x0d,0xee,0x15,0xb3,0x24,0x9b,0x1a,0x1b,0x95,0x8f,0x23,0x13,0x4c, | ||
| 1793 | 0x4b,0xcc,0xb7,0xd0,0x32,0x00,0xbc,0xe4,0x20,0xa2,0xf8,0xeb,0x66,0xdc,0xf3,0x64, | ||
| 1794 | 0x4d,0x14,0x23,0xc1,0xb5,0x69,0x90,0x03,0xc1,0x3e,0xce,0xf4,0xbf,0x38,0xa3,0xb6, | ||
| 1795 | 0x0e,0xed,0xc3,0x40,0x33,0xba,0xc1,0x90,0x27,0x83,0xdc,0x6d,0x89,0xe2,0xe7,0x74, | ||
| 1796 | 0x18,0x8a,0x43,0x9c,0x7e,0xbc,0xc0,0x67,0x2d,0xbd,0xa4,0xdd,0xcf,0xb2,0x79,0x46, | ||
| 1797 | 0x13,0xb0,0xbe,0x41,0x31,0x5e,0xf7,0x78,0x70,0x8a,0x70,0xee,0x7d,0x75,0x16,0x5c}, | ||
| 1798 | T20[]= {0x8b,0x30,0x7f,0x6b,0x33,0x28,0x6d,0x0a,0xb0,0x26,0xa9,0xed,0x3f,0xe1,0xe8,0x5f}; | ||
| 1799 | |||
| 1800 | #define TEST_CASE(n) do { \ | ||
| 1801 | u8 out[sizeof(P##n)]; \ | ||
| 1802 | AES_set_encrypt_key(K##n,sizeof(K##n)*8,&key); \ | ||
| 1803 | CRYPTO_gcm128_init(&ctx,&key,(block128_f)AES_encrypt); \ | ||
| 1804 | CRYPTO_gcm128_setiv(&ctx,IV##n,sizeof(IV##n)); \ | ||
| 1805 | memset(out,0,sizeof(out)); \ | ||
| 1806 | if (A##n) CRYPTO_gcm128_aad(&ctx,A##n,sizeof(A##n)); \ | ||
| 1807 | if (P##n) CRYPTO_gcm128_encrypt(&ctx,P##n,out,sizeof(out)); \ | ||
| 1808 | if (CRYPTO_gcm128_finish(&ctx,T##n,16) || \ | ||
| 1809 | (C##n && memcmp(out,C##n,sizeof(out)))) \ | ||
| 1810 | ret++, printf ("encrypt test#%d failed.\n",n); \ | ||
| 1811 | CRYPTO_gcm128_setiv(&ctx,IV##n,sizeof(IV##n)); \ | ||
| 1812 | memset(out,0,sizeof(out)); \ | ||
| 1813 | if (A##n) CRYPTO_gcm128_aad(&ctx,A##n,sizeof(A##n)); \ | ||
| 1814 | if (C##n) CRYPTO_gcm128_decrypt(&ctx,C##n,out,sizeof(out)); \ | ||
| 1815 | if (CRYPTO_gcm128_finish(&ctx,T##n,16) || \ | ||
| 1816 | (P##n && memcmp(out,P##n,sizeof(out)))) \ | ||
| 1817 | ret++, printf ("decrypt test#%d failed.\n",n); \ | ||
| 1818 | } while(0) | ||
| 1819 | |||
| 1820 | int main() | ||
| 1821 | { | ||
| 1822 | GCM128_CONTEXT ctx; | ||
| 1823 | AES_KEY key; | ||
| 1824 | int ret=0; | ||
| 1825 | |||
| 1826 | TEST_CASE(1); | ||
| 1827 | TEST_CASE(2); | ||
| 1828 | TEST_CASE(3); | ||
| 1829 | TEST_CASE(4); | ||
| 1830 | TEST_CASE(5); | ||
| 1831 | TEST_CASE(6); | ||
| 1832 | TEST_CASE(7); | ||
| 1833 | TEST_CASE(8); | ||
| 1834 | TEST_CASE(9); | ||
| 1835 | TEST_CASE(10); | ||
| 1836 | TEST_CASE(11); | ||
| 1837 | TEST_CASE(12); | ||
| 1838 | TEST_CASE(13); | ||
| 1839 | TEST_CASE(14); | ||
| 1840 | TEST_CASE(15); | ||
| 1841 | TEST_CASE(16); | ||
| 1842 | TEST_CASE(17); | ||
| 1843 | TEST_CASE(18); | ||
| 1844 | TEST_CASE(19); | ||
| 1845 | TEST_CASE(20); | ||
| 1846 | |||
| 1847 | return ret; | ||
| 1848 | } | ||
| 1849 | #endif | ||
diff --git a/src/regress/lib/libcrypto/Makefile b/src/regress/lib/libcrypto/Makefile index bdf17723df..d6510d64c6 100644 --- a/src/regress/lib/libcrypto/Makefile +++ b/src/regress/lib/libcrypto/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.11 2014/05/30 15:38:28 jsing Exp $ | 1 | # $OpenBSD: Makefile,v 1.12 2014/05/31 14:39:06 jsing Exp $ |
| 2 | 2 | ||
| 3 | SUBDIR= \ | 3 | SUBDIR= \ |
| 4 | aeswrap \ | 4 | aeswrap \ |
| @@ -7,6 +7,7 @@ SUBDIR= \ | |||
| 7 | bn \ | 7 | bn \ |
| 8 | cast \ | 8 | cast \ |
| 9 | chacha \ | 9 | chacha \ |
| 10 | cts128 \ | ||
| 10 | des \ | 11 | des \ |
| 11 | dh \ | 12 | dh \ |
| 12 | dsa \ | 13 | dsa \ |
diff --git a/src/regress/lib/libcrypto/cts128/Makefile b/src/regress/lib/libcrypto/cts128/Makefile new file mode 100644 index 0000000000..4423e9c20b --- /dev/null +++ b/src/regress/lib/libcrypto/cts128/Makefile | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2014/05/31 14:39:06 jsing Exp $ | ||
| 2 | |||
| 3 | PROG= cts128test | ||
| 4 | LDADD= -lcrypto | ||
| 5 | DPADD= ${LIBCRYPTO} | ||
| 6 | |||
| 7 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libcrypto/cts128/cts128test.c b/src/regress/lib/libcrypto/cts128/cts128test.c new file mode 100644 index 0000000000..84a3e0d46b --- /dev/null +++ b/src/regress/lib/libcrypto/cts128/cts128test.c | |||
| @@ -0,0 +1,160 @@ | |||
| 1 | /* ==================================================================== | ||
| 2 | * Copyright (c) 2008 The OpenSSL Project. All rights reserved. | ||
| 3 | * | ||
| 4 | * Rights for redistribution and usage in source and binary | ||
| 5 | * forms are granted according to the OpenSSL license. | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <stdio.h> | ||
| 9 | #include <stdlib.h> | ||
| 10 | #include <string.h> | ||
| 11 | |||
| 12 | #include <openssl/aes.h> | ||
| 13 | #include <openssl/modes.h> | ||
| 14 | |||
| 15 | /* test vectors from RFC 3962 */ | ||
| 16 | static const unsigned char test_key[16] = "chicken teriyaki"; | ||
| 17 | static const unsigned char test_input[64] = | ||
| 18 | "I would like the" " General Gau's C" | ||
| 19 | "hicken, please, " "and wonton soup."; | ||
| 20 | static const unsigned char test_iv[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | ||
| 21 | |||
| 22 | static const unsigned char vector_17[17] = | ||
| 23 | {0xc6,0x35,0x35,0x68,0xf2,0xbf,0x8c,0xb4, 0xd8,0xa5,0x80,0x36,0x2d,0xa7,0xff,0x7f, | ||
| 24 | 0x97}; | ||
| 25 | static const unsigned char vector_31[31] = | ||
| 26 | {0xfc,0x00,0x78,0x3e,0x0e,0xfd,0xb2,0xc1, 0xd4,0x45,0xd4,0xc8,0xef,0xf7,0xed,0x22, | ||
| 27 | 0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5}; | ||
| 28 | static const unsigned char vector_32[32] = | ||
| 29 | {0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8, | ||
| 30 | 0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84}; | ||
| 31 | static const unsigned char vector_47[47] = | ||
| 32 | {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, | ||
| 33 | 0xb3,0xff,0xfd,0x94,0x0c,0x16,0xa1,0x8c, 0x1b,0x55,0x49,0xd2,0xf8,0x38,0x02,0x9e, | ||
| 34 | 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5}; | ||
| 35 | static const unsigned char vector_48[48] = | ||
| 36 | {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, | ||
| 37 | 0x9d,0xad,0x8b,0xbb,0x96,0xc4,0xcd,0xc0, 0x3b,0xc1,0x03,0xe1,0xa1,0x94,0xbb,0xd8, | ||
| 38 | 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8}; | ||
| 39 | static const unsigned char vector_64[64] = | ||
| 40 | {0x97,0x68,0x72,0x68,0xd6,0xec,0xcc,0xc0, 0xc0,0x7b,0x25,0xe2,0x5e,0xcf,0xe5,0x84, | ||
| 41 | 0x39,0x31,0x25,0x23,0xa7,0x86,0x62,0xd5, 0xbe,0x7f,0xcb,0xcc,0x98,0xeb,0xf5,0xa8, | ||
| 42 | 0x48,0x07,0xef,0xe8,0x36,0xee,0x89,0xa5, 0x26,0x73,0x0d,0xbc,0x2f,0x7b,0xc8,0x40, | ||
| 43 | 0x9d,0xad,0x8b,0xbb,0x96,0xc4,0xcd,0xc0, 0x3b,0xc1,0x03,0xe1,0xa1,0x94,0xbb,0xd8}; | ||
| 44 | |||
| 45 | static AES_KEY encks, decks; | ||
| 46 | |||
| 47 | void test_vector(const unsigned char *vector,size_t len) | ||
| 48 | { unsigned char iv[sizeof(test_iv)]; | ||
| 49 | unsigned char cleartext[64],ciphertext[64]; | ||
| 50 | size_t tail; | ||
| 51 | |||
| 52 | printf("vector_%d\n",len); fflush(stdout); | ||
| 53 | |||
| 54 | if ((tail=len%16) == 0) tail = 16; | ||
| 55 | tail += 16; | ||
| 56 | |||
| 57 | /* test block-based encryption */ | ||
| 58 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 59 | CRYPTO_cts128_encrypt_block(test_input,ciphertext,len,&encks,iv,(block128_f)AES_encrypt); | ||
| 60 | if (memcmp(ciphertext,vector,len)) | ||
| 61 | fprintf(stderr,"output_%d mismatch\n",len), exit(1); | ||
| 62 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 63 | fprintf(stderr,"iv_%d mismatch\n",len), exit(1); | ||
| 64 | |||
| 65 | /* test block-based decryption */ | ||
| 66 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 67 | CRYPTO_cts128_decrypt_block(ciphertext,cleartext,len,&decks,iv,(block128_f)AES_decrypt); | ||
| 68 | if (memcmp(cleartext,test_input,len)) | ||
| 69 | fprintf(stderr,"input_%d mismatch\n",len), exit(2); | ||
| 70 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 71 | fprintf(stderr,"iv_%d mismatch\n",len), exit(2); | ||
| 72 | |||
| 73 | /* test streamed encryption */ | ||
| 74 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 75 | CRYPTO_cts128_encrypt(test_input,ciphertext,len,&encks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 76 | if (memcmp(ciphertext,vector,len)) | ||
| 77 | fprintf(stderr,"output_%d mismatch\n",len), exit(3); | ||
| 78 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 79 | fprintf(stderr,"iv_%d mismatch\n",len), exit(3); | ||
| 80 | |||
| 81 | /* test streamed decryption */ | ||
| 82 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 83 | CRYPTO_cts128_decrypt(ciphertext,cleartext,len,&decks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 84 | if (memcmp(cleartext,test_input,len)) | ||
| 85 | fprintf(stderr,"input_%d mismatch\n",len), exit(4); | ||
| 86 | if (memcmp(iv,vector+len-tail,sizeof(iv))) | ||
| 87 | fprintf(stderr,"iv_%d mismatch\n",len), exit(4); | ||
| 88 | } | ||
| 89 | |||
| 90 | void test_nistvector(const unsigned char *vector,size_t len) | ||
| 91 | { unsigned char iv[sizeof(test_iv)]; | ||
| 92 | unsigned char cleartext[64],ciphertext[64],nistvector[64]; | ||
| 93 | size_t tail; | ||
| 94 | |||
| 95 | printf("nistvector_%d\n",len); fflush(stdout); | ||
| 96 | |||
| 97 | if ((tail=len%16) == 0) tail = 16; | ||
| 98 | |||
| 99 | len -= 16 + tail; | ||
| 100 | memcpy(nistvector,vector,len); | ||
| 101 | /* flip two last blocks */ | ||
| 102 | memcpy(nistvector+len,vector+len+16,tail); | ||
| 103 | memcpy(nistvector+len+tail,vector+len,16); | ||
| 104 | len += 16 + tail; | ||
| 105 | tail = 16; | ||
| 106 | |||
| 107 | /* test block-based encryption */ | ||
| 108 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 109 | CRYPTO_nistcts128_encrypt_block(test_input,ciphertext,len,&encks,iv,(block128_f)AES_encrypt); | ||
| 110 | if (memcmp(ciphertext,nistvector,len)) | ||
| 111 | fprintf(stderr,"output_%d mismatch\n",len), exit(1); | ||
| 112 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 113 | fprintf(stderr,"iv_%d mismatch\n",len), exit(1); | ||
| 114 | |||
| 115 | /* test block-based decryption */ | ||
| 116 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 117 | CRYPTO_nistcts128_decrypt_block(ciphertext,cleartext,len,&decks,iv,(block128_f)AES_decrypt); | ||
| 118 | if (memcmp(cleartext,test_input,len)) | ||
| 119 | fprintf(stderr,"input_%d mismatch\n",len), exit(2); | ||
| 120 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 121 | fprintf(stderr,"iv_%d mismatch\n",len), exit(2); | ||
| 122 | |||
| 123 | /* test streamed encryption */ | ||
| 124 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 125 | CRYPTO_nistcts128_encrypt(test_input,ciphertext,len,&encks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 126 | if (memcmp(ciphertext,nistvector,len)) | ||
| 127 | fprintf(stderr,"output_%d mismatch\n",len), exit(3); | ||
| 128 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 129 | fprintf(stderr,"iv_%d mismatch\n",len), exit(3); | ||
| 130 | |||
| 131 | /* test streamed decryption */ | ||
| 132 | memcpy(iv,test_iv,sizeof(test_iv)); | ||
| 133 | CRYPTO_nistcts128_decrypt(ciphertext,cleartext,len,&decks,iv,(cbc128_f)AES_cbc_encrypt); | ||
| 134 | if (memcmp(cleartext,test_input,len)) | ||
| 135 | fprintf(stderr,"input_%d mismatch\n",len), exit(4); | ||
| 136 | if (memcmp(iv,nistvector+len-tail,sizeof(iv))) | ||
| 137 | fprintf(stderr,"iv_%d mismatch\n",len), exit(4); | ||
| 138 | } | ||
| 139 | |||
| 140 | int main() | ||
| 141 | { | ||
| 142 | AES_set_encrypt_key(test_key,128,&encks); | ||
| 143 | AES_set_decrypt_key(test_key,128,&decks); | ||
| 144 | |||
| 145 | test_vector(vector_17,sizeof(vector_17)); | ||
| 146 | test_vector(vector_31,sizeof(vector_31)); | ||
| 147 | test_vector(vector_32,sizeof(vector_32)); | ||
| 148 | test_vector(vector_47,sizeof(vector_47)); | ||
| 149 | test_vector(vector_48,sizeof(vector_48)); | ||
| 150 | test_vector(vector_64,sizeof(vector_64)); | ||
| 151 | |||
| 152 | test_nistvector(vector_17,sizeof(vector_17)); | ||
| 153 | test_nistvector(vector_31,sizeof(vector_31)); | ||
| 154 | test_nistvector(vector_32,sizeof(vector_32)); | ||
| 155 | test_nistvector(vector_47,sizeof(vector_47)); | ||
| 156 | test_nistvector(vector_48,sizeof(vector_48)); | ||
| 157 | test_nistvector(vector_64,sizeof(vector_64)); | ||
| 158 | |||
| 159 | return 0; | ||
| 160 | } | ||
diff --git a/src/regress/lib/libcrypto/gcm128/Makefile b/src/regress/lib/libcrypto/gcm128/Makefile index 7583403ad3..c1ce651f51 100644 --- a/src/regress/lib/libcrypto/gcm128/Makefile +++ b/src/regress/lib/libcrypto/gcm128/Makefile | |||
| @@ -1,10 +1,8 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2014/04/17 18:33:22 miod Exp $ | 1 | # $OpenBSD: Makefile,v 1.2 2014/05/31 14:39:06 jsing Exp $ |
| 2 | 2 | ||
| 3 | PROG= gcm128 | 3 | PROG= gcm128test |
| 4 | SRC= ${.CURDIR}/../../../../lib/libssl/src/crypto/modes | 4 | SRC= ${.CURDIR}/../../../../lib/libssl/src/crypto/modes |
| 5 | CFLAGS+= -DSELFTEST | 5 | CFLAGS+=-I${SRC} |
| 6 | CFLAGS+= -I${SRC} | ||
| 7 | .PATH: ${SRC} | ||
| 8 | 6 | ||
| 9 | LDADD= -lcrypto | 7 | LDADD= -lcrypto |
| 10 | DPADD= ${LIBCRYPTO} | 8 | DPADD= ${LIBCRYPTO} |
diff --git a/src/regress/lib/libcrypto/gcm128/gcm128test.c b/src/regress/lib/libcrypto/gcm128/gcm128test.c new file mode 100644 index 0000000000..5ed8e0a714 --- /dev/null +++ b/src/regress/lib/libcrypto/gcm128/gcm128test.c | |||
| @@ -0,0 +1,358 @@ | |||
| 1 | /* ==================================================================== | ||
| 2 | * Copyright (c) 2010 The OpenSSL Project. All rights reserved. | ||
| 3 | * | ||
| 4 | * Redistribution and use in source and binary forms, with or without | ||
| 5 | * modification, are permitted provided that the following conditions | ||
| 6 | * are met: | ||
| 7 | * | ||
| 8 | * 1. Redistributions of source code must retain the above copyright | ||
| 9 | * notice, this list of conditions and the following disclaimer. | ||
| 10 | * | ||
| 11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 12 | * notice, this list of conditions and the following disclaimer in | ||
| 13 | * the documentation and/or other materials provided with the | ||
| 14 | * distribution. | ||
| 15 | * | ||
| 16 | * 3. All advertising materials mentioning features or use of this | ||
| 17 | * software must display the following acknowledgment: | ||
| 18 | * "This product includes software developed by the OpenSSL Project | ||
| 19 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 20 | * | ||
| 21 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 22 | * endorse or promote products derived from this software without | ||
| 23 | * prior written permission. For written permission, please contact | ||
| 24 | * openssl-core@openssl.org. | ||
| 25 | * | ||
| 26 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 27 | * nor may "OpenSSL" appear in their names without prior written | ||
| 28 | * permission of the OpenSSL Project. | ||
| 29 | * | ||
| 30 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 31 | * acknowledgment: | ||
| 32 | * "This product includes software developed by the OpenSSL Project | ||
| 33 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 34 | * | ||
| 35 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 36 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 38 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 41 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 42 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 43 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 44 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 45 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 46 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 47 | * ==================================================================== | ||
| 48 | */ | ||
| 49 | |||
| 50 | #include <stdio.h> | ||
| 51 | #include <string.h> | ||
| 52 | |||
| 53 | #include <openssl/aes.h> | ||
| 54 | #include <openssl/modes.h> | ||
| 55 | |||
| 56 | #include "modes_lcl.h" | ||
| 57 | |||
| 58 | /* Test Case 1 */ | ||
| 59 | static const u8 K1[16], | ||
| 60 | *P1=NULL, | ||
| 61 | *A1=NULL, | ||
| 62 | IV1[12], | ||
| 63 | *C1=NULL, | ||
| 64 | T1[]= {0x58,0xe2,0xfc,0xce,0xfa,0x7e,0x30,0x61,0x36,0x7f,0x1d,0x57,0xa4,0xe7,0x45,0x5a}; | ||
| 65 | |||
| 66 | /* Test Case 2 */ | ||
| 67 | #define K2 K1 | ||
| 68 | #define A2 A1 | ||
| 69 | #define IV2 IV1 | ||
| 70 | static const u8 P2[16], | ||
| 71 | C2[]= {0x03,0x88,0xda,0xce,0x60,0xb6,0xa3,0x92,0xf3,0x28,0xc2,0xb9,0x71,0xb2,0xfe,0x78}, | ||
| 72 | T2[]= {0xab,0x6e,0x47,0xd4,0x2c,0xec,0x13,0xbd,0xf5,0x3a,0x67,0xb2,0x12,0x57,0xbd,0xdf}; | ||
| 73 | |||
| 74 | /* Test Case 3 */ | ||
| 75 | #define A3 A2 | ||
| 76 | static const u8 K3[]= {0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08}, | ||
| 77 | P3[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 78 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 79 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 80 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55}, | ||
| 81 | IV3[]= {0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad,0xde,0xca,0xf8,0x88}, | ||
| 82 | C3[]= {0x42,0x83,0x1e,0xc2,0x21,0x77,0x74,0x24,0x4b,0x72,0x21,0xb7,0x84,0xd0,0xd4,0x9c, | ||
| 83 | 0xe3,0xaa,0x21,0x2f,0x2c,0x02,0xa4,0xe0,0x35,0xc1,0x7e,0x23,0x29,0xac,0xa1,0x2e, | ||
| 84 | 0x21,0xd5,0x14,0xb2,0x54,0x66,0x93,0x1c,0x7d,0x8f,0x6a,0x5a,0xac,0x84,0xaa,0x05, | ||
| 85 | 0x1b,0xa3,0x0b,0x39,0x6a,0x0a,0xac,0x97,0x3d,0x58,0xe0,0x91,0x47,0x3f,0x59,0x85}, | ||
| 86 | T3[]= {0x4d,0x5c,0x2a,0xf3,0x27,0xcd,0x64,0xa6,0x2c,0xf3,0x5a,0xbd,0x2b,0xa6,0xfa,0xb4}; | ||
| 87 | |||
| 88 | /* Test Case 4 */ | ||
| 89 | #define K4 K3 | ||
| 90 | #define IV4 IV3 | ||
| 91 | static const u8 P4[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 92 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 93 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 94 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39}, | ||
| 95 | A4[]= {0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef,0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef, | ||
| 96 | 0xab,0xad,0xda,0xd2}, | ||
| 97 | C4[]= {0x42,0x83,0x1e,0xc2,0x21,0x77,0x74,0x24,0x4b,0x72,0x21,0xb7,0x84,0xd0,0xd4,0x9c, | ||
| 98 | 0xe3,0xaa,0x21,0x2f,0x2c,0x02,0xa4,0xe0,0x35,0xc1,0x7e,0x23,0x29,0xac,0xa1,0x2e, | ||
| 99 | 0x21,0xd5,0x14,0xb2,0x54,0x66,0x93,0x1c,0x7d,0x8f,0x6a,0x5a,0xac,0x84,0xaa,0x05, | ||
| 100 | 0x1b,0xa3,0x0b,0x39,0x6a,0x0a,0xac,0x97,0x3d,0x58,0xe0,0x91}, | ||
| 101 | T4[]= {0x5b,0xc9,0x4f,0xbc,0x32,0x21,0xa5,0xdb,0x94,0xfa,0xe9,0x5a,0xe7,0x12,0x1a,0x47}; | ||
| 102 | |||
| 103 | /* Test Case 5 */ | ||
| 104 | #define K5 K4 | ||
| 105 | #define P5 P4 | ||
| 106 | #define A5 A4 | ||
| 107 | static const u8 IV5[]= {0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad}, | ||
| 108 | C5[]= {0x61,0x35,0x3b,0x4c,0x28,0x06,0x93,0x4a,0x77,0x7f,0xf5,0x1f,0xa2,0x2a,0x47,0x55, | ||
| 109 | 0x69,0x9b,0x2a,0x71,0x4f,0xcd,0xc6,0xf8,0x37,0x66,0xe5,0xf9,0x7b,0x6c,0x74,0x23, | ||
| 110 | 0x73,0x80,0x69,0x00,0xe4,0x9f,0x24,0xb2,0x2b,0x09,0x75,0x44,0xd4,0x89,0x6b,0x42, | ||
| 111 | 0x49,0x89,0xb5,0xe1,0xeb,0xac,0x0f,0x07,0xc2,0x3f,0x45,0x98}, | ||
| 112 | T5[]= {0x36,0x12,0xd2,0xe7,0x9e,0x3b,0x07,0x85,0x56,0x1b,0xe1,0x4a,0xac,0xa2,0xfc,0xcb}; | ||
| 113 | |||
| 114 | /* Test Case 6 */ | ||
| 115 | #define K6 K5 | ||
| 116 | #define P6 P5 | ||
| 117 | #define A6 A5 | ||
| 118 | static const u8 IV6[]= {0x93,0x13,0x22,0x5d,0xf8,0x84,0x06,0xe5,0x55,0x90,0x9c,0x5a,0xff,0x52,0x69,0xaa, | ||
| 119 | 0x6a,0x7a,0x95,0x38,0x53,0x4f,0x7d,0xa1,0xe4,0xc3,0x03,0xd2,0xa3,0x18,0xa7,0x28, | ||
| 120 | 0xc3,0xc0,0xc9,0x51,0x56,0x80,0x95,0x39,0xfc,0xf0,0xe2,0x42,0x9a,0x6b,0x52,0x54, | ||
| 121 | 0x16,0xae,0xdb,0xf5,0xa0,0xde,0x6a,0x57,0xa6,0x37,0xb3,0x9b}, | ||
| 122 | C6[]= {0x8c,0xe2,0x49,0x98,0x62,0x56,0x15,0xb6,0x03,0xa0,0x33,0xac,0xa1,0x3f,0xb8,0x94, | ||
| 123 | 0xbe,0x91,0x12,0xa5,0xc3,0xa2,0x11,0xa8,0xba,0x26,0x2a,0x3c,0xca,0x7e,0x2c,0xa7, | ||
| 124 | 0x01,0xe4,0xa9,0xa4,0xfb,0xa4,0x3c,0x90,0xcc,0xdc,0xb2,0x81,0xd4,0x8c,0x7c,0x6f, | ||
| 125 | 0xd6,0x28,0x75,0xd2,0xac,0xa4,0x17,0x03,0x4c,0x34,0xae,0xe5}, | ||
| 126 | T6[]= {0x61,0x9c,0xc5,0xae,0xff,0xfe,0x0b,0xfa,0x46,0x2a,0xf4,0x3c,0x16,0x99,0xd0,0x50}; | ||
| 127 | |||
| 128 | /* Test Case 7 */ | ||
| 129 | static const u8 K7[24], | ||
| 130 | *P7=NULL, | ||
| 131 | *A7=NULL, | ||
| 132 | IV7[12], | ||
| 133 | *C7=NULL, | ||
| 134 | T7[]= {0xcd,0x33,0xb2,0x8a,0xc7,0x73,0xf7,0x4b,0xa0,0x0e,0xd1,0xf3,0x12,0x57,0x24,0x35}; | ||
| 135 | |||
| 136 | /* Test Case 8 */ | ||
| 137 | #define K8 K7 | ||
| 138 | #define IV8 IV7 | ||
| 139 | #define A8 A7 | ||
| 140 | static const u8 P8[16], | ||
| 141 | C8[]= {0x98,0xe7,0x24,0x7c,0x07,0xf0,0xfe,0x41,0x1c,0x26,0x7e,0x43,0x84,0xb0,0xf6,0x00}, | ||
| 142 | T8[]= {0x2f,0xf5,0x8d,0x80,0x03,0x39,0x27,0xab,0x8e,0xf4,0xd4,0x58,0x75,0x14,0xf0,0xfb}; | ||
| 143 | |||
| 144 | /* Test Case 9 */ | ||
| 145 | #define A9 A8 | ||
| 146 | static const u8 K9[]= {0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08, | ||
| 147 | 0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c}, | ||
| 148 | P9[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 149 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 150 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 151 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55}, | ||
| 152 | IV9[]= {0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad,0xde,0xca,0xf8,0x88}, | ||
| 153 | C9[]= {0x39,0x80,0xca,0x0b,0x3c,0x00,0xe8,0x41,0xeb,0x06,0xfa,0xc4,0x87,0x2a,0x27,0x57, | ||
| 154 | 0x85,0x9e,0x1c,0xea,0xa6,0xef,0xd9,0x84,0x62,0x85,0x93,0xb4,0x0c,0xa1,0xe1,0x9c, | ||
| 155 | 0x7d,0x77,0x3d,0x00,0xc1,0x44,0xc5,0x25,0xac,0x61,0x9d,0x18,0xc8,0x4a,0x3f,0x47, | ||
| 156 | 0x18,0xe2,0x44,0x8b,0x2f,0xe3,0x24,0xd9,0xcc,0xda,0x27,0x10,0xac,0xad,0xe2,0x56}, | ||
| 157 | T9[]= {0x99,0x24,0xa7,0xc8,0x58,0x73,0x36,0xbf,0xb1,0x18,0x02,0x4d,0xb8,0x67,0x4a,0x14}; | ||
| 158 | |||
| 159 | /* Test Case 10 */ | ||
| 160 | #define K10 K9 | ||
| 161 | #define IV10 IV9 | ||
| 162 | static const u8 P10[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 163 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 164 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 165 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39}, | ||
| 166 | A10[]= {0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef,0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef, | ||
| 167 | 0xab,0xad,0xda,0xd2}, | ||
| 168 | C10[]= {0x39,0x80,0xca,0x0b,0x3c,0x00,0xe8,0x41,0xeb,0x06,0xfa,0xc4,0x87,0x2a,0x27,0x57, | ||
| 169 | 0x85,0x9e,0x1c,0xea,0xa6,0xef,0xd9,0x84,0x62,0x85,0x93,0xb4,0x0c,0xa1,0xe1,0x9c, | ||
| 170 | 0x7d,0x77,0x3d,0x00,0xc1,0x44,0xc5,0x25,0xac,0x61,0x9d,0x18,0xc8,0x4a,0x3f,0x47, | ||
| 171 | 0x18,0xe2,0x44,0x8b,0x2f,0xe3,0x24,0xd9,0xcc,0xda,0x27,0x10}, | ||
| 172 | T10[]= {0x25,0x19,0x49,0x8e,0x80,0xf1,0x47,0x8f,0x37,0xba,0x55,0xbd,0x6d,0x27,0x61,0x8c}; | ||
| 173 | |||
| 174 | /* Test Case 11 */ | ||
| 175 | #define K11 K10 | ||
| 176 | #define P11 P10 | ||
| 177 | #define A11 A10 | ||
| 178 | static const u8 IV11[]={0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad}, | ||
| 179 | C11[]= {0x0f,0x10,0xf5,0x99,0xae,0x14,0xa1,0x54,0xed,0x24,0xb3,0x6e,0x25,0x32,0x4d,0xb8, | ||
| 180 | 0xc5,0x66,0x63,0x2e,0xf2,0xbb,0xb3,0x4f,0x83,0x47,0x28,0x0f,0xc4,0x50,0x70,0x57, | ||
| 181 | 0xfd,0xdc,0x29,0xdf,0x9a,0x47,0x1f,0x75,0xc6,0x65,0x41,0xd4,0xd4,0xda,0xd1,0xc9, | ||
| 182 | 0xe9,0x3a,0x19,0xa5,0x8e,0x8b,0x47,0x3f,0xa0,0xf0,0x62,0xf7}, | ||
| 183 | T11[]= {0x65,0xdc,0xc5,0x7f,0xcf,0x62,0x3a,0x24,0x09,0x4f,0xcc,0xa4,0x0d,0x35,0x33,0xf8}; | ||
| 184 | |||
| 185 | /* Test Case 12 */ | ||
| 186 | #define K12 K11 | ||
| 187 | #define P12 P11 | ||
| 188 | #define A12 A11 | ||
| 189 | static const u8 IV12[]={0x93,0x13,0x22,0x5d,0xf8,0x84,0x06,0xe5,0x55,0x90,0x9c,0x5a,0xff,0x52,0x69,0xaa, | ||
| 190 | 0x6a,0x7a,0x95,0x38,0x53,0x4f,0x7d,0xa1,0xe4,0xc3,0x03,0xd2,0xa3,0x18,0xa7,0x28, | ||
| 191 | 0xc3,0xc0,0xc9,0x51,0x56,0x80,0x95,0x39,0xfc,0xf0,0xe2,0x42,0x9a,0x6b,0x52,0x54, | ||
| 192 | 0x16,0xae,0xdb,0xf5,0xa0,0xde,0x6a,0x57,0xa6,0x37,0xb3,0x9b}, | ||
| 193 | C12[]= {0xd2,0x7e,0x88,0x68,0x1c,0xe3,0x24,0x3c,0x48,0x30,0x16,0x5a,0x8f,0xdc,0xf9,0xff, | ||
| 194 | 0x1d,0xe9,0xa1,0xd8,0xe6,0xb4,0x47,0xef,0x6e,0xf7,0xb7,0x98,0x28,0x66,0x6e,0x45, | ||
| 195 | 0x81,0xe7,0x90,0x12,0xaf,0x34,0xdd,0xd9,0xe2,0xf0,0x37,0x58,0x9b,0x29,0x2d,0xb3, | ||
| 196 | 0xe6,0x7c,0x03,0x67,0x45,0xfa,0x22,0xe7,0xe9,0xb7,0x37,0x3b}, | ||
| 197 | T12[]= {0xdc,0xf5,0x66,0xff,0x29,0x1c,0x25,0xbb,0xb8,0x56,0x8f,0xc3,0xd3,0x76,0xa6,0xd9}; | ||
| 198 | |||
| 199 | /* Test Case 13 */ | ||
| 200 | static const u8 K13[32], | ||
| 201 | *P13=NULL, | ||
| 202 | *A13=NULL, | ||
| 203 | IV13[12], | ||
| 204 | *C13=NULL, | ||
| 205 | T13[]={0x53,0x0f,0x8a,0xfb,0xc7,0x45,0x36,0xb9,0xa9,0x63,0xb4,0xf1,0xc4,0xcb,0x73,0x8b}; | ||
| 206 | |||
| 207 | /* Test Case 14 */ | ||
| 208 | #define K14 K13 | ||
| 209 | #define A14 A13 | ||
| 210 | static const u8 P14[16], | ||
| 211 | IV14[12], | ||
| 212 | C14[]= {0xce,0xa7,0x40,0x3d,0x4d,0x60,0x6b,0x6e,0x07,0x4e,0xc5,0xd3,0xba,0xf3,0x9d,0x18}, | ||
| 213 | T14[]= {0xd0,0xd1,0xc8,0xa7,0x99,0x99,0x6b,0xf0,0x26,0x5b,0x98,0xb5,0xd4,0x8a,0xb9,0x19}; | ||
| 214 | |||
| 215 | /* Test Case 15 */ | ||
| 216 | #define A15 A14 | ||
| 217 | static const u8 K15[]= {0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08, | ||
| 218 | 0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08}, | ||
| 219 | P15[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 220 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 221 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 222 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55}, | ||
| 223 | IV15[]={0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad,0xde,0xca,0xf8,0x88}, | ||
| 224 | C15[]= {0x52,0x2d,0xc1,0xf0,0x99,0x56,0x7d,0x07,0xf4,0x7f,0x37,0xa3,0x2a,0x84,0x42,0x7d, | ||
| 225 | 0x64,0x3a,0x8c,0xdc,0xbf,0xe5,0xc0,0xc9,0x75,0x98,0xa2,0xbd,0x25,0x55,0xd1,0xaa, | ||
| 226 | 0x8c,0xb0,0x8e,0x48,0x59,0x0d,0xbb,0x3d,0xa7,0xb0,0x8b,0x10,0x56,0x82,0x88,0x38, | ||
| 227 | 0xc5,0xf6,0x1e,0x63,0x93,0xba,0x7a,0x0a,0xbc,0xc9,0xf6,0x62,0x89,0x80,0x15,0xad}, | ||
| 228 | T15[]= {0xb0,0x94,0xda,0xc5,0xd9,0x34,0x71,0xbd,0xec,0x1a,0x50,0x22,0x70,0xe3,0xcc,0x6c}; | ||
| 229 | |||
| 230 | /* Test Case 16 */ | ||
| 231 | #define K16 K15 | ||
| 232 | #define IV16 IV15 | ||
| 233 | static const u8 P16[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 234 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 235 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 236 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39}, | ||
| 237 | A16[]= {0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef,0xfe,0xed,0xfa,0xce,0xde,0xad,0xbe,0xef, | ||
| 238 | 0xab,0xad,0xda,0xd2}, | ||
| 239 | C16[]= {0x52,0x2d,0xc1,0xf0,0x99,0x56,0x7d,0x07,0xf4,0x7f,0x37,0xa3,0x2a,0x84,0x42,0x7d, | ||
| 240 | 0x64,0x3a,0x8c,0xdc,0xbf,0xe5,0xc0,0xc9,0x75,0x98,0xa2,0xbd,0x25,0x55,0xd1,0xaa, | ||
| 241 | 0x8c,0xb0,0x8e,0x48,0x59,0x0d,0xbb,0x3d,0xa7,0xb0,0x8b,0x10,0x56,0x82,0x88,0x38, | ||
| 242 | 0xc5,0xf6,0x1e,0x63,0x93,0xba,0x7a,0x0a,0xbc,0xc9,0xf6,0x62}, | ||
| 243 | T16[]= {0x76,0xfc,0x6e,0xce,0x0f,0x4e,0x17,0x68,0xcd,0xdf,0x88,0x53,0xbb,0x2d,0x55,0x1b}; | ||
| 244 | |||
| 245 | /* Test Case 17 */ | ||
| 246 | #define K17 K16 | ||
| 247 | #define P17 P16 | ||
| 248 | #define A17 A16 | ||
| 249 | static const u8 IV17[]={0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad}, | ||
| 250 | C17[]= {0xc3,0x76,0x2d,0xf1,0xca,0x78,0x7d,0x32,0xae,0x47,0xc1,0x3b,0xf1,0x98,0x44,0xcb, | ||
| 251 | 0xaf,0x1a,0xe1,0x4d,0x0b,0x97,0x6a,0xfa,0xc5,0x2f,0xf7,0xd7,0x9b,0xba,0x9d,0xe0, | ||
| 252 | 0xfe,0xb5,0x82,0xd3,0x39,0x34,0xa4,0xf0,0x95,0x4c,0xc2,0x36,0x3b,0xc7,0x3f,0x78, | ||
| 253 | 0x62,0xac,0x43,0x0e,0x64,0xab,0xe4,0x99,0xf4,0x7c,0x9b,0x1f}, | ||
| 254 | T17[]= {0x3a,0x33,0x7d,0xbf,0x46,0xa7,0x92,0xc4,0x5e,0x45,0x49,0x13,0xfe,0x2e,0xa8,0xf2}; | ||
| 255 | |||
| 256 | /* Test Case 18 */ | ||
| 257 | #define K18 K17 | ||
| 258 | #define P18 P17 | ||
| 259 | #define A18 A17 | ||
| 260 | static const u8 IV18[]={0x93,0x13,0x22,0x5d,0xf8,0x84,0x06,0xe5,0x55,0x90,0x9c,0x5a,0xff,0x52,0x69,0xaa, | ||
| 261 | 0x6a,0x7a,0x95,0x38,0x53,0x4f,0x7d,0xa1,0xe4,0xc3,0x03,0xd2,0xa3,0x18,0xa7,0x28, | ||
| 262 | 0xc3,0xc0,0xc9,0x51,0x56,0x80,0x95,0x39,0xfc,0xf0,0xe2,0x42,0x9a,0x6b,0x52,0x54, | ||
| 263 | 0x16,0xae,0xdb,0xf5,0xa0,0xde,0x6a,0x57,0xa6,0x37,0xb3,0x9b}, | ||
| 264 | C18[]= {0x5a,0x8d,0xef,0x2f,0x0c,0x9e,0x53,0xf1,0xf7,0x5d,0x78,0x53,0x65,0x9e,0x2a,0x20, | ||
| 265 | 0xee,0xb2,0xb2,0x2a,0xaf,0xde,0x64,0x19,0xa0,0x58,0xab,0x4f,0x6f,0x74,0x6b,0xf4, | ||
| 266 | 0x0f,0xc0,0xc3,0xb7,0x80,0xf2,0x44,0x45,0x2d,0xa3,0xeb,0xf1,0xc5,0xd8,0x2c,0xde, | ||
| 267 | 0xa2,0x41,0x89,0x97,0x20,0x0e,0xf8,0x2e,0x44,0xae,0x7e,0x3f}, | ||
| 268 | T18[]= {0xa4,0x4a,0x82,0x66,0xee,0x1c,0x8e,0xb0,0xc8,0xb5,0xd4,0xcf,0x5a,0xe9,0xf1,0x9a}; | ||
| 269 | |||
| 270 | /* Test Case 19 */ | ||
| 271 | #define K19 K1 | ||
| 272 | #define P19 P1 | ||
| 273 | #define IV19 IV1 | ||
| 274 | #define C19 C1 | ||
| 275 | static const u8 A19[]= {0xd9,0x31,0x32,0x25,0xf8,0x84,0x06,0xe5,0xa5,0x59,0x09,0xc5,0xaf,0xf5,0x26,0x9a, | ||
| 276 | 0x86,0xa7,0xa9,0x53,0x15,0x34,0xf7,0xda,0x2e,0x4c,0x30,0x3d,0x8a,0x31,0x8a,0x72, | ||
| 277 | 0x1c,0x3c,0x0c,0x95,0x95,0x68,0x09,0x53,0x2f,0xcf,0x0e,0x24,0x49,0xa6,0xb5,0x25, | ||
| 278 | 0xb1,0x6a,0xed,0xf5,0xaa,0x0d,0xe6,0x57,0xba,0x63,0x7b,0x39,0x1a,0xaf,0xd2,0x55, | ||
| 279 | 0x52,0x2d,0xc1,0xf0,0x99,0x56,0x7d,0x07,0xf4,0x7f,0x37,0xa3,0x2a,0x84,0x42,0x7d, | ||
| 280 | 0x64,0x3a,0x8c,0xdc,0xbf,0xe5,0xc0,0xc9,0x75,0x98,0xa2,0xbd,0x25,0x55,0xd1,0xaa, | ||
| 281 | 0x8c,0xb0,0x8e,0x48,0x59,0x0d,0xbb,0x3d,0xa7,0xb0,0x8b,0x10,0x56,0x82,0x88,0x38, | ||
| 282 | 0xc5,0xf6,0x1e,0x63,0x93,0xba,0x7a,0x0a,0xbc,0xc9,0xf6,0x62,0x89,0x80,0x15,0xad}, | ||
| 283 | T19[]= {0x5f,0xea,0x79,0x3a,0x2d,0x6f,0x97,0x4d,0x37,0xe6,0x8e,0x0c,0xb8,0xff,0x94,0x92}; | ||
| 284 | |||
| 285 | /* Test Case 20 */ | ||
| 286 | #define K20 K1 | ||
| 287 | #define A20 A1 | ||
| 288 | static const u8 IV20[64]={0xff,0xff,0xff,0xff}, /* this results in 0xff in counter LSB */ | ||
| 289 | P20[288], | ||
| 290 | C20[]= {0x56,0xb3,0x37,0x3c,0xa9,0xef,0x6e,0x4a,0x2b,0x64,0xfe,0x1e,0x9a,0x17,0xb6,0x14, | ||
| 291 | 0x25,0xf1,0x0d,0x47,0xa7,0x5a,0x5f,0xce,0x13,0xef,0xc6,0xbc,0x78,0x4a,0xf2,0x4f, | ||
| 292 | 0x41,0x41,0xbd,0xd4,0x8c,0xf7,0xc7,0x70,0x88,0x7a,0xfd,0x57,0x3c,0xca,0x54,0x18, | ||
| 293 | 0xa9,0xae,0xff,0xcd,0x7c,0x5c,0xed,0xdf,0xc6,0xa7,0x83,0x97,0xb9,0xa8,0x5b,0x49, | ||
| 294 | 0x9d,0xa5,0x58,0x25,0x72,0x67,0xca,0xab,0x2a,0xd0,0xb2,0x3c,0xa4,0x76,0xa5,0x3c, | ||
| 295 | 0xb1,0x7f,0xb4,0x1c,0x4b,0x8b,0x47,0x5c,0xb4,0xf3,0xf7,0x16,0x50,0x94,0xc2,0x29, | ||
| 296 | 0xc9,0xe8,0xc4,0xdc,0x0a,0x2a,0x5f,0xf1,0x90,0x3e,0x50,0x15,0x11,0x22,0x13,0x76, | ||
| 297 | 0xa1,0xcd,0xb8,0x36,0x4c,0x50,0x61,0xa2,0x0c,0xae,0x74,0xbc,0x4a,0xcd,0x76,0xce, | ||
| 298 | 0xb0,0xab,0xc9,0xfd,0x32,0x17,0xef,0x9f,0x8c,0x90,0xbe,0x40,0x2d,0xdf,0x6d,0x86, | ||
| 299 | 0x97,0xf4,0xf8,0x80,0xdf,0xf1,0x5b,0xfb,0x7a,0x6b,0x28,0x24,0x1e,0xc8,0xfe,0x18, | ||
| 300 | 0x3c,0x2d,0x59,0xe3,0xf9,0xdf,0xff,0x65,0x3c,0x71,0x26,0xf0,0xac,0xb9,0xe6,0x42, | ||
| 301 | 0x11,0xf4,0x2b,0xae,0x12,0xaf,0x46,0x2b,0x10,0x70,0xbe,0xf1,0xab,0x5e,0x36,0x06, | ||
| 302 | 0x87,0x2c,0xa1,0x0d,0xee,0x15,0xb3,0x24,0x9b,0x1a,0x1b,0x95,0x8f,0x23,0x13,0x4c, | ||
| 303 | 0x4b,0xcc,0xb7,0xd0,0x32,0x00,0xbc,0xe4,0x20,0xa2,0xf8,0xeb,0x66,0xdc,0xf3,0x64, | ||
| 304 | 0x4d,0x14,0x23,0xc1,0xb5,0x69,0x90,0x03,0xc1,0x3e,0xce,0xf4,0xbf,0x38,0xa3,0xb6, | ||
| 305 | 0x0e,0xed,0xc3,0x40,0x33,0xba,0xc1,0x90,0x27,0x83,0xdc,0x6d,0x89,0xe2,0xe7,0x74, | ||
| 306 | 0x18,0x8a,0x43,0x9c,0x7e,0xbc,0xc0,0x67,0x2d,0xbd,0xa4,0xdd,0xcf,0xb2,0x79,0x46, | ||
| 307 | 0x13,0xb0,0xbe,0x41,0x31,0x5e,0xf7,0x78,0x70,0x8a,0x70,0xee,0x7d,0x75,0x16,0x5c}, | ||
| 308 | T20[]= {0x8b,0x30,0x7f,0x6b,0x33,0x28,0x6d,0x0a,0xb0,0x26,0xa9,0xed,0x3f,0xe1,0xe8,0x5f}; | ||
| 309 | |||
| 310 | #define TEST_CASE(n) do { \ | ||
| 311 | u8 out[sizeof(P##n)]; \ | ||
| 312 | AES_set_encrypt_key(K##n,sizeof(K##n)*8,&key); \ | ||
| 313 | CRYPTO_gcm128_init(&ctx,&key,(block128_f)AES_encrypt); \ | ||
| 314 | CRYPTO_gcm128_setiv(&ctx,IV##n,sizeof(IV##n)); \ | ||
| 315 | memset(out,0,sizeof(out)); \ | ||
| 316 | if (A##n) CRYPTO_gcm128_aad(&ctx,A##n,sizeof(A##n)); \ | ||
| 317 | if (P##n) CRYPTO_gcm128_encrypt(&ctx,P##n,out,sizeof(out)); \ | ||
| 318 | if (CRYPTO_gcm128_finish(&ctx,T##n,16) || \ | ||
| 319 | (C##n && memcmp(out,C##n,sizeof(out)))) \ | ||
| 320 | ret++, printf ("encrypt test#%d failed.\n",n); \ | ||
| 321 | CRYPTO_gcm128_setiv(&ctx,IV##n,sizeof(IV##n)); \ | ||
| 322 | memset(out,0,sizeof(out)); \ | ||
| 323 | if (A##n) CRYPTO_gcm128_aad(&ctx,A##n,sizeof(A##n)); \ | ||
| 324 | if (C##n) CRYPTO_gcm128_decrypt(&ctx,C##n,out,sizeof(out)); \ | ||
| 325 | if (CRYPTO_gcm128_finish(&ctx,T##n,16) || \ | ||
| 326 | (P##n && memcmp(out,P##n,sizeof(out)))) \ | ||
| 327 | ret++, printf ("decrypt test#%d failed.\n",n); \ | ||
| 328 | } while(0) | ||
| 329 | |||
| 330 | int main() | ||
| 331 | { | ||
| 332 | GCM128_CONTEXT ctx; | ||
| 333 | AES_KEY key; | ||
| 334 | int ret=0; | ||
| 335 | |||
| 336 | TEST_CASE(1); | ||
| 337 | TEST_CASE(2); | ||
| 338 | TEST_CASE(3); | ||
| 339 | TEST_CASE(4); | ||
| 340 | TEST_CASE(5); | ||
| 341 | TEST_CASE(6); | ||
| 342 | TEST_CASE(7); | ||
| 343 | TEST_CASE(8); | ||
| 344 | TEST_CASE(9); | ||
| 345 | TEST_CASE(10); | ||
| 346 | TEST_CASE(11); | ||
| 347 | TEST_CASE(12); | ||
| 348 | TEST_CASE(13); | ||
| 349 | TEST_CASE(14); | ||
| 350 | TEST_CASE(15); | ||
| 351 | TEST_CASE(16); | ||
| 352 | TEST_CASE(17); | ||
| 353 | TEST_CASE(18); | ||
| 354 | TEST_CASE(19); | ||
| 355 | TEST_CASE(20); | ||
| 356 | |||
| 357 | return ret; | ||
| 358 | } | ||
