lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20081102201518.GA23620@Chamillionaire.breakpoint.cc>
Date:	Sun, 2 Nov 2008 21:15:18 +0100
From:	Sebastian Andrzej Siewior <sebastian@...akpoint.cc>
To:	Jeff Garzik <jeff@...zik.org>
Cc:	herbert@...dor.apana.org.au, davem@...emloft.net,
	linux-crypto@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] crypto: add test vectors for skein256/512/1024

I grabed them from http://www.schneier.com/skein.html. The last test vector
(3) in every category is currently deactivated because it failed always.
It is unlikely that I made a type because I copy+pasted the tables + vim
magiced them. So maybe code may missbehave on requests lengths which are
not a multiple of 4 or the vectors can not be used due to some other
limitations that I've overseen.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@...akpoint.cc>
---
 crypto/tcrypt.c  |   24 ++++++++
 crypto/testmgr.c |   27 +++++++++
 crypto/testmgr.h |  166 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 216 insertions(+), 1 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 28a45a1..c7717e8 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -661,6 +661,18 @@ static void do_test(int m)
 		tcrypt_test("ecb(seed)");
 		break;
 
+	case 44:
+		tcrypt_test("skein256");
+		break;
+
+	case 45:
+		tcrypt_test("skein512");
+		break;
+
+	case 46:
+		tcrypt_test("skein1024");
+		break;
+
 	case 100:
 		tcrypt_test("hmac(md5)");
 		break;
