Commit ebfbb71d authored by Niels Möller's avatar Niels Möller

(TS_PROGS): Added tests for twofish and

blowfish.

Rev: src/nettle/testsuite/Makefile.am:1.4
Rev: src/nettle/testsuite/blowfish-test.m4:1.1
Rev: src/nettle/testsuite/twofist-test.m4:1.1
parent c491bcae
CFLAGS = -I$(top_srcdir) @CFLAGS@ -O0
CPPFLAGS = @CPPFLAGS@
TS_PROGS = aes-test arcfour-test des-test md5-test sha1-test
TS_PROGS = aes-test arcfour-test blowfish-test des-test md5-test sha1-test \
twofish-test
noinst_PROGRAMS = $(TS_PROGS)
......
#include "blowfish.h"
BEGIN_TEST
/* FIXME: All values below are bogus. */
struct blowfish_ctx ctx;
uint8_t msg[BLOWFISH_BLOCK_SIZE];
uint8_t cipher[BLOWFISH_BLOCK_SIZE];
uint8_t clear[BLOWFISH_BLOCK_SIZE];
/* 128 bit keys */
H(msg, "506812A45F08C889 B97F5980038B8359");
blowfish_set_key(&ctx, 16, H("0001020305060708 0A0B0C0D0F101112"));
blowfish_encrypt(&ctx, BLOWFISH_BLOCK_SIZE, cipher, msg);
if (!MEMEQ(16, cipher, H("D8F532538289EF7D 06B506A4FD5BE9C9")))
FAIL;
blowfish_decrypt(&ctx, BLOWFISH_BLOCK_SIZE, clear, cipher);
if (!MEMEQ(16, msg, clear))
FAIL;
H(msg, "5C6D71CA30DE8B8B 00549984D2EC7D4B");
blowfish_set_key(&ctx, 16, H("14151617191A1B1C 1E1F202123242526"));
blowfish_encrypt(&ctx, BLOWFISH_BLOCK_SIZE, cipher, msg);
if (!MEMEQ(16, cipher, H("59AB30F4D4EE6E4F F9907EF65B1FB68C")))
FAIL;
blowfish_decrypt(&ctx, BLOWFISH_BLOCK_SIZE, clear, cipher);
if (!MEMEQ(16, msg, clear))
FAIL;
H(msg, "53F3F4C64F8616E4 E7C56199F48F21F6");
blowfish_set_key(&ctx, 16, H("28292A2B2D2E2F30 323334353738393A"));
blowfish_encrypt(&ctx, BLOWFISH_BLOCK_SIZE, cipher, msg);
if (!MEMEQ(16, cipher, H("BF1ED2FCB2AF3FD4 1443B56D85025CB1")))
FAIL;
blowfish_decrypt(&ctx, BLOWFISH_BLOCK_SIZE, clear, cipher);
if (!MEMEQ(16, msg, clear))
FAIL;
H(msg, "F5F4F7F684878689 A6A7A0A1D2CDCCCF");
blowfish_set_key(&ctx, 16, H("A0A1A2A3A5A6A7A8 AAABACADAFB0B1B2"));
blowfish_encrypt(&ctx, BLOWFISH_BLOCK_SIZE, cipher, msg);
if (!MEMEQ(16, cipher, H("CE52AF650D088CA5 59425223F4D32694")))
FAIL;
blowfish_decrypt(&ctx, BLOWFISH_BLOCK_SIZE, clear, cipher);
if (!MEMEQ(16, msg, clear))
FAIL;
/* 192 bit keys */
H(msg, "2D33EEF2C0430A8A 9EBF45E809C40BB6");
blowfish_set_key(&ctx, 24, H("0001020305060708 0A0B0C0D0F101112"
"14151617191A1B1C"));
blowfish_encrypt(&ctx, BLOWFISH_BLOCK_SIZE, cipher, msg);
if (!MEMEQ(16, cipher, H("DFF4945E0336DF4C 1C56BC700EFF837F")))
FAIL;
blowfish_decrypt(&ctx, BLOWFISH_BLOCK_SIZE, clear, cipher);
if (!MEMEQ(16, msg, clear))
FAIL;
/* 256 bit keys */
H(msg, "834EADFCCAC7E1B30664B1ABA44815AB");
blowfish_set_key(&ctx, 32, H("0001020305060708 0A0B0C0D0F101112"
"14151617191A1B1C 1E1F202123242526"));
blowfish_encrypt(&ctx, BLOWFISH_BLOCK_SIZE, cipher, msg);
if (!MEMEQ(16, cipher, H("1946DABF6A03A2A2 C3D0B05080AED6FC")))
FAIL;
blowfish_decrypt(&ctx, BLOWFISH_BLOCK_SIZE, clear, cipher);
if (!MEMEQ(16, msg, clear))
FAIL;
#include "twofish.h"
BEGIN_TEST
struct twofish_ctx ctx;
uint8_t msg[TWOFISH_BLOCK_SIZE];
uint8_t cipher[TWOFISH_BLOCK_SIZE];
uint8_t clear[TWOFISH_BLOCK_SIZE];
/* 128 bit key */
H(msg, "0000000000000000 0000000000000000");
twofish_set_key(&ctx, 16, H("0000000000000000 0000000000000000"))
twofish_encrypt(&ctx, TWOFISH_BLOCK_SIZE, cipher, msg);
if (!MEMEQ(TWOFISH_BLOCK_SIZE, cipher,
H("9F589F5CF6122C32 B6BFEC2F2AE8C35A")))
FAIL;
twofish_decrypt(&ctx, TWOFISH_BLOCK_SIZE, clear, cipher);
if (!MEMEQ(TWOFISH_BLOCK_SIZE, msg, clear))
FAIL;
/* 192 bit key */
twofish_set_key(&ctx, 24, H("0123456789ABCDEF FEDCBA9876543210"
"0011223344556677"));
twofish_encrypt(&ctx, TWOFISH_BLOCK_SIZE, cipher, msg);
if (!MEMEQ(TWOFISH_BLOCK_SIZE, cipher,
H("CFD1D2E5A9BE9CDF 501F13B892BD2248")))
FAIL;
twofish_decrypt(&ctx, TWOFISH_BLOCK_SIZE, clear, cipher);
if (!MEMEQ(TWOFISH_BLOCK_SIZE, msg, clear))
FAIL;
/* 256 bit key */
twofish_set_key(&ctx, 32, H("0123456789ABCDEF FEDCBA9876543210"
"0011223344556677 8899AABBCCDDEEFF"));
FAIL;
twofish_encrypt(&ctx, TWOFISH_BLOCK_SIZE, cipher, msg);
if (!MEMEQ(TWOFISH_BLOCK_SIZE, cipher,
H("37527BE0052334B8 9F0CFCCAE87CFA20")))
FAIL;
twofish_decrypt(&ctx, TWOFISH_BLOCK_SIZE, clear, cipher);
if (!MEMEQ(TWOFISH_BLOCK_SIZE, msg, clear))
FAIL;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment