]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: tegra - Use HMAC fallback when keyslots are full
authorAkhil R <akhilrajeev@nvidia.com>
Mon, 24 Feb 2025 09:16:10 +0000 (14:46 +0530)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 8 Mar 2025 08:23:22 +0000 (16:23 +0800)
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>
drivers/crypto/tegra/tegra-se-hash.c

index 8bed13552ab9e7318110c9312e31d9a754f9fdb8..65a50f29bd7e6d96793985ed07115948dc450d09 100644 (file)
@@ -632,13 +632,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_init(struct ahash_request *req)