@@ -851,6 +863,18 @@ static void do_test(int m)
 		test_hash_speed("rmd320", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 
+	case 318:
+		test_hash_speed("skein256", sec, generic_hash_speed_template);
+		if (mode > 300 && mode < 400) break;
+
+	case 319:
+		test_hash_speed("skein512", sec, generic_hash_speed_template);
+		if (mode > 300 && mode < 400) break;
+
+	case 320:
+		test_hash_speed("skein1024", sec, generic_hash_speed_template);
+		if (mode > 300 && mode < 400) break;
+
 	case 399:
 		break;
 
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index b828c6c..bc6fc7f 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1693,6 +1693,33 @@ static const struct alg_test_desc alg_test_descs[] = {
 			}
 		}
 	}, {
+		.alg = "skein1024",
+		.test = alg_test_hash,
+		.suite = {
+			.hash = {
+				.vecs = skein1024_tv_template,
+				.count = SKEIN1024_TEST_VECTORS
+			}
+		}
+	}, {
+		.alg = "skein256",
+		.test = alg_test_hash,
+		.suite = {
+			.hash = {
+				.vecs = skein256_tv_template,
+				.count = SKEIN256_TEST_VECTORS
+			}
+		}
+	}, {
+		.alg = "skein512",
+		.test = alg_test_hash,
+		.suite = {
+			.hash = {
+				.vecs = skein512_tv_template,
+				.count = SKEIN512_TEST_VECTORS
+			}
+		}
+	}, {
 		.alg = "tgr128",
 		.test = alg_test_hash,
 		.suite = {
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index dee94d9..ebed56f 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -27,7 +27,7 @@ struct hash_testvec {
 	char *plaintext;
 	char *digest;
 	unsigned char tap[MAX_TAP];
-	unsigned char psize;
+	u16 psize;
 	unsigned char np;
 	unsigned char ksize;
 };
@@ -986,6 +986,170 @@ static struct hash_testvec tgr128_tv_template[] = {
 };
 
 /*
+ * SKEIN uses test vectors
+ *  from http://www.schneier.com/code/skein_NIST_CD_101308.zip
+ *  NIST/CD/KAT_MCT/skein_golden_kat_short.txt
+ */
+#define SKEIN256_TEST_VECTORS 2
+static struct hash_testvec skein256_tv_template[] = {
+	{
+		/* :Skein-256:   256-bit hash, msgLen =     8 bits */
+		.plaintext = "\xff",
+		.psize  = 1,
+		.digest = "\xa4\x7b\xe7\x1a\x18\x5b\xa0\xaf\x82\x0b\x3c\xe8\x45\xa3\xd3\x5a"
+			"\x80\xec\x64\xf9\x6a\x0d\x6a\x36\xe3\xf5\x36\x36\x24\xd8\xa0\x91",
+	}, {
+		/* :Skein-256:   256-bit hash, msgLen =   512 bits */
+		.plaintext = "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
+			"\xef\xee\xed\xec\xeb\xea\xe9\xe8\xe7\xe6\xe5\xe4\xe3\xe2\xe1\xe0"
+			"\xdf\xde\xdd\xdc\xdb\xda\xd9\xd8\xd7\xd6\xd5\xd4\xd3\xd2\xd1\xd0"
+			"\xcf\xce\xcd\xcc\xcb\xca\xc9\xc8\xc7\xc6\xc5\xc4\xc3\xc2\xc1\xc0",
+		.psize  = 64,
+		.digest = "\xfa\x1a\x76\x2b\x6b\x1c\x72\xb7\x0d\x52\x92\x63\x53\xe1\x0e\xb8"
+			"\xfb\x0e\xdd\x73\x13\xda\x20\xa2\x41\x31\x80\xb8\xe2\x89\xb8\x72",
+	}, {
+		/* :Skein-256:   256-bit hash, msgLen =  1016 bits. Tree: leaf=02, node=02, maxLevels=02 */
+		.plaintext = "\x00\x01\x02\x01\x04\x01\x06\x01\x08\x01\x0a\x01\x0c\x01\x0e\x01"
+			"\x10\x01\x12\x01\x14\x01\x16\x01\x18\x01\x1a\x01\x1c\x01\x1e\x01"
+			"\x20\x01\x22\x01\x24\x01\x26\x01\x28\x01\x2a\x01\x2c\x01\x2e\x01"
+			"\x30\x01\x32\x01\x34\x01\x36\x01\x38\x01\x3a\x01\x3c\x01\x3e\x01"
+			"\x40\x01\x42\x01\x44\x01\x46\x01\x48\x01\x4a\x01\x4c\x01\x4e\x01"
+			"\x50\x01\x52\x01\x54\x01\x56\x01\x58\x01\x5a\x01\x5c\x01\x5e\x01"
+			"\x60\x01\x62\x01\x64\x01\x66\x01\x68\x01\x6a\x01\x6c\x01\x6e\x01"
+			"\x70\x01\x72\x01\x74\x01\x76\x01\x78\x01\x7a\x01\x7c\x01\x7e",
+		.psize = 127,
+		.digest = "\xa9\x52\x58\x1e\x4e\x71\x2a\x71\xd4\x5c\x5e\xd6\x51\xa3\x91\x9b"
+			"\xdc\x89\x17\xe1\xdd\x82\x80\xbf\xcf\x94\x19\x31\xf5\xad\x72\xfb",
+	},
+};
+
+#define SKEIN512_TEST_VECTORS 2
+static struct hash_testvec skein512_tv_template[] = {
+	{
+		/* :Skein-512:   512-bit hash, msgLen =     8 bits */
+		.plaintext = "\xff",
+		.psize  = 1,
+		.digest = "\x9b\x76\x3e\xa7\x27\x8b\x79\xa0\xd3\x34\xc3\xc8\x38\x29\x0f\x1d"
+			"\x7f\x25\x80\x6f\xf8\xae\x9b\x29\x6e\x11\x98\x91\xdd\xb4\x47\x32"
+			"\x94\xce\xba\x7c\xcb\x85\x54\x2d\xf0\x0b\xab\x6a\x41\xf2\x4d\x06"
+			"\xef\x1e\x43\xac\x7f\x5e\xac\xc7\xa2\xe3\xfd\xf5\x38\x82\x3d\xb8",
+	}, {
+		/* :Skein-512:   512-bit hash, msgLen =   512 bits */
+		.plaintext = "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
+			"\xef\xee\xed\xec\xeb\xea\xe9\xe8\xe7\xe6\xe5\xe4\xe3\xe2\xe1\xe0"
+			"\xdf\xde\xdd\xdc\xdb\xda\xd9\xd8\xd7\xd6\xd5\xd4\xd3\xd2\xd1\xd0"
+			"\xcf\xce\xcd\xcc\xcb\xca\xc9\xc8\xc7\xc6\xc5\xc4\xc3\xc2\xc1\xc0",
+		.psize  = 64,
+		.digest = "\xde\xea\x5b\x2d\xda\xf4\x00\x5b\x5a\xb7\xdd\xa6\x0f\xbc\x72\x8d"
+			"\xc4\x83\xd9\xcb\x95\x10\xa3\x04\x52\x3a\x11\x41\x29\x00\x92\x8a"
+			"\x16\xac\xec\x86\xc0\x27\xed\x15\x83\xfb\xd5\x00\x4c\xb2\x49\x9e"
+			"\x06\x26\x8e\x8a\x93\xb1\xf3\xa0\x74\x05\xb8\x44\x33\x41\x9a\x77",
+	}, {
+		/* :Skein-512:   512-bit hash, msgLen =  2040 bits. Tree: leaf=02, node=02, maxLevels=02 */
+		.plaintext = "\x00\x02\x02\x02\x04\x02\x06\x02\x08\x02\x0a\x02\x0c\x02\x0e\x02"
+			"\x10\x02\x12\x02\x14\x02\x16\x02\x18\x02\x1a\x02\x1c\x02\x1e\x02"
+			"\x20\x02\x22\x02\x24\x02\x26\x02\x28\x02\x2a\x02\x2c\x02\x2e\x02"
+			"\x30\x02\x32\x02\x34\x02\x36\x02\x38\x02\x3a\x02\x3c\x02\x3e\x02"
+			"\x40\x02\x42\x02\x44\x02\x46\x02\x48\x02\x4a\x02\x4c\x02\x4e\x02"
+			"\x50\x02\x52\x02\x54\x02\x56\x02\x58\x02\x5a\x02\x5c\x02\x5e\x02"
+			"\x60\x02\x62\x02\x64\x02\x66\x02\x68\x02\x6a\x02\x6c\x02\x6e\x02"
+			"\x70\x02\x72\x02\x74\x02\x76\x02\x78\x02\x7a\x02\x7c\x02\x7e\x02"
+			"\x80\x02\x82\x02\x84\x02\x86\x02\x88\x02\x8a\x02\x8c\x02\x8e\x02"
+			"\x90\x02\x92\x02\x94\x02\x96\x02\x98\x02\x9a\x02\x9c\x02\x9e\x02"
+			"\xa0\x02\xa2\x02\xa4\x02\xa6\x02\xa8\x02\xaa\x02\xac\x02\xae\x02"
+			"\xb0\x02\xb2\x02\xb4\x02\xb6\x02\xb8\x02\xba\x02\xbc\x02\xbe\x02"
+			"\xc0\x02\xc2\x02\xc4\x02\xc6\x02\xc8\x02\xca\x02\xcc\x02\xce\x02"
+			"\xd0\x02\xd2\x02\xd4\x02\xd6\x02\xd8\x02\xda\x02\xdc\x02\xde\x02"
+			"\xe0\x02\xe2\x02\xe4\x02\xe6\x02\xe8\x02\xea\x02\xec\x02\xee\x02"
+			"\xf0\x02\xf2\x02\xf4\x02\xf6\x02\xf8\x02\xfa\x02\xfc\x02\xfe",
+		.psize = 255,
+		.digest = "\xd2\xb3\xe3\xec\x81\x4b\xaf\x4b\xc4\x8c\x8a\x85\x9b\x98\xfd\x42"
+			"\x03\x4a\xca\x33\x96\x89\x5c\x0b\x2b\x97\x23\x10\x4a\x0a\xa9\x1d"
+			"\x8f\x6a\x34\x9f\x4d\x06\x4c\x5a\xd6\x8a\x45\x5c\x58\xe2\xb2\x4c"
+			"\xac\x7b\x29\x9e\x4f\x8d\xd9\xba\xbe\xc7\x3f\xce\xb5\x49\x39\x63",
+	},
+};
+
+#define SKEIN1024_TEST_VECTORS 2
+static struct hash_testvec skein1024_tv_template[] = {
+	{
+		/* :Skein-1024: 1024-bit hash, msgLen =     8 bits */
+		.plaintext = "\xff",
+		.psize  = 1,
+		.digest = "\x93\x9e\x97\x6d\x2c\x1d\x76\x89\xa9\x6a\x9c\x7b\x3d\x6c\x3f\x3b"
+			"\x4d\x1e\xd2\xaf\x33\x70\x4d\xb9\x9c\xdb\x3d\xe1\xb7\x7d\x28\x3c"
+			"\x86\x8b\x62\xa6\x0a\x48\xf1\x73\x98\x06\x14\x4b\xe3\x1f\x00\x5b"
+			"\xbd\xa1\xc4\x1d\x41\xb2\x5c\x63\xae\x9d\x71\x59\x2d\x17\xfa\xb4"
+			"\xe4\x46\xc8\x8f\x2c\x1b\x19\x45\xa0\x63\x39\x66\xb9\xf2\x55\xaf"
+			"\x06\x42\x6f\xba\xd0\xee\xe0\xe9\xca\xb1\xe4\xe1\x7b\x14\xde\xdb"
+			"\xb0\x2d\x40\x88\x7f\xb7\x44\x82\xcb\xef\x9f\x17\xb7\xa1\x9f\x4b"
+			"\x79\x53\xa4\xea\xed\x00\x04\xa5\x47\x4a\xbb\x62\x95\x4e\x92\xf2",
+	}, {
+		/* :Skein-1024: 1024-bit hash, msgLen =  1024 bits */
+		.plaintext = "\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0"
+			"\xef\xee\xed\xec\xeb\xea\xe9\xe8\xe7\xe6\xe5\xe4\xe3\xe2\xe1\xe0"
+			"\xdf\xde\xdd\xdc\xdb\xda\xd9\xd8\xd7\xd6\xd5\xd4\xd3\xd2\xd1\xd0"
+			"\xcf\xce\xcd\xcc\xcb\xca\xc9\xc8\xc7\xc6\xc5\xc4\xc3\xc2\xc1\xc0"
+			"\xbf\xbe\xbd\xbc\xbb\xba\xb9\xb8\xb7\xb6\xb5\xb4\xb3\xb2\xb1\xb0"
+			"\xaf\xae\xad\xac\xab\xaa\xa9\xa8\xa7\xa6\xa5\xa4\xa3\xa2\xa1\xa0"
+			"\x9f\x9e\x9d\x9c\x9b\x9a\x99\x98\x97\x96\x95\x94\x93\x92\x91\x90"
+			"\x8f\x8e\x8d\x8c\x8b\x8a\x89\x88\x87\x86\x85\x84\x83\x82\x81\x80",
+		.psize  = 128,
+		.digest = "\xf1\xb2\x75\x2a\x26\xc1\x7b\x0e\x4d\xe4\x1c\xec\xaa\x73\xf1\xb3"
+			"\x85\x40\xb8\xe1\x63\xc2\x09\x5b\x54\x7b\xe2\xec\xaa\x65\xd9\x46"
+			"\x6a\xee\xf2\x2b\x7d\x82\xe2\x14\xdd\x3a\x4e\x82\x9c\x33\xc5\xc3"
+			"\x1f\xa6\xd9\x18\x44\x5f\x0e\xa0\x1d\xd8\x72\xe6\x1e\x43\x36\x61"
+			"\x0e\x6d\xbd\xf2\xd1\xa1\xc7\x4b\x1f\x5a\x92\xa5\x36\x6a\x6b\xb9"
+			"\x6b\x5d\xca\x53\xa4\x45\x74\x70\xcb\xff\x66\x57\xb0\x0c\x97\x94"
+			"\x28\x2f\xf1\x7f\x91\x23\x2a\x3b\x98\x27\xf9\x78\x2d\xd3\x83\x43"
+			"\x64\x9b\x4e\xcd\xd8\x27\xe4\x24\xac\xa6\xd7\x39\x82\x14\x86\x2b",
+	}, {
+		/*  :Skein-1024: 1024-bit hash, msgLen =  4088 bits. Tree: leaf=02, node=02, maxLevels=02 */
+		.plaintext = "\x00\x04\x02\x04\x04\x04\x06\x04\x08\x04\x0a\x04\x0c\x04\x0e\x04"
+			"\x10\x04\x12\x04\x14\x04\x16\x04\x18\x04\x1a\x04\x1c\x04\x1e\x04"
+			"\x20\x04\x22\x04\x24\x04\x26\x04\x28\x04\x2a\x04\x2c\x04\x2e\x04"
+			"\x30\x04\x32\x04\x34\x04\x36\x04\x38\x04\x3a\x04\x3c\x04\x3e\x04"
+			"\x40\x04\x42\x04\x44\x04\x46\x04\x48\x04\x4a\x04\x4c\x04\x4e\x04"
+			"\x50\x04\x52\x04\x54\x04\x56\x04\x58\x04\x5a\x04\x5c\x04\x5e\x04"
+			"\x60\x04\x62\x04\x64\x04\x66\x04\x68\x04\x6a\x04\x6c\x04\x6e\x04"
+			"\x70\x04\x72\x04\x74\x04\x76\x04\x78\x04\x7a\x04\x7c\x04\x7e\x04"
+			"\x80\x04\x82\x04\x84\x04\x86\x04\x88\x04\x8a\x04\x8c\x04\x8e\x04"
+			"\x90\x04\x92\x04\x94\x04\x96\x04\x98\x04\x9a\x04\x9c\x04\x9e\x04"
+			"\xa0\x04\xa2\x04\xa4\x04\xa6\x04\xa8\x04\xaa\x04\xac\x04\xae\x04"
+			"\xb0\x04\xb2\x04\xb4\x04\xb6\x04\xb8\x04\xba\x04\xbc\x04\xbe\x04"
+			"\xc0\x04\xc2\x04\xc4\x04\xc6\x04\xc8\x04\xca\x04\xcc\x04\xce\x04"
+			"\xd0\x04\xd2\x04\xd4\x04\xd6\x04\xd8\x04\xda\x04\xdc\x04\xde\x04"
+			"\xe0\x04\xe2\x04\xe4\x04\xe6\x04\xe8\x04\xea\x04\xec\x04\xee\x04"
+			"\xf0\x04\xf2\x04\xf4\x04\xf6\x04\xf8\x04\xfa\x04\xfc\x04\xfe\x04"
+			"\x00\x05\x02\x05\x04\x05\x06\x05\x08\x05\x0a\x05\x0c\x05\x0e\x05"
+			"\x10\x05\x12\x05\x14\x05\x16\x05\x18\x05\x1a\x05\x1c\x05\x1e\x05"
+			"\x20\x05\x22\x05\x24\x05\x26\x05\x28\x05\x2a\x05\x2c\x05\x2e\x05"
+			"\x30\x05\x32\x05\x34\x05\x36\x05\x38\x05\x3a\x05\x3c\x05\x3e\x05"
+			"\x40\x05\x42\x05\x44\x05\x46\x05\x48\x05\x4a\x05\x4c\x05\x4e\x05"
+			"\x50\x05\x52\x05\x54\x05\x56\x05\x58\x05\x5a\x05\x5c\x05\x5e\x05"
+			"\x60\x05\x62\x05\x64\x05\x66\x05\x68\x05\x6a\x05\x6c\x05\x6e\x05"
+			"\x70\x05\x72\x05\x74\x05\x76\x05\x78\x05\x7a\x05\x7c\x05\x7e\x05"
+			"\x80\x05\x82\x05\x84\x05\x86\x05\x88\x05\x8a\x05\x8c\x05\x8e\x05"
+			"\x90\x05\x92\x05\x94\x05\x96\x05\x98\x05\x9a\x05\x9c\x05\x9e\x05"
+			"\xa0\x05\xa2\x05\xa4\x05\xa6\x05\xa8\x05\xaa\x05\xac\x05\xae\x05"
+			"\xb0\x05\xb2\x05\xb4\x05\xb6\x05\xb8\x05\xba\x05\xbc\x05\xbe\x05"
+			"\xc0\x05\xc2\x05\xc4\x05\xc6\x05\xc8\x05\xca\x05\xcc\x05\xce\x05"
+			"\xd0\x05\xd2\x05\xd4\x05\xd6\x05\xd8\x05\xda\x05\xdc\x05\xde\x05"
+			"\xe0\x05\xe2\x05\xe4\x05\xe6\x05\xe8\x05\xea\x05\xec\x05\xee\x05"
+			"\xf0\x05\xf2\x05\xf4\x05\xf6\x05\xf8\x05\xfa\x05\xfc\x05\xfe",
+		.psize = 511,
+		.digest = "\x8c\xa9\x29\xda\xa9\xcf\xfe\x02\x74\x47\x9b\x38\x11\xf6\x8a\x0f"
+			"\x72\x06\xce\x53\x96\x27\x23\xb9\x59\xd3\xd4\xb0\x73\x86\xea\x5f"
+			"\x53\xcf\x25\x02\x98\x92\x05\x68\x03\x01\x15\x38\xb9\x5b\x4a\xd3"
+			"\xae\x9b\x3a\x4f\xcc\x70\xf2\x71\xdd\x6a\x51\x83\xac\xdf\xce\x80"
+			"\x5b\x3c\x8c\x75\x41\xce\x2f\x8d\x60\x35\xf3\x1d\xd8\xae\x09\x0a"
+			"\x5c\xa9\xa2\x9a\xd0\x07\x55\x8a\xae\xe7\x1c\xf9\x5e\x44\xd0\x9e"
+			"\x21\x76\x99\xbe\xca\xa4\x5c\xb8\x6e\x1f\x44\x80\x0e\x73\x18\xbd"
+			"\xa2\x22\xbe\x43\x49\x78\x7a\x43\x81\x57\x22\x24\x6d\xb0\x2c\x04",
+	},
+};
+
+/*
  * HMAC-MD5 test vectors from RFC2202
  * (These need to be fixed to not use strlen).
  */
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