Skip to contentSkip to conversation

Whirlpool-256 and -384

PATCH New Jean-Luc Cooke 1 participant 1 message Sep 21, 2004 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Whirlpool-256 and -384

Attached is a patch for the 2.6.9-rc2 tree.

Whirlpool is a 512bit hash function. This patch truncates the output to 256 and 384 bits for "whirlpool-256" and "whirlpool-384" respectivly.

Truncating of hash is standard pracatice in seen in 2nd generation of SHA functions as one example.

There was minor flaw in whirlpool.c's update function where WHIRLPOOL_DIGEST_SIZE was used inplace of WHIRLPOOL_BLOCK_SIZE. This isn't a big deal since they are identical values for DIGESTSIZE=512bits. I have fix this in the following patch.

tcrypt.c and tcrypt.h have been updated as well.

JLC

crypto/tcrypt.c +11 -1
diff -Nur old/crypto/tcrypt.c new/crypto/tcrypt.c
@@ -63,7 +63,7 @@
 	"des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish",
 	"twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6", 
 	"arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
-	"whirlpool", NULL
+	"whirlpool", "whirlpool-384", "whirlpool-256", NULL
 };
 
 static void
@@ -683,6 +683,8 @@
 		test_hash("sha384", sha384_tv_template, SHA384_TEST_VECTORS);
 		test_hash("sha512", sha512_tv_template, SHA512_TEST_VECTORS);
 		test_hash("whirlpool", whirlpool_tv_template, WHIRLPOOL_TEST_VECTORS);
+		test_hash("whirlpool-384", whirlpool384_tv_template, WHIRLPOOL384_TEST_VECTORS);
+		test_hash("whirlpool-256", whirlpool256_tv_template, WHIRLPOOL256_TEST_VECTORS);
 		test_deflate();
 		test_crc32c();
 #ifdef CONFIG_CRYPTO_HMAC
@@ -798,6 +800,14 @@
 		test_hash("whirlpool", whirlpool_tv_template, WHIRLPOOL_TEST_VECTORS);
 		break;
 
+	case 23:
+		test_hash("whirlpool-384", whirlpool384_tv_template, WHIRLPOOL384_TEST_VECTORS);
+		break;
+
+	case 24:
+		test_hash("whirlpool-256", whirlpool256_tv_template, WHIRLPOOL256_TEST_VECTORS);
+		break;
+
 #ifdef CONFIG_CRYPTO_HMAC
 	case 100:
 		test_hmac("md5", hmac_md5_tv_template, HMAC_MD5_TEST_VECTORS);
crypto/tcrypt.h +4 -0
diff -Nur old/crypto/tcrypt.h new/crypto/tcrypt.h
@@ -308,6 +308,10 @@
  * submission
  */
 #define WHIRLPOOL_TEST_VECTORS 8
+#define WHIRLPOOL384_TEST_VECTORS 8
+#define whirlpool384_tv_template whirlpool_tv_template
+#define WHIRLPOOL256_TEST_VECTORS 8
+#define whirlpool256_tv_template whirlpool_tv_template
 
 struct hash_testvec whirlpool_tv_template[] = {
 	{
crypto/whirlpool.c +71 -7

128 lines not on this page · raw message