18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Quick & dirty crypto testing module.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * This will only exist until we have a better testing mechanism
68c2ecf20Sopenharmony_ci * (e.g. a char device).
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
98c2ecf20Sopenharmony_ci * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
108c2ecf20Sopenharmony_ci * Copyright (c) 2007 Nokia Siemens Networks
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Updated RFC4106 AES-GCM testing.
138c2ecf20Sopenharmony_ci *    Authors: Aidan O'Mahony (aidan.o.mahony@intel.com)
148c2ecf20Sopenharmony_ci *             Adrian Hoban <adrian.hoban@intel.com>
158c2ecf20Sopenharmony_ci *             Gabriele Paoloni <gabriele.paoloni@intel.com>
168c2ecf20Sopenharmony_ci *             Tadeusz Struk (tadeusz.struk@intel.com)
178c2ecf20Sopenharmony_ci *             Copyright (c) 2010, Intel Corporation.
188c2ecf20Sopenharmony_ci */
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#include <crypto/aead.h>
238c2ecf20Sopenharmony_ci#include <crypto/hash.h>
248c2ecf20Sopenharmony_ci#include <crypto/skcipher.h>
258c2ecf20Sopenharmony_ci#include <linux/err.h>
268c2ecf20Sopenharmony_ci#include <linux/fips.h>
278c2ecf20Sopenharmony_ci#include <linux/init.h>
288c2ecf20Sopenharmony_ci#include <linux/gfp.h>
298c2ecf20Sopenharmony_ci#include <linux/module.h>
308c2ecf20Sopenharmony_ci#include <linux/scatterlist.h>
318c2ecf20Sopenharmony_ci#include <linux/string.h>
328c2ecf20Sopenharmony_ci#include <linux/moduleparam.h>
338c2ecf20Sopenharmony_ci#include <linux/jiffies.h>
348c2ecf20Sopenharmony_ci#include <linux/timex.h>
358c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
368c2ecf20Sopenharmony_ci#include "tcrypt.h"
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/*
398c2ecf20Sopenharmony_ci * Need slab memory for testing (size in number of pages).
408c2ecf20Sopenharmony_ci */
418c2ecf20Sopenharmony_ci#define TVMEMSIZE	4
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/*
448c2ecf20Sopenharmony_ci* Used by test_cipher_speed()
458c2ecf20Sopenharmony_ci*/
468c2ecf20Sopenharmony_ci#define ENCRYPT 1
478c2ecf20Sopenharmony_ci#define DECRYPT 0
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#define MAX_DIGEST_SIZE		64
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci/*
528c2ecf20Sopenharmony_ci * return a string with the driver name
538c2ecf20Sopenharmony_ci */
548c2ecf20Sopenharmony_ci#define get_driver_name(tfm_type, tfm) crypto_tfm_alg_driver_name(tfm_type ## _tfm(tfm))
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/*
578c2ecf20Sopenharmony_ci * Used by test_cipher_speed()
588c2ecf20Sopenharmony_ci */
598c2ecf20Sopenharmony_cistatic unsigned int sec;
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic char *alg = NULL;
628c2ecf20Sopenharmony_cistatic u32 type;
638c2ecf20Sopenharmony_cistatic u32 mask;
648c2ecf20Sopenharmony_cistatic int mode;
658c2ecf20Sopenharmony_cistatic u32 num_mb = 8;
668c2ecf20Sopenharmony_cistatic unsigned int klen;
678c2ecf20Sopenharmony_cistatic char *tvmem[TVMEMSIZE];
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic const char *check[] = {
708c2ecf20Sopenharmony_ci	"des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", "sm3",
718c2ecf20Sopenharmony_ci	"blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
728c2ecf20Sopenharmony_ci	"cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
738c2ecf20Sopenharmony_ci	"khazad", "wp512", "wp384", "wp256", "tnepres", "xeta",  "fcrypt",
748c2ecf20Sopenharmony_ci	"camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
758c2ecf20Sopenharmony_ci	"lzo", "lzo-rle", "cts", "sha3-224", "sha3-256", "sha3-384",
768c2ecf20Sopenharmony_ci	"sha3-512", "streebog256", "streebog512",
778c2ecf20Sopenharmony_ci	NULL
788c2ecf20Sopenharmony_ci};
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_cistatic u32 block_sizes[] = { 16, 64, 256, 1024, 1472, 8192, 0 };
818c2ecf20Sopenharmony_cistatic u32 aead_sizes[] = { 16, 64, 256, 512, 1024, 2048, 4096, 8192, 0 };
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#define XBUFSIZE 8
848c2ecf20Sopenharmony_ci#define MAX_IVLEN 32
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cistatic int testmgr_alloc_buf(char *buf[XBUFSIZE])
878c2ecf20Sopenharmony_ci{
888c2ecf20Sopenharmony_ci	int i;
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci	for (i = 0; i < XBUFSIZE; i++) {
918c2ecf20Sopenharmony_ci		buf[i] = (void *)__get_free_page(GFP_KERNEL);
928c2ecf20Sopenharmony_ci		if (!buf[i])
938c2ecf20Sopenharmony_ci			goto err_free_buf;
948c2ecf20Sopenharmony_ci	}
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	return 0;
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cierr_free_buf:
998c2ecf20Sopenharmony_ci	while (i-- > 0)
1008c2ecf20Sopenharmony_ci		free_page((unsigned long)buf[i]);
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci	return -ENOMEM;
1038c2ecf20Sopenharmony_ci}
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_cistatic void testmgr_free_buf(char *buf[XBUFSIZE])
1068c2ecf20Sopenharmony_ci{
1078c2ecf20Sopenharmony_ci	int i;
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci	for (i = 0; i < XBUFSIZE; i++)
1108c2ecf20Sopenharmony_ci		free_page((unsigned long)buf[i]);
1118c2ecf20Sopenharmony_ci}
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_cistatic void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
1148c2ecf20Sopenharmony_ci			 unsigned int buflen, const void *assoc,
1158c2ecf20Sopenharmony_ci			 unsigned int aad_size)
1168c2ecf20Sopenharmony_ci{
1178c2ecf20Sopenharmony_ci	int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE;
1188c2ecf20Sopenharmony_ci	int k, rem;
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	if (np > XBUFSIZE) {
1218c2ecf20Sopenharmony_ci		rem = PAGE_SIZE;
1228c2ecf20Sopenharmony_ci		np = XBUFSIZE;
1238c2ecf20Sopenharmony_ci	} else {
1248c2ecf20Sopenharmony_ci		rem = buflen % PAGE_SIZE;
1258c2ecf20Sopenharmony_ci	}
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	sg_init_table(sg, np + 1);
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci	sg_set_buf(&sg[0], assoc, aad_size);
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	if (rem)
1328c2ecf20Sopenharmony_ci		np--;
1338c2ecf20Sopenharmony_ci	for (k = 0; k < np; k++)
1348c2ecf20Sopenharmony_ci		sg_set_buf(&sg[k + 1], xbuf[k], PAGE_SIZE);
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	if (rem)
1378c2ecf20Sopenharmony_ci		sg_set_buf(&sg[k + 1], xbuf[k], rem);
1388c2ecf20Sopenharmony_ci}
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_cistatic inline int do_one_aead_op(struct aead_request *req, int ret)
1418c2ecf20Sopenharmony_ci{
1428c2ecf20Sopenharmony_ci	struct crypto_wait *wait = req->base.data;
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci	return crypto_wait_req(ret, wait);
1458c2ecf20Sopenharmony_ci}
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_cistruct test_mb_aead_data {
1488c2ecf20Sopenharmony_ci	struct scatterlist sg[XBUFSIZE];
1498c2ecf20Sopenharmony_ci	struct scatterlist sgout[XBUFSIZE];
1508c2ecf20Sopenharmony_ci	struct aead_request *req;
1518c2ecf20Sopenharmony_ci	struct crypto_wait wait;
1528c2ecf20Sopenharmony_ci	char *xbuf[XBUFSIZE];
1538c2ecf20Sopenharmony_ci	char *xoutbuf[XBUFSIZE];
1548c2ecf20Sopenharmony_ci	char *axbuf[XBUFSIZE];
1558c2ecf20Sopenharmony_ci};
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_cistatic int do_mult_aead_op(struct test_mb_aead_data *data, int enc,
1588c2ecf20Sopenharmony_ci				u32 num_mb, int *rc)
1598c2ecf20Sopenharmony_ci{
1608c2ecf20Sopenharmony_ci	int i, err = 0;
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	/* Fire up a bunch of concurrent requests */
1638c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; i++) {
1648c2ecf20Sopenharmony_ci		if (enc == ENCRYPT)
1658c2ecf20Sopenharmony_ci			rc[i] = crypto_aead_encrypt(data[i].req);
1668c2ecf20Sopenharmony_ci		else
1678c2ecf20Sopenharmony_ci			rc[i] = crypto_aead_decrypt(data[i].req);
1688c2ecf20Sopenharmony_ci	}
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	/* Wait for all requests to finish */
1718c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; i++) {
1728c2ecf20Sopenharmony_ci		rc[i] = crypto_wait_req(rc[i], &data[i].wait);
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci		if (rc[i]) {
1758c2ecf20Sopenharmony_ci			pr_info("concurrent request %d error %d\n", i, rc[i]);
1768c2ecf20Sopenharmony_ci			err = rc[i];
1778c2ecf20Sopenharmony_ci		}
1788c2ecf20Sopenharmony_ci	}
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci	return err;
1818c2ecf20Sopenharmony_ci}
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_cistatic int test_mb_aead_jiffies(struct test_mb_aead_data *data, int enc,
1848c2ecf20Sopenharmony_ci				int blen, int secs, u32 num_mb)
1858c2ecf20Sopenharmony_ci{
1868c2ecf20Sopenharmony_ci	unsigned long start, end;
1878c2ecf20Sopenharmony_ci	int bcount;
1888c2ecf20Sopenharmony_ci	int ret = 0;
1898c2ecf20Sopenharmony_ci	int *rc;
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
1928c2ecf20Sopenharmony_ci	if (!rc)
1938c2ecf20Sopenharmony_ci		return -ENOMEM;
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci	for (start = jiffies, end = start + secs * HZ, bcount = 0;
1968c2ecf20Sopenharmony_ci	     time_before(jiffies, end); bcount++) {
1978c2ecf20Sopenharmony_ci		ret = do_mult_aead_op(data, enc, num_mb, rc);
1988c2ecf20Sopenharmony_ci		if (ret)
1998c2ecf20Sopenharmony_ci			goto out;
2008c2ecf20Sopenharmony_ci	}
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci	pr_cont("%d operations in %d seconds (%llu bytes)\n",
2038c2ecf20Sopenharmony_ci		bcount * num_mb, secs, (u64)bcount * blen * num_mb);
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ciout:
2068c2ecf20Sopenharmony_ci	kfree(rc);
2078c2ecf20Sopenharmony_ci	return ret;
2088c2ecf20Sopenharmony_ci}
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_cistatic int test_mb_aead_cycles(struct test_mb_aead_data *data, int enc,
2118c2ecf20Sopenharmony_ci			       int blen, u32 num_mb)
2128c2ecf20Sopenharmony_ci{
2138c2ecf20Sopenharmony_ci	unsigned long cycles = 0;
2148c2ecf20Sopenharmony_ci	int ret = 0;
2158c2ecf20Sopenharmony_ci	int i;
2168c2ecf20Sopenharmony_ci	int *rc;
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
2198c2ecf20Sopenharmony_ci	if (!rc)
2208c2ecf20Sopenharmony_ci		return -ENOMEM;
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci	/* Warm-up run. */
2238c2ecf20Sopenharmony_ci	for (i = 0; i < 4; i++) {
2248c2ecf20Sopenharmony_ci		ret = do_mult_aead_op(data, enc, num_mb, rc);
2258c2ecf20Sopenharmony_ci		if (ret)
2268c2ecf20Sopenharmony_ci			goto out;
2278c2ecf20Sopenharmony_ci	}
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci	/* The real thing. */
2308c2ecf20Sopenharmony_ci	for (i = 0; i < 8; i++) {
2318c2ecf20Sopenharmony_ci		cycles_t start, end;
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci		start = get_cycles();
2348c2ecf20Sopenharmony_ci		ret = do_mult_aead_op(data, enc, num_mb, rc);
2358c2ecf20Sopenharmony_ci		end = get_cycles();
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci		if (ret)
2388c2ecf20Sopenharmony_ci			goto out;
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci		cycles += end - start;
2418c2ecf20Sopenharmony_ci	}
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci	pr_cont("1 operation in %lu cycles (%d bytes)\n",
2448c2ecf20Sopenharmony_ci		(cycles + 4) / (8 * num_mb), blen);
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ciout:
2478c2ecf20Sopenharmony_ci	kfree(rc);
2488c2ecf20Sopenharmony_ci	return ret;
2498c2ecf20Sopenharmony_ci}
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_cistatic void test_mb_aead_speed(const char *algo, int enc, int secs,
2528c2ecf20Sopenharmony_ci			       struct aead_speed_template *template,
2538c2ecf20Sopenharmony_ci			       unsigned int tcount, u8 authsize,
2548c2ecf20Sopenharmony_ci			       unsigned int aad_size, u8 *keysize, u32 num_mb)
2558c2ecf20Sopenharmony_ci{
2568c2ecf20Sopenharmony_ci	struct test_mb_aead_data *data;
2578c2ecf20Sopenharmony_ci	struct crypto_aead *tfm;
2588c2ecf20Sopenharmony_ci	unsigned int i, j, iv_len;
2598c2ecf20Sopenharmony_ci	const char *key;
2608c2ecf20Sopenharmony_ci	const char *e;
2618c2ecf20Sopenharmony_ci	void *assoc;
2628c2ecf20Sopenharmony_ci	u32 *b_size;
2638c2ecf20Sopenharmony_ci	char *iv;
2648c2ecf20Sopenharmony_ci	int ret;
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci	if (aad_size >= PAGE_SIZE) {
2688c2ecf20Sopenharmony_ci		pr_err("associate data length (%u) too big\n", aad_size);
2698c2ecf20Sopenharmony_ci		return;
2708c2ecf20Sopenharmony_ci	}
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci	iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
2738c2ecf20Sopenharmony_ci	if (!iv)
2748c2ecf20Sopenharmony_ci		return;
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	if (enc == ENCRYPT)
2778c2ecf20Sopenharmony_ci		e = "encryption";
2788c2ecf20Sopenharmony_ci	else
2798c2ecf20Sopenharmony_ci		e = "decryption";
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci	data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
2828c2ecf20Sopenharmony_ci	if (!data)
2838c2ecf20Sopenharmony_ci		goto out_free_iv;
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	tfm = crypto_alloc_aead(algo, 0, 0);
2868c2ecf20Sopenharmony_ci	if (IS_ERR(tfm)) {
2878c2ecf20Sopenharmony_ci		pr_err("failed to load transform for %s: %ld\n",
2888c2ecf20Sopenharmony_ci			algo, PTR_ERR(tfm));
2898c2ecf20Sopenharmony_ci		goto out_free_data;
2908c2ecf20Sopenharmony_ci	}
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci	ret = crypto_aead_setauthsize(tfm, authsize);
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i)
2958c2ecf20Sopenharmony_ci		if (testmgr_alloc_buf(data[i].xbuf)) {
2968c2ecf20Sopenharmony_ci			while (i--)
2978c2ecf20Sopenharmony_ci				testmgr_free_buf(data[i].xbuf);
2988c2ecf20Sopenharmony_ci			goto out_free_tfm;
2998c2ecf20Sopenharmony_ci		}
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i)
3028c2ecf20Sopenharmony_ci		if (testmgr_alloc_buf(data[i].axbuf)) {
3038c2ecf20Sopenharmony_ci			while (i--)
3048c2ecf20Sopenharmony_ci				testmgr_free_buf(data[i].axbuf);
3058c2ecf20Sopenharmony_ci			goto out_free_xbuf;
3068c2ecf20Sopenharmony_ci		}
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i)
3098c2ecf20Sopenharmony_ci		if (testmgr_alloc_buf(data[i].xoutbuf)) {
3108c2ecf20Sopenharmony_ci			while (i--)
3118c2ecf20Sopenharmony_ci				testmgr_free_buf(data[i].xoutbuf);
3128c2ecf20Sopenharmony_ci			goto out_free_axbuf;
3138c2ecf20Sopenharmony_ci		}
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i) {
3168c2ecf20Sopenharmony_ci		data[i].req = aead_request_alloc(tfm, GFP_KERNEL);
3178c2ecf20Sopenharmony_ci		if (!data[i].req) {
3188c2ecf20Sopenharmony_ci			pr_err("alg: skcipher: Failed to allocate request for %s\n",
3198c2ecf20Sopenharmony_ci			       algo);
3208c2ecf20Sopenharmony_ci			while (i--)
3218c2ecf20Sopenharmony_ci				aead_request_free(data[i].req);
3228c2ecf20Sopenharmony_ci			goto out_free_xoutbuf;
3238c2ecf20Sopenharmony_ci		}
3248c2ecf20Sopenharmony_ci	}
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i) {
3278c2ecf20Sopenharmony_ci		crypto_init_wait(&data[i].wait);
3288c2ecf20Sopenharmony_ci		aead_request_set_callback(data[i].req,
3298c2ecf20Sopenharmony_ci					  CRYPTO_TFM_REQ_MAY_BACKLOG,
3308c2ecf20Sopenharmony_ci					  crypto_req_done, &data[i].wait);
3318c2ecf20Sopenharmony_ci	}
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci	pr_info("\ntesting speed of multibuffer %s (%s) %s\n", algo,
3348c2ecf20Sopenharmony_ci		get_driver_name(crypto_aead, tfm), e);
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci	i = 0;
3378c2ecf20Sopenharmony_ci	do {
3388c2ecf20Sopenharmony_ci		b_size = aead_sizes;
3398c2ecf20Sopenharmony_ci		do {
3408c2ecf20Sopenharmony_ci			if (*b_size + authsize > XBUFSIZE * PAGE_SIZE) {
3418c2ecf20Sopenharmony_ci				pr_err("template (%u) too big for buffer (%lu)\n",
3428c2ecf20Sopenharmony_ci				       authsize + *b_size,
3438c2ecf20Sopenharmony_ci				       XBUFSIZE * PAGE_SIZE);
3448c2ecf20Sopenharmony_ci				goto out;
3458c2ecf20Sopenharmony_ci			}
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci			pr_info("test %u (%d bit key, %d byte blocks): ", i,
3488c2ecf20Sopenharmony_ci				*keysize * 8, *b_size);
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci			/* Set up tfm global state, i.e. the key */
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci			memset(tvmem[0], 0xff, PAGE_SIZE);
3538c2ecf20Sopenharmony_ci			key = tvmem[0];
3548c2ecf20Sopenharmony_ci			for (j = 0; j < tcount; j++) {
3558c2ecf20Sopenharmony_ci				if (template[j].klen == *keysize) {
3568c2ecf20Sopenharmony_ci					key = template[j].key;
3578c2ecf20Sopenharmony_ci					break;
3588c2ecf20Sopenharmony_ci				}
3598c2ecf20Sopenharmony_ci			}
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci			crypto_aead_clear_flags(tfm, ~0);
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ci			ret = crypto_aead_setkey(tfm, key, *keysize);
3648c2ecf20Sopenharmony_ci			if (ret) {
3658c2ecf20Sopenharmony_ci				pr_err("setkey() failed flags=%x\n",
3668c2ecf20Sopenharmony_ci				       crypto_aead_get_flags(tfm));
3678c2ecf20Sopenharmony_ci				goto out;
3688c2ecf20Sopenharmony_ci			}
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci			iv_len = crypto_aead_ivsize(tfm);
3718c2ecf20Sopenharmony_ci			if (iv_len)
3728c2ecf20Sopenharmony_ci				memset(iv, 0xff, iv_len);
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci			/* Now setup per request stuff, i.e. buffers */
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ci			for (j = 0; j < num_mb; ++j) {
3778c2ecf20Sopenharmony_ci				struct test_mb_aead_data *cur = &data[j];
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci				assoc = cur->axbuf[0];
3808c2ecf20Sopenharmony_ci				memset(assoc, 0xff, aad_size);
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci				sg_init_aead(cur->sg, cur->xbuf,
3838c2ecf20Sopenharmony_ci					     *b_size + (enc ? 0 : authsize),
3848c2ecf20Sopenharmony_ci					     assoc, aad_size);
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci				sg_init_aead(cur->sgout, cur->xoutbuf,
3878c2ecf20Sopenharmony_ci					     *b_size + (enc ? authsize : 0),
3888c2ecf20Sopenharmony_ci					     assoc, aad_size);
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci				aead_request_set_ad(cur->req, aad_size);
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci				if (!enc) {
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci					aead_request_set_crypt(cur->req,
3958c2ecf20Sopenharmony_ci							       cur->sgout,
3968c2ecf20Sopenharmony_ci							       cur->sg,
3978c2ecf20Sopenharmony_ci							       *b_size, iv);
3988c2ecf20Sopenharmony_ci					ret = crypto_aead_encrypt(cur->req);
3998c2ecf20Sopenharmony_ci					ret = do_one_aead_op(cur->req, ret);
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci					if (ret) {
4028c2ecf20Sopenharmony_ci						pr_err("calculating auth failed (%d)\n",
4038c2ecf20Sopenharmony_ci						       ret);
4048c2ecf20Sopenharmony_ci						break;
4058c2ecf20Sopenharmony_ci					}
4068c2ecf20Sopenharmony_ci				}
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_ci				aead_request_set_crypt(cur->req, cur->sg,
4098c2ecf20Sopenharmony_ci						       cur->sgout, *b_size +
4108c2ecf20Sopenharmony_ci						       (enc ? 0 : authsize),
4118c2ecf20Sopenharmony_ci						       iv);
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci			}
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci			if (secs) {
4168c2ecf20Sopenharmony_ci				ret = test_mb_aead_jiffies(data, enc, *b_size,
4178c2ecf20Sopenharmony_ci							   secs, num_mb);
4188c2ecf20Sopenharmony_ci				cond_resched();
4198c2ecf20Sopenharmony_ci			} else {
4208c2ecf20Sopenharmony_ci				ret = test_mb_aead_cycles(data, enc, *b_size,
4218c2ecf20Sopenharmony_ci							  num_mb);
4228c2ecf20Sopenharmony_ci			}
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci			if (ret) {
4258c2ecf20Sopenharmony_ci				pr_err("%s() failed return code=%d\n", e, ret);
4268c2ecf20Sopenharmony_ci				break;
4278c2ecf20Sopenharmony_ci			}
4288c2ecf20Sopenharmony_ci			b_size++;
4298c2ecf20Sopenharmony_ci			i++;
4308c2ecf20Sopenharmony_ci		} while (*b_size);
4318c2ecf20Sopenharmony_ci		keysize++;
4328c2ecf20Sopenharmony_ci	} while (*keysize);
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ciout:
4358c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i)
4368c2ecf20Sopenharmony_ci		aead_request_free(data[i].req);
4378c2ecf20Sopenharmony_ciout_free_xoutbuf:
4388c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i)
4398c2ecf20Sopenharmony_ci		testmgr_free_buf(data[i].xoutbuf);
4408c2ecf20Sopenharmony_ciout_free_axbuf:
4418c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i)
4428c2ecf20Sopenharmony_ci		testmgr_free_buf(data[i].axbuf);
4438c2ecf20Sopenharmony_ciout_free_xbuf:
4448c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i)
4458c2ecf20Sopenharmony_ci		testmgr_free_buf(data[i].xbuf);
4468c2ecf20Sopenharmony_ciout_free_tfm:
4478c2ecf20Sopenharmony_ci	crypto_free_aead(tfm);
4488c2ecf20Sopenharmony_ciout_free_data:
4498c2ecf20Sopenharmony_ci	kfree(data);
4508c2ecf20Sopenharmony_ciout_free_iv:
4518c2ecf20Sopenharmony_ci	kfree(iv);
4528c2ecf20Sopenharmony_ci}
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_cistatic int test_aead_jiffies(struct aead_request *req, int enc,
4558c2ecf20Sopenharmony_ci				int blen, int secs)
4568c2ecf20Sopenharmony_ci{
4578c2ecf20Sopenharmony_ci	unsigned long start, end;
4588c2ecf20Sopenharmony_ci	int bcount;
4598c2ecf20Sopenharmony_ci	int ret;
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_ci	for (start = jiffies, end = start + secs * HZ, bcount = 0;
4628c2ecf20Sopenharmony_ci	     time_before(jiffies, end); bcount++) {
4638c2ecf20Sopenharmony_ci		if (enc)
4648c2ecf20Sopenharmony_ci			ret = do_one_aead_op(req, crypto_aead_encrypt(req));
4658c2ecf20Sopenharmony_ci		else
4668c2ecf20Sopenharmony_ci			ret = do_one_aead_op(req, crypto_aead_decrypt(req));
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_ci		if (ret)
4698c2ecf20Sopenharmony_ci			return ret;
4708c2ecf20Sopenharmony_ci	}
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ci	pr_cont("%d operations in %d seconds (%llu bytes)\n",
4738c2ecf20Sopenharmony_ci	        bcount, secs, (u64)bcount * blen);
4748c2ecf20Sopenharmony_ci	return 0;
4758c2ecf20Sopenharmony_ci}
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_cistatic int test_aead_cycles(struct aead_request *req, int enc, int blen)
4788c2ecf20Sopenharmony_ci{
4798c2ecf20Sopenharmony_ci	unsigned long cycles = 0;
4808c2ecf20Sopenharmony_ci	int ret = 0;
4818c2ecf20Sopenharmony_ci	int i;
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci	/* Warm-up run. */
4848c2ecf20Sopenharmony_ci	for (i = 0; i < 4; i++) {
4858c2ecf20Sopenharmony_ci		if (enc)
4868c2ecf20Sopenharmony_ci			ret = do_one_aead_op(req, crypto_aead_encrypt(req));
4878c2ecf20Sopenharmony_ci		else
4888c2ecf20Sopenharmony_ci			ret = do_one_aead_op(req, crypto_aead_decrypt(req));
4898c2ecf20Sopenharmony_ci
4908c2ecf20Sopenharmony_ci		if (ret)
4918c2ecf20Sopenharmony_ci			goto out;
4928c2ecf20Sopenharmony_ci	}
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci	/* The real thing. */
4958c2ecf20Sopenharmony_ci	for (i = 0; i < 8; i++) {
4968c2ecf20Sopenharmony_ci		cycles_t start, end;
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_ci		start = get_cycles();
4998c2ecf20Sopenharmony_ci		if (enc)
5008c2ecf20Sopenharmony_ci			ret = do_one_aead_op(req, crypto_aead_encrypt(req));
5018c2ecf20Sopenharmony_ci		else
5028c2ecf20Sopenharmony_ci			ret = do_one_aead_op(req, crypto_aead_decrypt(req));
5038c2ecf20Sopenharmony_ci		end = get_cycles();
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_ci		if (ret)
5068c2ecf20Sopenharmony_ci			goto out;
5078c2ecf20Sopenharmony_ci
5088c2ecf20Sopenharmony_ci		cycles += end - start;
5098c2ecf20Sopenharmony_ci	}
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_ciout:
5128c2ecf20Sopenharmony_ci	if (ret == 0)
5138c2ecf20Sopenharmony_ci		printk("1 operation in %lu cycles (%d bytes)\n",
5148c2ecf20Sopenharmony_ci		       (cycles + 4) / 8, blen);
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_ci	return ret;
5178c2ecf20Sopenharmony_ci}
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_cistatic void test_aead_speed(const char *algo, int enc, unsigned int secs,
5208c2ecf20Sopenharmony_ci			    struct aead_speed_template *template,
5218c2ecf20Sopenharmony_ci			    unsigned int tcount, u8 authsize,
5228c2ecf20Sopenharmony_ci			    unsigned int aad_size, u8 *keysize)
5238c2ecf20Sopenharmony_ci{
5248c2ecf20Sopenharmony_ci	unsigned int i, j;
5258c2ecf20Sopenharmony_ci	struct crypto_aead *tfm;
5268c2ecf20Sopenharmony_ci	int ret = -ENOMEM;
5278c2ecf20Sopenharmony_ci	const char *key;
5288c2ecf20Sopenharmony_ci	struct aead_request *req;
5298c2ecf20Sopenharmony_ci	struct scatterlist *sg;
5308c2ecf20Sopenharmony_ci	struct scatterlist *sgout;
5318c2ecf20Sopenharmony_ci	const char *e;
5328c2ecf20Sopenharmony_ci	void *assoc;
5338c2ecf20Sopenharmony_ci	char *iv;
5348c2ecf20Sopenharmony_ci	char *xbuf[XBUFSIZE];
5358c2ecf20Sopenharmony_ci	char *xoutbuf[XBUFSIZE];
5368c2ecf20Sopenharmony_ci	char *axbuf[XBUFSIZE];
5378c2ecf20Sopenharmony_ci	unsigned int *b_size;
5388c2ecf20Sopenharmony_ci	unsigned int iv_len;
5398c2ecf20Sopenharmony_ci	struct crypto_wait wait;
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ci	iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
5428c2ecf20Sopenharmony_ci	if (!iv)
5438c2ecf20Sopenharmony_ci		return;
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci	if (aad_size >= PAGE_SIZE) {
5468c2ecf20Sopenharmony_ci		pr_err("associate data length (%u) too big\n", aad_size);
5478c2ecf20Sopenharmony_ci		goto out_noxbuf;
5488c2ecf20Sopenharmony_ci	}
5498c2ecf20Sopenharmony_ci
5508c2ecf20Sopenharmony_ci	if (enc == ENCRYPT)
5518c2ecf20Sopenharmony_ci		e = "encryption";
5528c2ecf20Sopenharmony_ci	else
5538c2ecf20Sopenharmony_ci		e = "decryption";
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_ci	if (testmgr_alloc_buf(xbuf))
5568c2ecf20Sopenharmony_ci		goto out_noxbuf;
5578c2ecf20Sopenharmony_ci	if (testmgr_alloc_buf(axbuf))
5588c2ecf20Sopenharmony_ci		goto out_noaxbuf;
5598c2ecf20Sopenharmony_ci	if (testmgr_alloc_buf(xoutbuf))
5608c2ecf20Sopenharmony_ci		goto out_nooutbuf;
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_ci	sg = kmalloc(sizeof(*sg) * 9 * 2, GFP_KERNEL);
5638c2ecf20Sopenharmony_ci	if (!sg)
5648c2ecf20Sopenharmony_ci		goto out_nosg;
5658c2ecf20Sopenharmony_ci	sgout = &sg[9];
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_ci	tfm = crypto_alloc_aead(algo, 0, 0);
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ci	if (IS_ERR(tfm)) {
5708c2ecf20Sopenharmony_ci		pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo,
5718c2ecf20Sopenharmony_ci		       PTR_ERR(tfm));
5728c2ecf20Sopenharmony_ci		goto out_notfm;
5738c2ecf20Sopenharmony_ci	}
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_ci	crypto_init_wait(&wait);
5768c2ecf20Sopenharmony_ci	printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo,
5778c2ecf20Sopenharmony_ci			get_driver_name(crypto_aead, tfm), e);
5788c2ecf20Sopenharmony_ci
5798c2ecf20Sopenharmony_ci	req = aead_request_alloc(tfm, GFP_KERNEL);
5808c2ecf20Sopenharmony_ci	if (!req) {
5818c2ecf20Sopenharmony_ci		pr_err("alg: aead: Failed to allocate request for %s\n",
5828c2ecf20Sopenharmony_ci		       algo);
5838c2ecf20Sopenharmony_ci		goto out_noreq;
5848c2ecf20Sopenharmony_ci	}
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_ci	aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
5878c2ecf20Sopenharmony_ci				  crypto_req_done, &wait);
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_ci	i = 0;
5908c2ecf20Sopenharmony_ci	do {
5918c2ecf20Sopenharmony_ci		b_size = aead_sizes;
5928c2ecf20Sopenharmony_ci		do {
5938c2ecf20Sopenharmony_ci			assoc = axbuf[0];
5948c2ecf20Sopenharmony_ci			memset(assoc, 0xff, aad_size);
5958c2ecf20Sopenharmony_ci
5968c2ecf20Sopenharmony_ci			if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
5978c2ecf20Sopenharmony_ci				pr_err("template (%u) too big for tvmem (%lu)\n",
5988c2ecf20Sopenharmony_ci				       *keysize + *b_size,
5998c2ecf20Sopenharmony_ci					TVMEMSIZE * PAGE_SIZE);
6008c2ecf20Sopenharmony_ci				goto out;
6018c2ecf20Sopenharmony_ci			}
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_ci			key = tvmem[0];
6048c2ecf20Sopenharmony_ci			for (j = 0; j < tcount; j++) {
6058c2ecf20Sopenharmony_ci				if (template[j].klen == *keysize) {
6068c2ecf20Sopenharmony_ci					key = template[j].key;
6078c2ecf20Sopenharmony_ci					break;
6088c2ecf20Sopenharmony_ci				}
6098c2ecf20Sopenharmony_ci			}
6108c2ecf20Sopenharmony_ci			ret = crypto_aead_setkey(tfm, key, *keysize);
6118c2ecf20Sopenharmony_ci			ret = crypto_aead_setauthsize(tfm, authsize);
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_ci			iv_len = crypto_aead_ivsize(tfm);
6148c2ecf20Sopenharmony_ci			if (iv_len)
6158c2ecf20Sopenharmony_ci				memset(iv, 0xff, iv_len);
6168c2ecf20Sopenharmony_ci
6178c2ecf20Sopenharmony_ci			crypto_aead_clear_flags(tfm, ~0);
6188c2ecf20Sopenharmony_ci			printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ",
6198c2ecf20Sopenharmony_ci					i, *keysize * 8, *b_size);
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ci
6228c2ecf20Sopenharmony_ci			memset(tvmem[0], 0xff, PAGE_SIZE);
6238c2ecf20Sopenharmony_ci
6248c2ecf20Sopenharmony_ci			if (ret) {
6258c2ecf20Sopenharmony_ci				pr_err("setkey() failed flags=%x\n",
6268c2ecf20Sopenharmony_ci						crypto_aead_get_flags(tfm));
6278c2ecf20Sopenharmony_ci				goto out;
6288c2ecf20Sopenharmony_ci			}
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci			sg_init_aead(sg, xbuf, *b_size + (enc ? 0 : authsize),
6318c2ecf20Sopenharmony_ci				     assoc, aad_size);
6328c2ecf20Sopenharmony_ci
6338c2ecf20Sopenharmony_ci			sg_init_aead(sgout, xoutbuf,
6348c2ecf20Sopenharmony_ci				     *b_size + (enc ? authsize : 0), assoc,
6358c2ecf20Sopenharmony_ci				     aad_size);
6368c2ecf20Sopenharmony_ci
6378c2ecf20Sopenharmony_ci			aead_request_set_ad(req, aad_size);
6388c2ecf20Sopenharmony_ci
6398c2ecf20Sopenharmony_ci			if (!enc) {
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci				/*
6428c2ecf20Sopenharmony_ci				 * For decryption we need a proper auth so
6438c2ecf20Sopenharmony_ci				 * we do the encryption path once with buffers
6448c2ecf20Sopenharmony_ci				 * reversed (input <-> output) to calculate it
6458c2ecf20Sopenharmony_ci				 */
6468c2ecf20Sopenharmony_ci				aead_request_set_crypt(req, sgout, sg,
6478c2ecf20Sopenharmony_ci						       *b_size, iv);
6488c2ecf20Sopenharmony_ci				ret = do_one_aead_op(req,
6498c2ecf20Sopenharmony_ci						     crypto_aead_encrypt(req));
6508c2ecf20Sopenharmony_ci
6518c2ecf20Sopenharmony_ci				if (ret) {
6528c2ecf20Sopenharmony_ci					pr_err("calculating auth failed (%d)\n",
6538c2ecf20Sopenharmony_ci					       ret);
6548c2ecf20Sopenharmony_ci					break;
6558c2ecf20Sopenharmony_ci				}
6568c2ecf20Sopenharmony_ci			}
6578c2ecf20Sopenharmony_ci
6588c2ecf20Sopenharmony_ci			aead_request_set_crypt(req, sg, sgout,
6598c2ecf20Sopenharmony_ci					       *b_size + (enc ? 0 : authsize),
6608c2ecf20Sopenharmony_ci					       iv);
6618c2ecf20Sopenharmony_ci
6628c2ecf20Sopenharmony_ci			if (secs) {
6638c2ecf20Sopenharmony_ci				ret = test_aead_jiffies(req, enc, *b_size,
6648c2ecf20Sopenharmony_ci							secs);
6658c2ecf20Sopenharmony_ci				cond_resched();
6668c2ecf20Sopenharmony_ci			} else {
6678c2ecf20Sopenharmony_ci				ret = test_aead_cycles(req, enc, *b_size);
6688c2ecf20Sopenharmony_ci			}
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ci			if (ret) {
6718c2ecf20Sopenharmony_ci				pr_err("%s() failed return code=%d\n", e, ret);
6728c2ecf20Sopenharmony_ci				break;
6738c2ecf20Sopenharmony_ci			}
6748c2ecf20Sopenharmony_ci			b_size++;
6758c2ecf20Sopenharmony_ci			i++;
6768c2ecf20Sopenharmony_ci		} while (*b_size);
6778c2ecf20Sopenharmony_ci		keysize++;
6788c2ecf20Sopenharmony_ci	} while (*keysize);
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ciout:
6818c2ecf20Sopenharmony_ci	aead_request_free(req);
6828c2ecf20Sopenharmony_ciout_noreq:
6838c2ecf20Sopenharmony_ci	crypto_free_aead(tfm);
6848c2ecf20Sopenharmony_ciout_notfm:
6858c2ecf20Sopenharmony_ci	kfree(sg);
6868c2ecf20Sopenharmony_ciout_nosg:
6878c2ecf20Sopenharmony_ci	testmgr_free_buf(xoutbuf);
6888c2ecf20Sopenharmony_ciout_nooutbuf:
6898c2ecf20Sopenharmony_ci	testmgr_free_buf(axbuf);
6908c2ecf20Sopenharmony_ciout_noaxbuf:
6918c2ecf20Sopenharmony_ci	testmgr_free_buf(xbuf);
6928c2ecf20Sopenharmony_ciout_noxbuf:
6938c2ecf20Sopenharmony_ci	kfree(iv);
6948c2ecf20Sopenharmony_ci}
6958c2ecf20Sopenharmony_ci
6968c2ecf20Sopenharmony_cistatic void test_hash_sg_init(struct scatterlist *sg)
6978c2ecf20Sopenharmony_ci{
6988c2ecf20Sopenharmony_ci	int i;
6998c2ecf20Sopenharmony_ci
7008c2ecf20Sopenharmony_ci	sg_init_table(sg, TVMEMSIZE);
7018c2ecf20Sopenharmony_ci	for (i = 0; i < TVMEMSIZE; i++) {
7028c2ecf20Sopenharmony_ci		sg_set_buf(sg + i, tvmem[i], PAGE_SIZE);
7038c2ecf20Sopenharmony_ci		memset(tvmem[i], 0xff, PAGE_SIZE);
7048c2ecf20Sopenharmony_ci	}
7058c2ecf20Sopenharmony_ci}
7068c2ecf20Sopenharmony_ci
7078c2ecf20Sopenharmony_cistatic inline int do_one_ahash_op(struct ahash_request *req, int ret)
7088c2ecf20Sopenharmony_ci{
7098c2ecf20Sopenharmony_ci	struct crypto_wait *wait = req->base.data;
7108c2ecf20Sopenharmony_ci
7118c2ecf20Sopenharmony_ci	return crypto_wait_req(ret, wait);
7128c2ecf20Sopenharmony_ci}
7138c2ecf20Sopenharmony_ci
7148c2ecf20Sopenharmony_cistruct test_mb_ahash_data {
7158c2ecf20Sopenharmony_ci	struct scatterlist sg[XBUFSIZE];
7168c2ecf20Sopenharmony_ci	char result[64];
7178c2ecf20Sopenharmony_ci	struct ahash_request *req;
7188c2ecf20Sopenharmony_ci	struct crypto_wait wait;
7198c2ecf20Sopenharmony_ci	char *xbuf[XBUFSIZE];
7208c2ecf20Sopenharmony_ci};
7218c2ecf20Sopenharmony_ci
7228c2ecf20Sopenharmony_cistatic inline int do_mult_ahash_op(struct test_mb_ahash_data *data, u32 num_mb,
7238c2ecf20Sopenharmony_ci				   int *rc)
7248c2ecf20Sopenharmony_ci{
7258c2ecf20Sopenharmony_ci	int i, err = 0;
7268c2ecf20Sopenharmony_ci
7278c2ecf20Sopenharmony_ci	/* Fire up a bunch of concurrent requests */
7288c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; i++)
7298c2ecf20Sopenharmony_ci		rc[i] = crypto_ahash_digest(data[i].req);
7308c2ecf20Sopenharmony_ci
7318c2ecf20Sopenharmony_ci	/* Wait for all requests to finish */
7328c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; i++) {
7338c2ecf20Sopenharmony_ci		rc[i] = crypto_wait_req(rc[i], &data[i].wait);
7348c2ecf20Sopenharmony_ci
7358c2ecf20Sopenharmony_ci		if (rc[i]) {
7368c2ecf20Sopenharmony_ci			pr_info("concurrent request %d error %d\n", i, rc[i]);
7378c2ecf20Sopenharmony_ci			err = rc[i];
7388c2ecf20Sopenharmony_ci		}
7398c2ecf20Sopenharmony_ci	}
7408c2ecf20Sopenharmony_ci
7418c2ecf20Sopenharmony_ci	return err;
7428c2ecf20Sopenharmony_ci}
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_cistatic int test_mb_ahash_jiffies(struct test_mb_ahash_data *data, int blen,
7458c2ecf20Sopenharmony_ci				 int secs, u32 num_mb)
7468c2ecf20Sopenharmony_ci{
7478c2ecf20Sopenharmony_ci	unsigned long start, end;
7488c2ecf20Sopenharmony_ci	int bcount;
7498c2ecf20Sopenharmony_ci	int ret = 0;
7508c2ecf20Sopenharmony_ci	int *rc;
7518c2ecf20Sopenharmony_ci
7528c2ecf20Sopenharmony_ci	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
7538c2ecf20Sopenharmony_ci	if (!rc)
7548c2ecf20Sopenharmony_ci		return -ENOMEM;
7558c2ecf20Sopenharmony_ci
7568c2ecf20Sopenharmony_ci	for (start = jiffies, end = start + secs * HZ, bcount = 0;
7578c2ecf20Sopenharmony_ci	     time_before(jiffies, end); bcount++) {
7588c2ecf20Sopenharmony_ci		ret = do_mult_ahash_op(data, num_mb, rc);
7598c2ecf20Sopenharmony_ci		if (ret)
7608c2ecf20Sopenharmony_ci			goto out;
7618c2ecf20Sopenharmony_ci	}
7628c2ecf20Sopenharmony_ci
7638c2ecf20Sopenharmony_ci	pr_cont("%d operations in %d seconds (%llu bytes)\n",
7648c2ecf20Sopenharmony_ci		bcount * num_mb, secs, (u64)bcount * blen * num_mb);
7658c2ecf20Sopenharmony_ci
7668c2ecf20Sopenharmony_ciout:
7678c2ecf20Sopenharmony_ci	kfree(rc);
7688c2ecf20Sopenharmony_ci	return ret;
7698c2ecf20Sopenharmony_ci}
7708c2ecf20Sopenharmony_ci
7718c2ecf20Sopenharmony_cistatic int test_mb_ahash_cycles(struct test_mb_ahash_data *data, int blen,
7728c2ecf20Sopenharmony_ci				u32 num_mb)
7738c2ecf20Sopenharmony_ci{
7748c2ecf20Sopenharmony_ci	unsigned long cycles = 0;
7758c2ecf20Sopenharmony_ci	int ret = 0;
7768c2ecf20Sopenharmony_ci	int i;
7778c2ecf20Sopenharmony_ci	int *rc;
7788c2ecf20Sopenharmony_ci
7798c2ecf20Sopenharmony_ci	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
7808c2ecf20Sopenharmony_ci	if (!rc)
7818c2ecf20Sopenharmony_ci		return -ENOMEM;
7828c2ecf20Sopenharmony_ci
7838c2ecf20Sopenharmony_ci	/* Warm-up run. */
7848c2ecf20Sopenharmony_ci	for (i = 0; i < 4; i++) {
7858c2ecf20Sopenharmony_ci		ret = do_mult_ahash_op(data, num_mb, rc);
7868c2ecf20Sopenharmony_ci		if (ret)
7878c2ecf20Sopenharmony_ci			goto out;
7888c2ecf20Sopenharmony_ci	}
7898c2ecf20Sopenharmony_ci
7908c2ecf20Sopenharmony_ci	/* The real thing. */
7918c2ecf20Sopenharmony_ci	for (i = 0; i < 8; i++) {
7928c2ecf20Sopenharmony_ci		cycles_t start, end;
7938c2ecf20Sopenharmony_ci
7948c2ecf20Sopenharmony_ci		start = get_cycles();
7958c2ecf20Sopenharmony_ci		ret = do_mult_ahash_op(data, num_mb, rc);
7968c2ecf20Sopenharmony_ci		end = get_cycles();
7978c2ecf20Sopenharmony_ci
7988c2ecf20Sopenharmony_ci		if (ret)
7998c2ecf20Sopenharmony_ci			goto out;
8008c2ecf20Sopenharmony_ci
8018c2ecf20Sopenharmony_ci		cycles += end - start;
8028c2ecf20Sopenharmony_ci	}
8038c2ecf20Sopenharmony_ci
8048c2ecf20Sopenharmony_ci	pr_cont("1 operation in %lu cycles (%d bytes)\n",
8058c2ecf20Sopenharmony_ci		(cycles + 4) / (8 * num_mb), blen);
8068c2ecf20Sopenharmony_ci
8078c2ecf20Sopenharmony_ciout:
8088c2ecf20Sopenharmony_ci	kfree(rc);
8098c2ecf20Sopenharmony_ci	return ret;
8108c2ecf20Sopenharmony_ci}
8118c2ecf20Sopenharmony_ci
8128c2ecf20Sopenharmony_cistatic void test_mb_ahash_speed(const char *algo, unsigned int secs,
8138c2ecf20Sopenharmony_ci				struct hash_speed *speed, u32 num_mb)
8148c2ecf20Sopenharmony_ci{
8158c2ecf20Sopenharmony_ci	struct test_mb_ahash_data *data;
8168c2ecf20Sopenharmony_ci	struct crypto_ahash *tfm;
8178c2ecf20Sopenharmony_ci	unsigned int i, j, k;
8188c2ecf20Sopenharmony_ci	int ret;
8198c2ecf20Sopenharmony_ci
8208c2ecf20Sopenharmony_ci	data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
8218c2ecf20Sopenharmony_ci	if (!data)
8228c2ecf20Sopenharmony_ci		return;
8238c2ecf20Sopenharmony_ci
8248c2ecf20Sopenharmony_ci	tfm = crypto_alloc_ahash(algo, 0, 0);
8258c2ecf20Sopenharmony_ci	if (IS_ERR(tfm)) {
8268c2ecf20Sopenharmony_ci		pr_err("failed to load transform for %s: %ld\n",
8278c2ecf20Sopenharmony_ci			algo, PTR_ERR(tfm));
8288c2ecf20Sopenharmony_ci		goto free_data;
8298c2ecf20Sopenharmony_ci	}
8308c2ecf20Sopenharmony_ci
8318c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i) {
8328c2ecf20Sopenharmony_ci		if (testmgr_alloc_buf(data[i].xbuf))
8338c2ecf20Sopenharmony_ci			goto out;
8348c2ecf20Sopenharmony_ci
8358c2ecf20Sopenharmony_ci		crypto_init_wait(&data[i].wait);
8368c2ecf20Sopenharmony_ci
8378c2ecf20Sopenharmony_ci		data[i].req = ahash_request_alloc(tfm, GFP_KERNEL);
8388c2ecf20Sopenharmony_ci		if (!data[i].req) {
8398c2ecf20Sopenharmony_ci			pr_err("alg: hash: Failed to allocate request for %s\n",
8408c2ecf20Sopenharmony_ci			       algo);
8418c2ecf20Sopenharmony_ci			goto out;
8428c2ecf20Sopenharmony_ci		}
8438c2ecf20Sopenharmony_ci
8448c2ecf20Sopenharmony_ci		ahash_request_set_callback(data[i].req, 0, crypto_req_done,
8458c2ecf20Sopenharmony_ci					   &data[i].wait);
8468c2ecf20Sopenharmony_ci
8478c2ecf20Sopenharmony_ci		sg_init_table(data[i].sg, XBUFSIZE);
8488c2ecf20Sopenharmony_ci		for (j = 0; j < XBUFSIZE; j++) {
8498c2ecf20Sopenharmony_ci			sg_set_buf(data[i].sg + j, data[i].xbuf[j], PAGE_SIZE);
8508c2ecf20Sopenharmony_ci			memset(data[i].xbuf[j], 0xff, PAGE_SIZE);
8518c2ecf20Sopenharmony_ci		}
8528c2ecf20Sopenharmony_ci	}
8538c2ecf20Sopenharmony_ci
8548c2ecf20Sopenharmony_ci	pr_info("\ntesting speed of multibuffer %s (%s)\n", algo,
8558c2ecf20Sopenharmony_ci		get_driver_name(crypto_ahash, tfm));
8568c2ecf20Sopenharmony_ci
8578c2ecf20Sopenharmony_ci	for (i = 0; speed[i].blen != 0; i++) {
8588c2ecf20Sopenharmony_ci		/* For some reason this only tests digests. */
8598c2ecf20Sopenharmony_ci		if (speed[i].blen != speed[i].plen)
8608c2ecf20Sopenharmony_ci			continue;
8618c2ecf20Sopenharmony_ci
8628c2ecf20Sopenharmony_ci		if (speed[i].blen > XBUFSIZE * PAGE_SIZE) {
8638c2ecf20Sopenharmony_ci			pr_err("template (%u) too big for tvmem (%lu)\n",
8648c2ecf20Sopenharmony_ci			       speed[i].blen, XBUFSIZE * PAGE_SIZE);
8658c2ecf20Sopenharmony_ci			goto out;
8668c2ecf20Sopenharmony_ci		}
8678c2ecf20Sopenharmony_ci
8688c2ecf20Sopenharmony_ci		if (klen)
8698c2ecf20Sopenharmony_ci			crypto_ahash_setkey(tfm, tvmem[0], klen);
8708c2ecf20Sopenharmony_ci
8718c2ecf20Sopenharmony_ci		for (k = 0; k < num_mb; k++)
8728c2ecf20Sopenharmony_ci			ahash_request_set_crypt(data[k].req, data[k].sg,
8738c2ecf20Sopenharmony_ci						data[k].result, speed[i].blen);
8748c2ecf20Sopenharmony_ci
8758c2ecf20Sopenharmony_ci		pr_info("test%3u "
8768c2ecf20Sopenharmony_ci			"(%5u byte blocks,%5u bytes per update,%4u updates): ",
8778c2ecf20Sopenharmony_ci			i, speed[i].blen, speed[i].plen,
8788c2ecf20Sopenharmony_ci			speed[i].blen / speed[i].plen);
8798c2ecf20Sopenharmony_ci
8808c2ecf20Sopenharmony_ci		if (secs) {
8818c2ecf20Sopenharmony_ci			ret = test_mb_ahash_jiffies(data, speed[i].blen, secs,
8828c2ecf20Sopenharmony_ci						    num_mb);
8838c2ecf20Sopenharmony_ci			cond_resched();
8848c2ecf20Sopenharmony_ci		} else {
8858c2ecf20Sopenharmony_ci			ret = test_mb_ahash_cycles(data, speed[i].blen, num_mb);
8868c2ecf20Sopenharmony_ci		}
8878c2ecf20Sopenharmony_ci
8888c2ecf20Sopenharmony_ci
8898c2ecf20Sopenharmony_ci		if (ret) {
8908c2ecf20Sopenharmony_ci			pr_err("At least one hashing failed ret=%d\n", ret);
8918c2ecf20Sopenharmony_ci			break;
8928c2ecf20Sopenharmony_ci		}
8938c2ecf20Sopenharmony_ci	}
8948c2ecf20Sopenharmony_ci
8958c2ecf20Sopenharmony_ciout:
8968c2ecf20Sopenharmony_ci	for (k = 0; k < num_mb; ++k)
8978c2ecf20Sopenharmony_ci		ahash_request_free(data[k].req);
8988c2ecf20Sopenharmony_ci
8998c2ecf20Sopenharmony_ci	for (k = 0; k < num_mb; ++k)
9008c2ecf20Sopenharmony_ci		testmgr_free_buf(data[k].xbuf);
9018c2ecf20Sopenharmony_ci
9028c2ecf20Sopenharmony_ci	crypto_free_ahash(tfm);
9038c2ecf20Sopenharmony_ci
9048c2ecf20Sopenharmony_cifree_data:
9058c2ecf20Sopenharmony_ci	kfree(data);
9068c2ecf20Sopenharmony_ci}
9078c2ecf20Sopenharmony_ci
9088c2ecf20Sopenharmony_cistatic int test_ahash_jiffies_digest(struct ahash_request *req, int blen,
9098c2ecf20Sopenharmony_ci				     char *out, int secs)
9108c2ecf20Sopenharmony_ci{
9118c2ecf20Sopenharmony_ci	unsigned long start, end;
9128c2ecf20Sopenharmony_ci	int bcount;
9138c2ecf20Sopenharmony_ci	int ret;
9148c2ecf20Sopenharmony_ci
9158c2ecf20Sopenharmony_ci	for (start = jiffies, end = start + secs * HZ, bcount = 0;
9168c2ecf20Sopenharmony_ci	     time_before(jiffies, end); bcount++) {
9178c2ecf20Sopenharmony_ci		ret = do_one_ahash_op(req, crypto_ahash_digest(req));
9188c2ecf20Sopenharmony_ci		if (ret)
9198c2ecf20Sopenharmony_ci			return ret;
9208c2ecf20Sopenharmony_ci	}
9218c2ecf20Sopenharmony_ci
9228c2ecf20Sopenharmony_ci	printk("%6u opers/sec, %9lu bytes/sec\n",
9238c2ecf20Sopenharmony_ci	       bcount / secs, ((long)bcount * blen) / secs);
9248c2ecf20Sopenharmony_ci
9258c2ecf20Sopenharmony_ci	return 0;
9268c2ecf20Sopenharmony_ci}
9278c2ecf20Sopenharmony_ci
9288c2ecf20Sopenharmony_cistatic int test_ahash_jiffies(struct ahash_request *req, int blen,
9298c2ecf20Sopenharmony_ci			      int plen, char *out, int secs)
9308c2ecf20Sopenharmony_ci{
9318c2ecf20Sopenharmony_ci	unsigned long start, end;
9328c2ecf20Sopenharmony_ci	int bcount, pcount;
9338c2ecf20Sopenharmony_ci	int ret;
9348c2ecf20Sopenharmony_ci
9358c2ecf20Sopenharmony_ci	if (plen == blen)
9368c2ecf20Sopenharmony_ci		return test_ahash_jiffies_digest(req, blen, out, secs);
9378c2ecf20Sopenharmony_ci
9388c2ecf20Sopenharmony_ci	for (start = jiffies, end = start + secs * HZ, bcount = 0;
9398c2ecf20Sopenharmony_ci	     time_before(jiffies, end); bcount++) {
9408c2ecf20Sopenharmony_ci		ret = do_one_ahash_op(req, crypto_ahash_init(req));
9418c2ecf20Sopenharmony_ci		if (ret)
9428c2ecf20Sopenharmony_ci			return ret;
9438c2ecf20Sopenharmony_ci		for (pcount = 0; pcount < blen; pcount += plen) {
9448c2ecf20Sopenharmony_ci			ret = do_one_ahash_op(req, crypto_ahash_update(req));
9458c2ecf20Sopenharmony_ci			if (ret)
9468c2ecf20Sopenharmony_ci				return ret;
9478c2ecf20Sopenharmony_ci		}
9488c2ecf20Sopenharmony_ci		/* we assume there is enough space in 'out' for the result */
9498c2ecf20Sopenharmony_ci		ret = do_one_ahash_op(req, crypto_ahash_final(req));
9508c2ecf20Sopenharmony_ci		if (ret)
9518c2ecf20Sopenharmony_ci			return ret;
9528c2ecf20Sopenharmony_ci	}
9538c2ecf20Sopenharmony_ci
9548c2ecf20Sopenharmony_ci	pr_cont("%6u opers/sec, %9lu bytes/sec\n",
9558c2ecf20Sopenharmony_ci		bcount / secs, ((long)bcount * blen) / secs);
9568c2ecf20Sopenharmony_ci
9578c2ecf20Sopenharmony_ci	return 0;
9588c2ecf20Sopenharmony_ci}
9598c2ecf20Sopenharmony_ci
9608c2ecf20Sopenharmony_cistatic int test_ahash_cycles_digest(struct ahash_request *req, int blen,
9618c2ecf20Sopenharmony_ci				    char *out)
9628c2ecf20Sopenharmony_ci{
9638c2ecf20Sopenharmony_ci	unsigned long cycles = 0;
9648c2ecf20Sopenharmony_ci	int ret, i;
9658c2ecf20Sopenharmony_ci
9668c2ecf20Sopenharmony_ci	/* Warm-up run. */
9678c2ecf20Sopenharmony_ci	for (i = 0; i < 4; i++) {
9688c2ecf20Sopenharmony_ci		ret = do_one_ahash_op(req, crypto_ahash_digest(req));
9698c2ecf20Sopenharmony_ci		if (ret)
9708c2ecf20Sopenharmony_ci			goto out;
9718c2ecf20Sopenharmony_ci	}
9728c2ecf20Sopenharmony_ci
9738c2ecf20Sopenharmony_ci	/* The real thing. */
9748c2ecf20Sopenharmony_ci	for (i = 0; i < 8; i++) {
9758c2ecf20Sopenharmony_ci		cycles_t start, end;
9768c2ecf20Sopenharmony_ci
9778c2ecf20Sopenharmony_ci		start = get_cycles();
9788c2ecf20Sopenharmony_ci
9798c2ecf20Sopenharmony_ci		ret = do_one_ahash_op(req, crypto_ahash_digest(req));
9808c2ecf20Sopenharmony_ci		if (ret)
9818c2ecf20Sopenharmony_ci			goto out;
9828c2ecf20Sopenharmony_ci
9838c2ecf20Sopenharmony_ci		end = get_cycles();
9848c2ecf20Sopenharmony_ci
9858c2ecf20Sopenharmony_ci		cycles += end - start;
9868c2ecf20Sopenharmony_ci	}
9878c2ecf20Sopenharmony_ci
9888c2ecf20Sopenharmony_ciout:
9898c2ecf20Sopenharmony_ci	if (ret)
9908c2ecf20Sopenharmony_ci		return ret;
9918c2ecf20Sopenharmony_ci
9928c2ecf20Sopenharmony_ci	pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
9938c2ecf20Sopenharmony_ci		cycles / 8, cycles / (8 * blen));
9948c2ecf20Sopenharmony_ci
9958c2ecf20Sopenharmony_ci	return 0;
9968c2ecf20Sopenharmony_ci}
9978c2ecf20Sopenharmony_ci
9988c2ecf20Sopenharmony_cistatic int test_ahash_cycles(struct ahash_request *req, int blen,
9998c2ecf20Sopenharmony_ci			     int plen, char *out)
10008c2ecf20Sopenharmony_ci{
10018c2ecf20Sopenharmony_ci	unsigned long cycles = 0;
10028c2ecf20Sopenharmony_ci	int i, pcount, ret;
10038c2ecf20Sopenharmony_ci
10048c2ecf20Sopenharmony_ci	if (plen == blen)
10058c2ecf20Sopenharmony_ci		return test_ahash_cycles_digest(req, blen, out);
10068c2ecf20Sopenharmony_ci
10078c2ecf20Sopenharmony_ci	/* Warm-up run. */
10088c2ecf20Sopenharmony_ci	for (i = 0; i < 4; i++) {
10098c2ecf20Sopenharmony_ci		ret = do_one_ahash_op(req, crypto_ahash_init(req));
10108c2ecf20Sopenharmony_ci		if (ret)
10118c2ecf20Sopenharmony_ci			goto out;
10128c2ecf20Sopenharmony_ci		for (pcount = 0; pcount < blen; pcount += plen) {
10138c2ecf20Sopenharmony_ci			ret = do_one_ahash_op(req, crypto_ahash_update(req));
10148c2ecf20Sopenharmony_ci			if (ret)
10158c2ecf20Sopenharmony_ci				goto out;
10168c2ecf20Sopenharmony_ci		}
10178c2ecf20Sopenharmony_ci		ret = do_one_ahash_op(req, crypto_ahash_final(req));
10188c2ecf20Sopenharmony_ci		if (ret)
10198c2ecf20Sopenharmony_ci			goto out;
10208c2ecf20Sopenharmony_ci	}
10218c2ecf20Sopenharmony_ci
10228c2ecf20Sopenharmony_ci	/* The real thing. */
10238c2ecf20Sopenharmony_ci	for (i = 0; i < 8; i++) {
10248c2ecf20Sopenharmony_ci		cycles_t start, end;
10258c2ecf20Sopenharmony_ci
10268c2ecf20Sopenharmony_ci		start = get_cycles();
10278c2ecf20Sopenharmony_ci
10288c2ecf20Sopenharmony_ci		ret = do_one_ahash_op(req, crypto_ahash_init(req));
10298c2ecf20Sopenharmony_ci		if (ret)
10308c2ecf20Sopenharmony_ci			goto out;
10318c2ecf20Sopenharmony_ci		for (pcount = 0; pcount < blen; pcount += plen) {
10328c2ecf20Sopenharmony_ci			ret = do_one_ahash_op(req, crypto_ahash_update(req));
10338c2ecf20Sopenharmony_ci			if (ret)
10348c2ecf20Sopenharmony_ci				goto out;
10358c2ecf20Sopenharmony_ci		}
10368c2ecf20Sopenharmony_ci		ret = do_one_ahash_op(req, crypto_ahash_final(req));
10378c2ecf20Sopenharmony_ci		if (ret)
10388c2ecf20Sopenharmony_ci			goto out;
10398c2ecf20Sopenharmony_ci
10408c2ecf20Sopenharmony_ci		end = get_cycles();
10418c2ecf20Sopenharmony_ci
10428c2ecf20Sopenharmony_ci		cycles += end - start;
10438c2ecf20Sopenharmony_ci	}
10448c2ecf20Sopenharmony_ci
10458c2ecf20Sopenharmony_ciout:
10468c2ecf20Sopenharmony_ci	if (ret)
10478c2ecf20Sopenharmony_ci		return ret;
10488c2ecf20Sopenharmony_ci
10498c2ecf20Sopenharmony_ci	pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
10508c2ecf20Sopenharmony_ci		cycles / 8, cycles / (8 * blen));
10518c2ecf20Sopenharmony_ci
10528c2ecf20Sopenharmony_ci	return 0;
10538c2ecf20Sopenharmony_ci}
10548c2ecf20Sopenharmony_ci
10558c2ecf20Sopenharmony_cistatic void test_ahash_speed_common(const char *algo, unsigned int secs,
10568c2ecf20Sopenharmony_ci				    struct hash_speed *speed, unsigned mask)
10578c2ecf20Sopenharmony_ci{
10588c2ecf20Sopenharmony_ci	struct scatterlist sg[TVMEMSIZE];
10598c2ecf20Sopenharmony_ci	struct crypto_wait wait;
10608c2ecf20Sopenharmony_ci	struct ahash_request *req;
10618c2ecf20Sopenharmony_ci	struct crypto_ahash *tfm;
10628c2ecf20Sopenharmony_ci	char *output;
10638c2ecf20Sopenharmony_ci	int i, ret;
10648c2ecf20Sopenharmony_ci
10658c2ecf20Sopenharmony_ci	tfm = crypto_alloc_ahash(algo, 0, mask);
10668c2ecf20Sopenharmony_ci	if (IS_ERR(tfm)) {
10678c2ecf20Sopenharmony_ci		pr_err("failed to load transform for %s: %ld\n",
10688c2ecf20Sopenharmony_ci		       algo, PTR_ERR(tfm));
10698c2ecf20Sopenharmony_ci		return;
10708c2ecf20Sopenharmony_ci	}
10718c2ecf20Sopenharmony_ci
10728c2ecf20Sopenharmony_ci	printk(KERN_INFO "\ntesting speed of async %s (%s)\n", algo,
10738c2ecf20Sopenharmony_ci			get_driver_name(crypto_ahash, tfm));
10748c2ecf20Sopenharmony_ci
10758c2ecf20Sopenharmony_ci	if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) {
10768c2ecf20Sopenharmony_ci		pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm),
10778c2ecf20Sopenharmony_ci		       MAX_DIGEST_SIZE);
10788c2ecf20Sopenharmony_ci		goto out;
10798c2ecf20Sopenharmony_ci	}
10808c2ecf20Sopenharmony_ci
10818c2ecf20Sopenharmony_ci	test_hash_sg_init(sg);
10828c2ecf20Sopenharmony_ci	req = ahash_request_alloc(tfm, GFP_KERNEL);
10838c2ecf20Sopenharmony_ci	if (!req) {
10848c2ecf20Sopenharmony_ci		pr_err("ahash request allocation failure\n");
10858c2ecf20Sopenharmony_ci		goto out;
10868c2ecf20Sopenharmony_ci	}
10878c2ecf20Sopenharmony_ci
10888c2ecf20Sopenharmony_ci	crypto_init_wait(&wait);
10898c2ecf20Sopenharmony_ci	ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
10908c2ecf20Sopenharmony_ci				   crypto_req_done, &wait);
10918c2ecf20Sopenharmony_ci
10928c2ecf20Sopenharmony_ci	output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL);
10938c2ecf20Sopenharmony_ci	if (!output)
10948c2ecf20Sopenharmony_ci		goto out_nomem;
10958c2ecf20Sopenharmony_ci
10968c2ecf20Sopenharmony_ci	for (i = 0; speed[i].blen != 0; i++) {
10978c2ecf20Sopenharmony_ci		if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
10988c2ecf20Sopenharmony_ci			pr_err("template (%u) too big for tvmem (%lu)\n",
10998c2ecf20Sopenharmony_ci			       speed[i].blen, TVMEMSIZE * PAGE_SIZE);
11008c2ecf20Sopenharmony_ci			break;
11018c2ecf20Sopenharmony_ci		}
11028c2ecf20Sopenharmony_ci
11038c2ecf20Sopenharmony_ci		if (klen)
11048c2ecf20Sopenharmony_ci			crypto_ahash_setkey(tfm, tvmem[0], klen);
11058c2ecf20Sopenharmony_ci
11068c2ecf20Sopenharmony_ci		pr_info("test%3u "
11078c2ecf20Sopenharmony_ci			"(%5u byte blocks,%5u bytes per update,%4u updates): ",
11088c2ecf20Sopenharmony_ci			i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
11098c2ecf20Sopenharmony_ci
11108c2ecf20Sopenharmony_ci		ahash_request_set_crypt(req, sg, output, speed[i].plen);
11118c2ecf20Sopenharmony_ci
11128c2ecf20Sopenharmony_ci		if (secs) {
11138c2ecf20Sopenharmony_ci			ret = test_ahash_jiffies(req, speed[i].blen,
11148c2ecf20Sopenharmony_ci						 speed[i].plen, output, secs);
11158c2ecf20Sopenharmony_ci			cond_resched();
11168c2ecf20Sopenharmony_ci		} else {
11178c2ecf20Sopenharmony_ci			ret = test_ahash_cycles(req, speed[i].blen,
11188c2ecf20Sopenharmony_ci						speed[i].plen, output);
11198c2ecf20Sopenharmony_ci		}
11208c2ecf20Sopenharmony_ci
11218c2ecf20Sopenharmony_ci		if (ret) {
11228c2ecf20Sopenharmony_ci			pr_err("hashing failed ret=%d\n", ret);
11238c2ecf20Sopenharmony_ci			break;
11248c2ecf20Sopenharmony_ci		}
11258c2ecf20Sopenharmony_ci	}
11268c2ecf20Sopenharmony_ci
11278c2ecf20Sopenharmony_ci	kfree(output);
11288c2ecf20Sopenharmony_ci
11298c2ecf20Sopenharmony_ciout_nomem:
11308c2ecf20Sopenharmony_ci	ahash_request_free(req);
11318c2ecf20Sopenharmony_ci
11328c2ecf20Sopenharmony_ciout:
11338c2ecf20Sopenharmony_ci	crypto_free_ahash(tfm);
11348c2ecf20Sopenharmony_ci}
11358c2ecf20Sopenharmony_ci
11368c2ecf20Sopenharmony_cistatic void test_ahash_speed(const char *algo, unsigned int secs,
11378c2ecf20Sopenharmony_ci			     struct hash_speed *speed)
11388c2ecf20Sopenharmony_ci{
11398c2ecf20Sopenharmony_ci	return test_ahash_speed_common(algo, secs, speed, 0);
11408c2ecf20Sopenharmony_ci}
11418c2ecf20Sopenharmony_ci
11428c2ecf20Sopenharmony_cistatic void test_hash_speed(const char *algo, unsigned int secs,
11438c2ecf20Sopenharmony_ci			    struct hash_speed *speed)
11448c2ecf20Sopenharmony_ci{
11458c2ecf20Sopenharmony_ci	return test_ahash_speed_common(algo, secs, speed, CRYPTO_ALG_ASYNC);
11468c2ecf20Sopenharmony_ci}
11478c2ecf20Sopenharmony_ci
11488c2ecf20Sopenharmony_cistruct test_mb_skcipher_data {
11498c2ecf20Sopenharmony_ci	struct scatterlist sg[XBUFSIZE];
11508c2ecf20Sopenharmony_ci	struct skcipher_request *req;
11518c2ecf20Sopenharmony_ci	struct crypto_wait wait;
11528c2ecf20Sopenharmony_ci	char *xbuf[XBUFSIZE];
11538c2ecf20Sopenharmony_ci};
11548c2ecf20Sopenharmony_ci
11558c2ecf20Sopenharmony_cistatic int do_mult_acipher_op(struct test_mb_skcipher_data *data, int enc,
11568c2ecf20Sopenharmony_ci				u32 num_mb, int *rc)
11578c2ecf20Sopenharmony_ci{
11588c2ecf20Sopenharmony_ci	int i, err = 0;
11598c2ecf20Sopenharmony_ci
11608c2ecf20Sopenharmony_ci	/* Fire up a bunch of concurrent requests */
11618c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; i++) {
11628c2ecf20Sopenharmony_ci		if (enc == ENCRYPT)
11638c2ecf20Sopenharmony_ci			rc[i] = crypto_skcipher_encrypt(data[i].req);
11648c2ecf20Sopenharmony_ci		else
11658c2ecf20Sopenharmony_ci			rc[i] = crypto_skcipher_decrypt(data[i].req);
11668c2ecf20Sopenharmony_ci	}
11678c2ecf20Sopenharmony_ci
11688c2ecf20Sopenharmony_ci	/* Wait for all requests to finish */
11698c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; i++) {
11708c2ecf20Sopenharmony_ci		rc[i] = crypto_wait_req(rc[i], &data[i].wait);
11718c2ecf20Sopenharmony_ci
11728c2ecf20Sopenharmony_ci		if (rc[i]) {
11738c2ecf20Sopenharmony_ci			pr_info("concurrent request %d error %d\n", i, rc[i]);
11748c2ecf20Sopenharmony_ci			err = rc[i];
11758c2ecf20Sopenharmony_ci		}
11768c2ecf20Sopenharmony_ci	}
11778c2ecf20Sopenharmony_ci
11788c2ecf20Sopenharmony_ci	return err;
11798c2ecf20Sopenharmony_ci}
11808c2ecf20Sopenharmony_ci
11818c2ecf20Sopenharmony_cistatic int test_mb_acipher_jiffies(struct test_mb_skcipher_data *data, int enc,
11828c2ecf20Sopenharmony_ci				int blen, int secs, u32 num_mb)
11838c2ecf20Sopenharmony_ci{
11848c2ecf20Sopenharmony_ci	unsigned long start, end;
11858c2ecf20Sopenharmony_ci	int bcount;
11868c2ecf20Sopenharmony_ci	int ret = 0;
11878c2ecf20Sopenharmony_ci	int *rc;
11888c2ecf20Sopenharmony_ci
11898c2ecf20Sopenharmony_ci	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
11908c2ecf20Sopenharmony_ci	if (!rc)
11918c2ecf20Sopenharmony_ci		return -ENOMEM;
11928c2ecf20Sopenharmony_ci
11938c2ecf20Sopenharmony_ci	for (start = jiffies, end = start + secs * HZ, bcount = 0;
11948c2ecf20Sopenharmony_ci	     time_before(jiffies, end); bcount++) {
11958c2ecf20Sopenharmony_ci		ret = do_mult_acipher_op(data, enc, num_mb, rc);
11968c2ecf20Sopenharmony_ci		if (ret)
11978c2ecf20Sopenharmony_ci			goto out;
11988c2ecf20Sopenharmony_ci	}
11998c2ecf20Sopenharmony_ci
12008c2ecf20Sopenharmony_ci	pr_cont("%d operations in %d seconds (%llu bytes)\n",
12018c2ecf20Sopenharmony_ci		bcount * num_mb, secs, (u64)bcount * blen * num_mb);
12028c2ecf20Sopenharmony_ci
12038c2ecf20Sopenharmony_ciout:
12048c2ecf20Sopenharmony_ci	kfree(rc);
12058c2ecf20Sopenharmony_ci	return ret;
12068c2ecf20Sopenharmony_ci}
12078c2ecf20Sopenharmony_ci
12088c2ecf20Sopenharmony_cistatic int test_mb_acipher_cycles(struct test_mb_skcipher_data *data, int enc,
12098c2ecf20Sopenharmony_ci			       int blen, u32 num_mb)
12108c2ecf20Sopenharmony_ci{
12118c2ecf20Sopenharmony_ci	unsigned long cycles = 0;
12128c2ecf20Sopenharmony_ci	int ret = 0;
12138c2ecf20Sopenharmony_ci	int i;
12148c2ecf20Sopenharmony_ci	int *rc;
12158c2ecf20Sopenharmony_ci
12168c2ecf20Sopenharmony_ci	rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
12178c2ecf20Sopenharmony_ci	if (!rc)
12188c2ecf20Sopenharmony_ci		return -ENOMEM;
12198c2ecf20Sopenharmony_ci
12208c2ecf20Sopenharmony_ci	/* Warm-up run. */
12218c2ecf20Sopenharmony_ci	for (i = 0; i < 4; i++) {
12228c2ecf20Sopenharmony_ci		ret = do_mult_acipher_op(data, enc, num_mb, rc);
12238c2ecf20Sopenharmony_ci		if (ret)
12248c2ecf20Sopenharmony_ci			goto out;
12258c2ecf20Sopenharmony_ci	}
12268c2ecf20Sopenharmony_ci
12278c2ecf20Sopenharmony_ci	/* The real thing. */
12288c2ecf20Sopenharmony_ci	for (i = 0; i < 8; i++) {
12298c2ecf20Sopenharmony_ci		cycles_t start, end;
12308c2ecf20Sopenharmony_ci
12318c2ecf20Sopenharmony_ci		start = get_cycles();
12328c2ecf20Sopenharmony_ci		ret = do_mult_acipher_op(data, enc, num_mb, rc);
12338c2ecf20Sopenharmony_ci		end = get_cycles();
12348c2ecf20Sopenharmony_ci
12358c2ecf20Sopenharmony_ci		if (ret)
12368c2ecf20Sopenharmony_ci			goto out;
12378c2ecf20Sopenharmony_ci
12388c2ecf20Sopenharmony_ci		cycles += end - start;
12398c2ecf20Sopenharmony_ci	}
12408c2ecf20Sopenharmony_ci
12418c2ecf20Sopenharmony_ci	pr_cont("1 operation in %lu cycles (%d bytes)\n",
12428c2ecf20Sopenharmony_ci		(cycles + 4) / (8 * num_mb), blen);
12438c2ecf20Sopenharmony_ci
12448c2ecf20Sopenharmony_ciout:
12458c2ecf20Sopenharmony_ci	kfree(rc);
12468c2ecf20Sopenharmony_ci	return ret;
12478c2ecf20Sopenharmony_ci}
12488c2ecf20Sopenharmony_ci
12498c2ecf20Sopenharmony_cistatic void test_mb_skcipher_speed(const char *algo, int enc, int secs,
12508c2ecf20Sopenharmony_ci				   struct cipher_speed_template *template,
12518c2ecf20Sopenharmony_ci				   unsigned int tcount, u8 *keysize, u32 num_mb)
12528c2ecf20Sopenharmony_ci{
12538c2ecf20Sopenharmony_ci	struct test_mb_skcipher_data *data;
12548c2ecf20Sopenharmony_ci	struct crypto_skcipher *tfm;
12558c2ecf20Sopenharmony_ci	unsigned int i, j, iv_len;
12568c2ecf20Sopenharmony_ci	const char *key;
12578c2ecf20Sopenharmony_ci	const char *e;
12588c2ecf20Sopenharmony_ci	u32 *b_size;
12598c2ecf20Sopenharmony_ci	char iv[128];
12608c2ecf20Sopenharmony_ci	int ret;
12618c2ecf20Sopenharmony_ci
12628c2ecf20Sopenharmony_ci	if (enc == ENCRYPT)
12638c2ecf20Sopenharmony_ci		e = "encryption";
12648c2ecf20Sopenharmony_ci	else
12658c2ecf20Sopenharmony_ci		e = "decryption";
12668c2ecf20Sopenharmony_ci
12678c2ecf20Sopenharmony_ci	data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
12688c2ecf20Sopenharmony_ci	if (!data)
12698c2ecf20Sopenharmony_ci		return;
12708c2ecf20Sopenharmony_ci
12718c2ecf20Sopenharmony_ci	tfm = crypto_alloc_skcipher(algo, 0, 0);
12728c2ecf20Sopenharmony_ci	if (IS_ERR(tfm)) {
12738c2ecf20Sopenharmony_ci		pr_err("failed to load transform for %s: %ld\n",
12748c2ecf20Sopenharmony_ci			algo, PTR_ERR(tfm));
12758c2ecf20Sopenharmony_ci		goto out_free_data;
12768c2ecf20Sopenharmony_ci	}
12778c2ecf20Sopenharmony_ci
12788c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i)
12798c2ecf20Sopenharmony_ci		if (testmgr_alloc_buf(data[i].xbuf)) {
12808c2ecf20Sopenharmony_ci			while (i--)
12818c2ecf20Sopenharmony_ci				testmgr_free_buf(data[i].xbuf);
12828c2ecf20Sopenharmony_ci			goto out_free_tfm;
12838c2ecf20Sopenharmony_ci		}
12848c2ecf20Sopenharmony_ci
12858c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i) {
12868c2ecf20Sopenharmony_ci		data[i].req = skcipher_request_alloc(tfm, GFP_KERNEL);
12878c2ecf20Sopenharmony_ci		if (!data[i].req) {
12888c2ecf20Sopenharmony_ci			pr_err("alg: skcipher: Failed to allocate request for %s\n",
12898c2ecf20Sopenharmony_ci			       algo);
12908c2ecf20Sopenharmony_ci			while (i--)
12918c2ecf20Sopenharmony_ci				skcipher_request_free(data[i].req);
12928c2ecf20Sopenharmony_ci			goto out_free_xbuf;
12938c2ecf20Sopenharmony_ci		}
12948c2ecf20Sopenharmony_ci	}
12958c2ecf20Sopenharmony_ci
12968c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i) {
12978c2ecf20Sopenharmony_ci		skcipher_request_set_callback(data[i].req,
12988c2ecf20Sopenharmony_ci					      CRYPTO_TFM_REQ_MAY_BACKLOG,
12998c2ecf20Sopenharmony_ci					      crypto_req_done, &data[i].wait);
13008c2ecf20Sopenharmony_ci		crypto_init_wait(&data[i].wait);
13018c2ecf20Sopenharmony_ci	}
13028c2ecf20Sopenharmony_ci
13038c2ecf20Sopenharmony_ci	pr_info("\ntesting speed of multibuffer %s (%s) %s\n", algo,
13048c2ecf20Sopenharmony_ci		get_driver_name(crypto_skcipher, tfm), e);
13058c2ecf20Sopenharmony_ci
13068c2ecf20Sopenharmony_ci	i = 0;
13078c2ecf20Sopenharmony_ci	do {
13088c2ecf20Sopenharmony_ci		b_size = block_sizes;
13098c2ecf20Sopenharmony_ci		do {
13108c2ecf20Sopenharmony_ci			if (*b_size > XBUFSIZE * PAGE_SIZE) {
13118c2ecf20Sopenharmony_ci				pr_err("template (%u) too big for buffer (%lu)\n",
13128c2ecf20Sopenharmony_ci				       *b_size, XBUFSIZE * PAGE_SIZE);
13138c2ecf20Sopenharmony_ci				goto out;
13148c2ecf20Sopenharmony_ci			}
13158c2ecf20Sopenharmony_ci
13168c2ecf20Sopenharmony_ci			pr_info("test %u (%d bit key, %d byte blocks): ", i,
13178c2ecf20Sopenharmony_ci				*keysize * 8, *b_size);
13188c2ecf20Sopenharmony_ci
13198c2ecf20Sopenharmony_ci			/* Set up tfm global state, i.e. the key */
13208c2ecf20Sopenharmony_ci
13218c2ecf20Sopenharmony_ci			memset(tvmem[0], 0xff, PAGE_SIZE);
13228c2ecf20Sopenharmony_ci			key = tvmem[0];
13238c2ecf20Sopenharmony_ci			for (j = 0; j < tcount; j++) {
13248c2ecf20Sopenharmony_ci				if (template[j].klen == *keysize) {
13258c2ecf20Sopenharmony_ci					key = template[j].key;
13268c2ecf20Sopenharmony_ci					break;
13278c2ecf20Sopenharmony_ci				}
13288c2ecf20Sopenharmony_ci			}
13298c2ecf20Sopenharmony_ci
13308c2ecf20Sopenharmony_ci			crypto_skcipher_clear_flags(tfm, ~0);
13318c2ecf20Sopenharmony_ci
13328c2ecf20Sopenharmony_ci			ret = crypto_skcipher_setkey(tfm, key, *keysize);
13338c2ecf20Sopenharmony_ci			if (ret) {
13348c2ecf20Sopenharmony_ci				pr_err("setkey() failed flags=%x\n",
13358c2ecf20Sopenharmony_ci				       crypto_skcipher_get_flags(tfm));
13368c2ecf20Sopenharmony_ci				goto out;
13378c2ecf20Sopenharmony_ci			}
13388c2ecf20Sopenharmony_ci
13398c2ecf20Sopenharmony_ci			iv_len = crypto_skcipher_ivsize(tfm);
13408c2ecf20Sopenharmony_ci			if (iv_len)
13418c2ecf20Sopenharmony_ci				memset(&iv, 0xff, iv_len);
13428c2ecf20Sopenharmony_ci
13438c2ecf20Sopenharmony_ci			/* Now setup per request stuff, i.e. buffers */
13448c2ecf20Sopenharmony_ci
13458c2ecf20Sopenharmony_ci			for (j = 0; j < num_mb; ++j) {
13468c2ecf20Sopenharmony_ci				struct test_mb_skcipher_data *cur = &data[j];
13478c2ecf20Sopenharmony_ci				unsigned int k = *b_size;
13488c2ecf20Sopenharmony_ci				unsigned int pages = DIV_ROUND_UP(k, PAGE_SIZE);
13498c2ecf20Sopenharmony_ci				unsigned int p = 0;
13508c2ecf20Sopenharmony_ci
13518c2ecf20Sopenharmony_ci				sg_init_table(cur->sg, pages);
13528c2ecf20Sopenharmony_ci
13538c2ecf20Sopenharmony_ci				while (k > PAGE_SIZE) {
13548c2ecf20Sopenharmony_ci					sg_set_buf(cur->sg + p, cur->xbuf[p],
13558c2ecf20Sopenharmony_ci						   PAGE_SIZE);
13568c2ecf20Sopenharmony_ci					memset(cur->xbuf[p], 0xff, PAGE_SIZE);
13578c2ecf20Sopenharmony_ci					p++;
13588c2ecf20Sopenharmony_ci					k -= PAGE_SIZE;
13598c2ecf20Sopenharmony_ci				}
13608c2ecf20Sopenharmony_ci
13618c2ecf20Sopenharmony_ci				sg_set_buf(cur->sg + p, cur->xbuf[p], k);
13628c2ecf20Sopenharmony_ci				memset(cur->xbuf[p], 0xff, k);
13638c2ecf20Sopenharmony_ci
13648c2ecf20Sopenharmony_ci				skcipher_request_set_crypt(cur->req, cur->sg,
13658c2ecf20Sopenharmony_ci							   cur->sg, *b_size,
13668c2ecf20Sopenharmony_ci							   iv);
13678c2ecf20Sopenharmony_ci			}
13688c2ecf20Sopenharmony_ci
13698c2ecf20Sopenharmony_ci			if (secs) {
13708c2ecf20Sopenharmony_ci				ret = test_mb_acipher_jiffies(data, enc,
13718c2ecf20Sopenharmony_ci							      *b_size, secs,
13728c2ecf20Sopenharmony_ci							      num_mb);
13738c2ecf20Sopenharmony_ci				cond_resched();
13748c2ecf20Sopenharmony_ci			} else {
13758c2ecf20Sopenharmony_ci				ret = test_mb_acipher_cycles(data, enc,
13768c2ecf20Sopenharmony_ci							     *b_size, num_mb);
13778c2ecf20Sopenharmony_ci			}
13788c2ecf20Sopenharmony_ci
13798c2ecf20Sopenharmony_ci			if (ret) {
13808c2ecf20Sopenharmony_ci				pr_err("%s() failed flags=%x\n", e,
13818c2ecf20Sopenharmony_ci				       crypto_skcipher_get_flags(tfm));
13828c2ecf20Sopenharmony_ci				break;
13838c2ecf20Sopenharmony_ci			}
13848c2ecf20Sopenharmony_ci			b_size++;
13858c2ecf20Sopenharmony_ci			i++;
13868c2ecf20Sopenharmony_ci		} while (*b_size);
13878c2ecf20Sopenharmony_ci		keysize++;
13888c2ecf20Sopenharmony_ci	} while (*keysize);
13898c2ecf20Sopenharmony_ci
13908c2ecf20Sopenharmony_ciout:
13918c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i)
13928c2ecf20Sopenharmony_ci		skcipher_request_free(data[i].req);
13938c2ecf20Sopenharmony_ciout_free_xbuf:
13948c2ecf20Sopenharmony_ci	for (i = 0; i < num_mb; ++i)
13958c2ecf20Sopenharmony_ci		testmgr_free_buf(data[i].xbuf);
13968c2ecf20Sopenharmony_ciout_free_tfm:
13978c2ecf20Sopenharmony_ci	crypto_free_skcipher(tfm);
13988c2ecf20Sopenharmony_ciout_free_data:
13998c2ecf20Sopenharmony_ci	kfree(data);
14008c2ecf20Sopenharmony_ci}
14018c2ecf20Sopenharmony_ci
14028c2ecf20Sopenharmony_cistatic inline int do_one_acipher_op(struct skcipher_request *req, int ret)
14038c2ecf20Sopenharmony_ci{
14048c2ecf20Sopenharmony_ci	struct crypto_wait *wait = req->base.data;
14058c2ecf20Sopenharmony_ci
14068c2ecf20Sopenharmony_ci	return crypto_wait_req(ret, wait);
14078c2ecf20Sopenharmony_ci}
14088c2ecf20Sopenharmony_ci
14098c2ecf20Sopenharmony_cistatic int test_acipher_jiffies(struct skcipher_request *req, int enc,
14108c2ecf20Sopenharmony_ci				int blen, int secs)
14118c2ecf20Sopenharmony_ci{
14128c2ecf20Sopenharmony_ci	unsigned long start, end;
14138c2ecf20Sopenharmony_ci	int bcount;
14148c2ecf20Sopenharmony_ci	int ret;
14158c2ecf20Sopenharmony_ci
14168c2ecf20Sopenharmony_ci	for (start = jiffies, end = start + secs * HZ, bcount = 0;
14178c2ecf20Sopenharmony_ci	     time_before(jiffies, end); bcount++) {
14188c2ecf20Sopenharmony_ci		if (enc)
14198c2ecf20Sopenharmony_ci			ret = do_one_acipher_op(req,
14208c2ecf20Sopenharmony_ci						crypto_skcipher_encrypt(req));
14218c2ecf20Sopenharmony_ci		else
14228c2ecf20Sopenharmony_ci			ret = do_one_acipher_op(req,
14238c2ecf20Sopenharmony_ci						crypto_skcipher_decrypt(req));
14248c2ecf20Sopenharmony_ci
14258c2ecf20Sopenharmony_ci		if (ret)
14268c2ecf20Sopenharmony_ci			return ret;
14278c2ecf20Sopenharmony_ci	}
14288c2ecf20Sopenharmony_ci
14298c2ecf20Sopenharmony_ci	pr_cont("%d operations in %d seconds (%llu bytes)\n",
14308c2ecf20Sopenharmony_ci		bcount, secs, (u64)bcount * blen);
14318c2ecf20Sopenharmony_ci	return 0;
14328c2ecf20Sopenharmony_ci}
14338c2ecf20Sopenharmony_ci
14348c2ecf20Sopenharmony_cistatic int test_acipher_cycles(struct skcipher_request *req, int enc,
14358c2ecf20Sopenharmony_ci			       int blen)
14368c2ecf20Sopenharmony_ci{
14378c2ecf20Sopenharmony_ci	unsigned long cycles = 0;
14388c2ecf20Sopenharmony_ci	int ret = 0;
14398c2ecf20Sopenharmony_ci	int i;
14408c2ecf20Sopenharmony_ci
14418c2ecf20Sopenharmony_ci	/* Warm-up run. */
14428c2ecf20Sopenharmony_ci	for (i = 0; i < 4; i++) {
14438c2ecf20Sopenharmony_ci		if (enc)
14448c2ecf20Sopenharmony_ci			ret = do_one_acipher_op(req,
14458c2ecf20Sopenharmony_ci						crypto_skcipher_encrypt(req));
14468c2ecf20Sopenharmony_ci		else
14478c2ecf20Sopenharmony_ci			ret = do_one_acipher_op(req,
14488c2ecf20Sopenharmony_ci						crypto_skcipher_decrypt(req));
14498c2ecf20Sopenharmony_ci
14508c2ecf20Sopenharmony_ci		if (ret)
14518c2ecf20Sopenharmony_ci			goto out;
14528c2ecf20Sopenharmony_ci	}
14538c2ecf20Sopenharmony_ci
14548c2ecf20Sopenharmony_ci	/* The real thing. */
14558c2ecf20Sopenharmony_ci	for (i = 0; i < 8; i++) {
14568c2ecf20Sopenharmony_ci		cycles_t start, end;
14578c2ecf20Sopenharmony_ci
14588c2ecf20Sopenharmony_ci		start = get_cycles();
14598c2ecf20Sopenharmony_ci		if (enc)
14608c2ecf20Sopenharmony_ci			ret = do_one_acipher_op(req,
14618c2ecf20Sopenharmony_ci						crypto_skcipher_encrypt(req));
14628c2ecf20Sopenharmony_ci		else
14638c2ecf20Sopenharmony_ci			ret = do_one_acipher_op(req,
14648c2ecf20Sopenharmony_ci						crypto_skcipher_decrypt(req));
14658c2ecf20Sopenharmony_ci		end = get_cycles();
14668c2ecf20Sopenharmony_ci
14678c2ecf20Sopenharmony_ci		if (ret)
14688c2ecf20Sopenharmony_ci			goto out;
14698c2ecf20Sopenharmony_ci
14708c2ecf20Sopenharmony_ci		cycles += end - start;
14718c2ecf20Sopenharmony_ci	}
14728c2ecf20Sopenharmony_ci
14738c2ecf20Sopenharmony_ciout:
14748c2ecf20Sopenharmony_ci	if (ret == 0)
14758c2ecf20Sopenharmony_ci		pr_cont("1 operation in %lu cycles (%d bytes)\n",
14768c2ecf20Sopenharmony_ci			(cycles + 4) / 8, blen);
14778c2ecf20Sopenharmony_ci
14788c2ecf20Sopenharmony_ci	return ret;
14798c2ecf20Sopenharmony_ci}
14808c2ecf20Sopenharmony_ci
14818c2ecf20Sopenharmony_cistatic void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
14828c2ecf20Sopenharmony_ci				struct cipher_speed_template *template,
14838c2ecf20Sopenharmony_ci				unsigned int tcount, u8 *keysize, bool async)
14848c2ecf20Sopenharmony_ci{
14858c2ecf20Sopenharmony_ci	unsigned int ret, i, j, k, iv_len;
14868c2ecf20Sopenharmony_ci	struct crypto_wait wait;
14878c2ecf20Sopenharmony_ci	const char *key;
14888c2ecf20Sopenharmony_ci	char iv[128];
14898c2ecf20Sopenharmony_ci	struct skcipher_request *req;
14908c2ecf20Sopenharmony_ci	struct crypto_skcipher *tfm;
14918c2ecf20Sopenharmony_ci	const char *e;
14928c2ecf20Sopenharmony_ci	u32 *b_size;
14938c2ecf20Sopenharmony_ci
14948c2ecf20Sopenharmony_ci	if (enc == ENCRYPT)
14958c2ecf20Sopenharmony_ci		e = "encryption";
14968c2ecf20Sopenharmony_ci	else
14978c2ecf20Sopenharmony_ci		e = "decryption";
14988c2ecf20Sopenharmony_ci
14998c2ecf20Sopenharmony_ci	crypto_init_wait(&wait);
15008c2ecf20Sopenharmony_ci
15018c2ecf20Sopenharmony_ci	tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC);
15028c2ecf20Sopenharmony_ci
15038c2ecf20Sopenharmony_ci	if (IS_ERR(tfm)) {
15048c2ecf20Sopenharmony_ci		pr_err("failed to load transform for %s: %ld\n", algo,
15058c2ecf20Sopenharmony_ci		       PTR_ERR(tfm));
15068c2ecf20Sopenharmony_ci		return;
15078c2ecf20Sopenharmony_ci	}
15088c2ecf20Sopenharmony_ci
15098c2ecf20Sopenharmony_ci	pr_info("\ntesting speed of %s %s (%s) %s\n", async ? "async" : "sync",
15108c2ecf20Sopenharmony_ci		algo, get_driver_name(crypto_skcipher, tfm), e);
15118c2ecf20Sopenharmony_ci
15128c2ecf20Sopenharmony_ci	req = skcipher_request_alloc(tfm, GFP_KERNEL);
15138c2ecf20Sopenharmony_ci	if (!req) {
15148c2ecf20Sopenharmony_ci		pr_err("tcrypt: skcipher: Failed to allocate request for %s\n",
15158c2ecf20Sopenharmony_ci		       algo);
15168c2ecf20Sopenharmony_ci		goto out;
15178c2ecf20Sopenharmony_ci	}
15188c2ecf20Sopenharmony_ci
15198c2ecf20Sopenharmony_ci	skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
15208c2ecf20Sopenharmony_ci				      crypto_req_done, &wait);
15218c2ecf20Sopenharmony_ci
15228c2ecf20Sopenharmony_ci	i = 0;
15238c2ecf20Sopenharmony_ci	do {
15248c2ecf20Sopenharmony_ci		b_size = block_sizes;
15258c2ecf20Sopenharmony_ci
15268c2ecf20Sopenharmony_ci		do {
15278c2ecf20Sopenharmony_ci			struct scatterlist sg[TVMEMSIZE];
15288c2ecf20Sopenharmony_ci
15298c2ecf20Sopenharmony_ci			if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
15308c2ecf20Sopenharmony_ci				pr_err("template (%u) too big for "
15318c2ecf20Sopenharmony_ci				       "tvmem (%lu)\n", *keysize + *b_size,
15328c2ecf20Sopenharmony_ci				       TVMEMSIZE * PAGE_SIZE);
15338c2ecf20Sopenharmony_ci				goto out_free_req;
15348c2ecf20Sopenharmony_ci			}
15358c2ecf20Sopenharmony_ci
15368c2ecf20Sopenharmony_ci			pr_info("test %u (%d bit key, %d byte blocks): ", i,
15378c2ecf20Sopenharmony_ci				*keysize * 8, *b_size);
15388c2ecf20Sopenharmony_ci
15398c2ecf20Sopenharmony_ci			memset(tvmem[0], 0xff, PAGE_SIZE);
15408c2ecf20Sopenharmony_ci
15418c2ecf20Sopenharmony_ci			/* set key, plain text and IV */
15428c2ecf20Sopenharmony_ci			key = tvmem[0];
15438c2ecf20Sopenharmony_ci			for (j = 0; j < tcount; j++) {
15448c2ecf20Sopenharmony_ci				if (template[j].klen == *keysize) {
15458c2ecf20Sopenharmony_ci					key = template[j].key;
15468c2ecf20Sopenharmony_ci					break;
15478c2ecf20Sopenharmony_ci				}
15488c2ecf20Sopenharmony_ci			}
15498c2ecf20Sopenharmony_ci
15508c2ecf20Sopenharmony_ci			crypto_skcipher_clear_flags(tfm, ~0);
15518c2ecf20Sopenharmony_ci
15528c2ecf20Sopenharmony_ci			ret = crypto_skcipher_setkey(tfm, key, *keysize);
15538c2ecf20Sopenharmony_ci			if (ret) {
15548c2ecf20Sopenharmony_ci				pr_err("setkey() failed flags=%x\n",
15558c2ecf20Sopenharmony_ci					crypto_skcipher_get_flags(tfm));
15568c2ecf20Sopenharmony_ci				goto out_free_req;
15578c2ecf20Sopenharmony_ci			}
15588c2ecf20Sopenharmony_ci
15598c2ecf20Sopenharmony_ci			k = *keysize + *b_size;
15608c2ecf20Sopenharmony_ci			sg_init_table(sg, DIV_ROUND_UP(k, PAGE_SIZE));
15618c2ecf20Sopenharmony_ci
15628c2ecf20Sopenharmony_ci			if (k > PAGE_SIZE) {
15638c2ecf20Sopenharmony_ci				sg_set_buf(sg, tvmem[0] + *keysize,
15648c2ecf20Sopenharmony_ci				   PAGE_SIZE - *keysize);
15658c2ecf20Sopenharmony_ci				k -= PAGE_SIZE;
15668c2ecf20Sopenharmony_ci				j = 1;
15678c2ecf20Sopenharmony_ci				while (k > PAGE_SIZE) {
15688c2ecf20Sopenharmony_ci					sg_set_buf(sg + j, tvmem[j], PAGE_SIZE);
15698c2ecf20Sopenharmony_ci					memset(tvmem[j], 0xff, PAGE_SIZE);
15708c2ecf20Sopenharmony_ci					j++;
15718c2ecf20Sopenharmony_ci					k -= PAGE_SIZE;
15728c2ecf20Sopenharmony_ci				}
15738c2ecf20Sopenharmony_ci				sg_set_buf(sg + j, tvmem[j], k);
15748c2ecf20Sopenharmony_ci				memset(tvmem[j], 0xff, k);
15758c2ecf20Sopenharmony_ci			} else {
15768c2ecf20Sopenharmony_ci				sg_set_buf(sg, tvmem[0] + *keysize, *b_size);
15778c2ecf20Sopenharmony_ci			}
15788c2ecf20Sopenharmony_ci
15798c2ecf20Sopenharmony_ci			iv_len = crypto_skcipher_ivsize(tfm);
15808c2ecf20Sopenharmony_ci			if (iv_len)
15818c2ecf20Sopenharmony_ci				memset(&iv, 0xff, iv_len);
15828c2ecf20Sopenharmony_ci
15838c2ecf20Sopenharmony_ci			skcipher_request_set_crypt(req, sg, sg, *b_size, iv);
15848c2ecf20Sopenharmony_ci
15858c2ecf20Sopenharmony_ci			if (secs) {
15868c2ecf20Sopenharmony_ci				ret = test_acipher_jiffies(req, enc,
15878c2ecf20Sopenharmony_ci							   *b_size, secs);
15888c2ecf20Sopenharmony_ci				cond_resched();
15898c2ecf20Sopenharmony_ci			} else {
15908c2ecf20Sopenharmony_ci				ret = test_acipher_cycles(req, enc,
15918c2ecf20Sopenharmony_ci							  *b_size);
15928c2ecf20Sopenharmony_ci			}
15938c2ecf20Sopenharmony_ci
15948c2ecf20Sopenharmony_ci			if (ret) {
15958c2ecf20Sopenharmony_ci				pr_err("%s() failed flags=%x\n", e,
15968c2ecf20Sopenharmony_ci				       crypto_skcipher_get_flags(tfm));
15978c2ecf20Sopenharmony_ci				break;
15988c2ecf20Sopenharmony_ci			}
15998c2ecf20Sopenharmony_ci			b_size++;
16008c2ecf20Sopenharmony_ci			i++;
16018c2ecf20Sopenharmony_ci		} while (*b_size);
16028c2ecf20Sopenharmony_ci		keysize++;
16038c2ecf20Sopenharmony_ci	} while (*keysize);
16048c2ecf20Sopenharmony_ci
16058c2ecf20Sopenharmony_ciout_free_req:
16068c2ecf20Sopenharmony_ci	skcipher_request_free(req);
16078c2ecf20Sopenharmony_ciout:
16088c2ecf20Sopenharmony_ci	crypto_free_skcipher(tfm);
16098c2ecf20Sopenharmony_ci}
16108c2ecf20Sopenharmony_ci
16118c2ecf20Sopenharmony_cistatic void test_acipher_speed(const char *algo, int enc, unsigned int secs,
16128c2ecf20Sopenharmony_ci			       struct cipher_speed_template *template,
16138c2ecf20Sopenharmony_ci			       unsigned int tcount, u8 *keysize)
16148c2ecf20Sopenharmony_ci{
16158c2ecf20Sopenharmony_ci	return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
16168c2ecf20Sopenharmony_ci				   true);
16178c2ecf20Sopenharmony_ci}
16188c2ecf20Sopenharmony_ci
16198c2ecf20Sopenharmony_cistatic void test_cipher_speed(const char *algo, int enc, unsigned int secs,
16208c2ecf20Sopenharmony_ci			      struct cipher_speed_template *template,
16218c2ecf20Sopenharmony_ci			      unsigned int tcount, u8 *keysize)
16228c2ecf20Sopenharmony_ci{
16238c2ecf20Sopenharmony_ci	return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
16248c2ecf20Sopenharmony_ci				   false);
16258c2ecf20Sopenharmony_ci}
16268c2ecf20Sopenharmony_ci
16278c2ecf20Sopenharmony_cistatic void test_available(void)
16288c2ecf20Sopenharmony_ci{
16298c2ecf20Sopenharmony_ci	const char **name = check;
16308c2ecf20Sopenharmony_ci
16318c2ecf20Sopenharmony_ci	while (*name) {
16328c2ecf20Sopenharmony_ci		printk("alg %s ", *name);
16338c2ecf20Sopenharmony_ci		printk(crypto_has_alg(*name, 0, 0) ?
16348c2ecf20Sopenharmony_ci		       "found\n" : "not found\n");
16358c2ecf20Sopenharmony_ci		name++;
16368c2ecf20Sopenharmony_ci	}
16378c2ecf20Sopenharmony_ci}
16388c2ecf20Sopenharmony_ci
16398c2ecf20Sopenharmony_cistatic inline int tcrypt_test(const char *alg)
16408c2ecf20Sopenharmony_ci{
16418c2ecf20Sopenharmony_ci	int ret;
16428c2ecf20Sopenharmony_ci
16438c2ecf20Sopenharmony_ci	pr_debug("testing %s\n", alg);
16448c2ecf20Sopenharmony_ci
16458c2ecf20Sopenharmony_ci	ret = alg_test(alg, alg, 0, 0);
16468c2ecf20Sopenharmony_ci	/* non-fips algs return -EINVAL in fips mode */
16478c2ecf20Sopenharmony_ci	if (fips_enabled && ret == -EINVAL)
16488c2ecf20Sopenharmony_ci		ret = 0;
16498c2ecf20Sopenharmony_ci	return ret;
16508c2ecf20Sopenharmony_ci}
16518c2ecf20Sopenharmony_ci
16528c2ecf20Sopenharmony_cistatic int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
16538c2ecf20Sopenharmony_ci{
16548c2ecf20Sopenharmony_ci	int i;
16558c2ecf20Sopenharmony_ci	int ret = 0;
16568c2ecf20Sopenharmony_ci
16578c2ecf20Sopenharmony_ci	switch (m) {
16588c2ecf20Sopenharmony_ci	case 0:
16598c2ecf20Sopenharmony_ci		if (alg) {
16608c2ecf20Sopenharmony_ci			if (!crypto_has_alg(alg, type,
16618c2ecf20Sopenharmony_ci					    mask ?: CRYPTO_ALG_TYPE_MASK))
16628c2ecf20Sopenharmony_ci				ret = -ENOENT;
16638c2ecf20Sopenharmony_ci			break;
16648c2ecf20Sopenharmony_ci		}
16658c2ecf20Sopenharmony_ci
16668c2ecf20Sopenharmony_ci		for (i = 1; i < 200; i++)
16678c2ecf20Sopenharmony_ci			ret += do_test(NULL, 0, 0, i, num_mb);
16688c2ecf20Sopenharmony_ci		break;
16698c2ecf20Sopenharmony_ci
16708c2ecf20Sopenharmony_ci	case 1:
16718c2ecf20Sopenharmony_ci		ret += tcrypt_test("md5");
16728c2ecf20Sopenharmony_ci		break;
16738c2ecf20Sopenharmony_ci
16748c2ecf20Sopenharmony_ci	case 2:
16758c2ecf20Sopenharmony_ci		ret += tcrypt_test("sha1");
16768c2ecf20Sopenharmony_ci		break;
16778c2ecf20Sopenharmony_ci
16788c2ecf20Sopenharmony_ci	case 3:
16798c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(des)");
16808c2ecf20Sopenharmony_ci		ret += tcrypt_test("cbc(des)");
16818c2ecf20Sopenharmony_ci		ret += tcrypt_test("ctr(des)");
16828c2ecf20Sopenharmony_ci		break;
16838c2ecf20Sopenharmony_ci
16848c2ecf20Sopenharmony_ci	case 4:
16858c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(des3_ede)");
16868c2ecf20Sopenharmony_ci		ret += tcrypt_test("cbc(des3_ede)");
16878c2ecf20Sopenharmony_ci		ret += tcrypt_test("ctr(des3_ede)");
16888c2ecf20Sopenharmony_ci		break;
16898c2ecf20Sopenharmony_ci
16908c2ecf20Sopenharmony_ci	case 5:
16918c2ecf20Sopenharmony_ci		ret += tcrypt_test("md4");
16928c2ecf20Sopenharmony_ci		break;
16938c2ecf20Sopenharmony_ci
16948c2ecf20Sopenharmony_ci	case 6:
16958c2ecf20Sopenharmony_ci		ret += tcrypt_test("sha256");
16968c2ecf20Sopenharmony_ci		break;
16978c2ecf20Sopenharmony_ci
16988c2ecf20Sopenharmony_ci	case 7:
16998c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(blowfish)");
17008c2ecf20Sopenharmony_ci		ret += tcrypt_test("cbc(blowfish)");
17018c2ecf20Sopenharmony_ci		ret += tcrypt_test("ctr(blowfish)");
17028c2ecf20Sopenharmony_ci		break;
17038c2ecf20Sopenharmony_ci
17048c2ecf20Sopenharmony_ci	case 8:
17058c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(twofish)");
17068c2ecf20Sopenharmony_ci		ret += tcrypt_test("cbc(twofish)");
17078c2ecf20Sopenharmony_ci		ret += tcrypt_test("ctr(twofish)");
17088c2ecf20Sopenharmony_ci		ret += tcrypt_test("lrw(twofish)");
17098c2ecf20Sopenharmony_ci		ret += tcrypt_test("xts(twofish)");
17108c2ecf20Sopenharmony_ci		break;
17118c2ecf20Sopenharmony_ci
17128c2ecf20Sopenharmony_ci	case 9:
17138c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(serpent)");
17148c2ecf20Sopenharmony_ci		ret += tcrypt_test("cbc(serpent)");
17158c2ecf20Sopenharmony_ci		ret += tcrypt_test("ctr(serpent)");
17168c2ecf20Sopenharmony_ci		ret += tcrypt_test("lrw(serpent)");
17178c2ecf20Sopenharmony_ci		ret += tcrypt_test("xts(serpent)");
17188c2ecf20Sopenharmony_ci		break;
17198c2ecf20Sopenharmony_ci
17208c2ecf20Sopenharmony_ci	case 10:
17218c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(aes)");
17228c2ecf20Sopenharmony_ci		ret += tcrypt_test("cbc(aes)");
17238c2ecf20Sopenharmony_ci		ret += tcrypt_test("lrw(aes)");
17248c2ecf20Sopenharmony_ci		ret += tcrypt_test("xts(aes)");
17258c2ecf20Sopenharmony_ci		ret += tcrypt_test("ctr(aes)");
17268c2ecf20Sopenharmony_ci		ret += tcrypt_test("rfc3686(ctr(aes))");
17278c2ecf20Sopenharmony_ci		ret += tcrypt_test("ofb(aes)");
17288c2ecf20Sopenharmony_ci		ret += tcrypt_test("cfb(aes)");
17298c2ecf20Sopenharmony_ci		break;
17308c2ecf20Sopenharmony_ci
17318c2ecf20Sopenharmony_ci	case 11:
17328c2ecf20Sopenharmony_ci		ret += tcrypt_test("sha384");
17338c2ecf20Sopenharmony_ci		break;
17348c2ecf20Sopenharmony_ci
17358c2ecf20Sopenharmony_ci	case 12:
17368c2ecf20Sopenharmony_ci		ret += tcrypt_test("sha512");
17378c2ecf20Sopenharmony_ci		break;
17388c2ecf20Sopenharmony_ci
17398c2ecf20Sopenharmony_ci	case 13:
17408c2ecf20Sopenharmony_ci		ret += tcrypt_test("deflate");
17418c2ecf20Sopenharmony_ci		break;
17428c2ecf20Sopenharmony_ci
17438c2ecf20Sopenharmony_ci	case 14:
17448c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(cast5)");
17458c2ecf20Sopenharmony_ci		ret += tcrypt_test("cbc(cast5)");
17468c2ecf20Sopenharmony_ci		ret += tcrypt_test("ctr(cast5)");
17478c2ecf20Sopenharmony_ci		break;
17488c2ecf20Sopenharmony_ci
17498c2ecf20Sopenharmony_ci	case 15:
17508c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(cast6)");
17518c2ecf20Sopenharmony_ci		ret += tcrypt_test("cbc(cast6)");
17528c2ecf20Sopenharmony_ci		ret += tcrypt_test("ctr(cast6)");
17538c2ecf20Sopenharmony_ci		ret += tcrypt_test("lrw(cast6)");
17548c2ecf20Sopenharmony_ci		ret += tcrypt_test("xts(cast6)");
17558c2ecf20Sopenharmony_ci		break;
17568c2ecf20Sopenharmony_ci
17578c2ecf20Sopenharmony_ci	case 16:
17588c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(arc4)");
17598c2ecf20Sopenharmony_ci		break;
17608c2ecf20Sopenharmony_ci
17618c2ecf20Sopenharmony_ci	case 17:
17628c2ecf20Sopenharmony_ci		ret += tcrypt_test("michael_mic");
17638c2ecf20Sopenharmony_ci		break;
17648c2ecf20Sopenharmony_ci
17658c2ecf20Sopenharmony_ci	case 18:
17668c2ecf20Sopenharmony_ci		ret += tcrypt_test("crc32c");
17678c2ecf20Sopenharmony_ci		break;
17688c2ecf20Sopenharmony_ci
17698c2ecf20Sopenharmony_ci	case 19:
17708c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(tea)");
17718c2ecf20Sopenharmony_ci		break;
17728c2ecf20Sopenharmony_ci
17738c2ecf20Sopenharmony_ci	case 20:
17748c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(xtea)");
17758c2ecf20Sopenharmony_ci		break;
17768c2ecf20Sopenharmony_ci
17778c2ecf20Sopenharmony_ci	case 21:
17788c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(khazad)");
17798c2ecf20Sopenharmony_ci		break;
17808c2ecf20Sopenharmony_ci
17818c2ecf20Sopenharmony_ci	case 22:
17828c2ecf20Sopenharmony_ci		ret += tcrypt_test("wp512");
17838c2ecf20Sopenharmony_ci		break;
17848c2ecf20Sopenharmony_ci
17858c2ecf20Sopenharmony_ci	case 23:
17868c2ecf20Sopenharmony_ci		ret += tcrypt_test("wp384");
17878c2ecf20Sopenharmony_ci		break;
17888c2ecf20Sopenharmony_ci
17898c2ecf20Sopenharmony_ci	case 24:
17908c2ecf20Sopenharmony_ci		ret += tcrypt_test("wp256");
17918c2ecf20Sopenharmony_ci		break;
17928c2ecf20Sopenharmony_ci
17938c2ecf20Sopenharmony_ci	case 25:
17948c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(tnepres)");
17958c2ecf20Sopenharmony_ci		break;
17968c2ecf20Sopenharmony_ci
17978c2ecf20Sopenharmony_ci	case 26:
17988c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(anubis)");
17998c2ecf20Sopenharmony_ci		ret += tcrypt_test("cbc(anubis)");
18008c2ecf20Sopenharmony_ci		break;
18018c2ecf20Sopenharmony_ci
18028c2ecf20Sopenharmony_ci	case 27:
18038c2ecf20Sopenharmony_ci		ret += tcrypt_test("tgr192");
18048c2ecf20Sopenharmony_ci		break;
18058c2ecf20Sopenharmony_ci
18068c2ecf20Sopenharmony_ci	case 28:
18078c2ecf20Sopenharmony_ci		ret += tcrypt_test("tgr160");
18088c2ecf20Sopenharmony_ci		break;
18098c2ecf20Sopenharmony_ci
18108c2ecf20Sopenharmony_ci	case 29:
18118c2ecf20Sopenharmony_ci		ret += tcrypt_test("tgr128");
18128c2ecf20Sopenharmony_ci		break;
18138c2ecf20Sopenharmony_ci
18148c2ecf20Sopenharmony_ci	case 30:
18158c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(xeta)");
18168c2ecf20Sopenharmony_ci		break;
18178c2ecf20Sopenharmony_ci
18188c2ecf20Sopenharmony_ci	case 31:
18198c2ecf20Sopenharmony_ci		ret += tcrypt_test("pcbc(fcrypt)");
18208c2ecf20Sopenharmony_ci		break;
18218c2ecf20Sopenharmony_ci
18228c2ecf20Sopenharmony_ci	case 32:
18238c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(camellia)");
18248c2ecf20Sopenharmony_ci		ret += tcrypt_test("cbc(camellia)");
18258c2ecf20Sopenharmony_ci		ret += tcrypt_test("ctr(camellia)");
18268c2ecf20Sopenharmony_ci		ret += tcrypt_test("lrw(camellia)");
18278c2ecf20Sopenharmony_ci		ret += tcrypt_test("xts(camellia)");
18288c2ecf20Sopenharmony_ci		break;
18298c2ecf20Sopenharmony_ci
18308c2ecf20Sopenharmony_ci	case 33:
18318c2ecf20Sopenharmony_ci		ret += tcrypt_test("sha224");
18328c2ecf20Sopenharmony_ci		break;
18338c2ecf20Sopenharmony_ci
18348c2ecf20Sopenharmony_ci	case 34:
18358c2ecf20Sopenharmony_ci		ret += tcrypt_test("salsa20");
18368c2ecf20Sopenharmony_ci		break;
18378c2ecf20Sopenharmony_ci
18388c2ecf20Sopenharmony_ci	case 35:
18398c2ecf20Sopenharmony_ci		ret += tcrypt_test("gcm(aes)");
18408c2ecf20Sopenharmony_ci		break;
18418c2ecf20Sopenharmony_ci
18428c2ecf20Sopenharmony_ci	case 36:
18438c2ecf20Sopenharmony_ci		ret += tcrypt_test("lzo");
18448c2ecf20Sopenharmony_ci		break;
18458c2ecf20Sopenharmony_ci
18468c2ecf20Sopenharmony_ci	case 37:
18478c2ecf20Sopenharmony_ci		ret += tcrypt_test("ccm(aes)");
18488c2ecf20Sopenharmony_ci		break;
18498c2ecf20Sopenharmony_ci
18508c2ecf20Sopenharmony_ci	case 38:
18518c2ecf20Sopenharmony_ci		ret += tcrypt_test("cts(cbc(aes))");
18528c2ecf20Sopenharmony_ci		break;
18538c2ecf20Sopenharmony_ci
18548c2ecf20Sopenharmony_ci        case 39:
18558c2ecf20Sopenharmony_ci		ret += tcrypt_test("rmd128");
18568c2ecf20Sopenharmony_ci		break;
18578c2ecf20Sopenharmony_ci
18588c2ecf20Sopenharmony_ci        case 40:
18598c2ecf20Sopenharmony_ci		ret += tcrypt_test("rmd160");
18608c2ecf20Sopenharmony_ci		break;
18618c2ecf20Sopenharmony_ci
18628c2ecf20Sopenharmony_ci	case 41:
18638c2ecf20Sopenharmony_ci		ret += tcrypt_test("rmd256");
18648c2ecf20Sopenharmony_ci		break;
18658c2ecf20Sopenharmony_ci
18668c2ecf20Sopenharmony_ci	case 42:
18678c2ecf20Sopenharmony_ci		ret += tcrypt_test("rmd320");
18688c2ecf20Sopenharmony_ci		break;
18698c2ecf20Sopenharmony_ci
18708c2ecf20Sopenharmony_ci	case 43:
18718c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(seed)");
18728c2ecf20Sopenharmony_ci		break;
18738c2ecf20Sopenharmony_ci
18748c2ecf20Sopenharmony_ci	case 45:
18758c2ecf20Sopenharmony_ci		ret += tcrypt_test("rfc4309(ccm(aes))");
18768c2ecf20Sopenharmony_ci		break;
18778c2ecf20Sopenharmony_ci
18788c2ecf20Sopenharmony_ci	case 46:
18798c2ecf20Sopenharmony_ci		ret += tcrypt_test("ghash");
18808c2ecf20Sopenharmony_ci		break;
18818c2ecf20Sopenharmony_ci
18828c2ecf20Sopenharmony_ci	case 47:
18838c2ecf20Sopenharmony_ci		ret += tcrypt_test("crct10dif");
18848c2ecf20Sopenharmony_ci		break;
18858c2ecf20Sopenharmony_ci
18868c2ecf20Sopenharmony_ci	case 48:
18878c2ecf20Sopenharmony_ci		ret += tcrypt_test("sha3-224");
18888c2ecf20Sopenharmony_ci		break;
18898c2ecf20Sopenharmony_ci
18908c2ecf20Sopenharmony_ci	case 49:
18918c2ecf20Sopenharmony_ci		ret += tcrypt_test("sha3-256");
18928c2ecf20Sopenharmony_ci		break;
18938c2ecf20Sopenharmony_ci
18948c2ecf20Sopenharmony_ci	case 50:
18958c2ecf20Sopenharmony_ci		ret += tcrypt_test("sha3-384");
18968c2ecf20Sopenharmony_ci		break;
18978c2ecf20Sopenharmony_ci
18988c2ecf20Sopenharmony_ci	case 51:
18998c2ecf20Sopenharmony_ci		ret += tcrypt_test("sha3-512");
19008c2ecf20Sopenharmony_ci		break;
19018c2ecf20Sopenharmony_ci
19028c2ecf20Sopenharmony_ci	case 52:
19038c2ecf20Sopenharmony_ci		ret += tcrypt_test("sm3");
19048c2ecf20Sopenharmony_ci		break;
19058c2ecf20Sopenharmony_ci
19068c2ecf20Sopenharmony_ci	case 53:
19078c2ecf20Sopenharmony_ci		ret += tcrypt_test("streebog256");
19088c2ecf20Sopenharmony_ci		break;
19098c2ecf20Sopenharmony_ci
19108c2ecf20Sopenharmony_ci	case 54:
19118c2ecf20Sopenharmony_ci		ret += tcrypt_test("streebog512");
19128c2ecf20Sopenharmony_ci		break;
19138c2ecf20Sopenharmony_ci
19148c2ecf20Sopenharmony_ci	case 100:
19158c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(md5)");
19168c2ecf20Sopenharmony_ci		break;
19178c2ecf20Sopenharmony_ci
19188c2ecf20Sopenharmony_ci	case 101:
19198c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(sha1)");
19208c2ecf20Sopenharmony_ci		break;
19218c2ecf20Sopenharmony_ci
19228c2ecf20Sopenharmony_ci	case 102:
19238c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(sha256)");
19248c2ecf20Sopenharmony_ci		break;
19258c2ecf20Sopenharmony_ci
19268c2ecf20Sopenharmony_ci	case 103:
19278c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(sha384)");
19288c2ecf20Sopenharmony_ci		break;
19298c2ecf20Sopenharmony_ci
19308c2ecf20Sopenharmony_ci	case 104:
19318c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(sha512)");
19328c2ecf20Sopenharmony_ci		break;
19338c2ecf20Sopenharmony_ci
19348c2ecf20Sopenharmony_ci	case 105:
19358c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(sha224)");
19368c2ecf20Sopenharmony_ci		break;
19378c2ecf20Sopenharmony_ci
19388c2ecf20Sopenharmony_ci	case 106:
19398c2ecf20Sopenharmony_ci		ret += tcrypt_test("xcbc(aes)");
19408c2ecf20Sopenharmony_ci		break;
19418c2ecf20Sopenharmony_ci
19428c2ecf20Sopenharmony_ci	case 107:
19438c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(rmd128)");
19448c2ecf20Sopenharmony_ci		break;
19458c2ecf20Sopenharmony_ci
19468c2ecf20Sopenharmony_ci	case 108:
19478c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(rmd160)");
19488c2ecf20Sopenharmony_ci		break;
19498c2ecf20Sopenharmony_ci
19508c2ecf20Sopenharmony_ci	case 109:
19518c2ecf20Sopenharmony_ci		ret += tcrypt_test("vmac64(aes)");
19528c2ecf20Sopenharmony_ci		break;
19538c2ecf20Sopenharmony_ci
19548c2ecf20Sopenharmony_ci	case 111:
19558c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(sha3-224)");
19568c2ecf20Sopenharmony_ci		break;
19578c2ecf20Sopenharmony_ci
19588c2ecf20Sopenharmony_ci	case 112:
19598c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(sha3-256)");
19608c2ecf20Sopenharmony_ci		break;
19618c2ecf20Sopenharmony_ci
19628c2ecf20Sopenharmony_ci	case 113:
19638c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(sha3-384)");
19648c2ecf20Sopenharmony_ci		break;
19658c2ecf20Sopenharmony_ci
19668c2ecf20Sopenharmony_ci	case 114:
19678c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(sha3-512)");
19688c2ecf20Sopenharmony_ci		break;
19698c2ecf20Sopenharmony_ci
19708c2ecf20Sopenharmony_ci	case 115:
19718c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(streebog256)");
19728c2ecf20Sopenharmony_ci		break;
19738c2ecf20Sopenharmony_ci
19748c2ecf20Sopenharmony_ci	case 116:
19758c2ecf20Sopenharmony_ci		ret += tcrypt_test("hmac(streebog512)");
19768c2ecf20Sopenharmony_ci		break;
19778c2ecf20Sopenharmony_ci
19788c2ecf20Sopenharmony_ci	case 150:
19798c2ecf20Sopenharmony_ci		ret += tcrypt_test("ansi_cprng");
19808c2ecf20Sopenharmony_ci		break;
19818c2ecf20Sopenharmony_ci
19828c2ecf20Sopenharmony_ci	case 151:
19838c2ecf20Sopenharmony_ci		ret += tcrypt_test("rfc4106(gcm(aes))");
19848c2ecf20Sopenharmony_ci		break;
19858c2ecf20Sopenharmony_ci
19868c2ecf20Sopenharmony_ci	case 152:
19878c2ecf20Sopenharmony_ci		ret += tcrypt_test("rfc4543(gcm(aes))");
19888c2ecf20Sopenharmony_ci		break;
19898c2ecf20Sopenharmony_ci
19908c2ecf20Sopenharmony_ci	case 153:
19918c2ecf20Sopenharmony_ci		ret += tcrypt_test("cmac(aes)");
19928c2ecf20Sopenharmony_ci		break;
19938c2ecf20Sopenharmony_ci
19948c2ecf20Sopenharmony_ci	case 154:
19958c2ecf20Sopenharmony_ci		ret += tcrypt_test("cmac(des3_ede)");
19968c2ecf20Sopenharmony_ci		break;
19978c2ecf20Sopenharmony_ci
19988c2ecf20Sopenharmony_ci	case 155:
19998c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))");
20008c2ecf20Sopenharmony_ci		break;
20018c2ecf20Sopenharmony_ci
20028c2ecf20Sopenharmony_ci	case 156:
20038c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(md5),ecb(cipher_null))");
20048c2ecf20Sopenharmony_ci		break;
20058c2ecf20Sopenharmony_ci
20068c2ecf20Sopenharmony_ci	case 157:
20078c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))");
20088c2ecf20Sopenharmony_ci		break;
20098c2ecf20Sopenharmony_ci	case 181:
20108c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha1),cbc(des))");
20118c2ecf20Sopenharmony_ci		break;
20128c2ecf20Sopenharmony_ci	case 182:
20138c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))");
20148c2ecf20Sopenharmony_ci		break;
20158c2ecf20Sopenharmony_ci	case 183:
20168c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha224),cbc(des))");
20178c2ecf20Sopenharmony_ci		break;
20188c2ecf20Sopenharmony_ci	case 184:
20198c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))");
20208c2ecf20Sopenharmony_ci		break;
20218c2ecf20Sopenharmony_ci	case 185:
20228c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha256),cbc(des))");
20238c2ecf20Sopenharmony_ci		break;
20248c2ecf20Sopenharmony_ci	case 186:
20258c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))");
20268c2ecf20Sopenharmony_ci		break;
20278c2ecf20Sopenharmony_ci	case 187:
20288c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha384),cbc(des))");
20298c2ecf20Sopenharmony_ci		break;
20308c2ecf20Sopenharmony_ci	case 188:
20318c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))");
20328c2ecf20Sopenharmony_ci		break;
20338c2ecf20Sopenharmony_ci	case 189:
20348c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha512),cbc(des))");
20358c2ecf20Sopenharmony_ci		break;
20368c2ecf20Sopenharmony_ci	case 190:
20378c2ecf20Sopenharmony_ci		ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))");
20388c2ecf20Sopenharmony_ci		break;
20398c2ecf20Sopenharmony_ci	case 191:
20408c2ecf20Sopenharmony_ci		ret += tcrypt_test("ecb(sm4)");
20418c2ecf20Sopenharmony_ci		ret += tcrypt_test("cbc(sm4)");
20428c2ecf20Sopenharmony_ci		ret += tcrypt_test("ctr(sm4)");
20438c2ecf20Sopenharmony_ci		break;
20448c2ecf20Sopenharmony_ci	case 200:
20458c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
20468c2ecf20Sopenharmony_ci				speed_template_16_24_32);
20478c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
20488c2ecf20Sopenharmony_ci				speed_template_16_24_32);
20498c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
20508c2ecf20Sopenharmony_ci				speed_template_16_24_32);
20518c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
20528c2ecf20Sopenharmony_ci				speed_template_16_24_32);
20538c2ecf20Sopenharmony_ci		test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
20548c2ecf20Sopenharmony_ci				speed_template_32_40_48);
20558c2ecf20Sopenharmony_ci		test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
20568c2ecf20Sopenharmony_ci				speed_template_32_40_48);
20578c2ecf20Sopenharmony_ci		test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
20588c2ecf20Sopenharmony_ci				speed_template_32_64);
20598c2ecf20Sopenharmony_ci		test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
20608c2ecf20Sopenharmony_ci				speed_template_32_64);
20618c2ecf20Sopenharmony_ci		test_cipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
20628c2ecf20Sopenharmony_ci				speed_template_16_24_32);
20638c2ecf20Sopenharmony_ci		test_cipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
20648c2ecf20Sopenharmony_ci				speed_template_16_24_32);
20658c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
20668c2ecf20Sopenharmony_ci				speed_template_16_24_32);
20678c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
20688c2ecf20Sopenharmony_ci				speed_template_16_24_32);
20698c2ecf20Sopenharmony_ci		test_cipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
20708c2ecf20Sopenharmony_ci				speed_template_16_24_32);
20718c2ecf20Sopenharmony_ci		test_cipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
20728c2ecf20Sopenharmony_ci				speed_template_16_24_32);
20738c2ecf20Sopenharmony_ci		break;
20748c2ecf20Sopenharmony_ci
20758c2ecf20Sopenharmony_ci	case 201:
20768c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
20778c2ecf20Sopenharmony_ci				des3_speed_template, DES3_SPEED_VECTORS,
20788c2ecf20Sopenharmony_ci				speed_template_24);
20798c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
20808c2ecf20Sopenharmony_ci				des3_speed_template, DES3_SPEED_VECTORS,
20818c2ecf20Sopenharmony_ci				speed_template_24);
20828c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
20838c2ecf20Sopenharmony_ci				des3_speed_template, DES3_SPEED_VECTORS,
20848c2ecf20Sopenharmony_ci				speed_template_24);
20858c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
20868c2ecf20Sopenharmony_ci				des3_speed_template, DES3_SPEED_VECTORS,
20878c2ecf20Sopenharmony_ci				speed_template_24);
20888c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(des3_ede)", ENCRYPT, sec,
20898c2ecf20Sopenharmony_ci				des3_speed_template, DES3_SPEED_VECTORS,
20908c2ecf20Sopenharmony_ci				speed_template_24);
20918c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(des3_ede)", DECRYPT, sec,
20928c2ecf20Sopenharmony_ci				des3_speed_template, DES3_SPEED_VECTORS,
20938c2ecf20Sopenharmony_ci				speed_template_24);
20948c2ecf20Sopenharmony_ci		break;
20958c2ecf20Sopenharmony_ci
20968c2ecf20Sopenharmony_ci	case 202:
20978c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
20988c2ecf20Sopenharmony_ci				speed_template_16_24_32);
20998c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
21008c2ecf20Sopenharmony_ci				speed_template_16_24_32);
21018c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
21028c2ecf20Sopenharmony_ci				speed_template_16_24_32);
21038c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
21048c2ecf20Sopenharmony_ci				speed_template_16_24_32);
21058c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
21068c2ecf20Sopenharmony_ci				speed_template_16_24_32);
21078c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
21088c2ecf20Sopenharmony_ci				speed_template_16_24_32);
21098c2ecf20Sopenharmony_ci		test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
21108c2ecf20Sopenharmony_ci				speed_template_32_40_48);
21118c2ecf20Sopenharmony_ci		test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
21128c2ecf20Sopenharmony_ci				speed_template_32_40_48);
21138c2ecf20Sopenharmony_ci		test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
21148c2ecf20Sopenharmony_ci				speed_template_32_48_64);
21158c2ecf20Sopenharmony_ci		test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
21168c2ecf20Sopenharmony_ci				speed_template_32_48_64);
21178c2ecf20Sopenharmony_ci		break;
21188c2ecf20Sopenharmony_ci
21198c2ecf20Sopenharmony_ci	case 203:
21208c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
21218c2ecf20Sopenharmony_ci				  speed_template_8_32);
21228c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
21238c2ecf20Sopenharmony_ci				  speed_template_8_32);
21248c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
21258c2ecf20Sopenharmony_ci				  speed_template_8_32);
21268c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
21278c2ecf20Sopenharmony_ci				  speed_template_8_32);
21288c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
21298c2ecf20Sopenharmony_ci				  speed_template_8_32);
21308c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
21318c2ecf20Sopenharmony_ci				  speed_template_8_32);
21328c2ecf20Sopenharmony_ci		break;
21338c2ecf20Sopenharmony_ci
21348c2ecf20Sopenharmony_ci	case 204:
21358c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
21368c2ecf20Sopenharmony_ci				  speed_template_8);
21378c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
21388c2ecf20Sopenharmony_ci				  speed_template_8);
21398c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
21408c2ecf20Sopenharmony_ci				  speed_template_8);
21418c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
21428c2ecf20Sopenharmony_ci				  speed_template_8);
21438c2ecf20Sopenharmony_ci		break;
21448c2ecf20Sopenharmony_ci
21458c2ecf20Sopenharmony_ci	case 205:
21468c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
21478c2ecf20Sopenharmony_ci				speed_template_16_24_32);
21488c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
21498c2ecf20Sopenharmony_ci				speed_template_16_24_32);
21508c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
21518c2ecf20Sopenharmony_ci				speed_template_16_24_32);
21528c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
21538c2ecf20Sopenharmony_ci				speed_template_16_24_32);
21548c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
21558c2ecf20Sopenharmony_ci				speed_template_16_24_32);
21568c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
21578c2ecf20Sopenharmony_ci				speed_template_16_24_32);
21588c2ecf20Sopenharmony_ci		test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
21598c2ecf20Sopenharmony_ci				speed_template_32_40_48);
21608c2ecf20Sopenharmony_ci		test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
21618c2ecf20Sopenharmony_ci				speed_template_32_40_48);
21628c2ecf20Sopenharmony_ci		test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
21638c2ecf20Sopenharmony_ci				speed_template_32_48_64);
21648c2ecf20Sopenharmony_ci		test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
21658c2ecf20Sopenharmony_ci				speed_template_32_48_64);
21668c2ecf20Sopenharmony_ci		break;
21678c2ecf20Sopenharmony_ci
21688c2ecf20Sopenharmony_ci	case 206:
21698c2ecf20Sopenharmony_ci		test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0,
21708c2ecf20Sopenharmony_ci				  speed_template_16_32);
21718c2ecf20Sopenharmony_ci		break;
21728c2ecf20Sopenharmony_ci
21738c2ecf20Sopenharmony_ci	case 207:
21748c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
21758c2ecf20Sopenharmony_ci				  speed_template_16_32);
21768c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
21778c2ecf20Sopenharmony_ci				  speed_template_16_32);
21788c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
21798c2ecf20Sopenharmony_ci				  speed_template_16_32);
21808c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
21818c2ecf20Sopenharmony_ci				  speed_template_16_32);
21828c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
21838c2ecf20Sopenharmony_ci				  speed_template_16_32);
21848c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
21858c2ecf20Sopenharmony_ci				  speed_template_16_32);
21868c2ecf20Sopenharmony_ci		test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
21878c2ecf20Sopenharmony_ci				  speed_template_32_48);
21888c2ecf20Sopenharmony_ci		test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
21898c2ecf20Sopenharmony_ci				  speed_template_32_48);
21908c2ecf20Sopenharmony_ci		test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
21918c2ecf20Sopenharmony_ci				  speed_template_32_64);
21928c2ecf20Sopenharmony_ci		test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
21938c2ecf20Sopenharmony_ci				  speed_template_32_64);
21948c2ecf20Sopenharmony_ci		break;
21958c2ecf20Sopenharmony_ci
21968c2ecf20Sopenharmony_ci	case 208:
21978c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
21988c2ecf20Sopenharmony_ci				  speed_template_8);
21998c2ecf20Sopenharmony_ci		break;
22008c2ecf20Sopenharmony_ci
22018c2ecf20Sopenharmony_ci	case 209:
22028c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
22038c2ecf20Sopenharmony_ci				  speed_template_8_16);
22048c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
22058c2ecf20Sopenharmony_ci				  speed_template_8_16);
22068c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
22078c2ecf20Sopenharmony_ci				  speed_template_8_16);
22088c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
22098c2ecf20Sopenharmony_ci				  speed_template_8_16);
22108c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
22118c2ecf20Sopenharmony_ci				  speed_template_8_16);
22128c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
22138c2ecf20Sopenharmony_ci				  speed_template_8_16);
22148c2ecf20Sopenharmony_ci		break;
22158c2ecf20Sopenharmony_ci
22168c2ecf20Sopenharmony_ci	case 210:
22178c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
22188c2ecf20Sopenharmony_ci				  speed_template_16_32);
22198c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
22208c2ecf20Sopenharmony_ci				  speed_template_16_32);
22218c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
22228c2ecf20Sopenharmony_ci				  speed_template_16_32);
22238c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
22248c2ecf20Sopenharmony_ci				  speed_template_16_32);
22258c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
22268c2ecf20Sopenharmony_ci				  speed_template_16_32);
22278c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
22288c2ecf20Sopenharmony_ci				  speed_template_16_32);
22298c2ecf20Sopenharmony_ci		test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
22308c2ecf20Sopenharmony_ci				  speed_template_32_48);
22318c2ecf20Sopenharmony_ci		test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
22328c2ecf20Sopenharmony_ci				  speed_template_32_48);
22338c2ecf20Sopenharmony_ci		test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
22348c2ecf20Sopenharmony_ci				  speed_template_32_64);
22358c2ecf20Sopenharmony_ci		test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
22368c2ecf20Sopenharmony_ci				  speed_template_32_64);
22378c2ecf20Sopenharmony_ci		break;
22388c2ecf20Sopenharmony_ci
22398c2ecf20Sopenharmony_ci	case 211:
22408c2ecf20Sopenharmony_ci		test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec,
22418c2ecf20Sopenharmony_ci				NULL, 0, 16, 16, aead_speed_template_20);
22428c2ecf20Sopenharmony_ci		test_aead_speed("gcm(aes)", ENCRYPT, sec,
22438c2ecf20Sopenharmony_ci				NULL, 0, 16, 8, speed_template_16_24_32);
22448c2ecf20Sopenharmony_ci		test_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec,
22458c2ecf20Sopenharmony_ci				NULL, 0, 16, 16, aead_speed_template_20);
22468c2ecf20Sopenharmony_ci		test_aead_speed("gcm(aes)", DECRYPT, sec,
22478c2ecf20Sopenharmony_ci				NULL, 0, 16, 8, speed_template_16_24_32);
22488c2ecf20Sopenharmony_ci		break;
22498c2ecf20Sopenharmony_ci
22508c2ecf20Sopenharmony_ci	case 212:
22518c2ecf20Sopenharmony_ci		test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec,
22528c2ecf20Sopenharmony_ci				NULL, 0, 16, 16, aead_speed_template_19);
22538c2ecf20Sopenharmony_ci		test_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec,
22548c2ecf20Sopenharmony_ci				NULL, 0, 16, 16, aead_speed_template_19);
22558c2ecf20Sopenharmony_ci		break;
22568c2ecf20Sopenharmony_ci
22578c2ecf20Sopenharmony_ci	case 213:
22588c2ecf20Sopenharmony_ci		test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec,
22598c2ecf20Sopenharmony_ci				NULL, 0, 16, 8, aead_speed_template_36);
22608c2ecf20Sopenharmony_ci		test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT, sec,
22618c2ecf20Sopenharmony_ci				NULL, 0, 16, 8, aead_speed_template_36);
22628c2ecf20Sopenharmony_ci		break;
22638c2ecf20Sopenharmony_ci
22648c2ecf20Sopenharmony_ci	case 214:
22658c2ecf20Sopenharmony_ci		test_cipher_speed("chacha20", ENCRYPT, sec, NULL, 0,
22668c2ecf20Sopenharmony_ci				  speed_template_32);
22678c2ecf20Sopenharmony_ci		break;
22688c2ecf20Sopenharmony_ci
22698c2ecf20Sopenharmony_ci	case 215:
22708c2ecf20Sopenharmony_ci		test_mb_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec, NULL,
22718c2ecf20Sopenharmony_ci				   0, 16, 16, aead_speed_template_20, num_mb);
22728c2ecf20Sopenharmony_ci		test_mb_aead_speed("gcm(aes)", ENCRYPT, sec, NULL, 0, 16, 8,
22738c2ecf20Sopenharmony_ci				   speed_template_16_24_32, num_mb);
22748c2ecf20Sopenharmony_ci		test_mb_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec, NULL,
22758c2ecf20Sopenharmony_ci				   0, 16, 16, aead_speed_template_20, num_mb);
22768c2ecf20Sopenharmony_ci		test_mb_aead_speed("gcm(aes)", DECRYPT, sec, NULL, 0, 16, 8,
22778c2ecf20Sopenharmony_ci				   speed_template_16_24_32, num_mb);
22788c2ecf20Sopenharmony_ci		break;
22798c2ecf20Sopenharmony_ci
22808c2ecf20Sopenharmony_ci	case 216:
22818c2ecf20Sopenharmony_ci		test_mb_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec, NULL, 0,
22828c2ecf20Sopenharmony_ci				   16, 16, aead_speed_template_19, num_mb);
22838c2ecf20Sopenharmony_ci		test_mb_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec, NULL, 0,
22848c2ecf20Sopenharmony_ci				   16, 16, aead_speed_template_19, num_mb);
22858c2ecf20Sopenharmony_ci		break;
22868c2ecf20Sopenharmony_ci
22878c2ecf20Sopenharmony_ci	case 217:
22888c2ecf20Sopenharmony_ci		test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT,
22898c2ecf20Sopenharmony_ci				   sec, NULL, 0, 16, 8, aead_speed_template_36,
22908c2ecf20Sopenharmony_ci				   num_mb);
22918c2ecf20Sopenharmony_ci		test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT,
22928c2ecf20Sopenharmony_ci				   sec, NULL, 0, 16, 8, aead_speed_template_36,
22938c2ecf20Sopenharmony_ci				   num_mb);
22948c2ecf20Sopenharmony_ci		break;
22958c2ecf20Sopenharmony_ci
22968c2ecf20Sopenharmony_ci	case 218:
22978c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(sm4)", ENCRYPT, sec, NULL, 0,
22988c2ecf20Sopenharmony_ci				speed_template_16);
22998c2ecf20Sopenharmony_ci		test_cipher_speed("ecb(sm4)", DECRYPT, sec, NULL, 0,
23008c2ecf20Sopenharmony_ci				speed_template_16);
23018c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(sm4)", ENCRYPT, sec, NULL, 0,
23028c2ecf20Sopenharmony_ci				speed_template_16);
23038c2ecf20Sopenharmony_ci		test_cipher_speed("cbc(sm4)", DECRYPT, sec, NULL, 0,
23048c2ecf20Sopenharmony_ci				speed_template_16);
23058c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(sm4)", ENCRYPT, sec, NULL, 0,
23068c2ecf20Sopenharmony_ci				speed_template_16);
23078c2ecf20Sopenharmony_ci		test_cipher_speed("ctr(sm4)", DECRYPT, sec, NULL, 0,
23088c2ecf20Sopenharmony_ci				speed_template_16);
23098c2ecf20Sopenharmony_ci		break;
23108c2ecf20Sopenharmony_ci
23118c2ecf20Sopenharmony_ci	case 219:
23128c2ecf20Sopenharmony_ci		test_cipher_speed("adiantum(xchacha12,aes)", ENCRYPT, sec, NULL,
23138c2ecf20Sopenharmony_ci				  0, speed_template_32);
23148c2ecf20Sopenharmony_ci		test_cipher_speed("adiantum(xchacha12,aes)", DECRYPT, sec, NULL,
23158c2ecf20Sopenharmony_ci				  0, speed_template_32);
23168c2ecf20Sopenharmony_ci		test_cipher_speed("adiantum(xchacha20,aes)", ENCRYPT, sec, NULL,
23178c2ecf20Sopenharmony_ci				  0, speed_template_32);
23188c2ecf20Sopenharmony_ci		test_cipher_speed("adiantum(xchacha20,aes)", DECRYPT, sec, NULL,
23198c2ecf20Sopenharmony_ci				  0, speed_template_32);
23208c2ecf20Sopenharmony_ci		break;
23218c2ecf20Sopenharmony_ci
23228c2ecf20Sopenharmony_ci	case 220:
23238c2ecf20Sopenharmony_ci		test_acipher_speed("essiv(cbc(aes),sha256)",
23248c2ecf20Sopenharmony_ci				  ENCRYPT, sec, NULL, 0,
23258c2ecf20Sopenharmony_ci				  speed_template_16_24_32);
23268c2ecf20Sopenharmony_ci		test_acipher_speed("essiv(cbc(aes),sha256)",
23278c2ecf20Sopenharmony_ci				  DECRYPT, sec, NULL, 0,
23288c2ecf20Sopenharmony_ci				  speed_template_16_24_32);
23298c2ecf20Sopenharmony_ci		break;
23308c2ecf20Sopenharmony_ci
23318c2ecf20Sopenharmony_ci	case 221:
23328c2ecf20Sopenharmony_ci		test_aead_speed("aegis128", ENCRYPT, sec,
23338c2ecf20Sopenharmony_ci				NULL, 0, 16, 8, speed_template_16);
23348c2ecf20Sopenharmony_ci		test_aead_speed("aegis128", DECRYPT, sec,
23358c2ecf20Sopenharmony_ci				NULL, 0, 16, 8, speed_template_16);
23368c2ecf20Sopenharmony_ci		break;
23378c2ecf20Sopenharmony_ci
23388c2ecf20Sopenharmony_ci	case 300:
23398c2ecf20Sopenharmony_ci		if (alg) {
23408c2ecf20Sopenharmony_ci			test_hash_speed(alg, sec, generic_hash_speed_template);
23418c2ecf20Sopenharmony_ci			break;
23428c2ecf20Sopenharmony_ci		}
23438c2ecf20Sopenharmony_ci		fallthrough;
23448c2ecf20Sopenharmony_ci	case 301:
23458c2ecf20Sopenharmony_ci		test_hash_speed("md4", sec, generic_hash_speed_template);
23468c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23478c2ecf20Sopenharmony_ci		fallthrough;
23488c2ecf20Sopenharmony_ci	case 302:
23498c2ecf20Sopenharmony_ci		test_hash_speed("md5", sec, generic_hash_speed_template);
23508c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23518c2ecf20Sopenharmony_ci		fallthrough;
23528c2ecf20Sopenharmony_ci	case 303:
23538c2ecf20Sopenharmony_ci		test_hash_speed("sha1", sec, generic_hash_speed_template);
23548c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23558c2ecf20Sopenharmony_ci		fallthrough;
23568c2ecf20Sopenharmony_ci	case 304:
23578c2ecf20Sopenharmony_ci		test_hash_speed("sha256", sec, generic_hash_speed_template);
23588c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23598c2ecf20Sopenharmony_ci		fallthrough;
23608c2ecf20Sopenharmony_ci	case 305:
23618c2ecf20Sopenharmony_ci		test_hash_speed("sha384", sec, generic_hash_speed_template);
23628c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23638c2ecf20Sopenharmony_ci		fallthrough;
23648c2ecf20Sopenharmony_ci	case 306:
23658c2ecf20Sopenharmony_ci		test_hash_speed("sha512", sec, generic_hash_speed_template);
23668c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23678c2ecf20Sopenharmony_ci		fallthrough;
23688c2ecf20Sopenharmony_ci	case 307:
23698c2ecf20Sopenharmony_ci		test_hash_speed("wp256", sec, generic_hash_speed_template);
23708c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23718c2ecf20Sopenharmony_ci		fallthrough;
23728c2ecf20Sopenharmony_ci	case 308:
23738c2ecf20Sopenharmony_ci		test_hash_speed("wp384", sec, generic_hash_speed_template);
23748c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23758c2ecf20Sopenharmony_ci		fallthrough;
23768c2ecf20Sopenharmony_ci	case 309:
23778c2ecf20Sopenharmony_ci		test_hash_speed("wp512", sec, generic_hash_speed_template);
23788c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23798c2ecf20Sopenharmony_ci		fallthrough;
23808c2ecf20Sopenharmony_ci	case 310:
23818c2ecf20Sopenharmony_ci		test_hash_speed("tgr128", sec, generic_hash_speed_template);
23828c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23838c2ecf20Sopenharmony_ci		fallthrough;
23848c2ecf20Sopenharmony_ci	case 311:
23858c2ecf20Sopenharmony_ci		test_hash_speed("tgr160", sec, generic_hash_speed_template);
23868c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23878c2ecf20Sopenharmony_ci		fallthrough;
23888c2ecf20Sopenharmony_ci	case 312:
23898c2ecf20Sopenharmony_ci		test_hash_speed("tgr192", sec, generic_hash_speed_template);
23908c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23918c2ecf20Sopenharmony_ci		fallthrough;
23928c2ecf20Sopenharmony_ci	case 313:
23938c2ecf20Sopenharmony_ci		test_hash_speed("sha224", sec, generic_hash_speed_template);
23948c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23958c2ecf20Sopenharmony_ci		fallthrough;
23968c2ecf20Sopenharmony_ci	case 314:
23978c2ecf20Sopenharmony_ci		test_hash_speed("rmd128", sec, generic_hash_speed_template);
23988c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
23998c2ecf20Sopenharmony_ci		fallthrough;
24008c2ecf20Sopenharmony_ci	case 315:
24018c2ecf20Sopenharmony_ci		test_hash_speed("rmd160", sec, generic_hash_speed_template);
24028c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24038c2ecf20Sopenharmony_ci		fallthrough;
24048c2ecf20Sopenharmony_ci	case 316:
24058c2ecf20Sopenharmony_ci		test_hash_speed("rmd256", sec, generic_hash_speed_template);
24068c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24078c2ecf20Sopenharmony_ci		fallthrough;
24088c2ecf20Sopenharmony_ci	case 317:
24098c2ecf20Sopenharmony_ci		test_hash_speed("rmd320", sec, generic_hash_speed_template);
24108c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24118c2ecf20Sopenharmony_ci		fallthrough;
24128c2ecf20Sopenharmony_ci	case 318:
24138c2ecf20Sopenharmony_ci		klen = 16;
24148c2ecf20Sopenharmony_ci		test_hash_speed("ghash", sec, generic_hash_speed_template);
24158c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24168c2ecf20Sopenharmony_ci		fallthrough;
24178c2ecf20Sopenharmony_ci	case 319:
24188c2ecf20Sopenharmony_ci		test_hash_speed("crc32c", sec, generic_hash_speed_template);
24198c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24208c2ecf20Sopenharmony_ci		fallthrough;
24218c2ecf20Sopenharmony_ci	case 320:
24228c2ecf20Sopenharmony_ci		test_hash_speed("crct10dif", sec, generic_hash_speed_template);
24238c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24248c2ecf20Sopenharmony_ci		fallthrough;
24258c2ecf20Sopenharmony_ci	case 321:
24268c2ecf20Sopenharmony_ci		test_hash_speed("poly1305", sec, poly1305_speed_template);
24278c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24288c2ecf20Sopenharmony_ci		fallthrough;
24298c2ecf20Sopenharmony_ci	case 322:
24308c2ecf20Sopenharmony_ci		test_hash_speed("sha3-224", sec, generic_hash_speed_template);
24318c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24328c2ecf20Sopenharmony_ci		fallthrough;
24338c2ecf20Sopenharmony_ci	case 323:
24348c2ecf20Sopenharmony_ci		test_hash_speed("sha3-256", sec, generic_hash_speed_template);
24358c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24368c2ecf20Sopenharmony_ci		fallthrough;
24378c2ecf20Sopenharmony_ci	case 324:
24388c2ecf20Sopenharmony_ci		test_hash_speed("sha3-384", sec, generic_hash_speed_template);
24398c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24408c2ecf20Sopenharmony_ci		fallthrough;
24418c2ecf20Sopenharmony_ci	case 325:
24428c2ecf20Sopenharmony_ci		test_hash_speed("sha3-512", sec, generic_hash_speed_template);
24438c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24448c2ecf20Sopenharmony_ci		fallthrough;
24458c2ecf20Sopenharmony_ci	case 326:
24468c2ecf20Sopenharmony_ci		test_hash_speed("sm3", sec, generic_hash_speed_template);
24478c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24488c2ecf20Sopenharmony_ci		fallthrough;
24498c2ecf20Sopenharmony_ci	case 327:
24508c2ecf20Sopenharmony_ci		test_hash_speed("streebog256", sec,
24518c2ecf20Sopenharmony_ci				generic_hash_speed_template);
24528c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24538c2ecf20Sopenharmony_ci		fallthrough;
24548c2ecf20Sopenharmony_ci	case 328:
24558c2ecf20Sopenharmony_ci		test_hash_speed("streebog512", sec,
24568c2ecf20Sopenharmony_ci				generic_hash_speed_template);
24578c2ecf20Sopenharmony_ci		if (mode > 300 && mode < 400) break;
24588c2ecf20Sopenharmony_ci		fallthrough;
24598c2ecf20Sopenharmony_ci	case 399:
24608c2ecf20Sopenharmony_ci		break;
24618c2ecf20Sopenharmony_ci
24628c2ecf20Sopenharmony_ci	case 400:
24638c2ecf20Sopenharmony_ci		if (alg) {
24648c2ecf20Sopenharmony_ci			test_ahash_speed(alg, sec, generic_hash_speed_template);
24658c2ecf20Sopenharmony_ci			break;
24668c2ecf20Sopenharmony_ci		}
24678c2ecf20Sopenharmony_ci		fallthrough;
24688c2ecf20Sopenharmony_ci	case 401:
24698c2ecf20Sopenharmony_ci		test_ahash_speed("md4", sec, generic_hash_speed_template);
24708c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
24718c2ecf20Sopenharmony_ci		fallthrough;
24728c2ecf20Sopenharmony_ci	case 402:
24738c2ecf20Sopenharmony_ci		test_ahash_speed("md5", sec, generic_hash_speed_template);
24748c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
24758c2ecf20Sopenharmony_ci		fallthrough;
24768c2ecf20Sopenharmony_ci	case 403:
24778c2ecf20Sopenharmony_ci		test_ahash_speed("sha1", sec, generic_hash_speed_template);
24788c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
24798c2ecf20Sopenharmony_ci		fallthrough;
24808c2ecf20Sopenharmony_ci	case 404:
24818c2ecf20Sopenharmony_ci		test_ahash_speed("sha256", sec, generic_hash_speed_template);
24828c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
24838c2ecf20Sopenharmony_ci		fallthrough;
24848c2ecf20Sopenharmony_ci	case 405:
24858c2ecf20Sopenharmony_ci		test_ahash_speed("sha384", sec, generic_hash_speed_template);
24868c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
24878c2ecf20Sopenharmony_ci		fallthrough;
24888c2ecf20Sopenharmony_ci	case 406:
24898c2ecf20Sopenharmony_ci		test_ahash_speed("sha512", sec, generic_hash_speed_template);
24908c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
24918c2ecf20Sopenharmony_ci		fallthrough;
24928c2ecf20Sopenharmony_ci	case 407:
24938c2ecf20Sopenharmony_ci		test_ahash_speed("wp256", sec, generic_hash_speed_template);
24948c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
24958c2ecf20Sopenharmony_ci		fallthrough;
24968c2ecf20Sopenharmony_ci	case 408:
24978c2ecf20Sopenharmony_ci		test_ahash_speed("wp384", sec, generic_hash_speed_template);
24988c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
24998c2ecf20Sopenharmony_ci		fallthrough;
25008c2ecf20Sopenharmony_ci	case 409:
25018c2ecf20Sopenharmony_ci		test_ahash_speed("wp512", sec, generic_hash_speed_template);
25028c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25038c2ecf20Sopenharmony_ci		fallthrough;
25048c2ecf20Sopenharmony_ci	case 410:
25058c2ecf20Sopenharmony_ci		test_ahash_speed("tgr128", sec, generic_hash_speed_template);
25068c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25078c2ecf20Sopenharmony_ci		fallthrough;
25088c2ecf20Sopenharmony_ci	case 411:
25098c2ecf20Sopenharmony_ci		test_ahash_speed("tgr160", sec, generic_hash_speed_template);
25108c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25118c2ecf20Sopenharmony_ci		fallthrough;
25128c2ecf20Sopenharmony_ci	case 412:
25138c2ecf20Sopenharmony_ci		test_ahash_speed("tgr192", sec, generic_hash_speed_template);
25148c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25158c2ecf20Sopenharmony_ci		fallthrough;
25168c2ecf20Sopenharmony_ci	case 413:
25178c2ecf20Sopenharmony_ci		test_ahash_speed("sha224", sec, generic_hash_speed_template);
25188c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25198c2ecf20Sopenharmony_ci		fallthrough;
25208c2ecf20Sopenharmony_ci	case 414:
25218c2ecf20Sopenharmony_ci		test_ahash_speed("rmd128", sec, generic_hash_speed_template);
25228c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25238c2ecf20Sopenharmony_ci		fallthrough;
25248c2ecf20Sopenharmony_ci	case 415:
25258c2ecf20Sopenharmony_ci		test_ahash_speed("rmd160", sec, generic_hash_speed_template);
25268c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25278c2ecf20Sopenharmony_ci		fallthrough;
25288c2ecf20Sopenharmony_ci	case 416:
25298c2ecf20Sopenharmony_ci		test_ahash_speed("rmd256", sec, generic_hash_speed_template);
25308c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25318c2ecf20Sopenharmony_ci		fallthrough;
25328c2ecf20Sopenharmony_ci	case 417:
25338c2ecf20Sopenharmony_ci		test_ahash_speed("rmd320", sec, generic_hash_speed_template);
25348c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25358c2ecf20Sopenharmony_ci		fallthrough;
25368c2ecf20Sopenharmony_ci	case 418:
25378c2ecf20Sopenharmony_ci		test_ahash_speed("sha3-224", sec, generic_hash_speed_template);
25388c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25398c2ecf20Sopenharmony_ci		fallthrough;
25408c2ecf20Sopenharmony_ci	case 419:
25418c2ecf20Sopenharmony_ci		test_ahash_speed("sha3-256", sec, generic_hash_speed_template);
25428c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25438c2ecf20Sopenharmony_ci		fallthrough;
25448c2ecf20Sopenharmony_ci	case 420:
25458c2ecf20Sopenharmony_ci		test_ahash_speed("sha3-384", sec, generic_hash_speed_template);
25468c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25478c2ecf20Sopenharmony_ci		fallthrough;
25488c2ecf20Sopenharmony_ci	case 421:
25498c2ecf20Sopenharmony_ci		test_ahash_speed("sha3-512", sec, generic_hash_speed_template);
25508c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25518c2ecf20Sopenharmony_ci		fallthrough;
25528c2ecf20Sopenharmony_ci	case 422:
25538c2ecf20Sopenharmony_ci		test_mb_ahash_speed("sha1", sec, generic_hash_speed_template,
25548c2ecf20Sopenharmony_ci				    num_mb);
25558c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25568c2ecf20Sopenharmony_ci		fallthrough;
25578c2ecf20Sopenharmony_ci	case 423:
25588c2ecf20Sopenharmony_ci		test_mb_ahash_speed("sha256", sec, generic_hash_speed_template,
25598c2ecf20Sopenharmony_ci				    num_mb);
25608c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25618c2ecf20Sopenharmony_ci		fallthrough;
25628c2ecf20Sopenharmony_ci	case 424:
25638c2ecf20Sopenharmony_ci		test_mb_ahash_speed("sha512", sec, generic_hash_speed_template,
25648c2ecf20Sopenharmony_ci				    num_mb);
25658c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25668c2ecf20Sopenharmony_ci		fallthrough;
25678c2ecf20Sopenharmony_ci	case 425:
25688c2ecf20Sopenharmony_ci		test_mb_ahash_speed("sm3", sec, generic_hash_speed_template,
25698c2ecf20Sopenharmony_ci				    num_mb);
25708c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25718c2ecf20Sopenharmony_ci		fallthrough;
25728c2ecf20Sopenharmony_ci	case 426:
25738c2ecf20Sopenharmony_ci		test_mb_ahash_speed("streebog256", sec,
25748c2ecf20Sopenharmony_ci				    generic_hash_speed_template, num_mb);
25758c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25768c2ecf20Sopenharmony_ci		fallthrough;
25778c2ecf20Sopenharmony_ci	case 427:
25788c2ecf20Sopenharmony_ci		test_mb_ahash_speed("streebog512", sec,
25798c2ecf20Sopenharmony_ci				    generic_hash_speed_template, num_mb);
25808c2ecf20Sopenharmony_ci		if (mode > 400 && mode < 500) break;
25818c2ecf20Sopenharmony_ci		fallthrough;
25828c2ecf20Sopenharmony_ci	case 499:
25838c2ecf20Sopenharmony_ci		break;
25848c2ecf20Sopenharmony_ci
25858c2ecf20Sopenharmony_ci	case 500:
25868c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
25878c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
25888c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
25898c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
25908c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
25918c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
25928c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
25938c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
25948c2ecf20Sopenharmony_ci		test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
25958c2ecf20Sopenharmony_ci				   speed_template_32_40_48);
25968c2ecf20Sopenharmony_ci		test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
25978c2ecf20Sopenharmony_ci				   speed_template_32_40_48);
25988c2ecf20Sopenharmony_ci		test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
25998c2ecf20Sopenharmony_ci				   speed_template_32_64);
26008c2ecf20Sopenharmony_ci		test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
26018c2ecf20Sopenharmony_ci				   speed_template_32_64);
26028c2ecf20Sopenharmony_ci		test_acipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
26038c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
26048c2ecf20Sopenharmony_ci		test_acipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
26058c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
26068c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
26078c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
26088c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
26098c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
26108c2ecf20Sopenharmony_ci		test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
26118c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
26128c2ecf20Sopenharmony_ci		test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
26138c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
26148c2ecf20Sopenharmony_ci		test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
26158c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
26168c2ecf20Sopenharmony_ci		test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
26178c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
26188c2ecf20Sopenharmony_ci		test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL, 0,
26198c2ecf20Sopenharmony_ci				   speed_template_20_28_36);
26208c2ecf20Sopenharmony_ci		test_acipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL, 0,
26218c2ecf20Sopenharmony_ci				   speed_template_20_28_36);
26228c2ecf20Sopenharmony_ci		break;
26238c2ecf20Sopenharmony_ci
26248c2ecf20Sopenharmony_ci	case 501:
26258c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec,
26268c2ecf20Sopenharmony_ci				   des3_speed_template, DES3_SPEED_VECTORS,
26278c2ecf20Sopenharmony_ci				   speed_template_24);
26288c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(des3_ede)", DECRYPT, sec,
26298c2ecf20Sopenharmony_ci				   des3_speed_template, DES3_SPEED_VECTORS,
26308c2ecf20Sopenharmony_ci				   speed_template_24);
26318c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec,
26328c2ecf20Sopenharmony_ci				   des3_speed_template, DES3_SPEED_VECTORS,
26338c2ecf20Sopenharmony_ci				   speed_template_24);
26348c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(des3_ede)", DECRYPT, sec,
26358c2ecf20Sopenharmony_ci				   des3_speed_template, DES3_SPEED_VECTORS,
26368c2ecf20Sopenharmony_ci				   speed_template_24);
26378c2ecf20Sopenharmony_ci		test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec,
26388c2ecf20Sopenharmony_ci				   des3_speed_template, DES3_SPEED_VECTORS,
26398c2ecf20Sopenharmony_ci				   speed_template_24);
26408c2ecf20Sopenharmony_ci		test_acipher_speed("cfb(des3_ede)", DECRYPT, sec,
26418c2ecf20Sopenharmony_ci				   des3_speed_template, DES3_SPEED_VECTORS,
26428c2ecf20Sopenharmony_ci				   speed_template_24);
26438c2ecf20Sopenharmony_ci		test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec,
26448c2ecf20Sopenharmony_ci				   des3_speed_template, DES3_SPEED_VECTORS,
26458c2ecf20Sopenharmony_ci				   speed_template_24);
26468c2ecf20Sopenharmony_ci		test_acipher_speed("ofb(des3_ede)", DECRYPT, sec,
26478c2ecf20Sopenharmony_ci				   des3_speed_template, DES3_SPEED_VECTORS,
26488c2ecf20Sopenharmony_ci				   speed_template_24);
26498c2ecf20Sopenharmony_ci		break;
26508c2ecf20Sopenharmony_ci
26518c2ecf20Sopenharmony_ci	case 502:
26528c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
26538c2ecf20Sopenharmony_ci				   speed_template_8);
26548c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
26558c2ecf20Sopenharmony_ci				   speed_template_8);
26568c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
26578c2ecf20Sopenharmony_ci				   speed_template_8);
26588c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
26598c2ecf20Sopenharmony_ci				   speed_template_8);
26608c2ecf20Sopenharmony_ci		test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
26618c2ecf20Sopenharmony_ci				   speed_template_8);
26628c2ecf20Sopenharmony_ci		test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
26638c2ecf20Sopenharmony_ci				   speed_template_8);
26648c2ecf20Sopenharmony_ci		test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
26658c2ecf20Sopenharmony_ci				   speed_template_8);
26668c2ecf20Sopenharmony_ci		test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
26678c2ecf20Sopenharmony_ci				   speed_template_8);
26688c2ecf20Sopenharmony_ci		break;
26698c2ecf20Sopenharmony_ci
26708c2ecf20Sopenharmony_ci	case 503:
26718c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
26728c2ecf20Sopenharmony_ci				   speed_template_16_32);
26738c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
26748c2ecf20Sopenharmony_ci				   speed_template_16_32);
26758c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
26768c2ecf20Sopenharmony_ci				   speed_template_16_32);
26778c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
26788c2ecf20Sopenharmony_ci				   speed_template_16_32);
26798c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
26808c2ecf20Sopenharmony_ci				   speed_template_16_32);
26818c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
26828c2ecf20Sopenharmony_ci				   speed_template_16_32);
26838c2ecf20Sopenharmony_ci		test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
26848c2ecf20Sopenharmony_ci				   speed_template_32_48);
26858c2ecf20Sopenharmony_ci		test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
26868c2ecf20Sopenharmony_ci				   speed_template_32_48);
26878c2ecf20Sopenharmony_ci		test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
26888c2ecf20Sopenharmony_ci				   speed_template_32_64);
26898c2ecf20Sopenharmony_ci		test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
26908c2ecf20Sopenharmony_ci				   speed_template_32_64);
26918c2ecf20Sopenharmony_ci		break;
26928c2ecf20Sopenharmony_ci
26938c2ecf20Sopenharmony_ci	case 504:
26948c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
26958c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
26968c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
26978c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
26988c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
26998c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
27008c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
27018c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
27028c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
27038c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
27048c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
27058c2ecf20Sopenharmony_ci				   speed_template_16_24_32);
27068c2ecf20Sopenharmony_ci		test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
27078c2ecf20Sopenharmony_ci				   speed_template_32_40_48);
27088c2ecf20Sopenharmony_ci		test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
27098c2ecf20Sopenharmony_ci				   speed_template_32_40_48);
27108c2ecf20Sopenharmony_ci		test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
27118c2ecf20Sopenharmony_ci				   speed_template_32_48_64);
27128c2ecf20Sopenharmony_ci		test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
27138c2ecf20Sopenharmony_ci				   speed_template_32_48_64);
27148c2ecf20Sopenharmony_ci		break;
27158c2ecf20Sopenharmony_ci
27168c2ecf20Sopenharmony_ci	case 505:
27178c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
27188c2ecf20Sopenharmony_ci				   speed_template_8);
27198c2ecf20Sopenharmony_ci		break;
27208c2ecf20Sopenharmony_ci
27218c2ecf20Sopenharmony_ci	case 506:
27228c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
27238c2ecf20Sopenharmony_ci				   speed_template_8_16);
27248c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
27258c2ecf20Sopenharmony_ci				   speed_template_8_16);
27268c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
27278c2ecf20Sopenharmony_ci				   speed_template_8_16);
27288c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
27298c2ecf20Sopenharmony_ci				   speed_template_8_16);
27308c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
27318c2ecf20Sopenharmony_ci				   speed_template_8_16);
27328c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
27338c2ecf20Sopenharmony_ci				   speed_template_8_16);
27348c2ecf20Sopenharmony_ci		break;
27358c2ecf20Sopenharmony_ci
27368c2ecf20Sopenharmony_ci	case 507:
27378c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
27388c2ecf20Sopenharmony_ci				   speed_template_16_32);
27398c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
27408c2ecf20Sopenharmony_ci				   speed_template_16_32);
27418c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
27428c2ecf20Sopenharmony_ci				   speed_template_16_32);
27438c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
27448c2ecf20Sopenharmony_ci				   speed_template_16_32);
27458c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
27468c2ecf20Sopenharmony_ci				   speed_template_16_32);
27478c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
27488c2ecf20Sopenharmony_ci				   speed_template_16_32);
27498c2ecf20Sopenharmony_ci		test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
27508c2ecf20Sopenharmony_ci				   speed_template_32_48);
27518c2ecf20Sopenharmony_ci		test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
27528c2ecf20Sopenharmony_ci				   speed_template_32_48);
27538c2ecf20Sopenharmony_ci		test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
27548c2ecf20Sopenharmony_ci				   speed_template_32_64);
27558c2ecf20Sopenharmony_ci		test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
27568c2ecf20Sopenharmony_ci				   speed_template_32_64);
27578c2ecf20Sopenharmony_ci		break;
27588c2ecf20Sopenharmony_ci
27598c2ecf20Sopenharmony_ci	case 508:
27608c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
27618c2ecf20Sopenharmony_ci				   speed_template_16_32);
27628c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
27638c2ecf20Sopenharmony_ci				   speed_template_16_32);
27648c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
27658c2ecf20Sopenharmony_ci				   speed_template_16_32);
27668c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
27678c2ecf20Sopenharmony_ci				   speed_template_16_32);
27688c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
27698c2ecf20Sopenharmony_ci				   speed_template_16_32);
27708c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
27718c2ecf20Sopenharmony_ci				   speed_template_16_32);
27728c2ecf20Sopenharmony_ci		test_acipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
27738c2ecf20Sopenharmony_ci				   speed_template_32_48);
27748c2ecf20Sopenharmony_ci		test_acipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
27758c2ecf20Sopenharmony_ci				   speed_template_32_48);
27768c2ecf20Sopenharmony_ci		test_acipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
27778c2ecf20Sopenharmony_ci				   speed_template_32_64);
27788c2ecf20Sopenharmony_ci		test_acipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
27798c2ecf20Sopenharmony_ci				   speed_template_32_64);
27808c2ecf20Sopenharmony_ci		break;
27818c2ecf20Sopenharmony_ci
27828c2ecf20Sopenharmony_ci	case 509:
27838c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
27848c2ecf20Sopenharmony_ci				   speed_template_8_32);
27858c2ecf20Sopenharmony_ci		test_acipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
27868c2ecf20Sopenharmony_ci				   speed_template_8_32);
27878c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
27888c2ecf20Sopenharmony_ci				   speed_template_8_32);
27898c2ecf20Sopenharmony_ci		test_acipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
27908c2ecf20Sopenharmony_ci				   speed_template_8_32);
27918c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
27928c2ecf20Sopenharmony_ci				   speed_template_8_32);
27938c2ecf20Sopenharmony_ci		test_acipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
27948c2ecf20Sopenharmony_ci				   speed_template_8_32);
27958c2ecf20Sopenharmony_ci		break;
27968c2ecf20Sopenharmony_ci
27978c2ecf20Sopenharmony_ci	case 600:
27988c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
27998c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28008c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
28018c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28028c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
28038c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28048c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
28058c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28068c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
28078c2ecf20Sopenharmony_ci				       speed_template_32_40_48, num_mb);
28088c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
28098c2ecf20Sopenharmony_ci				       speed_template_32_40_48, num_mb);
28108c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
28118c2ecf20Sopenharmony_ci				       speed_template_32_64, num_mb);
28128c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
28138c2ecf20Sopenharmony_ci				       speed_template_32_64, num_mb);
28148c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
28158c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28168c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
28178c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28188c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
28198c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28208c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
28218c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28228c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
28238c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28248c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
28258c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28268c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
28278c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28288c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
28298c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
28308c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL,
28318c2ecf20Sopenharmony_ci				       0, speed_template_20_28_36, num_mb);
28328c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL,
28338c2ecf20Sopenharmony_ci				       0, speed_template_20_28_36, num_mb);
28348c2ecf20Sopenharmony_ci		break;
28358c2ecf20Sopenharmony_ci
28368c2ecf20Sopenharmony_ci	case 601:
28378c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(des3_ede)", ENCRYPT, sec,
28388c2ecf20Sopenharmony_ci				       des3_speed_template, DES3_SPEED_VECTORS,
28398c2ecf20Sopenharmony_ci				       speed_template_24, num_mb);
28408c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(des3_ede)", DECRYPT, sec,
28418c2ecf20Sopenharmony_ci				       des3_speed_template, DES3_SPEED_VECTORS,
28428c2ecf20Sopenharmony_ci				       speed_template_24, num_mb);
28438c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(des3_ede)", ENCRYPT, sec,
28448c2ecf20Sopenharmony_ci				       des3_speed_template, DES3_SPEED_VECTORS,
28458c2ecf20Sopenharmony_ci				       speed_template_24, num_mb);
28468c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(des3_ede)", DECRYPT, sec,
28478c2ecf20Sopenharmony_ci				       des3_speed_template, DES3_SPEED_VECTORS,
28488c2ecf20Sopenharmony_ci				       speed_template_24, num_mb);
28498c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cfb(des3_ede)", ENCRYPT, sec,
28508c2ecf20Sopenharmony_ci				       des3_speed_template, DES3_SPEED_VECTORS,
28518c2ecf20Sopenharmony_ci				       speed_template_24, num_mb);
28528c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cfb(des3_ede)", DECRYPT, sec,
28538c2ecf20Sopenharmony_ci				       des3_speed_template, DES3_SPEED_VECTORS,
28548c2ecf20Sopenharmony_ci				       speed_template_24, num_mb);
28558c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ofb(des3_ede)", ENCRYPT, sec,
28568c2ecf20Sopenharmony_ci				       des3_speed_template, DES3_SPEED_VECTORS,
28578c2ecf20Sopenharmony_ci				       speed_template_24, num_mb);
28588c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ofb(des3_ede)", DECRYPT, sec,
28598c2ecf20Sopenharmony_ci				       des3_speed_template, DES3_SPEED_VECTORS,
28608c2ecf20Sopenharmony_ci				       speed_template_24, num_mb);
28618c2ecf20Sopenharmony_ci		break;
28628c2ecf20Sopenharmony_ci
28638c2ecf20Sopenharmony_ci	case 602:
28648c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
28658c2ecf20Sopenharmony_ci				       speed_template_8, num_mb);
28668c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
28678c2ecf20Sopenharmony_ci				       speed_template_8, num_mb);
28688c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
28698c2ecf20Sopenharmony_ci				       speed_template_8, num_mb);
28708c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
28718c2ecf20Sopenharmony_ci				       speed_template_8, num_mb);
28728c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
28738c2ecf20Sopenharmony_ci				       speed_template_8, num_mb);
28748c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
28758c2ecf20Sopenharmony_ci				       speed_template_8, num_mb);
28768c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
28778c2ecf20Sopenharmony_ci				       speed_template_8, num_mb);
28788c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
28798c2ecf20Sopenharmony_ci				       speed_template_8, num_mb);
28808c2ecf20Sopenharmony_ci		break;
28818c2ecf20Sopenharmony_ci
28828c2ecf20Sopenharmony_ci	case 603:
28838c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
28848c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
28858c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
28868c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
28878c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
28888c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
28898c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
28908c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
28918c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
28928c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
28938c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
28948c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
28958c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
28968c2ecf20Sopenharmony_ci				       speed_template_32_48, num_mb);
28978c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
28988c2ecf20Sopenharmony_ci				       speed_template_32_48, num_mb);
28998c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
29008c2ecf20Sopenharmony_ci				       speed_template_32_64, num_mb);
29018c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
29028c2ecf20Sopenharmony_ci				       speed_template_32_64, num_mb);
29038c2ecf20Sopenharmony_ci		break;
29048c2ecf20Sopenharmony_ci
29058c2ecf20Sopenharmony_ci	case 604:
29068c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
29078c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
29088c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
29098c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
29108c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
29118c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
29128c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
29138c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
29148c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
29158c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
29168c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
29178c2ecf20Sopenharmony_ci				       speed_template_16_24_32, num_mb);
29188c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
29198c2ecf20Sopenharmony_ci				       speed_template_32_40_48, num_mb);
29208c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
29218c2ecf20Sopenharmony_ci				       speed_template_32_40_48, num_mb);
29228c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
29238c2ecf20Sopenharmony_ci				       speed_template_32_48_64, num_mb);
29248c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
29258c2ecf20Sopenharmony_ci				       speed_template_32_48_64, num_mb);
29268c2ecf20Sopenharmony_ci		break;
29278c2ecf20Sopenharmony_ci
29288c2ecf20Sopenharmony_ci	case 605:
29298c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
29308c2ecf20Sopenharmony_ci				       speed_template_8, num_mb);
29318c2ecf20Sopenharmony_ci		break;
29328c2ecf20Sopenharmony_ci
29338c2ecf20Sopenharmony_ci	case 606:
29348c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
29358c2ecf20Sopenharmony_ci				       speed_template_8_16, num_mb);
29368c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
29378c2ecf20Sopenharmony_ci				       speed_template_8_16, num_mb);
29388c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
29398c2ecf20Sopenharmony_ci				       speed_template_8_16, num_mb);
29408c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
29418c2ecf20Sopenharmony_ci				       speed_template_8_16, num_mb);
29428c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
29438c2ecf20Sopenharmony_ci				       speed_template_8_16, num_mb);
29448c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
29458c2ecf20Sopenharmony_ci				       speed_template_8_16, num_mb);
29468c2ecf20Sopenharmony_ci		break;
29478c2ecf20Sopenharmony_ci
29488c2ecf20Sopenharmony_ci	case 607:
29498c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
29508c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29518c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
29528c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29538c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
29548c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29558c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
29568c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29578c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
29588c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29598c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
29608c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29618c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
29628c2ecf20Sopenharmony_ci				       speed_template_32_48, num_mb);
29638c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
29648c2ecf20Sopenharmony_ci				       speed_template_32_48, num_mb);
29658c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
29668c2ecf20Sopenharmony_ci				       speed_template_32_64, num_mb);
29678c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
29688c2ecf20Sopenharmony_ci				       speed_template_32_64, num_mb);
29698c2ecf20Sopenharmony_ci		break;
29708c2ecf20Sopenharmony_ci
29718c2ecf20Sopenharmony_ci	case 608:
29728c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
29738c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29748c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
29758c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29768c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
29778c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29788c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
29798c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29808c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
29818c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29828c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
29838c2ecf20Sopenharmony_ci				       speed_template_16_32, num_mb);
29848c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
29858c2ecf20Sopenharmony_ci				       speed_template_32_48, num_mb);
29868c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
29878c2ecf20Sopenharmony_ci				       speed_template_32_48, num_mb);
29888c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
29898c2ecf20Sopenharmony_ci				       speed_template_32_64, num_mb);
29908c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
29918c2ecf20Sopenharmony_ci				       speed_template_32_64, num_mb);
29928c2ecf20Sopenharmony_ci		break;
29938c2ecf20Sopenharmony_ci
29948c2ecf20Sopenharmony_ci	case 609:
29958c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
29968c2ecf20Sopenharmony_ci				       speed_template_8_32, num_mb);
29978c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
29988c2ecf20Sopenharmony_ci				       speed_template_8_32, num_mb);
29998c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
30008c2ecf20Sopenharmony_ci				       speed_template_8_32, num_mb);
30018c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
30028c2ecf20Sopenharmony_ci				       speed_template_8_32, num_mb);
30038c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
30048c2ecf20Sopenharmony_ci				       speed_template_8_32, num_mb);
30058c2ecf20Sopenharmony_ci		test_mb_skcipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
30068c2ecf20Sopenharmony_ci				       speed_template_8_32, num_mb);
30078c2ecf20Sopenharmony_ci		break;
30088c2ecf20Sopenharmony_ci
30098c2ecf20Sopenharmony_ci	case 1000:
30108c2ecf20Sopenharmony_ci		test_available();
30118c2ecf20Sopenharmony_ci		break;
30128c2ecf20Sopenharmony_ci	}
30138c2ecf20Sopenharmony_ci
30148c2ecf20Sopenharmony_ci	return ret;
30158c2ecf20Sopenharmony_ci}
30168c2ecf20Sopenharmony_ci
30178c2ecf20Sopenharmony_cistatic int __init tcrypt_mod_init(void)
30188c2ecf20Sopenharmony_ci{
30198c2ecf20Sopenharmony_ci	int err = -ENOMEM;
30208c2ecf20Sopenharmony_ci	int i;
30218c2ecf20Sopenharmony_ci
30228c2ecf20Sopenharmony_ci	for (i = 0; i < TVMEMSIZE; i++) {
30238c2ecf20Sopenharmony_ci		tvmem[i] = (void *)__get_free_page(GFP_KERNEL);
30248c2ecf20Sopenharmony_ci		if (!tvmem[i])
30258c2ecf20Sopenharmony_ci			goto err_free_tv;
30268c2ecf20Sopenharmony_ci	}
30278c2ecf20Sopenharmony_ci
30288c2ecf20Sopenharmony_ci	err = do_test(alg, type, mask, mode, num_mb);
30298c2ecf20Sopenharmony_ci
30308c2ecf20Sopenharmony_ci	if (err) {
30318c2ecf20Sopenharmony_ci		printk(KERN_ERR "tcrypt: one or more tests failed!\n");
30328c2ecf20Sopenharmony_ci		goto err_free_tv;
30338c2ecf20Sopenharmony_ci	} else {
30348c2ecf20Sopenharmony_ci		pr_debug("all tests passed\n");
30358c2ecf20Sopenharmony_ci	}
30368c2ecf20Sopenharmony_ci
30378c2ecf20Sopenharmony_ci	/* We intentionaly return -EAGAIN to prevent keeping the module,
30388c2ecf20Sopenharmony_ci	 * unless we're running in fips mode. It does all its work from
30398c2ecf20Sopenharmony_ci	 * init() and doesn't offer any runtime functionality, but in
30408c2ecf20Sopenharmony_ci	 * the fips case, checking for a successful load is helpful.
30418c2ecf20Sopenharmony_ci	 * => we don't need it in the memory, do we?
30428c2ecf20Sopenharmony_ci	 *                                        -- mludvig
30438c2ecf20Sopenharmony_ci	 */
30448c2ecf20Sopenharmony_ci	if (!fips_enabled)
30458c2ecf20Sopenharmony_ci		err = -EAGAIN;
30468c2ecf20Sopenharmony_ci
30478c2ecf20Sopenharmony_cierr_free_tv:
30488c2ecf20Sopenharmony_ci	for (i = 0; i < TVMEMSIZE && tvmem[i]; i++)
30498c2ecf20Sopenharmony_ci		free_page((unsigned long)tvmem[i]);
30508c2ecf20Sopenharmony_ci
30518c2ecf20Sopenharmony_ci	return err;
30528c2ecf20Sopenharmony_ci}
30538c2ecf20Sopenharmony_ci
30548c2ecf20Sopenharmony_ci/*
30558c2ecf20Sopenharmony_ci * If an init function is provided, an exit function must also be provided
30568c2ecf20Sopenharmony_ci * to allow module unload.
30578c2ecf20Sopenharmony_ci */
30588c2ecf20Sopenharmony_cistatic void __exit tcrypt_mod_fini(void) { }
30598c2ecf20Sopenharmony_ci
30608c2ecf20Sopenharmony_cisubsys_initcall(tcrypt_mod_init);
30618c2ecf20Sopenharmony_cimodule_exit(tcrypt_mod_fini);
30628c2ecf20Sopenharmony_ci
30638c2ecf20Sopenharmony_cimodule_param(alg, charp, 0);
30648c2ecf20Sopenharmony_cimodule_param(type, uint, 0);
30658c2ecf20Sopenharmony_cimodule_param(mask, uint, 0);
30668c2ecf20Sopenharmony_cimodule_param(mode, int, 0);
30678c2ecf20Sopenharmony_cimodule_param(sec, uint, 0);
30688c2ecf20Sopenharmony_ciMODULE_PARM_DESC(sec, "Length in seconds of speed tests "
30698c2ecf20Sopenharmony_ci		      "(defaults to zero which uses CPU cycles instead)");
30708c2ecf20Sopenharmony_cimodule_param(num_mb, uint, 0000);
30718c2ecf20Sopenharmony_ciMODULE_PARM_DESC(num_mb, "Number of concurrent requests to be used in mb speed tests (defaults to 8)");
30728c2ecf20Sopenharmony_cimodule_param(klen, uint, 0);
30738c2ecf20Sopenharmony_ciMODULE_PARM_DESC(klen, "Key length (defaults to 0)");
30748c2ecf20Sopenharmony_ci
30758c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
30768c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Quick & dirty crypto testing module");
30778c2ecf20Sopenharmony_ciMODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
3078