summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorKasoju Mallikarjun <mkasoju@nvidia.com>2011-06-01 18:06:46 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:41:47 -0800
commit048b7ff1f34a6f0387d6cf33d8d22085873b2b20 (patch)
tree917b95c49909010e8bd3107fdd51b65d8a9c4478 /crypto
parentbc02b5aa21c0710f23f06a94698d48813131ab45 (diff)
crypto: testmgr - Adding ofb(aes) and cmac(aes) tests
Added ofb(aes) and cmac(aes) tests Original-Change-Id: Ia79b0f979af88d337e91164f0b8b6d0eba18cd03 Reviewed-on: http://git-master/r/34701 Reviewed-by: Mallikarjun Kasoju <mkasoju@nvidia.com> Tested-by: Mallikarjun Kasoju <mkasoju@nvidia.com> Reviewed-by: Hanumanth Venkateswa Moganty <vmoganty@nvidia.com> Rebase-Id: R383d7f642cab41350f54367687861615f9484cf3
Diffstat (limited to 'crypto')
-rw-r--r--crypto/tcrypt.c8
-rw-r--r--crypto/testmgr.c10
-rw-r--r--crypto/testmgr.h215
3 files changed, 231 insertions, 2 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 2222617b3bed..7569ba9b6210 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -944,6 +944,10 @@ static int do_test(int m)
ret += tcrypt_test("rfc4309(ccm(aes))");
break;
+ case 46:
+ ret += tcrypt_test("ofb(aes)");
+ break;
+
case 100:
ret += tcrypt_test("hmac(md5)");
break;
@@ -984,6 +988,10 @@ static int do_test(int m)
ret += tcrypt_test("vmac(aes)");
break;
+ case 110:
+ ret += tcrypt_test("cmac(aes)");
+ break;
+
case 150:
ret += tcrypt_test("ansi_cprng");
break;
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index b6b93d416351..80ff90bb9252 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1705,6 +1705,16 @@ static const struct alg_test_desc alg_test_descs[] = {
}
}
}
+ },{
+ .alg = "cmac(aes)",
+ .test = alg_test_hash,
+ .fips_allowed = 1,
+ .suite = {
+ .hash = {
+ .vecs = cmac_aes_tv_template,
+ .count = CMAC_AES_TEST_VECTORS
+ }
+ }
}, {
.alg = "crc32c",
.test = alg_test_crc32c,
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 27adc92842ba..82ae18099863 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -656,6 +656,59 @@ static struct hash_testvec sha512_tv_template[] = {
},
};
+#define CMAC_AES_TEST_VECTORS 4
+
+static struct hash_testvec cmac_aes_tv_template[] = {
+ {
+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
+ .ksize = 16,
+ .plaintext = "",
+ .psize = 0,
+ .digest = "\xbb\x1d\x69\x29\xe9\x59\x37\x28"
+ "\x7f\xa3\x7d\x12\x9b\x75\x67\x46",
+ },
+ {
+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
+ .ksize = 16,
+ .plaintext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a",
+ .psize = 16,
+ .digest = "\x07\x0a\x16\xb4\x6b\x4d\x41\x44"
+ "\xf7\x9b\xdd\x9d\xd0\x4a\x28\x7c",
+ },
+ {
+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
+ .ksize = 16,
+ .plaintext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11",
+ .psize = 40,
+ .digest = "\xdf\xa6\x67\x47\xde\x9a\xe6\x30"
+ "\x30\xca\x32\x61\x14\x97\xc8\x27",
+ },
+ {
+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
+ .ksize = 16,
+ .plaintext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .psize = 64,
+ .digest = "\x51\xf0\xbe\xbf\x7e\x3b\x9d\x92"
+ "\xfc\x49\x74\x17\x79\x36\x3c\xfe",
+ },
+
+};
/*
* WHIRLPOOL test vectors from Whirlpool package
@@ -2980,8 +3033,8 @@ static struct cipher_testvec cast6_dec_tv_template[] = {
#define AES_XTS_DEC_TEST_VECTORS 5
#define AES_CTR_ENC_TEST_VECTORS 3
#define AES_CTR_DEC_TEST_VECTORS 3
-#define AES_OFB_ENC_TEST_VECTORS 1
-#define AES_OFB_DEC_TEST_VECTORS 1
+#define AES_OFB_ENC_TEST_VECTORS 3
+#define AES_OFB_DEC_TEST_VECTORS 3
#define AES_CTR_3686_ENC_TEST_VECTORS 7
#define AES_CTR_3686_DEC_TEST_VECTORS 6
#define AES_GCM_ENC_TEST_VECTORS 9
@@ -4574,6 +4627,164 @@ static struct cipher_testvec aes_ctr_dec_tv_template[] = {
}
};
+static struct cipher_testvec aes_ofb_enc_tv_template[] = {
+ { /* From NIST Special Publication 800-38A, Appendix F.5 */
+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
+ .klen = 16,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\x3B\x3F\xD9\x2E\xB7\x2D\xAD\x20"
+ "\x33\x34\x49\xF8\xE8\x3C\xFB\x4A"
+ "\x77\x89\x50\x8D\x16\x91\x8F\x03"
+ "\xF5\x3C\x52\xDA\xC5\x4E\xD8\x25"
+ "\x97\x40\x05\x1E\x9C\x5F\xEC\xF6"
+ "\x43\x44\xF7\xA8\x22\x60\xED\xCC"
+ "\x30\x4C\x65\x28\xF6\x59\xC7\x78"
+ "\x66\xA5\x10\xD9\xC1\xD6\xAE\x5E",
+ .rlen = 64,
+ }, {
+ .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
+ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
+ .klen = 24,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\xCD\xC8\x0D\x6F\xDD\xF1\x8C\xAB"
+ "\x34\xC2\x59\x09\xC9\x9A\x41\x74"
+ "\xFC\xC2\x8B\x8D\x4C\x63\x83\x7C"
+ "\x09\xE8\x17\x00\xC1\x10\x04\x01"
+ "\x8D\x9A\x9A\xEA\xC0\xF6\x59\x6F"
+ "\x55\x9C\x6D\x4D\xAF\x59\xA5\xF2"
+ "\x6D\x9F\x20\x08\x57\xCA\x6C\x3E"
+ "\x9C\xAC\x52\x4B\xD9\xAC\xC9\x2A",
+ .rlen = 64,
+ }, {
+ .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
+ "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
+ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
+ .klen = 32,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .ilen = 64,
+ .result = "\xDC\x7E\x84\xBF\xDA\x79\x16\x4B"
+ "\x7E\xCD\x84\x86\x98\x5D\x38\x60"
+ "\x4F\xEB\xDC\x67\x40\xD2\x0B\x3A"
+ "\xC8\x8F\x6A\xD8\x2A\x4F\xB0\x8D"
+ "\x71\xAB\x47\xA0\x86\xE8\x6E\xED"
+ "\xF3\x9D\x1C\x5B\xBA\x97\xC4\x08"
+ "\x01\x26\x14\x1D\x67\xF3\x7B\xE8"
+ "\x53\x8F\x5A\x8B\xE7\x40\xE4\x84",
+ .rlen = 64,
+ }
+};
+
+static struct cipher_testvec aes_ofb_dec_tv_template[] = {
+ { /* From NIST Special Publication 800-38A, Appendix F.5 */
+ .key = "\x2b\x7e\x15\x16\x28\xae\xd2\xa6"
+ "\xab\xf7\x15\x88\x09\xcf\x4f\x3c",
+ .klen = 16,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\x3B\x3F\xD9\x2E\xB7\x2D\xAD\x20"
+ "\x33\x34\x49\xF8\xE8\x3C\xFB\x4A"
+ "\x77\x89\x50\x8D\x16\x91\x8F\x03"
+ "\xF5\x3C\x52\xDA\xC5\x4E\xD8\x25"
+ "\x97\x40\x05\x1E\x9C\x5F\xEC\xF6"
+ "\x43\x44\xF7\xA8\x22\x60\xED\xCC"
+ "\x30\x4C\x65\x28\xF6\x59\xC7\x78"
+ "\x66\xA5\x10\xD9\xC1\xD6\xAE\x5E",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+ }, {
+ .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52"
+ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b",
+ .klen = 24,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\xCD\xC8\x0D\x6F\xDD\xF1\x8C\xAB"
+ "\x34\xC2\x59\x09\xC9\x9A\x41\x74"
+ "\xFC\xC2\x8B\x8D\x4C\x63\x83\x7C"
+ "\x09\xE8\x17\x00\xC1\x10\x04\x01"
+ "\x8D\x9A\x9A\xEA\xC0\xF6\x59\x6F"
+ "\x55\x9C\x6D\x4D\xAF\x59\xA5\xF2"
+ "\x6D\x9F\x20\x08\x57\xCA\x6C\x3E"
+ "\x9C\xAC\x52\x4B\xD9\xAC\xC9\x2A",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+ }, {
+ .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe"
+ "\x2b\x73\xae\xf0\x85\x7d\x77\x81"
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7"
+ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4",
+ .klen = 32,
+ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ .input = "\xDC\x7E\x84\xBF\xDA\x79\x16\x4B"
+ "\x7E\xCD\x84\x86\x98\x5D\x38\x60"
+ "\x4F\xEB\xDC\x67\x40\xD2\x0B\x3A"
+ "\xC8\x8F\x6A\xD8\x2A\x4F\xB0\x8D"
+ "\x71\xAB\x47\xA0\x86\xE8\x6E\xED"
+ "\xF3\x9D\x1C\x5B\xBA\x97\xC4\x08"
+ "\x01\x26\x14\x1D\x67\xF3\x7B\xE8"
+ "\x53\x8F\x5A\x8B\xE7\x40\xE4\x84",
+ .ilen = 64,
+ .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96"
+ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c"
+ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11"
+ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17"
+ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10",
+ .rlen = 64,
+ }
+};
+
static struct cipher_testvec aes_ctr_rfc3686_enc_tv_template[] = {
{ /* From RFC 3686 */
.key = "\xae\x68\x52\xf8\x12\x10\x67\xcc"