| 67 | } |
| 68 | |
| 69 | static void TestAES128(const std::string &hexkey, const std::string &hexin, const std::string &hexout) |
| 70 | { |
| 71 | std::vector<unsigned char> key = ParseHex(hexkey); |
| 72 | std::vector<unsigned char> in = ParseHex(hexin); |
| 73 | std::vector<unsigned char> correctout = ParseHex(hexout); |
| 74 | std::vector<unsigned char> buf, buf2; |
| 75 | |
| 76 | assert(key.size() == 16); |
| 77 | assert(in.size() == 16); |
| 78 | assert(correctout.size() == 16); |
| 79 | AES128Encrypt enc(key.data()); |
| 80 | buf.resize(correctout.size()); |
| 81 | buf2.resize(correctout.size()); |
| 82 | enc.Encrypt(buf.data(), in.data()); |
| 83 | BOOST_CHECK_EQUAL(HexStr(buf), HexStr(correctout)); |
| 84 | AES128Decrypt dec(key.data()); |
| 85 | dec.Decrypt(buf2.data(), buf.data()); |
| 86 | BOOST_CHECK_EQUAL(HexStr(buf2), HexStr(in)); |
| 87 | } |
| 88 | |
| 89 | static void TestAES256(const std::string &hexkey, const std::string &hexin, const std::string &hexout) |
| 90 | { |