| 993 | |
| 994 | |
| 995 | int aes_test() |
| 996 | { |
| 997 | AES_CBC_Encryption enc; |
| 998 | AES_CBC_Decryption dec; |
| 999 | const int bs(TaoCrypt::AES::BLOCK_SIZE); |
| 1000 | |
| 1001 | byte key[] = "0123456789abcdef "; // align |
| 1002 | byte iv[] = "1234567890abcdef "; // align |
| 1003 | |
| 1004 | enc.SetKey(key, bs, iv); |
| 1005 | dec.SetKey(key, bs, iv); |
| 1006 | |
| 1007 | enc.Process(cipher, msg, bs); |
| 1008 | dec.Process(plain, cipher, bs); |
| 1009 | |
| 1010 | if (memcmp(plain, msg, bs)) |
| 1011 | return -60; |
| 1012 | |
| 1013 | const byte verify[] = |
| 1014 | { |
| 1015 | 0x95,0x94,0x92,0x57,0x5f,0x42,0x81,0x53, |
| 1016 | 0x2c,0xcc,0x9d,0x46,0x77,0xa2,0x33,0xcb |
| 1017 | }; |
| 1018 | |
| 1019 | if (memcmp(cipher, verify, bs)) |
| 1020 | return -61; |
| 1021 | |
| 1022 | AES_ECB_Encryption enc2; |
| 1023 | AES_ECB_Decryption dec2; |
| 1024 | |
| 1025 | enc2.SetKey(key, bs, iv); |
| 1026 | dec2.SetKey(key, bs, iv); |
| 1027 | |
| 1028 | enc2.Process(cipher, msg, bs); |
| 1029 | dec2.Process(plain, cipher, bs); |
| 1030 | |
| 1031 | if (memcmp(plain, msg, bs)) |
| 1032 | return -62; |
| 1033 | |
| 1034 | const byte verify2[] = |
| 1035 | { |
| 1036 | 0xd0,0xc9,0xd9,0xc9,0x40,0xe8,0x97,0xb6, |
| 1037 | 0xc8,0x8c,0x33,0x3b,0xb5,0x8f,0x85,0xd1 |
| 1038 | }; |
| 1039 | |
| 1040 | if (memcmp(cipher, verify2, bs)) |
| 1041 | return -63; |
| 1042 | |
| 1043 | return 0; |
| 1044 | } |
| 1045 | |
| 1046 | |
| 1047 | int twofish_test() |
no test coverage detected