[PATCH] crypto: testmgr: add test vectors for skein

From: Juan Manuel Torres Palma
Date: Wed Jun 20 2018 - 06:56:41 EST


Adds test vectors specified in skein v1.3
specification. The main code is still in staging
directory, but this is required to eventually be
moved to the crypto directory.

Signed-off-by: Juan Manuel Torres Palma <j.m.torrespalma@xxxxxxxxx>
---
crypto/testmgr.c | 21 ++++++
crypto/testmgr.h | 203 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 224 insertions(+)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 11e45352fd0b..9fa08cbc8852 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -3453,6 +3453,27 @@ static const struct alg_test_desc alg_test_descs[] = {
.suite = {
.hash = __VECS(sha512_tv_template)
}
+ }, {
+ .alg = "skein1024",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = __VECS(skein1024_tv_template)
+ }
+ }, {
+ .alg = "skein256",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = __VECS(skein256_tv_template)
+ }
+ }, {
+ .alg = "skein512",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = __VECS(skein512_tv_template)
+ }
}, {
.alg = "sm3",
.test = alg_test_hash,
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index b950aa234e43..50239e84e283 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -1699,6 +1699,209 @@ static const struct hash_testvec sha3_512_tv_template[] = {
},
};

+/*
+ * Skein test vectors from skein specification v1.3
+ */
+static const struct hash_testvec skein256_tv_template[] = {
+ {
+ .plaintext = "\xff",
+ .psize = 1,
+ .digest = "\x0b\x98\xdc\xd1\x98\xea\x0e\x50"
+ "\xa7\xa2\x44\xc4\x44\xe2\x5c\x23"
+ "\xda\x30\xc1\x0f\xc9\xa1\xf2\x70"
+ "\xa6\x63\x7f\x1f\x34\xe6\x7e\xd2",
+ }, {
+ .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",
+ .psize = 32,
+ .digest = "\x8d\x0f\xa4\xef\x77\x7f\xd7\x59"
+ "\xdf\xd4\x04\x4e\x6f\x6a\x5a\xc3"
+ "\xc7\x74\xae\xc9\x43\xdc\xfc\x07"
+ "\x92\x7b\x72\x3b\x5d\xbf\x40\x8b",
+ }, {
+ .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 = "\xdf\x28\xe9\x16\x63\x0d\x0b\x44"
+ "\xc4\xa8\x49\xdc\x9a\x02\xf0\x7a"
+ "\x07\xcb\x30\xf7\x32\x31\x82\x56"
+ "\xb1\x5d\x86\x5a\xc4\xae\x16\x2f",
+ }
+};
+
+static const struct hash_testvec skein512_tv_template[] = {
+ {
+ .plaintext = "\xff",
+ .psize = 1,
+ .digest = "\x71\xb7\xbc\xe6\xfe\x64\x52\x22"
+ "\x7b\x9c\xed\x60\x14\x24\x9e\x5b"
+ "\xf9\xa9\x75\x4c\x3a\xd6\x18\xcc"
+ "\xc4\xe0\xaa\xe1\x6b\x31\x6c\xc8"
+ "\xca\x69\x8d\x86\x43\x07\xed\x3e"
+ "\x80\xb6\xef\x15\x70\x81\x2a\xc5"
+ "\x27\x2d\xc4\x09\xb5\xa0\x12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+ "\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 = "\x91\xcc\xa5\x10\xc2\x63\xc4\xdd"
+ "\xd0\x10\x53\x0a\x33\x07\x33\x09"
+ "\x62\x86\x31\xf3\x08\x74\x7e\x1b"
+ "\xcb\xaa\x90\xe4\x51\xca\xb9\x2e"
+ "\x51\x88\x08\x7a\xf4\x18\x87\x73"
+ "\xa3\x32\x30\x3e\x66\x67\xa7\xa2"
+ "\x10\x85\x6f\x74\x21\x39\x00\x00"
+ "\x71\xf4\x8e\x8b\xa2\xa5\xad\xb7",
+ }
+};
+
+static const struct hash_testvec skein1024_tv_template[] = {
+ {
+ .plaintext = "\xff",
+ .psize = 1,
+ .digest = "\xe6\x2c\x05\x80\x2e\xa0\x15\x24"
+ "\x07\xcd\xd8\x78\x7f\xda\x9e\x35"
+ "\x70\x3d\xe8\x62\xa4\xfb\xc1\x19"
+ "\xcf\xf8\x59\x0a\xfe\x79\x25\x0b"
+ "\xcc\xc8\xb3\xfa\xf1\xbd\x24\x22"
+ "\xab\x5c\x0d\x26\x3f\xb2\xf8\xaf"
+ "\xb3\xf7\x96\xf0\x48\x00\x03\x81"
+ "\x53\x1b\x6f\x00\xd8\x51\x61\xbc"
+ "\x0f\xff\x4b\xef\x24\x86\xb1\xeb"
+ "\xcd\x37\x73\xfa\xbf\x50\xad\x4a"
+ "\xd5\x63\x9a\xf9\x04\x0e\x3f\x29"
+ "\xc6\xc9\x31\x30\x1b\xf7\x98\x32"
+ "\xe9\xda\x09\x85\x7e\x83\x1e\x82"
+ "\xef\x8b\x46\x91\xc2\x35\x65\x65"
+ "\x15\xd4\x37\xd2\xbd\xa3\x3b\xce"
+ "\xc0\x01\xc6\x7f\x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f\x0e\xe0\xa3"
+ "\x9a\x42\xef\xc5\x4f\x18\xd9\x37"
+ "\x76\x08\x09\x85\xf9\x07\x57\x4f"
+ "\x99\x5e\xc6\xa3\x71\x53\xa5\x78",
+ }, {
+ .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"
+ "\x7f\x7e\x7d\x7c\x7b\x7a\x79\x78"
+ "\x77\x76\x75\x74\x73\x72\x71\x70"
+ "\x6f\x6e\x6d\x6c\x6b\x6a\x69\x68"
+ "\x67\x66\x65\x64\x63\x62\x61\x60"
+ "\x5f\x5e\x5d\x5c\x5b\x5a\x59\x58"
+ "\x57\x56\x55\x54\x53\x52\x51\x50"
+ "\x4f\x4e\x4d\x4c\x4b\x4a\x49\x48"
+ "\x47\x46\x45\x44\x43\x42\x41\x40"
+ "\x3f\x3e\x3d\x3c\x3b\x3a\x39\x38"
+ "\x37\x36\x35\x34\x33\x32\x31\x30"
+ "\x2f\x2e\x2d\x2c\x2b\x2a\x29\x28"
+ "\x27\x26\x25\x24\x23\x22\x21\x20"
+ "\x1f\x1e\x1d\x1c\x1b\x1a\x19\x18"
+ "\x17\x16\x15\x14\x13\x12\x11\x10"
+ "\x0f\x0e\x0d\x0c\x0b\x0a\x09\x08"
+ "\x07\x06\x05\x04\x03\x02\x01\x00",
+ .psize = 256,
+ .digest = "\x84\x2a\x53\xc9\x9c\x12\xb0\xcf"
+ "\x80\xcf\x69\x49\x1b\xe5\xe2\xf7"
+ "\x51\x5d\xe8\x73\x3b\x6e\xa9\x42"
+ "\x2d\xfd\x67\x66\x65\xb5\xfa\x42"
+ "\xff\xb3\xa9\xc4\x8c\x21\x77\x77"
+ "\x95\x08\x48\xce\xcd\xb4\x8f\x64"
+ "\x0f\x81\xfb\x92\xbe\xf6\xf8\x8f"
+ "\x7a\x85\xc1\xf7\xcd\x14\x46\xc9"
+ "\x16\x1c\x0a\xfe\x8f\x25\xae\x44"
+ "\x4f\x40\xd3\x68\x00\x81\xc3\x5a"
+ "\xa4\x3f\x64\x0f\xd5\xfa\x3c\x3c"
+ "\x03\x0b\xcc\x06\xab\xac\x01\xd0"
+ "\x98\xbc\xc9\x84\xeb\xd8\x32\x27"
+ "\x12\x92\x1e\x00\xb1\xba\x07\xd6"
+ "\xd0\x1f\x26\x90\x70\x50\x25\x5e"
+ "\xf2\xc8\xe2\x4f\x71\x6c\x52\xa5",
+ }
+};

/*
* MD5 test vectors from RFC1321
--
2.14.4