Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: hisilicon/sec - add some comments for soft fallback

Modify the print of information that might lead to user misunderstanding.
Currently only XTS mode need the fallback tfm when using 192bit key.
Others algs not need soft fallback tfm. So others algs can return
directly.

Signed-off-by: Kai Ye <yekai13@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Kai Ye and committed by
Herbert Xu
e764d81d 60ef3dde

+6 -6
+6 -6
drivers/crypto/hisilicon/sec2/sec_crypto.c
··· 641 641 struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; 642 642 643 643 c_ctx->fallback = false; 644 + 645 + /* Currently, only XTS mode need fallback tfm when using 192bit key */ 644 646 if (likely(strncmp(alg, "xts", SEC_XTS_NAME_SZ))) 645 647 return 0; 646 648 647 649 c_ctx->fbtfm = crypto_alloc_sync_skcipher(alg, 0, 648 650 CRYPTO_ALG_NEED_FALLBACK); 649 651 if (IS_ERR(c_ctx->fbtfm)) { 650 - pr_err("failed to alloc fallback tfm!\n"); 652 + pr_err("failed to alloc xts mode fallback tfm!\n"); 651 653 return PTR_ERR(c_ctx->fbtfm); 652 654 } 653 655 ··· 810 808 } 811 809 812 810 memcpy(c_ctx->c_key, key, keylen); 813 - if (c_ctx->fallback) { 811 + if (c_ctx->fallback && c_ctx->fbtfm) { 814 812 ret = crypto_sync_skcipher_setkey(c_ctx->fbtfm, key, keylen); 815 813 if (ret) { 816 814 dev_err(dev, "failed to set fallback skcipher key!\n"); ··· 2034 2032 struct skcipher_request *sreq, bool encrypt) 2035 2033 { 2036 2034 struct sec_cipher_ctx *c_ctx = &ctx->c_ctx; 2035 + SYNC_SKCIPHER_REQUEST_ON_STACK(subreq, c_ctx->fbtfm); 2037 2036 struct device *dev = ctx->dev; 2038 2037 int ret; 2039 2038 2040 - SYNC_SKCIPHER_REQUEST_ON_STACK(subreq, c_ctx->fbtfm); 2041 - 2042 2039 if (!c_ctx->fbtfm) { 2043 - dev_err(dev, "failed to check fallback tfm\n"); 2040 + dev_err_ratelimited(dev, "the soft tfm isn't supported in the current system.\n"); 2044 2041 return -EINVAL; 2045 2042 } 2046 2043 ··· 2257 2256 if (ctx->sec->qm.ver == QM_HW_V2) { 2258 2257 if (unlikely(!req->cryptlen || (!sreq->c_req.encrypt && 2259 2258 req->cryptlen <= authsize))) { 2260 - dev_err(dev, "Kunpeng920 not support 0 length!\n"); 2261 2259 ctx->a_ctx.fallback = true; 2262 2260 return -EINVAL; 2263 2261 }