summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkhil R <akhilrajeev@nvidia.com>2025-02-24 14:46:10 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-04-10 14:39:17 +0200
commit46ea02988bb9d171bb2135dd0bb7ceeaef585424 (patch)
treea9fe02e31906b7d1596da882ffbb8bfc7a40e433
parent057298d193342ef6c4a37d6f69cbccb45e7812f4 (diff)
crypto: tegra - Use HMAC fallback when keyslots are full
[ Upstream commit f80a2e2e77bedd0aa645a60f89b4f581c70accda ] The intermediate results for HMAC is stored in the allocated keyslot by the hardware. Dynamic allocation of keyslot during an operation is hence not possible. As the number of keyslots are limited in the hardware, fallback to the HMAC software implementation if keyslots are not available Fixes: 0880bb3b00c8 ("crypto: tegra - Add Tegra Security Engine driver") Signed-off-by: Akhil R <akhilrajeev@nvidia.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/crypto/tegra/tegra-se-hash.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/crypto/tegra/tegra-se-hash.c b/drivers/crypto/tegra/tegra-se-hash.c
index 5aead114bd96..726e30c0e63e 100644
--- a/drivers/crypto/tegra/tegra-se-hash.c
+++ b/drivers/crypto/tegra/tegra-se-hash.c
@@ -567,13 +567,18 @@ static int tegra_hmac_setkey(struct crypto_ahash *tfm, const u8 *key,
unsigned int keylen)
{
struct tegra_sha_ctx *ctx = crypto_ahash_ctx(tfm);
+ int ret;
if (aes_check_keylen(keylen))
return tegra_hmac_fallback_setkey(ctx, key, keylen);
+ ret = tegra_key_submit(ctx->se, key, keylen, ctx->alg, &ctx->key_id);
+ if (ret)
+ return tegra_hmac_fallback_setkey(ctx, key, keylen);
+
ctx->fallback = false;
- return tegra_key_submit(ctx->se, key, keylen, ctx->alg, &ctx->key_id);
+ return 0;
}
static int tegra_sha_update(struct ahash_request *req)