| 21 | |
| 22 | |
| 23 | TEST(dmCrypt, XTea) |
| 24 | { |
| 25 | uint8_t original[19]; |
| 26 | const char* s = "ABCDEFGH12345678XYZ"; |
| 27 | int n = strlen(s); |
| 28 | memcpy(original, s, n); |
| 29 | |
| 30 | uint8_t buf[19]; |
| 31 | memcpy(buf, s, n); |
| 32 | |
| 33 | uint8_t key[16] = {0}; |
| 34 | memcpy(key, "12345678abcdefgh", 16); |
| 35 | |
| 36 | Encrypt(dmCrypt::ALGORITHM_XTEA, buf, n, key, 16); |
| 37 | uint8_t expected[] = { 0x81, 0xb4, 0xa1, 0x04, 0x2d, 0xac, 0xe5, 0xcb, 0x77, |
| 38 | 0x89, 0xec, 0x11, 0x61, 0xc3, 0xdc, 0xfa, 0xb9, 0xa3, 0x25 }; |
| 39 | ASSERT_EQ(sizeof(expected), (size_t)n); |
| 40 | ASSERT_ARRAY_EQ(expected, buf); |
| 41 | |
| 42 | Decrypt(dmCrypt::ALGORITHM_XTEA, buf, n, key, 16); |
| 43 | ASSERT_ARRAY_EQ(original, buf); |
| 44 | } |
| 45 | |
| 46 | TEST(dmCrypt, XTeaUnaligned) |
| 47 | { |
nothing calls this directly
no test coverage detected