mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
crypto: hisilicon/sec2 - optimize the error return process
[ Upstream commit 1bed82257b1881b689ee41f14ecb4c20a273cac0 ] Add the printf of an error message and optimized the handling process of ret. Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Stable-dep-of: fd337f852b26 ("crypto: hisilicon/sec2 - fix for aead icv error") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d55edbe092
commit
fdc596efd7
@@ -850,6 +850,7 @@ static int sec_skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
|||||||
ret = sec_skcipher_aes_sm4_setkey(c_ctx, keylen, c_mode);
|
ret = sec_skcipher_aes_sm4_setkey(c_ctx, keylen, c_mode);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
dev_err(dev, "sec c_alg err!\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1175,7 +1176,8 @@ static int sec_aead_setkey(struct crypto_aead *tfm, const u8 *key,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crypto_authenc_extractkeys(&keys, key, keylen))
|
ret = crypto_authenc_extractkeys(&keys, key, keylen);
|
||||||
|
if (ret)
|
||||||
goto bad_key;
|
goto bad_key;
|
||||||
|
|
||||||
ret = sec_aead_aes_set_key(c_ctx, &keys);
|
ret = sec_aead_aes_set_key(c_ctx, &keys);
|
||||||
@@ -1192,6 +1194,7 @@ static int sec_aead_setkey(struct crypto_aead *tfm, const u8 *key,
|
|||||||
|
|
||||||
if ((ctx->a_ctx.mac_len & SEC_SQE_LEN_RATE_MASK) ||
|
if ((ctx->a_ctx.mac_len & SEC_SQE_LEN_RATE_MASK) ||
|
||||||
(ctx->a_ctx.a_key_len & SEC_SQE_LEN_RATE_MASK)) {
|
(ctx->a_ctx.a_key_len & SEC_SQE_LEN_RATE_MASK)) {
|
||||||
|
ret = -EINVAL;
|
||||||
dev_err(dev, "MAC or AUTH key length error!\n");
|
dev_err(dev, "MAC or AUTH key length error!\n");
|
||||||
goto bad_key;
|
goto bad_key;
|
||||||
}
|
}
|
||||||
@@ -1200,7 +1203,7 @@ static int sec_aead_setkey(struct crypto_aead *tfm, const u8 *key,
|
|||||||
|
|
||||||
bad_key:
|
bad_key:
|
||||||
memzero_explicit(&keys, sizeof(struct crypto_authenc_keys));
|
memzero_explicit(&keys, sizeof(struct crypto_authenc_keys));
|
||||||
return -EINVAL;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user