^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Quick & dirty crypto testing module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * This will only exist until we have a better testing mechanism
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * (e.g. a char device).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Copyright (c) 2007 Nokia Siemens Networks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Updated RFC4106 AES-GCM testing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Authors: Aidan O'Mahony (aidan.o.mahony@intel.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Adrian Hoban <adrian.hoban@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Gabriele Paoloni <gabriele.paoloni@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Tadeusz Struk (tadeusz.struk@intel.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Copyright (c) 2010, Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <crypto/aead.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <crypto/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <crypto/skcipher.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/fips.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/gfp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/scatterlist.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/timex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include "tcrypt.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * Need slab memory for testing (size in number of pages).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define TVMEMSIZE 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * Used by test_cipher_speed()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define ENCRYPT 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define DECRYPT 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define MAX_DIGEST_SIZE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * return a string with the driver name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define get_driver_name(tfm_type, tfm) crypto_tfm_alg_driver_name(tfm_type ## _tfm(tfm))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * Used by test_cipher_speed()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static unsigned int sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static char *alg = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static u32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static u32 mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static int mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static u32 num_mb = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static unsigned int klen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static char *tvmem[TVMEMSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) static const char *check[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256", "sm3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) "lzo", "lzo-rle", "cts", "sha3-224", "sha3-256", "sha3-384",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) "sha3-512", "streebog256", "streebog512",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) static u32 block_sizes[] = { 16, 64, 256, 1024, 1472, 8192, 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static u32 aead_sizes[] = { 16, 64, 256, 512, 1024, 2048, 4096, 8192, 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define XBUFSIZE 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define MAX_IVLEN 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static int testmgr_alloc_buf(char *buf[XBUFSIZE])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) for (i = 0; i < XBUFSIZE; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) buf[i] = (void *)__get_free_page(GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) if (!buf[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) goto err_free_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) err_free_buf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) while (i-- > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) free_page((unsigned long)buf[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static void testmgr_free_buf(char *buf[XBUFSIZE])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) for (i = 0; i < XBUFSIZE; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) free_page((unsigned long)buf[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) unsigned int buflen, const void *assoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) unsigned int aad_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int k, rem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (np > XBUFSIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) rem = PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) np = XBUFSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) rem = buflen % PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) sg_init_table(sg, np + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) sg_set_buf(&sg[0], assoc, aad_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if (rem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) np--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) for (k = 0; k < np; k++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) sg_set_buf(&sg[k + 1], xbuf[k], PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) if (rem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) sg_set_buf(&sg[k + 1], xbuf[k], rem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static inline int do_one_aead_op(struct aead_request *req, int ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct crypto_wait *wait = req->base.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) return crypto_wait_req(ret, wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct test_mb_aead_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct scatterlist sg[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct scatterlist sgout[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct aead_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct crypto_wait wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) char *xbuf[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) char *xoutbuf[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) char *axbuf[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static int do_mult_aead_op(struct test_mb_aead_data *data, int enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) u32 num_mb, int *rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) int i, err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /* Fire up a bunch of concurrent requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) for (i = 0; i < num_mb; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if (enc == ENCRYPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) rc[i] = crypto_aead_encrypt(data[i].req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) rc[i] = crypto_aead_decrypt(data[i].req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /* Wait for all requests to finish */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) for (i = 0; i < num_mb; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) rc[i] = crypto_wait_req(rc[i], &data[i].wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if (rc[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) pr_info("concurrent request %d error %d\n", i, rc[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) err = rc[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static int test_mb_aead_jiffies(struct test_mb_aead_data *data, int enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) int blen, int secs, u32 num_mb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) unsigned long start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) int bcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) int *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) for (start = jiffies, end = start + secs * HZ, bcount = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) time_before(jiffies, end); bcount++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) ret = do_mult_aead_op(data, enc, num_mb, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) pr_cont("%d operations in %d seconds (%llu bytes)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) bcount * num_mb, secs, (u64)bcount * blen * num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) kfree(rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static int test_mb_aead_cycles(struct test_mb_aead_data *data, int enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) int blen, u32 num_mb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) unsigned long cycles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) int *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) /* Warm-up run. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) for (i = 0; i < 4; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) ret = do_mult_aead_op(data, enc, num_mb, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) /* The real thing. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) for (i = 0; i < 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) cycles_t start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) start = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) ret = do_mult_aead_op(data, enc, num_mb, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) end = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) cycles += end - start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) pr_cont("1 operation in %lu cycles (%d bytes)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) (cycles + 4) / (8 * num_mb), blen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) kfree(rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static void test_mb_aead_speed(const char *algo, int enc, int secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) struct aead_speed_template *template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) unsigned int tcount, u8 authsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) unsigned int aad_size, u8 *keysize, u32 num_mb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) struct test_mb_aead_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) struct crypto_aead *tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) unsigned int i, j, iv_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) const char *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) const char *e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) void *assoc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) u32 *b_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) char *iv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) if (aad_size >= PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) pr_err("associate data length (%u) too big\n", aad_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) if (!iv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) if (enc == ENCRYPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) e = "encryption";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) e = "decryption";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) goto out_free_iv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) tfm = crypto_alloc_aead(algo, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) if (IS_ERR(tfm)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) pr_err("failed to load transform for %s: %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) algo, PTR_ERR(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) goto out_free_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) ret = crypto_aead_setauthsize(tfm, authsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) for (i = 0; i < num_mb; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) if (testmgr_alloc_buf(data[i].xbuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) while (i--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) testmgr_free_buf(data[i].xbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) goto out_free_tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) for (i = 0; i < num_mb; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) if (testmgr_alloc_buf(data[i].axbuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) while (i--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) testmgr_free_buf(data[i].axbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) goto out_free_xbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) for (i = 0; i < num_mb; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) if (testmgr_alloc_buf(data[i].xoutbuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) while (i--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) testmgr_free_buf(data[i].xoutbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) goto out_free_axbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) for (i = 0; i < num_mb; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) data[i].req = aead_request_alloc(tfm, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) if (!data[i].req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) pr_err("alg: skcipher: Failed to allocate request for %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) algo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) while (i--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) aead_request_free(data[i].req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) goto out_free_xoutbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) for (i = 0; i < num_mb; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) crypto_init_wait(&data[i].wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) aead_request_set_callback(data[i].req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) CRYPTO_TFM_REQ_MAY_BACKLOG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) crypto_req_done, &data[i].wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) pr_info("\ntesting speed of multibuffer %s (%s) %s\n", algo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) get_driver_name(crypto_aead, tfm), e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) b_size = aead_sizes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) if (*b_size + authsize > XBUFSIZE * PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) pr_err("template (%u) too big for buffer (%lu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) authsize + *b_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) XBUFSIZE * PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) pr_info("test %u (%d bit key, %d byte blocks): ", i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) *keysize * 8, *b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) /* Set up tfm global state, i.e. the key */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) memset(tvmem[0], 0xff, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) key = tvmem[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) for (j = 0; j < tcount; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) if (template[j].klen == *keysize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) key = template[j].key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) crypto_aead_clear_flags(tfm, ~0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) ret = crypto_aead_setkey(tfm, key, *keysize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) pr_err("setkey() failed flags=%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) crypto_aead_get_flags(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) iv_len = crypto_aead_ivsize(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) if (iv_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) memset(iv, 0xff, iv_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) /* Now setup per request stuff, i.e. buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) for (j = 0; j < num_mb; ++j) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) struct test_mb_aead_data *cur = &data[j];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) assoc = cur->axbuf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) memset(assoc, 0xff, aad_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) sg_init_aead(cur->sg, cur->xbuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) *b_size + (enc ? 0 : authsize),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) assoc, aad_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) sg_init_aead(cur->sgout, cur->xoutbuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) *b_size + (enc ? authsize : 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) assoc, aad_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) aead_request_set_ad(cur->req, aad_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) if (!enc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) aead_request_set_crypt(cur->req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) cur->sgout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) cur->sg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) *b_size, iv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) ret = crypto_aead_encrypt(cur->req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) ret = do_one_aead_op(cur->req, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) pr_err("calculating auth failed (%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) aead_request_set_crypt(cur->req, cur->sg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) cur->sgout, *b_size +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) (enc ? 0 : authsize),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) iv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) if (secs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) ret = test_mb_aead_jiffies(data, enc, *b_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) secs, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) cond_resched();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) ret = test_mb_aead_cycles(data, enc, *b_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) pr_err("%s() failed return code=%d\n", e, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) b_size++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) } while (*b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) keysize++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) } while (*keysize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) for (i = 0; i < num_mb; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) aead_request_free(data[i].req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) out_free_xoutbuf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) for (i = 0; i < num_mb; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) testmgr_free_buf(data[i].xoutbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) out_free_axbuf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) for (i = 0; i < num_mb; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) testmgr_free_buf(data[i].axbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) out_free_xbuf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) for (i = 0; i < num_mb; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) testmgr_free_buf(data[i].xbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) out_free_tfm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) crypto_free_aead(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) out_free_data:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) kfree(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) out_free_iv:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) kfree(iv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) static int test_aead_jiffies(struct aead_request *req, int enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) int blen, int secs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) unsigned long start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) int bcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) for (start = jiffies, end = start + secs * HZ, bcount = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) time_before(jiffies, end); bcount++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) if (enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) ret = do_one_aead_op(req, crypto_aead_encrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) ret = do_one_aead_op(req, crypto_aead_decrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) pr_cont("%d operations in %d seconds (%llu bytes)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) bcount, secs, (u64)bcount * blen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) static int test_aead_cycles(struct aead_request *req, int enc, int blen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) unsigned long cycles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) /* Warm-up run. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) for (i = 0; i < 4; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) if (enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) ret = do_one_aead_op(req, crypto_aead_encrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) ret = do_one_aead_op(req, crypto_aead_decrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) /* The real thing. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) for (i = 0; i < 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) cycles_t start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) start = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) if (enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) ret = do_one_aead_op(req, crypto_aead_encrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) ret = do_one_aead_op(req, crypto_aead_decrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) end = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) cycles += end - start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) if (ret == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) printk("1 operation in %lu cycles (%d bytes)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) (cycles + 4) / 8, blen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) static void test_aead_speed(const char *algo, int enc, unsigned int secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) struct aead_speed_template *template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) unsigned int tcount, u8 authsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) unsigned int aad_size, u8 *keysize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) unsigned int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) struct crypto_aead *tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) int ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) const char *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) struct aead_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) struct scatterlist *sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) struct scatterlist *sgout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) const char *e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) void *assoc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) char *iv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) char *xbuf[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) char *xoutbuf[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) char *axbuf[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) unsigned int *b_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) unsigned int iv_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) struct crypto_wait wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) if (!iv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) if (aad_size >= PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) pr_err("associate data length (%u) too big\n", aad_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) goto out_noxbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) if (enc == ENCRYPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) e = "encryption";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) e = "decryption";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (testmgr_alloc_buf(xbuf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) goto out_noxbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) if (testmgr_alloc_buf(axbuf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) goto out_noaxbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) if (testmgr_alloc_buf(xoutbuf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) goto out_nooutbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) sg = kmalloc(sizeof(*sg) * 9 * 2, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) if (!sg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) goto out_nosg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) sgout = &sg[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) tfm = crypto_alloc_aead(algo, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) if (IS_ERR(tfm)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) PTR_ERR(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) goto out_notfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) crypto_init_wait(&wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) get_driver_name(crypto_aead, tfm), e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) req = aead_request_alloc(tfm, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) if (!req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) pr_err("alg: aead: Failed to allocate request for %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) algo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) goto out_noreq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) crypto_req_done, &wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) b_size = aead_sizes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) assoc = axbuf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) memset(assoc, 0xff, aad_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) pr_err("template (%u) too big for tvmem (%lu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) *keysize + *b_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) TVMEMSIZE * PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) key = tvmem[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) for (j = 0; j < tcount; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) if (template[j].klen == *keysize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) key = template[j].key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) ret = crypto_aead_setkey(tfm, key, *keysize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) ret = crypto_aead_setauthsize(tfm, authsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) iv_len = crypto_aead_ivsize(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) if (iv_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) memset(iv, 0xff, iv_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) crypto_aead_clear_flags(tfm, ~0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) i, *keysize * 8, *b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) memset(tvmem[0], 0xff, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) pr_err("setkey() failed flags=%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) crypto_aead_get_flags(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) sg_init_aead(sg, xbuf, *b_size + (enc ? 0 : authsize),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) assoc, aad_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) sg_init_aead(sgout, xoutbuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) *b_size + (enc ? authsize : 0), assoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) aad_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) aead_request_set_ad(req, aad_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) if (!enc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) * For decryption we need a proper auth so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) * we do the encryption path once with buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) * reversed (input <-> output) to calculate it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) aead_request_set_crypt(req, sgout, sg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) *b_size, iv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) ret = do_one_aead_op(req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) crypto_aead_encrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) pr_err("calculating auth failed (%d)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) aead_request_set_crypt(req, sg, sgout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) *b_size + (enc ? 0 : authsize),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) iv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) if (secs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) ret = test_aead_jiffies(req, enc, *b_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) secs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) cond_resched();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) ret = test_aead_cycles(req, enc, *b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) pr_err("%s() failed return code=%d\n", e, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) b_size++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) } while (*b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) keysize++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) } while (*keysize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) aead_request_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) out_noreq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) crypto_free_aead(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) out_notfm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) kfree(sg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) out_nosg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) testmgr_free_buf(xoutbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) out_nooutbuf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) testmgr_free_buf(axbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) out_noaxbuf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) testmgr_free_buf(xbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) out_noxbuf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) kfree(iv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) static void test_hash_sg_init(struct scatterlist *sg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) sg_init_table(sg, TVMEMSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) for (i = 0; i < TVMEMSIZE; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) sg_set_buf(sg + i, tvmem[i], PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) memset(tvmem[i], 0xff, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) static inline int do_one_ahash_op(struct ahash_request *req, int ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) struct crypto_wait *wait = req->base.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) return crypto_wait_req(ret, wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) struct test_mb_ahash_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) struct scatterlist sg[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) char result[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) struct ahash_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) struct crypto_wait wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) char *xbuf[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) static inline int do_mult_ahash_op(struct test_mb_ahash_data *data, u32 num_mb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) int *rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) int i, err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) /* Fire up a bunch of concurrent requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) for (i = 0; i < num_mb; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) rc[i] = crypto_ahash_digest(data[i].req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) /* Wait for all requests to finish */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) for (i = 0; i < num_mb; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) rc[i] = crypto_wait_req(rc[i], &data[i].wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) if (rc[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) pr_info("concurrent request %d error %d\n", i, rc[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) err = rc[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) static int test_mb_ahash_jiffies(struct test_mb_ahash_data *data, int blen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) int secs, u32 num_mb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) unsigned long start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) int bcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) int *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) for (start = jiffies, end = start + secs * HZ, bcount = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) time_before(jiffies, end); bcount++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) ret = do_mult_ahash_op(data, num_mb, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) pr_cont("%d operations in %d seconds (%llu bytes)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) bcount * num_mb, secs, (u64)bcount * blen * num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) kfree(rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) static int test_mb_ahash_cycles(struct test_mb_ahash_data *data, int blen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) u32 num_mb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) unsigned long cycles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) int *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) /* Warm-up run. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) for (i = 0; i < 4; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) ret = do_mult_ahash_op(data, num_mb, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) /* The real thing. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) for (i = 0; i < 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) cycles_t start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) start = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) ret = do_mult_ahash_op(data, num_mb, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) end = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) cycles += end - start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) pr_cont("1 operation in %lu cycles (%d bytes)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) (cycles + 4) / (8 * num_mb), blen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) kfree(rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) static void test_mb_ahash_speed(const char *algo, unsigned int secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) struct hash_speed *speed, u32 num_mb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) struct test_mb_ahash_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) struct crypto_ahash *tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) unsigned int i, j, k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) tfm = crypto_alloc_ahash(algo, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) if (IS_ERR(tfm)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) pr_err("failed to load transform for %s: %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) algo, PTR_ERR(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) goto free_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) for (i = 0; i < num_mb; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) if (testmgr_alloc_buf(data[i].xbuf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) crypto_init_wait(&data[i].wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) data[i].req = ahash_request_alloc(tfm, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) if (!data[i].req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) pr_err("alg: hash: Failed to allocate request for %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) algo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) ahash_request_set_callback(data[i].req, 0, crypto_req_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) &data[i].wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) sg_init_table(data[i].sg, XBUFSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) for (j = 0; j < XBUFSIZE; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) sg_set_buf(data[i].sg + j, data[i].xbuf[j], PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) memset(data[i].xbuf[j], 0xff, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) pr_info("\ntesting speed of multibuffer %s (%s)\n", algo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) get_driver_name(crypto_ahash, tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) for (i = 0; speed[i].blen != 0; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) /* For some reason this only tests digests. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) if (speed[i].blen != speed[i].plen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) if (speed[i].blen > XBUFSIZE * PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) pr_err("template (%u) too big for tvmem (%lu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) speed[i].blen, XBUFSIZE * PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) if (klen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) crypto_ahash_setkey(tfm, tvmem[0], klen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) for (k = 0; k < num_mb; k++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) ahash_request_set_crypt(data[k].req, data[k].sg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) data[k].result, speed[i].blen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) pr_info("test%3u "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) "(%5u byte blocks,%5u bytes per update,%4u updates): ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) i, speed[i].blen, speed[i].plen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) speed[i].blen / speed[i].plen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) if (secs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) ret = test_mb_ahash_jiffies(data, speed[i].blen, secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) cond_resched();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) ret = test_mb_ahash_cycles(data, speed[i].blen, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) pr_err("At least one hashing failed ret=%d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) for (k = 0; k < num_mb; ++k)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) ahash_request_free(data[k].req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) for (k = 0; k < num_mb; ++k)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) testmgr_free_buf(data[k].xbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) crypto_free_ahash(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) free_data:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) kfree(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) static int test_ahash_jiffies_digest(struct ahash_request *req, int blen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) char *out, int secs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) unsigned long start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) int bcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) for (start = jiffies, end = start + secs * HZ, bcount = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) time_before(jiffies, end); bcount++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) ret = do_one_ahash_op(req, crypto_ahash_digest(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) printk("%6u opers/sec, %9lu bytes/sec\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) bcount / secs, ((long)bcount * blen) / secs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) static int test_ahash_jiffies(struct ahash_request *req, int blen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) int plen, char *out, int secs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) unsigned long start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) int bcount, pcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) if (plen == blen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) return test_ahash_jiffies_digest(req, blen, out, secs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) for (start = jiffies, end = start + secs * HZ, bcount = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) time_before(jiffies, end); bcount++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) ret = do_one_ahash_op(req, crypto_ahash_init(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) for (pcount = 0; pcount < blen; pcount += plen) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) ret = do_one_ahash_op(req, crypto_ahash_update(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) /* we assume there is enough space in 'out' for the result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) ret = do_one_ahash_op(req, crypto_ahash_final(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) pr_cont("%6u opers/sec, %9lu bytes/sec\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) bcount / secs, ((long)bcount * blen) / secs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) static int test_ahash_cycles_digest(struct ahash_request *req, int blen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) char *out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) unsigned long cycles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) /* Warm-up run. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) for (i = 0; i < 4; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) ret = do_one_ahash_op(req, crypto_ahash_digest(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) /* The real thing. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) for (i = 0; i < 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) cycles_t start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) start = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) ret = do_one_ahash_op(req, crypto_ahash_digest(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) end = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) cycles += end - start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) cycles / 8, cycles / (8 * blen));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) static int test_ahash_cycles(struct ahash_request *req, int blen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) int plen, char *out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) unsigned long cycles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) int i, pcount, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) if (plen == blen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) return test_ahash_cycles_digest(req, blen, out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) /* Warm-up run. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) for (i = 0; i < 4; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) ret = do_one_ahash_op(req, crypto_ahash_init(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) for (pcount = 0; pcount < blen; pcount += plen) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) ret = do_one_ahash_op(req, crypto_ahash_update(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) ret = do_one_ahash_op(req, crypto_ahash_final(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) /* The real thing. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) for (i = 0; i < 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) cycles_t start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) start = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) ret = do_one_ahash_op(req, crypto_ahash_init(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) for (pcount = 0; pcount < blen; pcount += plen) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) ret = do_one_ahash_op(req, crypto_ahash_update(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) ret = do_one_ahash_op(req, crypto_ahash_final(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) end = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) cycles += end - start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) cycles / 8, cycles / (8 * blen));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) static void test_ahash_speed_common(const char *algo, unsigned int secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) struct hash_speed *speed, unsigned mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) struct scatterlist sg[TVMEMSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) struct crypto_wait wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) struct ahash_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) struct crypto_ahash *tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) char *output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) int i, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) tfm = crypto_alloc_ahash(algo, 0, mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) if (IS_ERR(tfm)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) pr_err("failed to load transform for %s: %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) algo, PTR_ERR(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) printk(KERN_INFO "\ntesting speed of async %s (%s)\n", algo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) get_driver_name(crypto_ahash, tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) MAX_DIGEST_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) test_hash_sg_init(sg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) req = ahash_request_alloc(tfm, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) if (!req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) pr_err("ahash request allocation failure\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) crypto_init_wait(&wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) crypto_req_done, &wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) if (!output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) goto out_nomem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) for (i = 0; speed[i].blen != 0; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) pr_err("template (%u) too big for tvmem (%lu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) speed[i].blen, TVMEMSIZE * PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) if (klen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) crypto_ahash_setkey(tfm, tvmem[0], klen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) pr_info("test%3u "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) "(%5u byte blocks,%5u bytes per update,%4u updates): ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) ahash_request_set_crypt(req, sg, output, speed[i].plen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) if (secs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) ret = test_ahash_jiffies(req, speed[i].blen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) speed[i].plen, output, secs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) cond_resched();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) ret = test_ahash_cycles(req, speed[i].blen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) speed[i].plen, output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) pr_err("hashing failed ret=%d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) kfree(output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) out_nomem:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) ahash_request_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) crypto_free_ahash(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) static void test_ahash_speed(const char *algo, unsigned int secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) struct hash_speed *speed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) return test_ahash_speed_common(algo, secs, speed, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) static void test_hash_speed(const char *algo, unsigned int secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) struct hash_speed *speed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) return test_ahash_speed_common(algo, secs, speed, CRYPTO_ALG_ASYNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) struct test_mb_skcipher_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) struct scatterlist sg[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) struct skcipher_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) struct crypto_wait wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) char *xbuf[XBUFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) static int do_mult_acipher_op(struct test_mb_skcipher_data *data, int enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) u32 num_mb, int *rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) int i, err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) /* Fire up a bunch of concurrent requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) for (i = 0; i < num_mb; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) if (enc == ENCRYPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) rc[i] = crypto_skcipher_encrypt(data[i].req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) rc[i] = crypto_skcipher_decrypt(data[i].req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) /* Wait for all requests to finish */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) for (i = 0; i < num_mb; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) rc[i] = crypto_wait_req(rc[i], &data[i].wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) if (rc[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) pr_info("concurrent request %d error %d\n", i, rc[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) err = rc[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) static int test_mb_acipher_jiffies(struct test_mb_skcipher_data *data, int enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) int blen, int secs, u32 num_mb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) unsigned long start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) int bcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) int *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) for (start = jiffies, end = start + secs * HZ, bcount = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) time_before(jiffies, end); bcount++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) ret = do_mult_acipher_op(data, enc, num_mb, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) pr_cont("%d operations in %d seconds (%llu bytes)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) bcount * num_mb, secs, (u64)bcount * blen * num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) kfree(rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) static int test_mb_acipher_cycles(struct test_mb_skcipher_data *data, int enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) int blen, u32 num_mb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) unsigned long cycles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) int *rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) rc = kcalloc(num_mb, sizeof(*rc), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) /* Warm-up run. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) for (i = 0; i < 4; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) ret = do_mult_acipher_op(data, enc, num_mb, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) /* The real thing. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) for (i = 0; i < 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) cycles_t start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) start = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) ret = do_mult_acipher_op(data, enc, num_mb, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) end = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) cycles += end - start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) pr_cont("1 operation in %lu cycles (%d bytes)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) (cycles + 4) / (8 * num_mb), blen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) kfree(rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) static void test_mb_skcipher_speed(const char *algo, int enc, int secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) struct cipher_speed_template *template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) unsigned int tcount, u8 *keysize, u32 num_mb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) struct test_mb_skcipher_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) struct crypto_skcipher *tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) unsigned int i, j, iv_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) const char *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) const char *e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) u32 *b_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) char iv[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) if (enc == ENCRYPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) e = "encryption";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) e = "decryption";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) tfm = crypto_alloc_skcipher(algo, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) if (IS_ERR(tfm)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) pr_err("failed to load transform for %s: %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) algo, PTR_ERR(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) goto out_free_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) for (i = 0; i < num_mb; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) if (testmgr_alloc_buf(data[i].xbuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) while (i--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) testmgr_free_buf(data[i].xbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) goto out_free_tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) for (i = 0; i < num_mb; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) if (testmgr_alloc_buf(data[i].xbuf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) while (i--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) testmgr_free_buf(data[i].xbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) goto out_free_tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) for (i = 0; i < num_mb; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) data[i].req = skcipher_request_alloc(tfm, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) if (!data[i].req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) pr_err("alg: skcipher: Failed to allocate request for %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) algo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) while (i--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) skcipher_request_free(data[i].req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) goto out_free_xbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) for (i = 0; i < num_mb; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) skcipher_request_set_callback(data[i].req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) CRYPTO_TFM_REQ_MAY_BACKLOG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) crypto_req_done, &data[i].wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) crypto_init_wait(&data[i].wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) pr_info("\ntesting speed of multibuffer %s (%s) %s\n", algo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) get_driver_name(crypto_skcipher, tfm), e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) b_size = block_sizes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) if (*b_size > XBUFSIZE * PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) pr_err("template (%u) too big for buffer (%lu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) *b_size, XBUFSIZE * PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) pr_info("test %u (%d bit key, %d byte blocks): ", i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) *keysize * 8, *b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) /* Set up tfm global state, i.e. the key */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) memset(tvmem[0], 0xff, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) key = tvmem[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) for (j = 0; j < tcount; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) if (template[j].klen == *keysize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) key = template[j].key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) crypto_skcipher_clear_flags(tfm, ~0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) ret = crypto_skcipher_setkey(tfm, key, *keysize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) pr_err("setkey() failed flags=%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) crypto_skcipher_get_flags(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) iv_len = crypto_skcipher_ivsize(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) if (iv_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) memset(&iv, 0xff, iv_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) /* Now setup per request stuff, i.e. buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) for (j = 0; j < num_mb; ++j) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) struct test_mb_skcipher_data *cur = &data[j];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) unsigned int k = *b_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) unsigned int pages = DIV_ROUND_UP(k, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) unsigned int p = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) sg_init_table(cur->sg, pages);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) while (k > PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) sg_set_buf(cur->sg + p, cur->xbuf[p],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) memset(cur->xbuf[p], 0xff, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) p++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) k -= PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) sg_set_buf(cur->sg + p, cur->xbuf[p], k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) memset(cur->xbuf[p], 0xff, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) skcipher_request_set_crypt(cur->req, cur->sg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) cur->sg, *b_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) iv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) if (secs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) ret = test_mb_acipher_jiffies(data, enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) *b_size, secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) cond_resched();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) ret = test_mb_acipher_cycles(data, enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) *b_size, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) pr_err("%s() failed flags=%x\n", e,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) crypto_skcipher_get_flags(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) b_size++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) } while (*b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) keysize++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) } while (*keysize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) for (i = 0; i < num_mb; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) skcipher_request_free(data[i].req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) out_free_xbuf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) for (i = 0; i < num_mb; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) testmgr_free_buf(data[i].xbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) out_free_tfm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) crypto_free_skcipher(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) out_free_data:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) kfree(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) static inline int do_one_acipher_op(struct skcipher_request *req, int ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) struct crypto_wait *wait = req->base.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) return crypto_wait_req(ret, wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) static int test_acipher_jiffies(struct skcipher_request *req, int enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) int blen, int secs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) unsigned long start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) int bcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) for (start = jiffies, end = start + secs * HZ, bcount = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) time_before(jiffies, end); bcount++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) if (enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) ret = do_one_acipher_op(req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) crypto_skcipher_encrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) ret = do_one_acipher_op(req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) crypto_skcipher_decrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) pr_cont("%d operations in %d seconds (%llu bytes)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) bcount, secs, (u64)bcount * blen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) static int test_acipher_cycles(struct skcipher_request *req, int enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) int blen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) unsigned long cycles = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) /* Warm-up run. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) for (i = 0; i < 4; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) if (enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) ret = do_one_acipher_op(req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) crypto_skcipher_encrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) ret = do_one_acipher_op(req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) crypto_skcipher_decrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) /* The real thing. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) for (i = 0; i < 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) cycles_t start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) start = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) if (enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) ret = do_one_acipher_op(req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) crypto_skcipher_encrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) ret = do_one_acipher_op(req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) crypto_skcipher_decrypt(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) end = get_cycles();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) cycles += end - start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) if (ret == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) pr_cont("1 operation in %lu cycles (%d bytes)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) (cycles + 4) / 8, blen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) struct cipher_speed_template *template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) unsigned int tcount, u8 *keysize, bool async)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) unsigned int ret, i, j, k, iv_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) struct crypto_wait wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) const char *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) char iv[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) struct skcipher_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) struct crypto_skcipher *tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) const char *e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) u32 *b_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) if (enc == ENCRYPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) e = "encryption";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) e = "decryption";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) crypto_init_wait(&wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) if (IS_ERR(tfm)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) pr_err("failed to load transform for %s: %ld\n", algo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) PTR_ERR(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) pr_info("\ntesting speed of %s %s (%s) %s\n", async ? "async" : "sync",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) algo, get_driver_name(crypto_skcipher, tfm), e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) req = skcipher_request_alloc(tfm, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) if (!req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) pr_err("tcrypt: skcipher: Failed to allocate request for %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) algo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) crypto_req_done, &wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) b_size = block_sizes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) struct scatterlist sg[TVMEMSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) pr_err("template (%u) too big for "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) "tvmem (%lu)\n", *keysize + *b_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) TVMEMSIZE * PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) goto out_free_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) pr_info("test %u (%d bit key, %d byte blocks): ", i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) *keysize * 8, *b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) memset(tvmem[0], 0xff, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) /* set key, plain text and IV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) key = tvmem[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) for (j = 0; j < tcount; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) if (template[j].klen == *keysize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) key = template[j].key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) crypto_skcipher_clear_flags(tfm, ~0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) ret = crypto_skcipher_setkey(tfm, key, *keysize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) pr_err("setkey() failed flags=%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) crypto_skcipher_get_flags(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) goto out_free_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) k = *keysize + *b_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) sg_init_table(sg, DIV_ROUND_UP(k, PAGE_SIZE));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) if (k > PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) sg_set_buf(sg, tvmem[0] + *keysize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) PAGE_SIZE - *keysize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) k -= PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) j = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) while (k > PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) sg_set_buf(sg + j, tvmem[j], PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) memset(tvmem[j], 0xff, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) j++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) k -= PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) sg_set_buf(sg + j, tvmem[j], k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) memset(tvmem[j], 0xff, k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) sg_set_buf(sg, tvmem[0] + *keysize, *b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) iv_len = crypto_skcipher_ivsize(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) if (iv_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) memset(&iv, 0xff, iv_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) skcipher_request_set_crypt(req, sg, sg, *b_size, iv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) if (secs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) ret = test_acipher_jiffies(req, enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) *b_size, secs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) cond_resched();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) ret = test_acipher_cycles(req, enc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) *b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) pr_err("%s() failed flags=%x\n", e,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) crypto_skcipher_get_flags(tfm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) b_size++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) } while (*b_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) keysize++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) } while (*keysize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) out_free_req:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) skcipher_request_free(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) crypto_free_skcipher(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) static void test_acipher_speed(const char *algo, int enc, unsigned int secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) struct cipher_speed_template *template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) unsigned int tcount, u8 *keysize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) static void test_cipher_speed(const char *algo, int enc, unsigned int secs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) struct cipher_speed_template *template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) unsigned int tcount, u8 *keysize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) static void test_available(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) const char **name = check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) while (*name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) printk("alg %s ", *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) printk(crypto_has_alg(*name, 0, 0) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) "found\n" : "not found\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) name++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) static inline int tcrypt_test(const char *alg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) pr_debug("testing %s\n", alg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) ret = alg_test(alg, alg, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) /* non-fips algs return -EINVAL in fips mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) if (fips_enabled && ret == -EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) switch (m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) if (alg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) if (!crypto_has_alg(alg, type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) mask ?: CRYPTO_ALG_TYPE_MASK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) ret = -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) for (i = 1; i < 200; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) ret += do_test(NULL, 0, 0, i, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) ret += tcrypt_test("md5");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) ret += tcrypt_test("sha1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) ret += tcrypt_test("ecb(des)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) ret += tcrypt_test("cbc(des)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) ret += tcrypt_test("ctr(des)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) case 4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) ret += tcrypt_test("ecb(des3_ede)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) ret += tcrypt_test("cbc(des3_ede)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) ret += tcrypt_test("ctr(des3_ede)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) case 5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) ret += tcrypt_test("md4");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) case 6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) ret += tcrypt_test("sha256");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) case 7:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) ret += tcrypt_test("ecb(blowfish)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) ret += tcrypt_test("cbc(blowfish)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) ret += tcrypt_test("ctr(blowfish)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) case 8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) ret += tcrypt_test("ecb(twofish)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) ret += tcrypt_test("cbc(twofish)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) ret += tcrypt_test("ctr(twofish)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) ret += tcrypt_test("lrw(twofish)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) ret += tcrypt_test("xts(twofish)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) case 9:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) ret += tcrypt_test("ecb(serpent)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) ret += tcrypt_test("cbc(serpent)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) ret += tcrypt_test("ctr(serpent)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) ret += tcrypt_test("lrw(serpent)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) ret += tcrypt_test("xts(serpent)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) case 10:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) ret += tcrypt_test("ecb(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) ret += tcrypt_test("cbc(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) ret += tcrypt_test("lrw(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) ret += tcrypt_test("xts(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) ret += tcrypt_test("ctr(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) ret += tcrypt_test("rfc3686(ctr(aes))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) ret += tcrypt_test("ofb(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) ret += tcrypt_test("cfb(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) case 11:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) ret += tcrypt_test("sha384");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) case 12:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) ret += tcrypt_test("sha512");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) case 13:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) ret += tcrypt_test("deflate");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) case 14:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) ret += tcrypt_test("ecb(cast5)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) ret += tcrypt_test("cbc(cast5)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) ret += tcrypt_test("ctr(cast5)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) case 15:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) ret += tcrypt_test("ecb(cast6)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) ret += tcrypt_test("cbc(cast6)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) ret += tcrypt_test("ctr(cast6)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) ret += tcrypt_test("lrw(cast6)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) ret += tcrypt_test("xts(cast6)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) case 16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) ret += tcrypt_test("ecb(arc4)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) case 17:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) ret += tcrypt_test("michael_mic");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) case 18:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) ret += tcrypt_test("crc32c");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) case 19:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) ret += tcrypt_test("ecb(tea)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) case 20:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) ret += tcrypt_test("ecb(xtea)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) case 21:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) ret += tcrypt_test("ecb(khazad)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) case 22:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) ret += tcrypt_test("wp512");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) case 23:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) ret += tcrypt_test("wp384");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) case 24:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) ret += tcrypt_test("wp256");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) case 25:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) ret += tcrypt_test("ecb(tnepres)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) case 26:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) ret += tcrypt_test("ecb(anubis)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) ret += tcrypt_test("cbc(anubis)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) case 27:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) ret += tcrypt_test("tgr192");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) case 28:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) ret += tcrypt_test("tgr160");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) case 29:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) ret += tcrypt_test("tgr128");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) case 30:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) ret += tcrypt_test("ecb(xeta)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) case 31:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) ret += tcrypt_test("pcbc(fcrypt)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) case 32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) ret += tcrypt_test("ecb(camellia)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) ret += tcrypt_test("cbc(camellia)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) ret += tcrypt_test("ctr(camellia)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) ret += tcrypt_test("lrw(camellia)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) ret += tcrypt_test("xts(camellia)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) case 33:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) ret += tcrypt_test("sha224");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) case 34:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) ret += tcrypt_test("salsa20");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) case 35:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) ret += tcrypt_test("gcm(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) case 36:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) ret += tcrypt_test("lzo");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) case 37:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) ret += tcrypt_test("ccm(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) case 38:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) ret += tcrypt_test("cts(cbc(aes))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) case 39:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) ret += tcrypt_test("rmd128");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) case 40:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) ret += tcrypt_test("rmd160");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) case 41:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) ret += tcrypt_test("rmd256");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) case 42:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) ret += tcrypt_test("rmd320");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) case 43:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) ret += tcrypt_test("ecb(seed)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) case 45:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) ret += tcrypt_test("rfc4309(ccm(aes))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) case 46:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) ret += tcrypt_test("ghash");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) case 47:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) ret += tcrypt_test("crct10dif");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) case 48:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) ret += tcrypt_test("sha3-224");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) case 49:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) ret += tcrypt_test("sha3-256");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) case 50:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) ret += tcrypt_test("sha3-384");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) case 51:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) ret += tcrypt_test("sha3-512");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) case 52:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) ret += tcrypt_test("sm3");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) case 53:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) ret += tcrypt_test("streebog256");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) case 54:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) ret += tcrypt_test("streebog512");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) case 100:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) ret += tcrypt_test("hmac(md5)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) case 101:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) ret += tcrypt_test("hmac(sha1)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) case 102:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) ret += tcrypt_test("hmac(sha256)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) case 103:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) ret += tcrypt_test("hmac(sha384)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) case 104:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) ret += tcrypt_test("hmac(sha512)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) case 105:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) ret += tcrypt_test("hmac(sha224)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) case 106:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) ret += tcrypt_test("xcbc(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) case 107:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) ret += tcrypt_test("hmac(rmd128)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) case 108:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) ret += tcrypt_test("hmac(rmd160)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) case 109:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) ret += tcrypt_test("vmac64(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) case 111:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) ret += tcrypt_test("hmac(sha3-224)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) case 112:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) ret += tcrypt_test("hmac(sha3-256)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) case 113:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) ret += tcrypt_test("hmac(sha3-384)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) case 114:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) ret += tcrypt_test("hmac(sha3-512)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) case 115:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) ret += tcrypt_test("hmac(streebog256)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) case 116:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) ret += tcrypt_test("hmac(streebog512)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) case 150:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) ret += tcrypt_test("ansi_cprng");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) case 151:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) ret += tcrypt_test("rfc4106(gcm(aes))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) case 152:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) ret += tcrypt_test("rfc4543(gcm(aes))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) case 153:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) ret += tcrypt_test("cmac(aes)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) case 154:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) ret += tcrypt_test("cmac(des3_ede)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) case 155:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) case 156:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) ret += tcrypt_test("authenc(hmac(md5),ecb(cipher_null))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) case 157:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) case 181:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) ret += tcrypt_test("authenc(hmac(sha1),cbc(des))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) case 182:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) case 183:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) ret += tcrypt_test("authenc(hmac(sha224),cbc(des))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) case 184:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) case 185:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) ret += tcrypt_test("authenc(hmac(sha256),cbc(des))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) case 186:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) case 187:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) ret += tcrypt_test("authenc(hmac(sha384),cbc(des))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) case 188:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) case 189:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) ret += tcrypt_test("authenc(hmac(sha512),cbc(des))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) case 190:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) case 191:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) ret += tcrypt_test("ecb(sm4)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) ret += tcrypt_test("cbc(sm4)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) ret += tcrypt_test("ctr(sm4)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) case 200:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) speed_template_32_40_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) speed_template_32_40_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) test_cipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) test_cipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) test_cipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) test_cipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) case 201:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) test_cipher_speed("ctr(des3_ede)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) test_cipher_speed("ctr(des3_ede)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) case 202:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) speed_template_32_40_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) speed_template_32_40_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) speed_template_32_48_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) speed_template_32_48_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) case 203:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) case 204:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) case 205:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) speed_template_32_40_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) speed_template_32_40_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) speed_template_32_48_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) speed_template_32_48_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) case 206:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) test_cipher_speed("salsa20", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) case 207:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) speed_template_32_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) speed_template_32_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) case 208:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) case 209:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) case 210:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) speed_template_32_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) speed_template_32_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) case 211:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) NULL, 0, 16, 16, aead_speed_template_20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) test_aead_speed("gcm(aes)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) NULL, 0, 16, 8, speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) test_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) NULL, 0, 16, 16, aead_speed_template_20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) test_aead_speed("gcm(aes)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) NULL, 0, 16, 8, speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) case 212:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) NULL, 0, 16, 16, aead_speed_template_19);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) test_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) NULL, 0, 16, 16, aead_speed_template_19);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) case 213:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) NULL, 0, 16, 8, aead_speed_template_36);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) NULL, 0, 16, 8, aead_speed_template_36);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) case 214:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) test_cipher_speed("chacha20", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) speed_template_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) case 215:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) test_mb_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) 0, 16, 16, aead_speed_template_20, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) test_mb_aead_speed("gcm(aes)", ENCRYPT, sec, NULL, 0, 16, 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) test_mb_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) 0, 16, 16, aead_speed_template_20, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) test_mb_aead_speed("gcm(aes)", DECRYPT, sec, NULL, 0, 16, 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) case 216:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) test_mb_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) 16, 16, aead_speed_template_19, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) test_mb_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) 16, 16, aead_speed_template_19, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) case 217:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) sec, NULL, 0, 16, 8, aead_speed_template_36,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) sec, NULL, 0, 16, 8, aead_speed_template_36,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) case 218:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) test_cipher_speed("ecb(sm4)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) speed_template_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) test_cipher_speed("ecb(sm4)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) speed_template_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) test_cipher_speed("cbc(sm4)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) speed_template_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) test_cipher_speed("cbc(sm4)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) speed_template_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) test_cipher_speed("ctr(sm4)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) speed_template_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) test_cipher_speed("ctr(sm4)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) speed_template_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) case 219:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) test_cipher_speed("adiantum(xchacha12,aes)", ENCRYPT, sec, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) 0, speed_template_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) test_cipher_speed("adiantum(xchacha12,aes)", DECRYPT, sec, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) 0, speed_template_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) test_cipher_speed("adiantum(xchacha20,aes)", ENCRYPT, sec, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) 0, speed_template_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) test_cipher_speed("adiantum(xchacha20,aes)", DECRYPT, sec, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) 0, speed_template_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) case 220:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) test_acipher_speed("essiv(cbc(aes),sha256)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) test_acipher_speed("essiv(cbc(aes),sha256)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) case 221:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) test_aead_speed("aegis128", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) NULL, 0, 16, 8, speed_template_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) test_aead_speed("aegis128", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) NULL, 0, 16, 8, speed_template_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) case 300:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) if (alg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) test_hash_speed(alg, sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) case 301:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) test_hash_speed("md4", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) case 302:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) test_hash_speed("md5", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) case 303:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) test_hash_speed("sha1", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) case 304:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) test_hash_speed("sha256", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) case 305:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) test_hash_speed("sha384", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) case 306:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) test_hash_speed("sha512", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) case 307:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) test_hash_speed("wp256", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) case 308:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) test_hash_speed("wp384", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) case 309:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) test_hash_speed("wp512", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) case 310:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) test_hash_speed("tgr128", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) case 311:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) test_hash_speed("tgr160", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) case 312:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) test_hash_speed("tgr192", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) case 313:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) test_hash_speed("sha224", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) case 314:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) test_hash_speed("rmd128", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) case 315:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) test_hash_speed("rmd160", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) case 316:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) test_hash_speed("rmd256", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) case 317:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) test_hash_speed("rmd320", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) case 318:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) klen = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) test_hash_speed("ghash", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) case 319:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) test_hash_speed("crc32c", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) case 320:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) test_hash_speed("crct10dif", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) case 321:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) test_hash_speed("poly1305", sec, poly1305_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) case 322:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) test_hash_speed("sha3-224", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) case 323:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) test_hash_speed("sha3-256", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) case 324:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) test_hash_speed("sha3-384", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) case 325:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) test_hash_speed("sha3-512", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) case 326:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) test_hash_speed("sm3", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) case 327:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) test_hash_speed("streebog256", sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) case 328:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) test_hash_speed("streebog512", sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) if (mode > 300 && mode < 400) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) case 399:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) case 400:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) if (alg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) test_ahash_speed(alg, sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) case 401:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) test_ahash_speed("md4", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) case 402:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) test_ahash_speed("md5", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) case 403:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) test_ahash_speed("sha1", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) case 404:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) test_ahash_speed("sha256", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) case 405:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) test_ahash_speed("sha384", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) case 406:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) test_ahash_speed("sha512", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) case 407:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) test_ahash_speed("wp256", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) case 408:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) test_ahash_speed("wp384", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) case 409:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) test_ahash_speed("wp512", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) case 410:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) test_ahash_speed("tgr128", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) case 411:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) test_ahash_speed("tgr160", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) case 412:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) test_ahash_speed("tgr192", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) case 413:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) test_ahash_speed("sha224", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) case 414:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) test_ahash_speed("rmd128", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) case 415:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) test_ahash_speed("rmd160", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) case 416:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) test_ahash_speed("rmd256", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) case 417:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) test_ahash_speed("rmd320", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) case 418:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) test_ahash_speed("sha3-224", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) case 419:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) test_ahash_speed("sha3-256", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) case 420:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) test_ahash_speed("sha3-384", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) case 421:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) test_ahash_speed("sha3-512", sec, generic_hash_speed_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) case 422:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) test_mb_ahash_speed("sha1", sec, generic_hash_speed_template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) case 423:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) test_mb_ahash_speed("sha256", sec, generic_hash_speed_template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) case 424:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) test_mb_ahash_speed("sha512", sec, generic_hash_speed_template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) case 425:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) test_mb_ahash_speed("sm3", sec, generic_hash_speed_template,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) case 426:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) test_mb_ahash_speed("streebog256", sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) generic_hash_speed_template, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) case 427:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) test_mb_ahash_speed("streebog512", sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) generic_hash_speed_template, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) if (mode > 400 && mode < 500) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) case 499:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) case 500:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) speed_template_32_40_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) speed_template_32_40_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) test_acipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) test_acipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) speed_template_20_28_36);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) test_acipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) speed_template_20_28_36);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) case 501:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) test_acipher_speed("ecb(des3_ede)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) test_acipher_speed("cbc(des3_ede)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) test_acipher_speed("cfb(des3_ede)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) test_acipher_speed("ofb(des3_ede)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) speed_template_24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) case 502:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) case 503:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) speed_template_32_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) speed_template_32_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) case 504:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) speed_template_16_24_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) speed_template_32_40_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) speed_template_32_40_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) speed_template_32_48_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) speed_template_32_48_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) case 505:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) speed_template_8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) case 506:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) speed_template_8_16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) case 507:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) speed_template_32_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) speed_template_32_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) case 508:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) test_acipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) test_acipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) test_acipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) test_acipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) test_acipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) test_acipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) speed_template_16_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) test_acipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) speed_template_32_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) test_acipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) speed_template_32_48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) test_acipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) test_acipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) speed_template_32_64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) case 509:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) test_acipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) test_acipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) test_acipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) test_acipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) test_acipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) test_acipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) speed_template_8_32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) case 600:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) test_mb_skcipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) test_mb_skcipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) test_mb_skcipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) test_mb_skcipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) test_mb_skcipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) speed_template_32_40_48, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) test_mb_skcipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) speed_template_32_40_48, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) test_mb_skcipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) speed_template_32_64, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) test_mb_skcipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) speed_template_32_64, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) test_mb_skcipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) test_mb_skcipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) test_mb_skcipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) test_mb_skcipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) test_mb_skcipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) test_mb_skcipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) test_mb_skcipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) test_mb_skcipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) test_mb_skcipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) 0, speed_template_20_28_36, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) test_mb_skcipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) 0, speed_template_20_28_36, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) case 601:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) test_mb_skcipher_speed("ecb(des3_ede)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) speed_template_24, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) test_mb_skcipher_speed("ecb(des3_ede)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) speed_template_24, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) test_mb_skcipher_speed("cbc(des3_ede)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) speed_template_24, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) test_mb_skcipher_speed("cbc(des3_ede)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) speed_template_24, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) test_mb_skcipher_speed("cfb(des3_ede)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) speed_template_24, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) test_mb_skcipher_speed("cfb(des3_ede)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) speed_template_24, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) test_mb_skcipher_speed("ofb(des3_ede)", ENCRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) speed_template_24, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) test_mb_skcipher_speed("ofb(des3_ede)", DECRYPT, sec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) des3_speed_template, DES3_SPEED_VECTORS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) speed_template_24, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) case 602:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) test_mb_skcipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) speed_template_8, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) test_mb_skcipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) speed_template_8, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) test_mb_skcipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) speed_template_8, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) test_mb_skcipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) speed_template_8, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) test_mb_skcipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) speed_template_8, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) test_mb_skcipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) speed_template_8, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) test_mb_skcipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) speed_template_8, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) test_mb_skcipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) speed_template_8, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) case 603:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) test_mb_skcipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) test_mb_skcipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) test_mb_skcipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) test_mb_skcipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) test_mb_skcipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) test_mb_skcipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) test_mb_skcipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) speed_template_32_48, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) test_mb_skcipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) speed_template_32_48, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) test_mb_skcipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) speed_template_32_64, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) test_mb_skcipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) speed_template_32_64, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) case 604:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) test_mb_skcipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) test_mb_skcipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) test_mb_skcipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) test_mb_skcipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) test_mb_skcipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) test_mb_skcipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) speed_template_16_24_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) test_mb_skcipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) speed_template_32_40_48, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) test_mb_skcipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) speed_template_32_40_48, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) test_mb_skcipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) speed_template_32_48_64, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) test_mb_skcipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) speed_template_32_48_64, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) case 605:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) test_mb_skcipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) speed_template_8, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) case 606:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) test_mb_skcipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) speed_template_8_16, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) test_mb_skcipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) speed_template_8_16, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) test_mb_skcipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) speed_template_8_16, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) test_mb_skcipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) speed_template_8_16, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) test_mb_skcipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) speed_template_8_16, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) test_mb_skcipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) speed_template_8_16, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) case 607:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) test_mb_skcipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) test_mb_skcipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) test_mb_skcipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) test_mb_skcipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) test_mb_skcipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) test_mb_skcipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) test_mb_skcipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) speed_template_32_48, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) test_mb_skcipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) speed_template_32_48, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) test_mb_skcipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) speed_template_32_64, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) test_mb_skcipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) speed_template_32_64, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) case 608:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) test_mb_skcipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) test_mb_skcipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) test_mb_skcipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) test_mb_skcipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) test_mb_skcipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) test_mb_skcipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) speed_template_16_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) test_mb_skcipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) speed_template_32_48, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) test_mb_skcipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) speed_template_32_48, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) test_mb_skcipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) speed_template_32_64, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) test_mb_skcipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) speed_template_32_64, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003) case 609:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) test_mb_skcipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) speed_template_8_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) test_mb_skcipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) speed_template_8_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) test_mb_skcipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) speed_template_8_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) test_mb_skcipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) speed_template_8_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) test_mb_skcipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) speed_template_8_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) test_mb_skcipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) speed_template_8_32, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) case 1000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) test_available();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) static int __init tcrypt_mod_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) int err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) for (i = 0; i < TVMEMSIZE; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) tvmem[i] = (void *)__get_free_page(GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) if (!tvmem[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) goto err_free_tv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) err = do_test(alg, type, mask, mode, num_mb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) printk(KERN_ERR "tcrypt: one or more tests failed!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) goto err_free_tv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) pr_debug("all tests passed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) /* We intentionaly return -EAGAIN to prevent keeping the module,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) * unless we're running in fips mode. It does all its work from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) * init() and doesn't offer any runtime functionality, but in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) * the fips case, checking for a successful load is helpful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) * => we don't need it in the memory, do we?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) * -- mludvig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) if (!fips_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) err = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) err_free_tv:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) for (i = 0; i < TVMEMSIZE && tvmem[i]; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) free_page((unsigned long)tvmem[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) * If an init function is provided, an exit function must also be provided
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) * to allow module unload.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) static void __exit tcrypt_mod_fini(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) subsys_initcall(tcrypt_mod_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) module_exit(tcrypt_mod_fini);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) module_param(alg, charp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) module_param(type, uint, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) module_param(mask, uint, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) module_param(mode, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) module_param(sec, uint, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) MODULE_PARM_DESC(sec, "Length in seconds of speed tests "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) "(defaults to zero which uses CPU cycles instead)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) module_param(num_mb, uint, 0000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) MODULE_PARM_DESC(num_mb, "Number of concurrent requests to be used in mb speed tests (defaults to 8)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) module_param(klen, uint, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) MODULE_PARM_DESC(klen, "Key length (defaults to 0)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) MODULE_DESCRIPTION("Quick & dirty crypto testing module");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");