Add test vectors for rfc3686(ctr(aria)) and rfc4106(gcm(aria)) to exercise the existing crypto API implementations before adding XFRM support. Cover all three ARIA key lengths (128, 192 and 256 bits). For RFC3686, include single-block and multi-block test cases. For RFC4106, cover 64-bit, 96-bit and 128-bit authentication tags. The test vectors were generated using OpenSSL. Tested under QEMU x86_64 with CONFIG_CRYPTO_SELFTESTS and CONFIG_CRYPTO_SELFTESTS_FULL enabled. Both algorithms passed the crypto API self-tests using the generic ARIA implementation. Signed-off-by: Hong In-su --- crypto/testmgr.c | 17 +++ crypto/testmgr.h | 266 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 283 insertions(+) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 9419d61d0602..7737e387d8d2 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -5220,6 +5220,12 @@ static const struct alg_test_desc alg_test_descs[] = { .suite = { .cipher = __VECS(aes_ctr_rfc3686_tv_template) } + }, { + .alg = "rfc3686(ctr(aria))", + .test = alg_test_skcipher, + .suite = { + .cipher = __VECS(aria_ctr_rfc3686_tv_template) + } }, { .alg = "rfc3686(ctr(sm4))", .test = alg_test_skcipher, @@ -5238,6 +5244,17 @@ static const struct alg_test_desc alg_test_descs[] = { .aad_iv = 1, } } + }, { + .alg = "rfc4106(gcm(aria))", + .generic_driver = "rfc4106(gcm_base(ctr(aria-generic),ghash-lib))", + .test = alg_test_aead, + .suite = { + .aead = { + ____VECS(aria_gcm_rfc4106_tv_template), + .einval_allowed = 1, + .aad_iv = 1, + } + } }, { .alg = "rfc4309(ccm(aes))", .generic_driver = "rfc4309(ccm_base(ctr(aes-lib),cbcmac-aes-lib))", diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 0ee15a8fae27..53bbd219f9b6 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h @@ -28486,6 +28486,91 @@ static const struct cipher_testvec aria_ctr_tv_template[] = { } }; +static const struct cipher_testvec aria_ctr_rfc3686_tv_template[] = { + { /* Generated using OpenSSL */ + .key = "\xae\x68\x52\xf8\x12\x10\x67\xcc" + "\x4b\xf7\xa5\x76\x55\x77\xf3\x9e" + "\x00\x00\x00\x30", + .klen = 20, + .iv = "\x00\x00\x00\x00\x00\x00\x00\x00", + .ptext = "Single block msg", + .ctext = "\x04\x88\x4b\x0e\xee\xc3\xd1\x8e" + "\xc9\x68\x30\x8a\x38\xbf\xf6\x8c", + .len = 16, + }, { + .key = "\x7e\x24\x06\x78\x17\xfa\xe0\xd7" + "\x43\xd6\xce\x1f\x32\x53\x91\x63" + "\x00\x6c\xb6\xdb", + .klen = 20, + .iv = "\xc0\x54\x3b\x59\xda\x48\xd9\x0b", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", + .ctext = "\x2f\x64\x9d\x04\x9d\x52\x34\x74" + "\x25\x44\x5e\x14\xfa\x01\x8e\x72" + "\x13\xb6\x1f\x1e\x42\x9f\xfe\xd0" + "\x25\x53\x47\xaa\xce\x1e\x0b\x15", + .len = 32, + }, { + .key = "\x16\xaf\x5b\x14\x5f\xc9\xf5\x79" + "\xc1\x75\xf9\x3e\x3b\xfb\x0e\xed" + "\x86\x3d\x06\xcc\xfd\xb7\x85\x15" + "\x00\x00\x00\x48", + .klen = 28, + .iv = "\x36\x73\x3c\x14\x7d\x6d\x93\xcb", + .ptext = "Single block msg", + .ctext = "\xea\xc2\xed\x97\x9e\xcd\x5a\x8e" + "\xbd\xfe\xe4\x6f\xfd\x3e\x42\x3e", + .len = 16, + }, { + .key = "\x7c\x5c\xb2\x40\x1b\x3d\xc3\x3c" + "\x19\xe7\x34\x08\x19\xe0\xf6\x9c" + "\x67\x8c\x3d\xb8\xe6\xf6\xa9\x1a" + "\x00\x96\xb0\x3b", + .klen = 28, + .iv = "\x02\x0c\x6e\xad\xc2\xcb\x50\x0d", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", + .ctext = "\x80\xf1\x58\xa7\xed\xed\xeb\xd1" + "\x04\x1f\x78\x12\x7d\xf5\xe0\xfc" + "\xf0\x9e\x5e\x55\xe3\xa1\xf9\x3c" + "\x0d\x65\x20\x59\xaa\x4a\xdd\xf8", + .len = 32, + }, { + .key = "\x77\x6b\xef\xf2\x85\x1d\xb0\x6f" + "\x4c\x8a\x05\x42\xc8\x69\x6f\x6c" + "\x6a\x81\xaf\x1e\xec\x96\xb4\xd3" + "\x7f\xc1\xd6\x89\xe6\xc1\xc1\x04" + "\x00\x00\x00\x60", + .klen = 36, + .iv = "\xdb\x56\x72\xc9\x7a\xa8\xf0\xb2", + .ptext = "Single block msg", + .ctext = "\x2f\x73\xab\x5c\x9a\x19\xc2\xfb" + "\x1a\x16\xde\x7c\xa8\x2f\x36\xef", + .len = 16, + }, { + .key = "\xf6\xd6\x6d\x6b\xd5\x2d\x59\xbb" + "\x07\x96\x36\x58\x79\xef\xf8\x86" + "\xc6\x6d\xd5\x1a\x5b\x6a\x99\x74" + "\x4b\x50\x59\x0c\x87\xa2\x38\x84" + "\x00\xfa\xac\x24", + .klen = 36, + .iv = "\xc1\x58\x5e\xf1\x5a\x43\xd8\x75", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", + .ctext = "\xa0\x20\xbf\xe2\x84\x6a\x25\x76" + "\xf8\xbf\xac\x4f\x48\xec\xca\xf2" + "\xf8\xee\x06\x00\x86\x9a\x16\x9b" + "\x15\x9f\x91\x70\xd7\x8c\x66\x34", + .len = 32, + } +}; + static const struct aead_testvec aria_gcm_tv_template[] = { { .key = "\xe9\x1e\x5e\x75\xda\x65\x55\x4a" @@ -28598,6 +28683,187 @@ static const struct aead_testvec aria_gcm_tv_template[] = { } }; +static const struct aead_testvec aria_gcm_rfc4106_tv_template[] = { + { /* Generated using OpenSSL */ + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\xa0\xa1\xa2\xa3", + .klen = 20, + .iv = "\x00\x00\x00\x00\x00\x00\x00\x02", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16", + .plen = 23, + .assoc = "\x01\x02\x03\x04\x00\x00\x00\x01" + "\x00\x00\x00\x00\x00\x00\x00\x02", + .alen = 16, + .ctext = "\xdb\x18\x05\x3a\xc4\x1c\xa9\xb3" + "\xf7\xdb\x87\x65\x7b\xbe\xc8\x51" + "\xdf\xd8\x8f\xbf\x28\x47\x4f\x71" + "\x99\x33\x51\xfc\xc1\x89\xb2", + .clen = 31, + }, { + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\xa0\xa1\xa2\xa3", + .klen = 20, + .iv = "\x00\x00\x00\x00\x00\x00\x00\x03", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16", + .plen = 23, + .assoc = "\x01\x02\x03\x04\x00\x00\x00\x01" + "\x00\x00\x00\x00\x00\x00\x00\x03", + .alen = 16, + .ctext = "\xfc\xe1\x92\xcc\x77\xf8\xf8\x24" + "\x86\x45\x3d\x86\x7c\xc2\x2b\xf7" + "\xb3\x04\x62\xd7\x4f\xcd\xa1\x93" + "\xd5\x46\xd1\x3e\x5b\xbb\x7a\x0b" + "\xec\x7c\x23", + .clen = 35, + }, { + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\xa0\xa1\xa2\xa3", + .klen = 20, + .iv = "\x00\x00\x00\x00\x00\x00\x00\x04", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16", + .plen = 23, + .assoc = "\x01\x02\x03\x04\x00\x00\x00\x01" + "\x00\x00\x00\x00\x00\x00\x00\x04", + .alen = 16, + .ctext = "\xae\x7d\x94\xcb\xe3\xdb\x7e\xb3" + "\x27\x7e\x91\x5c\xbb\xf3\x6d\x40" + "\x79\x78\x75\x54\x23\xc7\x8f\xfc" + "\x07\x91\x6b\xac\xce\x8d\x52\x6e" + "\x29\x14\xd1\xec\x81\xac\xb5", + .clen = 39, + }, { + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\xa0\xa1\xa2\xa3", + .klen = 28, + .iv = "\x00\x00\x00\x00\x00\x00\x00\x02", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16", + .plen = 23, + .assoc = "\x01\x02\x03\x04\x00\x00\x00\x01" + "\x00\x00\x00\x00\x00\x00\x00\x02", + .alen = 16, + .ctext = "\x03\x65\x6c\xd9\x51\x6d\x0f\xb3" + "\x14\x79\x76\x1b\x7b\x98\x82\x7c" + "\xe7\xbc\x9f\xc9\x0e\x30\xc8\x9d" + "\x3b\xaa\x49\x2f\x1c\x2f\x4b", + .clen = 31, + }, { + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\xa0\xa1\xa2\xa3", + .klen = 28, + .iv = "\x00\x00\x00\x00\x00\x00\x00\x03", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16", + .plen = 23, + .assoc = "\x01\x02\x03\x04\x00\x00\x00\x01" + "\x00\x00\x00\x00\x00\x00\x00\x03", + .alen = 16, + .ctext = "\xb5\x5a\xcd\x47\xb0\x7e\x43\x36" + "\x60\x8f\xa9\xdd\xb1\x13\xcf\xdd" + "\x0e\x18\x8d\xb6\xaf\xd6\x9c\xc1" + "\x80\x94\xd4\xf7\xf7\xa4\xfe\xf7" + "\x6e\x1f\xae", + .clen = 35, + }, { + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\xa0\xa1\xa2\xa3", + .klen = 28, + .iv = "\x00\x00\x00\x00\x00\x00\x00\x04", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16", + .plen = 23, + .assoc = "\x01\x02\x03\x04\x00\x00\x00\x01" + "\x00\x00\x00\x00\x00\x00\x00\x04", + .alen = 16, + .ctext = "\x33\xef\x88\x18\xb5\xc7\xb8\xf1" + "\x17\x5e\xed\xc2\x1f\x9c\xf6\x69" + "\x78\x7d\x1a\x74\x78\xd4\xc5\xca" + "\xab\xd1\x23\xb9\x14\xc8\xea\x4e" + "\xfe\x99\xb4\xda\x2b\x49\x49", + .clen = 39, + }, { + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + "\xa0\xa1\xa2\xa3", + .klen = 36, + .iv = "\x00\x00\x00\x00\x00\x00\x00\x02", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16", + .plen = 23, + .assoc = "\x01\x02\x03\x04\x00\x00\x00\x01" + "\x00\x00\x00\x00\x00\x00\x00\x02", + .alen = 16, + .ctext = "\x5a\xa6\xcd\x5b\xe9\x06\xa9\xfa" + "\x30\x64\x41\xb4\x87\x14\x09\xa2" + "\x1a\x4b\xc9\x1a\x1a\x32\x85\xb1" + "\xf3\xd9\xdc\x47\x67\x12\x28", + .clen = 31, + }, { + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + "\xa0\xa1\xa2\xa3", + .klen = 36, + .iv = "\x00\x00\x00\x00\x00\x00\x00\x03", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16", + .plen = 23, + .assoc = "\x01\x02\x03\x04\x00\x00\x00\x01" + "\x00\x00\x00\x00\x00\x00\x00\x03", + .alen = 16, + .ctext = "\x84\x9e\x7c\xb1\x13\x59\x93\x1d" + "\x1d\x80\x6e\xce\xf1\x09\x7b\x90" + "\x9f\x17\xc1\x85\x9b\x81\x16\x37" + "\x5d\x7e\x98\x87\xa9\x5e\xf6\x51" + "\x41\x3d\x39", + .clen = 35, + }, { + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + "\xa0\xa1\xa2\xa3", + .klen = 36, + .iv = "\x00\x00\x00\x00\x00\x00\x00\x04", + .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16", + .plen = 23, + .assoc = "\x01\x02\x03\x04\x00\x00\x00\x01" + "\x00\x00\x00\x00\x00\x00\x00\x04", + .alen = 16, + .ctext = "\x11\x31\x6c\xde\xf3\xec\x76\xae" + "\x8b\x00\x28\xc0\x59\x07\xe3\x90" + "\x39\x40\xda\x87\x4d\xc8\x50\x05" + "\x76\x91\xc0\x1a\x43\x90\xbb\xe6" + "\xdd\x74\x29\x89\xb8\xa6\x05", + .clen = 39, + } +}; + static const struct cipher_testvec chacha20_tv_template[] = { { /* RFC7539 A.2. Test Vector #1 */ .key = "\x00\x00\x00\x00\x00\x00\x00\x00" -- 2.43.0