From 0a0dd7279d7b7110834d6622783f9e35c067f3a5 Mon Sep 17 00:00:00 2001 From: lihuhua <18245010845@163.com> Date: Wed, 7 Sep 2022 11:21:51 +0800 Subject: [PATCH] change the aes encryption mode to asynchronous invocation --- auth/security_auth_enhance.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/auth/security_auth_enhance.c b/auth/security_auth_enhance.c index 14cd08f..fc367f9 100644 --- a/auth/security_auth_enhance.c +++ b/auth/security_auth_enhance.c @@ -518,6 +518,7 @@ static int crypto_aescbc_key256(uint8_t *output, const uint8_t *input, int ret; uint8_t temp_iv[IV_BYTESIZE] = {0}; + DECLARE_CRYPTO_WAIT(wait); skcipher = crypto_alloc_skcipher("cbc(aes)", 0, 0); if (IS_ERR_OR_NULL(skcipher)) { tloge("crypto_alloc_skcipher() failed\n"); @@ -546,11 +547,14 @@ static int crypto_aescbc_key256(uint8_t *output, const uint8_t *input, sg_init_table(&src, 1); /* init table to 1 */ sg_set_buf(&dst, output, size); sg_set_buf(&src, input, size); + skcipher_request_set_callback(req, 0, crypto_req_done, &wait); skcipher_request_set_crypt(req, &src, &dst, size, temp_iv); if (encrypto_type) - ret = crypto_skcipher_encrypt(req); + ret = crypto_wait_req(crypto_skcipher_encrypt(req), &wait); else - ret = crypto_skcipher_decrypt(req); + ret = crypto_wait_req(crypto_skcipher_decrypt(req), &wait); + if (ret) + tloge("%s data failed, ret=%d\n", encrypto_type ? "encrypt" : "decrypt", ret); skcipher_request_free(req); crypto_free_skcipher(skcipher); return ret; -- Gitee