MCPcopy Create free account
hub / github.com/defold/defold / TEST

Function TEST

engine/dlib/src/test/test_crypt.cpp:23–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22
23TEST(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
46TEST(dmCrypt, XTeaUnaligned)
47{

Callers

nothing calls this directly

Calls 9

EncryptFunction · 0.85
DecryptFunction · 0.85
randClass · 0.85
HashMd5Function · 0.85
HashSha1Function · 0.85
HashSha256Function · 0.85
HashSha512Function · 0.85
Base64EncodeFunction · 0.85
Base64DecodeFunction · 0.85

Tested by

no test coverage detected