diff --git a/testsuite/serpent-test.m4 b/testsuite/serpent-test.m4 index d46a8f3c546527a972b03e6b7605fb9060b54bad..f51b54057030ae67aaecf7a5148cb1abc0ac0add 100644 --- a/testsuite/serpent-test.m4 +++ b/testsuite/serpent-test.m4 @@ -8,6 +8,100 @@ uint8_t msg[SERPENT_BLOCK_SIZE]; uint8_t cipher[SERPENT_BLOCK_SIZE]; uint8_t clear[SERPENT_BLOCK_SIZE]; -/* FIXME: No tests! */ +/* The first test for each key size from the ecb_vk.txt and ecb_vt.txt + * files in the serpent package. */ + +/* 128 bit key */ + +/* vk, 1 */ +H(msg, "0000000000000000 0000000000000000"); + +serpent_set_key(&ctx, 16, H("8000000000000000 0000000000000000")); +serpent_encrypt(&ctx, SERPENT_BLOCK_SIZE, cipher, msg); + +if (!MEMEQ(SERPENT_BLOCK_SIZE, cipher, + H("49AFBFAD9D5A3405 2CD8FFA5986BD2DD"))) + FAIL; + +serpent_decrypt(&ctx, SERPENT_BLOCK_SIZE, clear, cipher); +if (!MEMEQ(SERPENT_BLOCK_SIZE, msg, clear)) + FAIL; + +/* vt, 1 */ +H(msg, "8000000000000000 0000000000000000"); + +serpent_set_key(&ctx, 16, H("0000000000000000 0000000000000000")); +serpent_encrypt(&ctx, SERPENT_BLOCK_SIZE, cipher, msg); + +if (!MEMEQ(SERPENT_BLOCK_SIZE, cipher, + H("10B5FFB720B8CB90 02A1142B0BA2E94A"))) + FAIL; + +serpent_decrypt(&ctx, SERPENT_BLOCK_SIZE, clear, cipher); +if (!MEMEQ(SERPENT_BLOCK_SIZE, msg, clear)) + FAIL; + +/* 192 bit key */ + +/* vk, 1 */ +H(msg, "0000000000000000 0000000000000000"); + +serpent_set_key(&ctx, 24, H("8000000000000000 0000000000000000" + "0000000000000000")); +serpent_encrypt(&ctx, SERPENT_BLOCK_SIZE, cipher, msg); + +if (!MEMEQ(SERPENT_BLOCK_SIZE, cipher, + H("E78E5402C7195568 AC3678F7A3F60C66"))) + FAIL; + +serpent_decrypt(&ctx, SERPENT_BLOCK_SIZE, clear, cipher); +if (!MEMEQ(SERPENT_BLOCK_SIZE, msg, clear)) + FAIL; + +/* vt, 1 */ +H(msg, "8000000000000000 0000000000000000"); + +serpent_set_key(&ctx, 24, H("0000000000000000 0000000000000000" + "0000000000000000")); +serpent_encrypt(&ctx, SERPENT_BLOCK_SIZE, cipher, msg); + +if (!MEMEQ(SERPENT_BLOCK_SIZE, cipher, + H("B10B271BA25257E1 294F2B51F076D0D9"))) + FAIL; + +serpent_decrypt(&ctx, SERPENT_BLOCK_SIZE, clear, cipher); +if (!MEMEQ(SERPENT_BLOCK_SIZE, msg, clear)) + FAIL; + +/* 256 bit key */ + +/* vk, 1 */ +H(msg, "0000000000000000 0000000000000000"); + +serpent_set_key(&ctx, 32, H("8000000000000000 0000000000000000" + "0000000000000000 0000000000000000")); +serpent_encrypt(&ctx, SERPENT_BLOCK_SIZE, cipher, msg); + +if (!MEMEQ(SERPENT_BLOCK_SIZE, cipher, + H("ABED96E766BF28CB C0EBD21A82EF0819"))) + FAIL; + +serpent_decrypt(&ctx, SERPENT_BLOCK_SIZE, clear, cipher); +if (!MEMEQ(SERPENT_BLOCK_SIZE, msg, clear)) + FAIL; + +/* vt, 1 */ +H(msg, "8000000000000000 0000000000000000"); + +serpent_set_key(&ctx, 32, H("0000000000000000 0000000000000000" + "0000000000000000 0000000000000000")); +serpent_encrypt(&ctx, SERPENT_BLOCK_SIZE, cipher, msg); + +if (!MEMEQ(SERPENT_BLOCK_SIZE, cipher, + H("DA5A7992B1B4AE6F 8C004BC8A7DE5520"))) + FAIL; + +serpent_decrypt(&ctx, SERPENT_BLOCK_SIZE, clear, cipher); +if (!MEMEQ(SERPENT_BLOCK_SIZE, msg, clear)) + FAIL; -#warning no tests