]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - crypto/testmgr.c
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
[linux.git] / crypto / testmgr.c
index c31da0f3f680426c3528470193c261d47926e583..d1d99843cce4d731f3cca0df1c3af6ec32d50308 100644 (file)
@@ -84,10 +84,8 @@ struct aead_test_suite {
 };
 
 struct cipher_test_suite {
-       struct {
-               const struct cipher_testvec *vecs;
-               unsigned int count;
-       } enc, dec;
+       const struct cipher_testvec *vecs;
+       unsigned int count;
 };
 
 struct comp_test_suite {
@@ -988,6 +986,7 @@ static int test_cipher(struct crypto_cipher *tfm, int enc,
        unsigned int i, j, k;
        char *q;
        const char *e;
+       const char *input, *result;
        void *data;
        char *xbuf[XBUFSIZE];
        int ret = -ENOMEM;
@@ -1008,14 +1007,16 @@ static int test_cipher(struct crypto_cipher *tfm, int enc,
                if (fips_enabled && template[i].fips_skip)
                        continue;
 
+               input  = enc ? template[i].ptext : template[i].ctext;
+               result = enc ? template[i].ctext : template[i].ptext;
                j++;
 
                ret = -EINVAL;
-               if (WARN_ON(template[i].ilen > PAGE_SIZE))
+               if (WARN_ON(template[i].len > PAGE_SIZE))
                        goto out;
 
                data = xbuf[0];
-               memcpy(data, template[i].input, template[i].ilen);
+               memcpy(data, input, template[i].len);
 
                crypto_cipher_clear_flags(tfm, ~0);
                if (template[i].wk)
@@ -1031,7 +1032,7 @@ static int test_cipher(struct crypto_cipher *tfm, int enc,
                } else if (ret)
                        continue;
 
-               for (k = 0; k < template[i].ilen;
+               for (k = 0; k < template[i].len;
                     k += crypto_cipher_blocksize(tfm)) {
                        if (enc)
                                crypto_cipher_encrypt_one(tfm, data + k,
@@ -1042,10 +1043,10 @@ static int test_cipher(struct crypto_cipher *tfm, int enc,
                }
 
                q = data;
-               if (memcmp(q, template[i].result, template[i].rlen)) {
+               if (memcmp(q, result, template[i].len)) {
                        printk(KERN_ERR "alg: cipher: Test %d failed "
                               "on %s for %s\n", j, e, algo);
-                       hexdump(q, template[i].rlen);
+                       hexdump(q, template[i].len);
                        ret = -EINVAL;
                        goto out;
                }
@@ -1073,6 +1074,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
        struct scatterlist sgout[8];
        const char *e, *d;
        struct crypto_wait wait;
+       const char *input, *result;
        void *data;
        char iv[MAX_IVLEN];
        char *xbuf[XBUFSIZE];
@@ -1116,19 +1118,21 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
                if (fips_enabled && template[i].fips_skip)
                        continue;
 
-               if (template[i].iv)
+               if (template[i].iv && !(template[i].generates_iv && enc))
                        memcpy(iv, template[i].iv, ivsize);
                else
                        memset(iv, 0, MAX_IVLEN);
 
+               input  = enc ? template[i].ptext : template[i].ctext;
+               result = enc ? template[i].ctext : template[i].ptext;
                j++;
                ret = -EINVAL;
-               if (WARN_ON(align_offset + template[i].ilen > PAGE_SIZE))
+               if (WARN_ON(align_offset + template[i].len > PAGE_SIZE))
                        goto out;
 
                data = xbuf[0];
                data += align_offset;
-               memcpy(data, template[i].input, template[i].ilen);
+               memcpy(data, input, template[i].len);
 
                crypto_skcipher_clear_flags(tfm, ~0);
                if (template[i].wk)
@@ -1144,15 +1148,15 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
                } else if (ret)
                        continue;
 
-               sg_init_one(&sg[0], data, template[i].ilen);
+               sg_init_one(&sg[0], data, template[i].len);
                if (diff_dst) {
                        data = xoutbuf[0];
                        data += align_offset;
-                       sg_init_one(&sgout[0], data, template[i].ilen);
+                       sg_init_one(&sgout[0], data, template[i].len);
                }
 
                skcipher_request_set_crypt(req, sg, (diff_dst) ? sgout : sg,
-                                          template[i].ilen, iv);
+                                          template[i].len, iv);
                ret = crypto_wait_req(enc ? crypto_skcipher_encrypt(req) :
                                      crypto_skcipher_decrypt(req), &wait);
 
@@ -1163,17 +1167,16 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
                }
 
                q = data;
-               if (memcmp(q, template[i].result, template[i].rlen)) {
+               if (memcmp(q, result, template[i].len)) {
                        pr_err("alg: skcipher%s: Test %d failed (invalid result) on %s for %s\n",
                               d, j, e, algo);
-                       hexdump(q, template[i].rlen);
+                       hexdump(q, template[i].len);
                        ret = -EINVAL;
                        goto out;
                }
 
-               if (template[i].iv_out &&
-                   memcmp(iv, template[i].iv_out,
-                          crypto_skcipher_ivsize(tfm))) {
+               if (template[i].generates_iv && enc &&
+                   memcmp(iv, template[i].iv, crypto_skcipher_ivsize(tfm))) {
                        pr_err("alg: skcipher%s: Test %d failed (invalid output IV) on %s for %s\n",
                               d, j, e, algo);
                        hexdump(iv, crypto_skcipher_ivsize(tfm));
@@ -1194,11 +1197,13 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
                if (fips_enabled && template[i].fips_skip)
                        continue;
 
-               if (template[i].iv)
+               if (template[i].iv && !(template[i].generates_iv && enc))
                        memcpy(iv, template[i].iv, ivsize);
                else
                        memset(iv, 0, MAX_IVLEN);
 
+               input  = enc ? template[i].ptext : template[i].ctext;
+               result = enc ? template[i].ctext : template[i].ptext;
                j++;
                crypto_skcipher_clear_flags(tfm, ~0);
                if (template[i].wk)
@@ -1226,7 +1231,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
 
                        q = xbuf[IDX[k] >> PAGE_SHIFT] + offset_in_page(IDX[k]);
 
-                       memcpy(q, template[i].input + temp, template[i].tap[k]);
+                       memcpy(q, input + temp, template[i].tap[k]);
 
                        if (offset_in_page(q) + template[i].tap[k] < PAGE_SIZE)
                                q[template[i].tap[k]] = 0;
@@ -1248,7 +1253,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
                }
 
                skcipher_request_set_crypt(req, sg, (diff_dst) ? sgout : sg,
-                                          template[i].ilen, iv);
+                                          template[i].len, iv);
 
                ret = crypto_wait_req(enc ? crypto_skcipher_encrypt(req) :
                                      crypto_skcipher_decrypt(req), &wait);
@@ -1269,8 +1274,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
                                q = xbuf[IDX[k] >> PAGE_SHIFT] +
                                    offset_in_page(IDX[k]);
 
-                       if (memcmp(q, template[i].result + temp,
-                                  template[i].tap[k])) {
+                       if (memcmp(q, result + temp, template[i].tap[k])) {
                                pr_err("alg: skcipher%s: Chunk test %d failed on %s at page %u for %s\n",
                                       d, j, e, k, algo);
                                hexdump(q, template[i].tap[k]);
@@ -1705,8 +1709,9 @@ static int alg_test_aead(const struct alg_test_desc *desc, const char *driver,
 static int alg_test_cipher(const struct alg_test_desc *desc,
                           const char *driver, u32 type, u32 mask)
 {
+       const struct cipher_test_suite *suite = &desc->suite.cipher;
        struct crypto_cipher *tfm;
-       int err = 0;
+       int err;
 
        tfm = crypto_alloc_cipher(driver, type, mask);
        if (IS_ERR(tfm)) {
@@ -1715,18 +1720,10 @@ static int alg_test_cipher(const struct alg_test_desc *desc,
                return PTR_ERR(tfm);
        }
 
-       if (desc->suite.cipher.enc.vecs) {
-               err = test_cipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs,
-                                 desc->suite.cipher.enc.count);
-               if (err)
-                       goto out;
-       }
-
-       if (desc->suite.cipher.dec.vecs)
-               err = test_cipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs,
-                                 desc->suite.cipher.dec.count);
+       err = test_cipher(tfm, ENCRYPT, suite->vecs, suite->count);
+       if (!err)
+               err = test_cipher(tfm, DECRYPT, suite->vecs, suite->count);
 
-out:
        crypto_free_cipher(tfm);
        return err;
 }
@@ -1734,8 +1731,9 @@ static int alg_test_cipher(const struct alg_test_desc *desc,
 static int alg_test_skcipher(const struct alg_test_desc *desc,
                             const char *driver, u32 type, u32 mask)
 {
+       const struct cipher_test_suite *suite = &desc->suite.cipher;
        struct crypto_skcipher *tfm;
-       int err = 0;
+       int err;
 
        tfm = crypto_alloc_skcipher(driver, type, mask);
        if (IS_ERR(tfm)) {
@@ -1744,18 +1742,10 @@ static int alg_test_skcipher(const struct alg_test_desc *desc,
                return PTR_ERR(tfm);
        }
 
-       if (desc->suite.cipher.enc.vecs) {
-               err = test_skcipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs,
-                                   desc->suite.cipher.enc.count);
-               if (err)
-                       goto out;
-       }
-
-       if (desc->suite.cipher.dec.vecs)
-               err = test_skcipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs,
-                                   desc->suite.cipher.dec.count);
+       err = test_skcipher(tfm, ENCRYPT, suite->vecs, suite->count);
+       if (!err)
+               err = test_skcipher(tfm, DECRYPT, suite->vecs, suite->count);
 
-out:
        crypto_free_skcipher(tfm);
        return err;
 }
@@ -1798,8 +1788,9 @@ static int alg_test_comp(const struct alg_test_desc *desc, const char *driver,
        return err;
 }
 
-static int alg_test_hash(const struct alg_test_desc *desc, const char *driver,
-                        u32 type, u32 mask)
+static int __alg_test_hash(const struct hash_testvec *template,
+                          unsigned int tcount, const char *driver,
+                          u32 type, u32 mask)
 {
        struct crypto_ahash *tfm;
        int err;
@@ -1811,16 +1802,51 @@ static int alg_test_hash(const struct alg_test_desc *desc, const char *driver,
                return PTR_ERR(tfm);
        }
 
-       err = test_hash(tfm, desc->suite.hash.vecs,
-                       desc->suite.hash.count, true);
+       err = test_hash(tfm, template, tcount, true);
        if (!err)
-               err = test_hash(tfm, desc->suite.hash.vecs,
-                               desc->suite.hash.count, false);
-
+               err = test_hash(tfm, template, tcount, false);
        crypto_free_ahash(tfm);
        return err;
 }
 
+static int alg_test_hash(const struct alg_test_desc *desc, const char *driver,
+                        u32 type, u32 mask)
+{
+       const struct hash_testvec *template = desc->suite.hash.vecs;
+       unsigned int tcount = desc->suite.hash.count;
+       unsigned int nr_unkeyed, nr_keyed;
+       int err;
+
+       /*
+        * For OPTIONAL_KEY algorithms, we have to do all the unkeyed tests
+        * first, before setting a key on the tfm.  To make this easier, we
+        * require that the unkeyed test vectors (if any) are listed first.
+        */
+
+       for (nr_unkeyed = 0; nr_unkeyed < tcount; nr_unkeyed++) {
+               if (template[nr_unkeyed].ksize)
+                       break;
+       }
+       for (nr_keyed = 0; nr_unkeyed + nr_keyed < tcount; nr_keyed++) {
+               if (!template[nr_unkeyed + nr_keyed].ksize) {
+                       pr_err("alg: hash: test vectors for %s out of order, "
+                              "unkeyed ones must come first\n", desc->alg);
+                       return -EINVAL;
+               }
+       }
+
+       err = 0;
+       if (nr_unkeyed) {
+               err = __alg_test_hash(template, nr_unkeyed, driver, type, mask);
+               template += nr_unkeyed;
+       }
+
+       if (!err && nr_keyed)
+               err = __alg_test_hash(template, nr_keyed, driver, type, mask);
+
+       return err;
+}
+
 static int alg_test_crc32c(const struct alg_test_desc *desc,
                           const char *driver, u32 type, u32 mask)
 {
@@ -2340,6 +2366,33 @@ static int alg_test_null(const struct alg_test_desc *desc,
 /* Please keep this list sorted by algorithm name. */
 static const struct alg_test_desc alg_test_descs[] = {
        {
+               .alg = "aegis128",
+               .test = alg_test_aead,
+               .suite = {
+                       .aead = {
+                               .enc = __VECS(aegis128_enc_tv_template),
+                               .dec = __VECS(aegis128_dec_tv_template),
+                       }
+               }
+       }, {
+               .alg = "aegis128l",
+               .test = alg_test_aead,
+               .suite = {
+                       .aead = {
+                               .enc = __VECS(aegis128l_enc_tv_template),
+                               .dec = __VECS(aegis128l_dec_tv_template),
+                       }
+               }
+       }, {
+               .alg = "aegis256",
+               .test = alg_test_aead,
+               .suite = {
+                       .aead = {
+                               .enc = __VECS(aegis256_enc_tv_template),
+                               .dec = __VECS(aegis256_dec_tv_template),
+                       }
+               }
+       }, {
                .alg = "ansi_cprng",
                .test = alg_test_cprng,
                .suite = {
@@ -2512,75 +2565,51 @@ static const struct alg_test_desc alg_test_descs[] = {
                .test = alg_test_skcipher,
                .fips_allowed = 1,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(aes_cbc_enc_tv_template),
-                               .dec = __VECS(aes_cbc_dec_tv_template)
-                       }
-               }
+                       .cipher = __VECS(aes_cbc_tv_template)
+               },
        }, {
                .alg = "cbc(anubis)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(anubis_cbc_enc_tv_template),
-                               .dec = __VECS(anubis_cbc_dec_tv_template)
-                       }
-               }
+                       .cipher = __VECS(anubis_cbc_tv_template)
+               },
        }, {
                .alg = "cbc(blowfish)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(bf_cbc_enc_tv_template),
-                               .dec = __VECS(bf_cbc_dec_tv_template)
-                       }
-               }
+                       .cipher = __VECS(bf_cbc_tv_template)
+               },
        }, {
                .alg = "cbc(camellia)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(camellia_cbc_enc_tv_template),
-                               .dec = __VECS(camellia_cbc_dec_tv_template)
-                       }
-               }
+                       .cipher = __VECS(camellia_cbc_tv_template)
+               },
        }, {
                .alg = "cbc(cast5)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(cast5_cbc_enc_tv_template),
-                               .dec = __VECS(cast5_cbc_dec_tv_template)
-                       }
-               }
+                       .cipher = __VECS(cast5_cbc_tv_template)
+               },
        }, {
                .alg = "cbc(cast6)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(cast6_cbc_enc_tv_template),
-                               .dec = __VECS(cast6_cbc_dec_tv_template)
-                       }
-               }
+                       .cipher = __VECS(cast6_cbc_tv_template)
+               },
        }, {
                .alg = "cbc(des)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(des_cbc_enc_tv_template),
-                               .dec = __VECS(des_cbc_dec_tv_template)
-                       }
-               }
+                       .cipher = __VECS(des_cbc_tv_template)
+               },
        }, {
                .alg = "cbc(des3_ede)",
                .test = alg_test_skcipher,
                .fips_allowed = 1,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(des3_ede_cbc_enc_tv_template),
-                               .dec = __VECS(des3_ede_cbc_dec_tv_template)
-                       }
-               }
+                       .cipher = __VECS(des3_ede_cbc_tv_template)
+               },
        }, {
                /* Same as cbc(aes) except the key is stored in
                 * hardware secure memory which we reference by index
@@ -2592,20 +2621,14 @@ static const struct alg_test_desc alg_test_descs[] = {
                .alg = "cbc(serpent)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(serpent_cbc_enc_tv_template),
-                               .dec = __VECS(serpent_cbc_dec_tv_template)
-                       }
-               }
+                       .cipher = __VECS(serpent_cbc_tv_template)
+               },
        }, {
                .alg = "cbc(twofish)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(tf_cbc_enc_tv_template),
-                               .dec = __VECS(tf_cbc_dec_tv_template)
-                       }
-               }
+                       .cipher = __VECS(tf_cbc_tv_template)
+               },
        }, {
                .alg = "cbcmac(aes)",
                .fips_allowed = 1,
@@ -2627,11 +2650,8 @@ static const struct alg_test_desc alg_test_descs[] = {
                .alg = "chacha20",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(chacha20_enc_tv_template),
-                               .dec = __VECS(chacha20_enc_tv_template),
-                       }
-               }
+                       .cipher = __VECS(chacha20_tv_template)
+               },
        }, {
                .alg = "cmac(aes)",
                .fips_allowed = 1,
@@ -2674,65 +2694,44 @@ static const struct alg_test_desc alg_test_descs[] = {
                .test = alg_test_skcipher,
                .fips_allowed = 1,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(aes_ctr_enc_tv_template),
-                               .dec = __VECS(aes_ctr_dec_tv_template)
-                       }
+                       .cipher = __VECS(aes_ctr_tv_template)
                }
        }, {
                .alg = "ctr(blowfish)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(bf_ctr_enc_tv_template),
-                               .dec = __VECS(bf_ctr_dec_tv_template)
-                       }
+                       .cipher = __VECS(bf_ctr_tv_template)
                }
        }, {
                .alg = "ctr(camellia)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(camellia_ctr_enc_tv_template),
-                               .dec = __VECS(camellia_ctr_dec_tv_template)
-                       }
+                       .cipher = __VECS(camellia_ctr_tv_template)
                }
        }, {
                .alg = "ctr(cast5)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(cast5_ctr_enc_tv_template),
-                               .dec = __VECS(cast5_ctr_dec_tv_template)
-                       }
+                       .cipher = __VECS(cast5_ctr_tv_template)
                }
        }, {
                .alg = "ctr(cast6)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(cast6_ctr_enc_tv_template),
-                               .dec = __VECS(cast6_ctr_dec_tv_template)
-                       }
+                       .cipher = __VECS(cast6_ctr_tv_template)
                }
        }, {
                .alg = "ctr(des)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(des_ctr_enc_tv_template),
-                               .dec = __VECS(des_ctr_dec_tv_template)
-                       }
+                       .cipher = __VECS(des_ctr_tv_template)
                }
        }, {
                .alg = "ctr(des3_ede)",
                .test = alg_test_skcipher,
                .fips_allowed = 1,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(des3_ede_ctr_enc_tv_template),
-                               .dec = __VECS(des3_ede_ctr_dec_tv_template)
-                       }
+                       .cipher = __VECS(des3_ede_ctr_tv_template)
                }
        }, {
                /* Same as ctr(aes) except the key is stored in
@@ -2745,28 +2744,19 @@ static const struct alg_test_desc alg_test_descs[] = {
                .alg = "ctr(serpent)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(serpent_ctr_enc_tv_template),
-                               .dec = __VECS(serpent_ctr_dec_tv_template)
-                       }
+                       .cipher = __VECS(serpent_ctr_tv_template)
                }
        }, {
                .alg = "ctr(twofish)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(tf_ctr_enc_tv_template),
-                               .dec = __VECS(tf_ctr_dec_tv_template)
-                       }
+                       .cipher = __VECS(tf_ctr_tv_template)
                }
        }, {
                .alg = "cts(cbc(aes))",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(cts_mode_enc_tv_template),
-                               .dec = __VECS(cts_mode_dec_tv_template)
-                       }
+                       .cipher = __VECS(cts_mode_tv_template)
                }
        }, {
                .alg = "deflate",
@@ -2914,64 +2904,43 @@ static const struct alg_test_desc alg_test_descs[] = {
                .test = alg_test_skcipher,
                .fips_allowed = 1,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(aes_enc_tv_template),
-                               .dec = __VECS(aes_dec_tv_template)
-                       }
+                       .cipher = __VECS(aes_tv_template)
                }
        }, {
                .alg = "ecb(anubis)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(anubis_enc_tv_template),
-                               .dec = __VECS(anubis_dec_tv_template)
-                       }
+                       .cipher = __VECS(anubis_tv_template)
                }
        }, {
                .alg = "ecb(arc4)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(arc4_enc_tv_template),
-                               .dec = __VECS(arc4_dec_tv_template)
-                       }
+                       .cipher = __VECS(arc4_tv_template)
                }
        }, {
                .alg = "ecb(blowfish)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(bf_enc_tv_template),
-                               .dec = __VECS(bf_dec_tv_template)
-                       }
+                       .cipher = __VECS(bf_tv_template)
                }
        }, {
                .alg = "ecb(camellia)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(camellia_enc_tv_template),
-                               .dec = __VECS(camellia_dec_tv_template)
-                       }
+                       .cipher = __VECS(camellia_tv_template)
                }
        }, {
                .alg = "ecb(cast5)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(cast5_enc_tv_template),
-                               .dec = __VECS(cast5_dec_tv_template)
-                       }
+                       .cipher = __VECS(cast5_tv_template)
                }
        }, {
                .alg = "ecb(cast6)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(cast6_enc_tv_template),
-                               .dec = __VECS(cast6_dec_tv_template)
-                       }
+                       .cipher = __VECS(cast6_tv_template)
                }
        }, {
                .alg = "ecb(cipher_null)",
@@ -2981,36 +2950,30 @@ static const struct alg_test_desc alg_test_descs[] = {
                .alg = "ecb(des)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(des_enc_tv_template),
-                               .dec = __VECS(des_dec_tv_template)
-                       }
+                       .cipher = __VECS(des_tv_template)
                }
        }, {
                .alg = "ecb(des3_ede)",
                .test = alg_test_skcipher,
                .fips_allowed = 1,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(des3_ede_enc_tv_template),
-                               .dec = __VECS(des3_ede_dec_tv_template)
-                       }
+                       .cipher = __VECS(des3_ede_tv_template)
                }
        }, {
                .alg = "ecb(fcrypt)",
                .test = alg_test_skcipher,
                .suite = {
                        .cipher = {
-                               .enc = {
-                                       .vecs = fcrypt_pcbc_enc_tv_template,
-                                       .count = 1
-                               },
-                               .dec = {
-                                       .vecs = fcrypt_pcbc_dec_tv_template,
-                                       .count = 1
-                               }
+                               .vecs = fcrypt_pcbc_tv_template,
+                               .count = 1
                        }
                }
+       }, {
+               .alg = "ecb(khazad)",
+               .test = alg_test_skcipher,
+               .suite = {
+                       .cipher = __VECS(khazad_tv_template)
+               }
        }, {
                /* Same as ecb(aes) except the key is stored in
                 * hardware secure memory which we reference by index
@@ -3018,104 +2981,65 @@ static const struct alg_test_desc alg_test_descs[] = {
                .alg = "ecb(paes)",
                .test = alg_test_null,
                .fips_allowed = 1,
-       }, {
-               .alg = "ecb(khazad)",
-               .test = alg_test_skcipher,
-               .suite = {
-                       .cipher = {
-                               .enc = __VECS(khazad_enc_tv_template),
-                               .dec = __VECS(khazad_dec_tv_template)
-                       }
-               }
        }, {
                .alg = "ecb(seed)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(seed_enc_tv_template),
-                               .dec = __VECS(seed_dec_tv_template)
-                       }
+                       .cipher = __VECS(seed_tv_template)
                }
        }, {
                .alg = "ecb(serpent)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(serpent_enc_tv_template),
-                               .dec = __VECS(serpent_dec_tv_template)
-                       }
+                       .cipher = __VECS(serpent_tv_template)
                }
        }, {
                .alg = "ecb(sm4)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(sm4_enc_tv_template),
-                               .dec = __VECS(sm4_dec_tv_template)
-                       }
+                       .cipher = __VECS(sm4_tv_template)
                }
        }, {
                .alg = "ecb(speck128)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(speck128_enc_tv_template),
-                               .dec = __VECS(speck128_dec_tv_template)
-                       }
+                       .cipher = __VECS(speck128_tv_template)
                }
        }, {
                .alg = "ecb(speck64)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(speck64_enc_tv_template),
-                               .dec = __VECS(speck64_dec_tv_template)
-                       }
+                       .cipher = __VECS(speck64_tv_template)
                }
        }, {
                .alg = "ecb(tea)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(tea_enc_tv_template),
-                               .dec = __VECS(tea_dec_tv_template)
-                       }
+                       .cipher = __VECS(tea_tv_template)
                }
        }, {
                .alg = "ecb(tnepres)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(tnepres_enc_tv_template),
-                               .dec = __VECS(tnepres_dec_tv_template)
-                       }
+                       .cipher = __VECS(tnepres_tv_template)
                }
        }, {
                .alg = "ecb(twofish)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(tf_enc_tv_template),
-                               .dec = __VECS(tf_dec_tv_template)
-                       }
+                       .cipher = __VECS(tf_tv_template)
                }
        }, {
                .alg = "ecb(xeta)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(xeta_enc_tv_template),
-                               .dec = __VECS(xeta_dec_tv_template)
-                       }
+                       .cipher = __VECS(xeta_tv_template)
                }
        }, {
                .alg = "ecb(xtea)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(xtea_enc_tv_template),
-                               .dec = __VECS(xtea_dec_tv_template)
-                       }
+                       .cipher = __VECS(xtea_tv_template)
                }
        }, {
                .alg = "ecdh",
@@ -3141,12 +3065,6 @@ static const struct alg_test_desc alg_test_descs[] = {
                .suite = {
                        .hash = __VECS(ghash_tv_template)
                }
-       }, {
-               .alg = "hmac(crc32)",
-               .test = alg_test_hash,
-               .suite = {
-                       .hash = __VECS(bfin_crc_tv_template)
-               }
        }, {
                .alg = "hmac(md5)",
                .test = alg_test_hash,
@@ -3237,55 +3155,37 @@ static const struct alg_test_desc alg_test_descs[] = {
                .test = alg_test_skcipher,
                .fips_allowed = 1,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(aes_kw_enc_tv_template),
-                               .dec = __VECS(aes_kw_dec_tv_template)
-                       }
+                       .cipher = __VECS(aes_kw_tv_template)
                }
        }, {
                .alg = "lrw(aes)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(aes_lrw_enc_tv_template),
-                               .dec = __VECS(aes_lrw_dec_tv_template)
-                       }
+                       .cipher = __VECS(aes_lrw_tv_template)
                }
        }, {
                .alg = "lrw(camellia)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(camellia_lrw_enc_tv_template),
-                               .dec = __VECS(camellia_lrw_dec_tv_template)
-                       }
+                       .cipher = __VECS(camellia_lrw_tv_template)
                }
        }, {
                .alg = "lrw(cast6)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(cast6_lrw_enc_tv_template),
-                               .dec = __VECS(cast6_lrw_dec_tv_template)
-                       }
+                       .cipher = __VECS(cast6_lrw_tv_template)
                }
        }, {
                .alg = "lrw(serpent)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(serpent_lrw_enc_tv_template),
-                               .dec = __VECS(serpent_lrw_dec_tv_template)
-                       }
+                       .cipher = __VECS(serpent_lrw_tv_template)
                }
        }, {
                .alg = "lrw(twofish)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(tf_lrw_enc_tv_template),
-                               .dec = __VECS(tf_lrw_dec_tv_template)
-                       }
+                       .cipher = __VECS(tf_lrw_tv_template)
                }
        }, {
                .alg = "lz4",
@@ -3335,15 +3235,30 @@ static const struct alg_test_desc alg_test_descs[] = {
                .suite = {
                        .hash = __VECS(michael_mic_tv_template)
                }
+       }, {
+               .alg = "morus1280",
+               .test = alg_test_aead,
+               .suite = {
+                       .aead = {
+                               .enc = __VECS(morus1280_enc_tv_template),
+                               .dec = __VECS(morus1280_dec_tv_template),
+                       }
+               }
+       }, {
+               .alg = "morus640",
+               .test = alg_test_aead,
+               .suite = {
+                       .aead = {
+                               .enc = __VECS(morus640_enc_tv_template),
+                               .dec = __VECS(morus640_dec_tv_template),
+                       }
+               }
        }, {
                .alg = "ofb(aes)",
                .test = alg_test_skcipher,
                .fips_allowed = 1,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(aes_ofb_enc_tv_template),
-                               .dec = __VECS(aes_ofb_dec_tv_template)
-                       }
+                       .cipher = __VECS(aes_ofb_tv_template)
                }
        }, {
                /* Same as ofb(aes) except the key is stored in
@@ -3356,10 +3271,7 @@ static const struct alg_test_desc alg_test_descs[] = {
                .alg = "pcbc(fcrypt)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(fcrypt_pcbc_enc_tv_template),
-                               .dec = __VECS(fcrypt_pcbc_dec_tv_template)
-                       }
+                       .cipher = __VECS(fcrypt_pcbc_tv_template)
                }
        }, {
                .alg = "pkcs1pad(rsa,sha224)",
@@ -3391,10 +3303,7 @@ static const struct alg_test_desc alg_test_descs[] = {
                .test = alg_test_skcipher,
                .fips_allowed = 1,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(aes_ctr_rfc3686_enc_tv_template),
-                               .dec = __VECS(aes_ctr_rfc3686_dec_tv_template)
-                       }
+                       .cipher = __VECS(aes_ctr_rfc3686_tv_template)
                }
        }, {
                .alg = "rfc4106(gcm(aes))",
@@ -3478,9 +3387,7 @@ static const struct alg_test_desc alg_test_descs[] = {
                .alg = "salsa20",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(salsa20_stream_enc_tv_template)
-                       }
+                       .cipher = __VECS(salsa20_stream_tv_template)
                }
        }, {
                .alg = "sha1",
@@ -3604,80 +3511,59 @@ static const struct alg_test_desc alg_test_descs[] = {
                .test = alg_test_skcipher,
                .fips_allowed = 1,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(aes_xts_enc_tv_template),
-                               .dec = __VECS(aes_xts_dec_tv_template)
-                       }
+                       .cipher = __VECS(aes_xts_tv_template)
                }
-       }, {
-               /* Same as xts(aes) except the key is stored in
-                * hardware secure memory which we reference by index
-                */
-               .alg = "xts(paes)",
-               .test = alg_test_null,
-               .fips_allowed = 1,
-       }, {
-               .alg = "xts4096(paes)",
-               .test = alg_test_null,
-               .fips_allowed = 1,
-       }, {
-               .alg = "xts512(paes)",
-               .test = alg_test_null,
-               .fips_allowed = 1,
        }, {
                .alg = "xts(camellia)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(camellia_xts_enc_tv_template),
-                               .dec = __VECS(camellia_xts_dec_tv_template)
-                       }
+                       .cipher = __VECS(camellia_xts_tv_template)
                }
        }, {
                .alg = "xts(cast6)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(cast6_xts_enc_tv_template),
-                               .dec = __VECS(cast6_xts_dec_tv_template)
-                       }
+                       .cipher = __VECS(cast6_xts_tv_template)
                }
