--- zzzz-none-000/linux-4.4.271/crypto/tcrypt.c 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/crypto/tcrypt.c 2023-04-19 10:22:28.000000000 +0000 @@ -305,11 +305,11 @@ unsigned int tcount, u8 authsize, unsigned int aad_size, u8 *keysize) { - unsigned int i, j; struct crypto_aead *tfm; + struct aead_request *req; + unsigned int i, j; int ret = -ENOMEM; const char *key; - struct aead_request *req; struct scatterlist *sg; struct scatterlist *sgout; const char *e; @@ -348,32 +348,32 @@ goto out_nosg; sgout = &sg[9]; - tfm = crypto_alloc_aead(algo, 0, 0); - - if (IS_ERR(tfm)) { - pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo, - PTR_ERR(tfm)); - goto out_notfm; - } - - init_completion(&result.completion); - printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo, - get_driver_name(crypto_aead, tfm), e); - - req = aead_request_alloc(tfm, GFP_KERNEL); - if (!req) { - pr_err("alg: aead: Failed to allocate request for %s\n", - algo); - goto out_noreq; - } - - aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + pr_info("testing speed of %s %s\n", algo, e); i = 0; do { b_size = aead_sizes; do { + tfm = crypto_alloc_aead(algo, 0, 0); + if (IS_ERR(tfm)) { + pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo, + PTR_ERR(tfm)); + goto out_notfm; + } + + init_completion(&result.completion); + + req = aead_request_alloc(tfm, GFP_KERNEL); + if (!req) { + pr_err("alg: aead: Failed to allocate request for %s\n", + algo); + crypto_free_aead(tfm); + goto out_notfm; + } + + aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, + tcrypt_complete, &result); + assoc = axbuf[0]; memset(assoc, 0xff, aad_size); @@ -381,7 +381,9 @@ pr_err("template (%u) too big for tvmem (%lu)\n", *keysize + *b_size, TVMEMSIZE * PAGE_SIZE); - goto out; + aead_request_free(req); + crypto_free_aead(tfm); + goto out_notfm; } key = tvmem[0]; @@ -402,13 +404,14 @@ printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ", i, *keysize * 8, *b_size); - memset(tvmem[0], 0xff, PAGE_SIZE); if (ret) { pr_err("setkey() failed flags=%x\n", crypto_aead_get_flags(tfm)); - goto out; + aead_request_free(req); + crypto_free_aead(tfm); + goto out_notfm; } sg_init_aead(sg, xbuf, @@ -437,14 +440,13 @@ } b_size++; i++; + aead_request_free(req); + crypto_free_aead(tfm); } while (*b_size); keysize++; } while (*keysize); + pr_info("speed test completed for %s algorithm\n", algo); -out: - aead_request_free(req); -out_noreq: - crypto_free_aead(tfm); out_notfm: kfree(sg); out_nosg: @@ -462,11 +464,11 @@ struct cipher_speed_template *template, unsigned int tcount, u8 *keysize) { + struct crypto_blkcipher *tfm; + struct blkcipher_desc desc; unsigned int ret, i, j, iv_len; const char *key; char iv[128]; - struct crypto_blkcipher *tfm; - struct blkcipher_desc desc; const char *e; u32 *b_size; @@ -475,18 +477,7 @@ else e = "decryption"; - tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC); - - if (IS_ERR(tfm)) { - printk("failed to load transform for %s: %ld\n", algo, - PTR_ERR(tfm)); - return; - } - desc.tfm = tfm; - desc.flags = 0; - - printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo, - get_driver_name(crypto_blkcipher, tfm), e); + pr_info("testing speed of %s %s\n", algo, e); i = 0; do { @@ -495,14 +486,25 @@ do { struct scatterlist sg[TVMEMSIZE]; + tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC); + + if (IS_ERR(tfm)) { + printk("failed to load transform for %s: %ld\n", algo, + PTR_ERR(tfm)); + return; + } + desc.tfm = tfm; + desc.flags = 0; + if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { printk("template (%u) too big for " "tvmem (%lu)\n", *keysize + *b_size, TVMEMSIZE * PAGE_SIZE); - goto out; + crypto_free_blkcipher(tfm); + return; } - printk("test %u (%d bit key, %d byte blocks): ", i, + pr_info("cipher speed test %u (%d bit key, %d byte blocks): ", i, *keysize * 8, *b_size); memset(tvmem[0], 0xff, PAGE_SIZE); @@ -520,7 +522,8 @@ if (ret) { printk("setkey() failed flags=%x\n", crypto_blkcipher_get_flags(tfm)); - goto out; + crypto_free_blkcipher(tfm); + return; } sg_init_table(sg, TVMEMSIZE); @@ -546,16 +549,15 @@ if (ret) { printk("%s() failed flags=%x\n", e, desc.flags); + crypto_free_blkcipher(tfm); break; } b_size++; i++; + crypto_free_blkcipher(tfm); } while (*b_size); keysize++; } while (*keysize); - -out: - crypto_free_blkcipher(tfm); } static int test_hash_jiffies_digest(struct hash_desc *desc, @@ -997,6 +999,8 @@ break; } + test_hash_sg_init(sg); + pr_info("test%3u " "(%5u byte blocks,%5u bytes per update,%4u updates): ", i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen); @@ -1294,9 +1298,11 @@ break; case 4: +#ifdef CONFIG_CRYPTO_ALL_CASES ret += tcrypt_test("ecb(des3_ede)"); - ret += tcrypt_test("cbc(des3_ede)"); ret += tcrypt_test("ctr(des3_ede)"); +#endif + ret += tcrypt_test("cbc(des3_ede)"); break; case 5: @@ -1330,12 +1336,12 @@ break; case 10: - ret += tcrypt_test("ecb(aes)"); ret += tcrypt_test("cbc(aes)"); +#ifdef CONFIG_CRYPTO_ALL_CASES ret += tcrypt_test("lrw(aes)"); ret += tcrypt_test("xts(aes)"); ret += tcrypt_test("ctr(aes)"); - ret += tcrypt_test("rfc3686(ctr(aes))"); +#endif break; case 11: @@ -1497,6 +1503,14 @@ ret += tcrypt_test("crct10dif"); break; + case 48: + ret += tcrypt_test("ecb(aes)"); + break; + + case 49: + ret += tcrypt_test("rfc3686(ctr(aes))"); + break; + case 100: ret += tcrypt_test("hmac(md5)"); break; @@ -1572,6 +1586,9 @@ case 157: ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))"); break; + case 180: + ret += tcrypt_test("authenc(hmac(sha256),cbc(aes))"); + break; case 181: ret += tcrypt_test("authenc(hmac(sha1),cbc(des))"); break; @@ -1602,6 +1619,13 @@ case 190: ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))"); break; + case 191: + ret += tcrypt_test("authenc(hmac(sha384),cbc(aes))"); + break; + case 192: + ret += tcrypt_test("authenc(hmac(sha512),cbc(aes))"); + break; + case 200: test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, speed_template_16_24_32); @@ -1611,6 +1635,7 @@ speed_template_16_24_32); test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, speed_template_16_24_32); +#ifdef CONFIG_CRYPTO_ALL_CASES test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0, speed_template_32_40_48); test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0, @@ -1623,6 +1648,7 @@ speed_template_16_24_32); test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0, speed_template_16_24_32); +#endif break; case 201: @@ -1811,7 +1837,6 @@ speed_template_32); break; - case 300: if (alg) { test_hash_speed(alg, sec, generic_hash_speed_template);