From b566ebd52eeb661337ef5f52a000528af59479df Mon Sep 17 00:00:00 2001 From: Vincent Jardin Date: Mon, 28 Sep 2026 16:09:16 +0200 Subject: [PATCH] crypto: caam/qi,qi2 - set plain_keylen for skcipher descriptors Since the commit 66b9a095f7f9 ("crypto: caam - Add support of paes algorithm") The shared descriptor then loads a zero-length key and the SEC decodes the inlined key bytes as commands. Test: with CONFIG_CRYPTO_SELFTESTS on LX2160A every skcipher but xts fails: dpaa2_caam dpseci.0: 40000307: DECO: desc idx 3: Invalid LOAD Command alg: skcipher: ctr-aes-caam-qi2 encryption failed on test vector 0; expected_error=0, actual_error=-22, cfg="in-place (one sglist)" caamalg_qi.c is compile-tested only. Fixes: 66b9a095f7f9 ("crypto: caam - Add support of paes algorithm") Signed-off-by: Vincent Jardin Signed-off-by: Herbert Xu --- drivers/crypto/caam/caamalg_qi.c | 2 ++ drivers/crypto/caam/caamalg_qi2.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c index aa779caacfe5..2f2682c8bcd8 100644 --- a/drivers/crypto/caam/caamalg_qi.c +++ b/drivers/crypto/caam/caamalg_qi.c @@ -637,6 +637,8 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key, ctx->cdata.keylen = keylen; ctx->cdata.key_virt = key; ctx->cdata.key_inline = true; + ctx->cdata.plain_keylen = keylen; + ctx->cdata.key_cmd_opt = 0; /* skcipher encrypt, decrypt shared descriptors */ cnstr_shdsc_skcipher_encap(ctx->sh_desc_enc, &ctx->cdata, ivsize, diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c index 6dccbd3b27a3..959e7963f161 100644 --- a/drivers/crypto/caam/caamalg_qi2.c +++ b/drivers/crypto/caam/caamalg_qi2.c @@ -961,6 +961,8 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key, ctx->cdata.keylen = keylen; ctx->cdata.key_virt = key; ctx->cdata.key_inline = true; + ctx->cdata.plain_keylen = keylen; + ctx->cdata.key_cmd_opt = 0; /* skcipher_encrypt shared descriptor */ flc = &ctx->flc[ENCRYPT];