+       }, {
+               /* Same as xts(aes) except the key is stored in
+                * hardware secure memory which we reference by index
+                */
+               .alg = "xts(paes)",
+               .test = alg_test_null,
+               .fips_allowed = 1,
        }, {
                .alg = "xts(serpent)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(serpent_xts_enc_tv_template),
-                               .dec = __VECS(serpent_xts_dec_tv_template)
-                       }
+                       .cipher = __VECS(serpent_xts_tv_template)
                }
        }, {
                .alg = "xts(speck128)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(speck128_xts_enc_tv_template),
-                               .dec = __VECS(speck128_xts_dec_tv_template)
-                       }
+                       .cipher = __VECS(speck128_xts_tv_template)
                }
        }, {
                .alg = "xts(speck64)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(speck64_xts_enc_tv_template),
-                               .dec = __VECS(speck64_xts_dec_tv_template)
-                       }
+                       .cipher = __VECS(speck64_xts_tv_template)
                }
        }, {
                .alg = "xts(twofish)",
                .test = alg_test_skcipher,
                .suite = {
-                       .cipher = {
-                               .enc = __VECS(tf_xts_enc_tv_template),
-                               .dec = __VECS(tf_xts_dec_tv_template)
-                       }
+                       .cipher = __VECS(tf_xts_tv_template)
                }
+       }, {
+               .alg = "xts4096(paes)",
+               .test = alg_test_null,
+               .fips_allowed = 1,
+       }, {
+               .alg = "xts512(paes)",
+               .test = alg_test_null,
+               .fips_allowed = 1,
        }, {
                .alg = "zlib-deflate",
                .test = alg_test_comp,