[PATCH 2/4] crypto: add eboiv(cbc(aes)) test vectors

From: Gilad Ben-Yossef
Date: Mon Oct 26 2020 - 09:05:18 EST


Add test vectors for the use of the EBOIV template with cbc(aes)
modes as it is being used by dm-crypt for BitLocker support.

Vectors taken from dm-crypt test suite images.

Signed-off-by: Gilad Ben-Yossef <gilad@xxxxxxxxxxxxx>
---
crypto/tcrypt.c | 9 ++
crypto/testmgr.c | 6 +
crypto/testmgr.h | 279 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 294 insertions(+)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 234b1adcfbcb..583c027fe8f5 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -2344,6 +2344,15 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
NULL, 0, 16, 8, speed_template_16);
break;

+ case 222:
+ test_acipher_speed("eboiv(cbc(aes))",
+ ENCRYPT, sec, NULL, 0,
+ speed_template_16_32);
+ test_acipher_speed("eboiv(cbc(aes))",
+ DECRYPT, sec, NULL, 0,
+ speed_template_16_32);
+ break;
+
case 300:
if (alg) {
test_hash_speed(alg, sec, generic_hash_speed_template);
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 66ee3bbc9872..9c30db79f323 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -4771,6 +4771,12 @@ static const struct alg_test_desc alg_test_descs[] = {
.alg = "drbg_pr_sha512",
.fips_allowed = 1,
.test = alg_test_null,
+ }, {
+ .alg = "eboiv(cbc(aes))",
+ .test = alg_test_skcipher,
+ .suite = {
+ .cipher = __VECS(eboiv_aes_cbc_tv_template)
+ }
}, {
.alg = "ecb(aes)",
.test = alg_test_skcipher,
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index cc9dc4cfec8c..0dc18148ea04 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -33045,6 +33045,285 @@ static const struct comp_testvec zstd_decomp_tv_template[] = {
},
};

+/* vectors taken from cryptosetup test suite images */
+static const struct cipher_testvec eboiv_aes_cbc_tv_template[] = {
+ {
+ /* cbc-aes-128 with 512b sector size, 0th sector */
+ .key = "\x6c\x96\xf8\x2a\x94\x2e\x87\x5f"
+ "\x02\x9c\x3d\xd9\xe4\x35\x17\x73",
+ .klen = 16,
+ .iv = "\x00\x50\x1a\x02\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ptext = "\xeb\x52\x90\x4e\x54\x46\x53\x20"
+ "\x20\x20\x20\x00\x02\x08\x00\x00"
+ "\x00\x00\x00\x00\x00\xf8\x00\x00"
+ "\x3f\x00\xff\x00\x00\x08\x00\x00"
+ "\x00\x00\x00\x00\x80\x00\x00\x00"
+ "\xff\x1f\x03\x00\x00\x00\x00\x00"
+ "\x55\x21\x00\x00\x00\x00\x00\x00"
+ "\x02\x00\x00\x00\x00\x00\x00\x00"
+ "\xf6\x00\x00\x00\x01\x00\x00\x00"
+ "\x13\x1e\xf1\xd4\x56\xf1\xd4\xf2"
+ "\x00\x00\x00\x00\xfa\x33\xc0\x8e"
+ "\xd0\xbc\x00\x7c\xfb\x68\xc0\x07"
+ "\x1f\x1e\x68\x66\x00\xcb\x88\x16"
+ "\x0e\x00\x66\x81\x3e\x03\x00\x4e"
+ "\x54\x46\x53\x75\x15\xb4\x41\xbb"
+ "\xaa\x55\xcd\x13\x72\x0c\x81\xfb"
+ "\x55\xaa\x75\x06\xf7\xc1\x01\x00"
+ "\x75\x03\xe9\xdd\x00\x1e\x83\xec"
+ "\x18\x68\x1a\x00\xb4\x48\x8a\x16"
+ "\x0e\x00\x8b\xf4\x16\x1f\xcd\x13"
+ "\x9f\x83\xc4\x18\x9e\x58\x1f\x72"
+ "\xe1\x3b\x06\x0b\x00\x75\xdb\xa3"
+ "\x0f\x00\xc1\x2e\x0f\x00\x04\x1e"
+ "\x5a\x33\xdb\xb9\x00\x20\x2b\xc8"
+ "\x66\xff\x06\x11\x00\x03\x16\x0f"
+ "\x00\x8e\xc2\xff\x06\x16\x00\xe8"
+ "\x4b\x00\x2b\xc8\x77\xef\xb8\x00"
+ "\xbb\xcd\x1a\x66\x23\xc0\x75\x2d"
+ "\x66\x81\xfb\x54\x43\x50\x41\x75"
+ "\x24\x81\xf9\x02\x01\x72\x1e\x16"
+ "\x68\x07\xbb\x16\x68\x52\x11\x16"
+ "\x68\x09\x00\x66\x53\x66\x53\x66"
+ "\x55\x16\x16\x16\x68\xb8\x01\x66"
+ "\x61\x0e\x07\xcd\x1a\x33\xc0\xbf"
+ "\x0a\x13\xb9\xf6\x0c\xfc\xf3\xaa"
+ "\xe9\xfe\x01\x90\x90\x66\x60\x1e"
+ "\x06\x66\xa1\x11\x00\x66\x03\x06"
+ "\x1c\x00\x1e\x66\x68\x00\x00\x00"
+ "\x00\x66\x50\x06\x53\x68\x01\x00"
+ "\x68\x10\x00\xb4\x42\x8a\x16\x0e"
+ "\x00\x16\x1f\x8b\xf4\xcd\x13\x66"
+ "\x59\x5b\x5a\x66\x59\x66\x59\x1f"
+ "\x0f\x82\x16\x00\x66\xff\x06\x11"
+ "\x00\x03\x16\x0f\x00\x8e\xc2\xff"
+ "\x0e\x16\x00\x75\xbc\x07\x1f\x66"
+ "\x61\xc3\xa1\xf6\x01\xe8\x09\x00"
+ "\xa1\xfa\x01\xe8\x03\x00\xf4\xeb"
+ "\xfd\x8b\xf0\xac\x3c\x00\x74\x09"
+ "\xb4\x0e\xbb\x07\x00\xcd\x10\xeb"
+ "\xf2\xc3\x0d\x0a\x41\x20\x64\x69"
+ "\x73\x6b\x20\x72\x65\x61\x64\x20"
+ "\x65\x72\x72\x6f\x72\x20\x6f\x63"
+ "\x63\x75\x72\x72\x65\x64\x00\x0d"
+ "\x0a\x42\x4f\x4f\x54\x4d\x47\x52"
+ "\x20\x69\x73\x20\x63\x6f\x6d\x70"
+ "\x72\x65\x73\x73\x65\x64\x00\x0d"
+ "\x0a\x50\x72\x65\x73\x73\x20\x43"
+ "\x74\x72\x6c\x2b\x41\x6c\x74\x2b"
+ "\x44\x65\x6c\x20\x74\x6f\x20\x72"
+ "\x65\x73\x74\x61\x72\x74\x0d\x0a"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x8a\x01"
+ "\xa7\x01\xbf\x01\x00\x00\x55\xaa",
+ .ctext = "\xae\x81\x3f\xac\x8a\xee\x8d\x6e"
+ "\xc2\x6b\xff\x87\x65\xe8\xfd\x0d"
+ "\xdc\x99\x61\xd3\x01\xa4\x26\x05"
+ "\x7e\xf1\x1e\x61\xde\x84\x1f\x21"
+ "\xf9\x27\x10\x31\x64\xdd\xee\xd2"
+ "\xce\xaf\xb6\x1a\x11\xcf\xde\x2d"
+ "\x1e\xd1\x0d\x42\x51\x89\x4c\x01"
+ "\x6f\xae\x26\x65\xff\x12\xe3\xa2"
+ "\xa4\x8a\x0c\x74\xed\xfa\xab\x05"
+ "\x7d\x6e\x58\x24\x92\x2e\xc2\x33"
+ "\xa2\x71\x3b\xec\x4e\x3b\x17\xde"
+ "\xfb\xc0\xaa\x04\x72\xe7\x76\x3d"
+ "\xf2\x3d\xc4\x50\x3d\x5e\xac\x5d"
+ "\x95\x4d\x02\xbc\xe1\xed\x46\x25"
+ "\xe5\x8e\x51\x36\x31\x6d\xb4\x2f"
+ "\x04\x09\x18\xa8\x66\x5f\xbc\xb2"
+ "\x39\x20\x79\xd7\x3c\xc3\xf7\x3e"
+ "\x3e\xe6\x31\xc8\x9a\xd8\xdc\xcf"
+ "\xb7\x49\x0e\x5b\x9e\xc3\xd4\x5d"
+ "\x2c\xa2\xaf\x7c\x9e\xb0\x5d\x45"
+ "\x18\x32\xbf\x50\xc8\x47\xc1\x55"
+ "\x1c\xd8\xf9\xc8\xdd\x97\x46\xba"
+ "\x3c\x8c\xbd\x14\x07\xf7\x14\xa7"
+ "\x5e\x44\xc3\x41\x86\x37\x46\xbc"
+ "\x45\xcb\xaf\xff\xf4\xba\xdf\xe5"
+ "\xfa\x62\xa6\x04\x74\x90\x24\x38"
+ "\x13\x37\x9f\xe5\x73\x76\x4e\x4c"
+ "\x1b\x57\xe5\x85\x14\xa2\x24\x24"
+ "\xb1\xc7\xa4\x47\xfa\x5f\x4d\x32"
+ "\xfa\x43\x0c\x71\x49\x45\x2a\xcb"
+ "\x5d\xd5\xa4\x75\x1d\x53\x21\x5c"
+ "\xa3\x0b\xd4\x23\xba\x20\x10\x00"
+ "\x27\x2b\x9f\xbe\x49\x0b\x2c\xe9"
+ "\x2f\x61\x19\x9f\x88\x06\x94\xb4"
+ "\x35\xdf\x15\xff\xc9\x76\x1b\x18"
+ "\xf4\x0d\xb5\x41\x53\x51\x4e\x41"
+ "\xf3\x1a\x60\x8f\x2d\x48\x60\x05"
+ "\xff\xb7\x5c\x46\x77\xd6\x29\xad"
+ "\x51\x10\x51\x7f\x97\x44\x4c\xa3"
+ "\xf5\x71\x95\x9c\x9d\x82\xfb\x3e"
+ "\x1c\xfd\x88\x99\xe3\x0c\xdf\xad"
+ "\xf3\xba\x0e\x44\x4a\x24\x8e\xf7"
+ "\x5d\x44\x41\x78\xc0\x0c\x80\xe2"
+ "\xaa\x52\xad\x65\xea\x09\x15\x52"
+ "\x67\x0d\xa2\x39\x74\xde\x4f\x64"
+ "\x1c\x5b\x58\x55\x2a\x30\xef\x8f"
+ "\xc1\x53\x4d\xe4\x3d\xae\x4c\x04"
+ "\xf5\x1c\x04\x47\xad\x8e\xdf\xd8"
+ "\x8f\xe2\x64\xcc\x37\xdd\xf1\x4f"
+ "\xab\xc2\x53\x4f\x7d\xe3\xb1\x57"
+ "\xfe\x3d\x5c\xea\xfb\xe0\x1b\xad"
+ "\xc3\x0f\xc5\xed\x42\xb1\xac\x88"
+ "\x96\x96\x7c\xd3\xe4\x44\xd1\xe6"
+ "\x88\xd2\xae\xdd\x7a\xd4\x20\x53"
+ "\xb2\x4f\x0f\x46\xe3\xf0\x08\x3b"
+ "\x57\xc3\x93\xe8\x47\x96\xae\xe1"
+ "\xfe\x85\x37\xdc\xd1\x77\xce\x12"
+ "\x6c\xa8\x73\x42\x84\x12\x0e\x95"
+ "\x20\x02\xdc\xfd\x5e\x26\x70\x2c"
+ "\x96\xa1\x72\x5d\x88\xdb\xf3\xb2"
+ "\x8c\xc0\xf9\x02\xea\x93\x7a\x62"
+ "\x64\x42\xbb\xe3\x50\x7d\xdd\x07"
+ "\xd0\xe6\x1a\x11\x82\xa3\xc5\x34"
+ "\x3b\x1f\x3a\x8a\xbe\xd4\xea\x23",
+ .len = 512,
+ }, {
+ /* cbc-aes-256 with 512b sector size, nth sector */
+ .key = "\x9c\x3c\x73\xa4\xad\x15\xac\xcc"
+ "\xc5\x02\x0c\x41\x00\xf5\xc2\x70"
+ "\x83\x66\x49\x65\x07\x9c\xf6\xb9"
+ "\xde\x18\x54\xa1\x76\xf0\x66\xee",
+ .klen = 32,
+ .iv = "\x00\x50\x1a\x02\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00",
+ .ptext = "\xeb\x52\x90\x4e\x54\x46\x53\x20"
+ "\x20\x20\x20\x00\x02\x08\x00\x00"
+ "\x00\x00\x00\x00\x00\xf8\x00\x00"
+ "\x3f\x00\xff\x00\x00\x28\x03\x00"
+ "\x00\x00\x00\x00\x80\x00\x00\x00"
+ "\xff\x1f\x03\x00\x00\x00\x00\x00"
+ "\x55\x21\x00\x00\x00\x00\x00\x00"
+ "\x02\x00\x00\x00\x00\x00\x00\x00"
+ "\xf6\x00\x00\x00\x01\x00\x00\x00"
+ "\x75\xf2\x02\xc0\x10\x03\xc0\x9a"
+ "\x00\x00\x00\x00\xfa\x33\xc0\x8e"
+ "\xd0\xbc\x00\x7c\xfb\x68\xc0\x07"
+ "\x1f\x1e\x68\x66\x00\xcb\x88\x16"
+ "\x0e\x00\x66\x81\x3e\x03\x00\x4e"
+ "\x54\x46\x53\x75\x15\xb4\x41\xbb"
+ "\xaa\x55\xcd\x13\x72\x0c\x81\xfb"
+ "\x55\xaa\x75\x06\xf7\xc1\x01\x00"
+ "\x75\x03\xe9\xdd\x00\x1e\x83\xec"
+ "\x18\x68\x1a\x00\xb4\x48\x8a\x16"
+ "\x0e\x00\x8b\xf4\x16\x1f\xcd\x13"
+ "\x9f\x83\xc4\x18\x9e\x58\x1f\x72"
+ "\xe1\x3b\x06\x0b\x00\x75\xdb\xa3"
+ "\x0f\x00\xc1\x2e\x0f\x00\x04\x1e"
+ "\x5a\x33\xdb\xb9\x00\x20\x2b\xc8"
+ "\x66\xff\x06\x11\x00\x03\x16\x0f"
+ "\x00\x8e\xc2\xff\x06\x16\x00\xe8"
+ "\x4b\x00\x2b\xc8\x77\xef\xb8\x00"
+ "\xbb\xcd\x1a\x66\x23\xc0\x75\x2d"
+ "\x66\x81\xfb\x54\x43\x50\x41\x75"
+ "\x24\x81\xf9\x02\x01\x72\x1e\x16"
+ "\x68\x07\xbb\x16\x68\x52\x11\x16"
+ "\x68\x09\x00\x66\x53\x66\x53\x66"
+ "\x55\x16\x16\x16\x68\xb8\x01\x66"
+ "\x61\x0e\x07\xcd\x1a\x33\xc0\xbf"
+ "\x0a\x13\xb9\xf6\x0c\xfc\xf3\xaa"
+ "\xe9\xfe\x01\x90\x90\x66\x60\x1e"
+ "\x06\x66\xa1\x11\x00\x66\x03\x06"
+ "\x1c\x00\x1e\x66\x68\x00\x00\x00"
+ "\x00\x66\x50\x06\x53\x68\x01\x00"
+ "\x68\x10\x00\xb4\x42\x8a\x16\x0e"
+ "\x00\x16\x1f\x8b\xf4\xcd\x13\x66"
+ "\x59\x5b\x5a\x66\x59\x66\x59\x1f"
+ "\x0f\x82\x16\x00\x66\xff\x06\x11"
+ "\x00\x03\x16\x0f\x00\x8e\xc2\xff"
+ "\x0e\x16\x00\x75\xbc\x07\x1f\x66"
+ "\x61\xc3\xa1\xf6\x01\xe8\x09\x00"
+ "\xa1\xfa\x01\xe8\x03\x00\xf4\xeb"
+ "\xfd\x8b\xf0\xac\x3c\x00\x74\x09"
+ "\xb4\x0e\xbb\x07\x00\xcd\x10\xeb"
+ "\xf2\xc3\x0d\x0a\x41\x20\x64\x69"
+ "\x73\x6b\x20\x72\x65\x61\x64\x20"
+ "\x65\x72\x72\x6f\x72\x20\x6f\x63"
+ "\x63\x75\x72\x72\x65\x64\x00\x0d"
+ "\x0a\x42\x4f\x4f\x54\x4d\x47\x52"
+ "\x20\x69\x73\x20\x63\x6f\x6d\x70"
+ "\x72\x65\x73\x73\x65\x64\x00\x0d"
+ "\x0a\x50\x72\x65\x73\x73\x20\x43"
+ "\x74\x72\x6c\x2b\x41\x6c\x74\x2b"
+ "\x44\x65\x6c\x20\x74\x6f\x20\x72"
+ "\x65\x73\x74\x61\x72\x74\x0d\x0a"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x8a\x01"
+ "\xa7\x01\xbf\x01\x00\x00\x55\xaa",
+ .ctext = "\x95\xec\x37\xc9\x2c\xf8\x91\x1d"
+ "\xdd\x17\xa5\x17\x8a\x56\x34\xec"
+ "\xba\x14\x06\x20\xc1\xd2\xb3\xda"
+ "\xf3\xfc\x05\x32\x93\x83\x3d\xbb"
+ "\x41\x30\xce\xc9\x2e\x92\x0d\x5a"
+ "\xb4\xab\x59\x21\xda\xbd\x1e\xfb"
+ "\xbf\xf9\x6d\x8d\x91\x85\x02\xdc"
+ "\xe4\xae\xb6\xf0\x26\x9f\xa2\xb0"
+ "\xb2\x8b\x52\xfe\xd1\x19\x33\x8f"
+ "\x9f\x4e\x39\x83\x6f\x89\x6f\x13"
+ "\xb6\xbd\x14\xfb\xff\x46\xf1\xf0"
+ "\x87\x8b\x2b\x92\x3d\x16\x57\x84"
+ "\x07\x6e\x5a\xd0\x03\xab\x2d\x22"
+ "\x4b\xf4\xc1\xbd\xe4\xb8\x6a\x72"
+ "\x76\x9a\xc4\xa5\x11\xb0\x56\xa9"
+ "\xee\xe4\xdd\x19\xc3\x79\x57\x61"
+ "\x03\x07\x16\x15\xc8\x17\x23\xcd"
+ "\xb7\x24\xa8\x06\x24\x8f\x26\x68"
+ "\xf8\x54\xce\xfe\xc7\xc0\x11\x75"
+ "\xc8\xa6\xc7\xf4\x4c\x49\x3c\x65"
+ "\x3e\x18\xbf\x16\xac\xd4\xc1\x97"
+ "\x7b\x02\x04\x78\x04\xf4\x14\x15"
+ "\x4c\x60\xbc\x22\xd6\xb1\x8a\x51"
+ "\xd5\x40\xe7\x9c\xf7\xd0\x63\xe0"
+ "\xe9\x84\x0d\xb8\x1b\x45\x69\x11"
+ "\x70\xfb\xeb\x0d\x07\xeb\x25\xaf"
+ "\x6e\x5c\x90\xae\x9a\x75\x6d\xbf"
+ "\x4c\xac\x60\xe6\xdb\x71\x38\xdc"
+ "\xa5\xaa\x3e\x75\xf4\xe5\x43\x59"
+ "\xe9\x86\x46\x9f\xc1\x5c\x77\x3e"
+ "\xeb\x8d\x31\xd3\x4b\x85\x68\xb8"
+ "\x10\x1f\x58\x27\xe8\x60\xeb\x65"
+ "\xe2\xda\x03\xbb\x06\x4e\x11\x44"
+ "\x1d\xd1\xe9\xa7\xae\x37\x48\x73"
+ "\xd1\xae\xa7\xae\x24\x9a\xb2\x62"
+ "\xb7\x12\x7f\x89\x7f\x98\x9b\x07"
+ "\xfe\xb6\xc6\x1a\x25\xc4\x78\xac"
+ "\x5b\x31\x30\x22\xf2\x89\x3f\x4d"
+ "\x8c\x4c\xfb\xe7\xb0\x7c\x92\x28"
+ "\x65\xb6\x8d\x04\x47\x48\xc3\xb4"
+ "\x77\xac\xe2\xa4\xe0\x08\x11\x7e"
+ "\x53\x08\xde\x4c\xec\xdf\x9e\x5b"
+ "\xbe\x24\x7a\x08\x6b\x53\xec\x29"
+ "\x96\x61\x30\xd2\xcb\x72\x80\x5b"
+ "\xba\x1f\xcf\xaa\x46\x6f\x5b\xe3"
+ "\xd5\x32\xb9\x7b\xe0\x69\x2f\xa2"
+ "\x0b\xb2\x43\xf1\x3e\x30\xdd\x76"
+ "\x73\xe1\xe7\x28\xac\x91\xa8\x9e"
+ "\x6e\x77\xac\x6d\x0b\xbc\x52\x98"
+ "\x65\x36\x2b\x10\x9b\x40\xe0\x1e"
+ "\x7d\x5b\xfb\xe3\x9d\xa7\x93\xff"
+ "\xfa\xe3\x42\xc5\x8e\x2c\xa4\x2a"
+ "\x5d\x0b\x18\xec\xfb\xcf\x18\xaf"
+ "\x06\x30\xf1\xa3\x9d\x51\xe3\xc3"
+ "\x2f\x10\x06\x3e\x74\x23\xbb\x14"
+ "\xfe\x05\x08\xf9\xd1\xb2\x47\x6a"
+ "\x17\xd3\x1b\x9d\xac\xc9\x55\x1f"
+ "\xde\x1f\x51\x03\x96\xe3\x64\xe0"
+ "\xd2\xd6\x01\xc2\x6c\x79\x07\x4f"
+ "\x08\x03\x78\x23\x16\xd2\x23\xec"
+ "\x3f\x5d\xb6\xdc\xa5\xea\xbf\x8f"
+ "\x47\xc0\x34\x3f\x61\x55\x30\x03"
+ "\x36\xd9\xbf\xbb\x39\x7b\x90\xfb"
+ "\x8d\xf1\x47\xa2\x03\x25\x3f\x92",
+ .len = 512,
+ },
+};
+
/* based on aes_cbc_tv_template */
static const struct cipher_testvec essiv_aes_cbc_tv_template[] = {
{
--
2.28.0