Skip to content

Commit c64eb55

Browse files
chleroygregkh
authored andcommitted
crypto: talitos - Fix ctr(aes) on SEC1
[ Upstream commit 43a942d ] While ctr(aes) requires the use of a special descriptor on SEC2 (see commit 70d355c ("crypto: talitos - fix ctr-aes-talitos")), that special descriptor doesn't work on SEC1, see commit e738c5f ("powerpc/8xx: Add DT node for using the SEC engine of the MPC885"). However, the common nonsnoop descriptor works properly on SEC1 for ctr(aes). Add a second template for ctr(aes) that will be registered only on SEC1. Fixes: 70d355c ("crypto: talitos - fix ctr-aes-talitos") Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 62aa24d commit c64eb55

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/crypto/talitos.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,6 +2764,22 @@ static struct talitos_alg_template driver_algs[] = {
27642764
DESC_HDR_SEL0_AESU |
27652765
DESC_HDR_MODE0_AESU_CTR,
27662766
},
2767+
{ .type = CRYPTO_ALG_TYPE_SKCIPHER,
2768+
.alg.skcipher = {
2769+
.base.cra_name = "ctr(aes)",
2770+
.base.cra_driver_name = "ctr-aes-talitos",
2771+
.base.cra_blocksize = 1,
2772+
.base.cra_flags = CRYPTO_ALG_ASYNC |
2773+
CRYPTO_ALG_ALLOCATES_MEMORY,
2774+
.min_keysize = AES_MIN_KEY_SIZE,
2775+
.max_keysize = AES_MAX_KEY_SIZE,
2776+
.ivsize = AES_BLOCK_SIZE,
2777+
.setkey = skcipher_aes_setkey,
2778+
},
2779+
.desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
2780+
DESC_HDR_SEL0_AESU |
2781+
DESC_HDR_MODE0_AESU_CTR,
2782+
},
27672783
{ .type = CRYPTO_ALG_TYPE_SKCIPHER,
27682784
.alg.skcipher = {
27692785
.base.cra_name = "ecb(des)",
@@ -3181,6 +3197,12 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,
31813197
t_alg->algt.alg.skcipher.setkey ?: skcipher_setkey;
31823198
t_alg->algt.alg.skcipher.encrypt = skcipher_encrypt;
31833199
t_alg->algt.alg.skcipher.decrypt = skcipher_decrypt;
3200+
if (!strcmp(alg->cra_name, "ctr(aes)") && !has_ftr_sec1(priv) &&
3201+
DESC_TYPE(t_alg->algt.desc_hdr_template) !=
3202+
DESC_TYPE(DESC_HDR_TYPE_AESU_CTR_NONSNOOP)) {
3203+
devm_kfree(dev, t_alg);
3204+
return ERR_PTR(-ENOTSUPP);
3205+
}
31843206
break;
31853207
case CRYPTO_ALG_TYPE_AEAD:
31863208
alg = &t_alg->algt.alg.aead.base;

0 commit comments

Comments
 (0)