| 1097 | |
| 1098 | |
| 1099 | int blowfish_test() |
| 1100 | { |
| 1101 | Blowfish_CBC_Encryption enc; |
| 1102 | Blowfish_CBC_Decryption dec; |
| 1103 | const int bs(TaoCrypt::Blowfish::BLOCK_SIZE); |
| 1104 | |
| 1105 | byte key[] = "0123456789abcdef "; // align |
| 1106 | byte iv[] = "1234567890abcdef "; // align |
| 1107 | |
| 1108 | enc.SetKey(key, 16, iv); |
| 1109 | dec.SetKey(key, 16, iv); |
| 1110 | |
| 1111 | enc.Process(cipher, msg, bs * 2); |
| 1112 | dec.Process(plain, cipher, bs * 2); |
| 1113 | |
| 1114 | if (memcmp(plain, msg, bs)) |
| 1115 | return -60; |
| 1116 | |
| 1117 | const byte verify[] = |
| 1118 | { |
| 1119 | 0x0E,0x26,0xAA,0x29,0x11,0x25,0xAB,0xB5, |
| 1120 | 0xBC,0xD9,0x08,0xC4,0x94,0x6C,0x89,0xA3 |
| 1121 | }; |
| 1122 | |
| 1123 | if (memcmp(cipher, verify, bs)) |
| 1124 | return -61; |
| 1125 | |
| 1126 | Blowfish_ECB_Encryption enc2; |
| 1127 | Blowfish_ECB_Decryption dec2; |
| 1128 | |
| 1129 | enc2.SetKey(key, 16, iv); |
| 1130 | dec2.SetKey(key, 16, iv); |
| 1131 | |
| 1132 | enc2.Process(cipher, msg, bs * 2); |
| 1133 | dec2.Process(plain, cipher, bs * 2); |
| 1134 | |
| 1135 | if (memcmp(plain, msg, bs)) |
| 1136 | return -62; |
| 1137 | |
| 1138 | const byte verify2[] = |
| 1139 | { |
| 1140 | 0xE7,0x42,0xB9,0x37,0xC8,0x7D,0x93,0xCA, |
| 1141 | 0x8F,0xCE,0x39,0x32,0xDE,0xD7,0xBC,0x5B |
| 1142 | }; |
| 1143 | |
| 1144 | if (memcmp(cipher, verify2, bs)) |
| 1145 | return -63; |
| 1146 | |
| 1147 | return 0; |
| 1148 | } |
| 1149 | |
| 1150 | |
| 1151 | int rsa_test() |
no test coverage detected