From 512eb5655d4645b4f0c10cf66d1f9abee56432d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Sun, 17 Jun 2001 00:45:18 +0200 Subject: [PATCH] *** empty log message *** Rev: src/nettle/ChangeLog:1.8 Rev: src/nettle/serpent.h:1.3 Rev: src/nettle/testsuite/.cvsignore:1.4 Rev: src/nettle/testsuite/twofish-test.m4:1.2 Rev: src/nettle/twofish.h:1.2 --- ChangeLog | 49 +++++++++++++++++++++++++++++++++++++++ serpent.h | 14 +++++------ testsuite/.cvsignore | 4 ++++ testsuite/.gitignore | 4 ++++ testsuite/twofish-test.m4 | 4 +--- twofish.h | 2 +- 6 files changed, 66 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index fbb2f78b..9bc87665 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,52 @@ +2001-06-17 Niels M�ller <nisse@cuckoo.hack.org> + + * testsuite/serpent-test.m4: Added a few rudimentary tests + extracted from the serpent package. + + * twofish.c: Adapted to nettle. Made constant tables const. + Deleted bytes_to_word and word_to_bytes; use LE_READ_UINT32 and + LE_WRITE_UINT32 instead. + (twofish_selftest): Deleted. Moved the tests to the external + testsuite. + (twofish_set_key): Don't silently truncate too large keys. + + * sha1.c (sha1_update): Use unsigned for length. + + * serpent.c (serpent_set_key): Read the key backwards. Fixed + padding (but there are no test vectors for key_size not a multiple + of 4). + (serpent_encrypt): Read and write data in the strange order used + by the reference implementation. + (serpent_decrypt): Likewise. + + * macros.h (FOR_BLOCKS): New macro, taken from lsh. + + * blowfish.h (struct blowfish_ctx): Use a two-dimensional array + for s. + + * blowfish.c (initial_ctx): Arrange constants into a struct, to + simplify key setup. + (F): Deleted all but one definitions of the F function/macro. + Added a context argument, and use that to find the subkeys. + (R): Added context argument, and use that to find the subkeys. + (blowfish_set_key): Some simplification. + + (encrypt): Deleted code for non-standard number of rounds. Deleted + a bunch of local variables. Using the context pointer for + everything should consume less registers. + (decrypt): Likewise. + + * Makefile.am (libnettle_a_SOURCES): Added twofish. + +2001-06-16 Niels M�ller <nisse@cuckoo.hack.org> + + * testsuite/blowfish-test.m4: Fixed test. + + * Added twofish implementation. + + * blowfish.h (struct blowfish_ctx): Use the correct size for the p + array. + 2001-06-15 Niels M�ller <nisse@ehand.com> * testsuite/blowfish-test.m4: Fixed testcase, use correct key diff --git a/serpent.h b/serpent.h index 5f5053ad..281e050a 100644 --- a/serpent.h +++ b/serpent.h @@ -33,14 +33,14 @@ #include <stdint.h> -#define SERPENT_BLOCKSIZE 16 +#define SERPENT_BLOCK_SIZE 16 -/* Other key lengths are possible, but we only use 256 bits. Besides, the - design of Serpent makes other key lengths useless; they cheated with the - AES requirements, using a 256-bit key length exclusively and just padding - it out if the desired key length was less, so there really is no advantage - to using key lengths less than 256 bits. */ -#define SERPENT_KEYSIZE 32 +/* Other key lengths are possible, but the design of Serpent makes + * smaller key lengths quite pointless; they cheated with the AES + * requirements, using a 256-bit key length exclusively and just + * padding it out if the desired key length was less, so there really + * is no advantage to using key lengths less than 256 bits. */ +#define SERPENT_KEY_SIZE 32 /* Allow keys of size 128 <= bits <= 256 */ diff --git a/testsuite/.cvsignore b/testsuite/.cvsignore index 641dc9eb..bcf766a6 100644 --- a/testsuite/.cvsignore +++ b/testsuite/.cvsignore @@ -11,5 +11,9 @@ des-test des-test.c md5-test md5-test.c +serpent-test +serpent-test.c sha1-test sha1-test.c +twofish-test +twofish-test.c diff --git a/testsuite/.gitignore b/testsuite/.gitignore index e8e5a170..54b6bb58 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -11,5 +11,9 @@ /des-test.c /md5-test /md5-test.c +/serpent-test +/serpent-test.c /sha1-test /sha1-test.c +/twofish-test +/twofish-test.c diff --git a/testsuite/twofish-test.m4 b/testsuite/twofish-test.m4 index 8b2a3512..98840bf2 100644 --- a/testsuite/twofish-test.m4 +++ b/testsuite/twofish-test.m4 @@ -11,7 +11,7 @@ uint8_t clear[TWOFISH_BLOCK_SIZE]; /* 128 bit key */ H(msg, "0000000000000000 0000000000000000"); -twofish_set_key(&ctx, 16, H("0000000000000000 0000000000000000")) +twofish_set_key(&ctx, 16, H("0000000000000000 0000000000000000")); twofish_encrypt(&ctx, TWOFISH_BLOCK_SIZE, cipher, msg); if (!MEMEQ(TWOFISH_BLOCK_SIZE, cipher, @@ -39,8 +39,6 @@ if (!MEMEQ(TWOFISH_BLOCK_SIZE, msg, clear)) /* 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, diff --git a/twofish.h b/twofish.h index 0b4c6ef0..81a19287 100644 --- a/twofish.h +++ b/twofish.h @@ -46,7 +46,7 @@ struct twofish_ctx { uint32_t keys[40]; - uitn32_t s_box[4][256]; + uint32_t s_box[4][256]; }; void -- GitLab