Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: talitos - Fix ctr(aes) on SEC1

While ctr(aes) requires the use of a special descriptor on SEC2 (see
commit 70d355ccea89 ("crypto: talitos - fix ctr-aes-talitos")), that
special descriptor doesn't work on SEC1, see commit e738c5f15562
("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: 70d355ccea89 ("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>

authored by

Christophe Leroy and committed by
Herbert Xu
43a942d2 416b8467

+22
+22
drivers/crypto/talitos.c
··· 2767 2767 }, 2768 2768 { .type = CRYPTO_ALG_TYPE_SKCIPHER, 2769 2769 .alg.skcipher = { 2770 + .base.cra_name = "ctr(aes)", 2771 + .base.cra_driver_name = "ctr-aes-talitos", 2772 + .base.cra_blocksize = 1, 2773 + .base.cra_flags = CRYPTO_ALG_ASYNC | 2774 + CRYPTO_ALG_ALLOCATES_MEMORY, 2775 + .min_keysize = AES_MIN_KEY_SIZE, 2776 + .max_keysize = AES_MAX_KEY_SIZE, 2777 + .ivsize = AES_BLOCK_SIZE, 2778 + .setkey = skcipher_aes_setkey, 2779 + }, 2780 + .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | 2781 + DESC_HDR_SEL0_AESU | 2782 + DESC_HDR_MODE0_AESU_CTR, 2783 + }, 2784 + { .type = CRYPTO_ALG_TYPE_SKCIPHER, 2785 + .alg.skcipher = { 2770 2786 .base.cra_name = "ecb(des)", 2771 2787 .base.cra_driver_name = "ecb-des-talitos", 2772 2788 .base.cra_blocksize = DES_BLOCK_SIZE, ··· 3198 3182 t_alg->algt.alg.skcipher.setkey ?: skcipher_setkey; 3199 3183 t_alg->algt.alg.skcipher.encrypt = skcipher_encrypt; 3200 3184 t_alg->algt.alg.skcipher.decrypt = skcipher_decrypt; 3185 + if (!strcmp(alg->cra_name, "ctr(aes)") && !has_ftr_sec1(priv) && 3186 + DESC_TYPE(t_alg->algt.desc_hdr_template) != 3187 + DESC_TYPE(DESC_HDR_TYPE_AESU_CTR_NONSNOOP)) { 3188 + devm_kfree(dev, t_alg); 3189 + return ERR_PTR(-ENOTSUPP); 3190 + } 3201 3191 break; 3202 3192 case CRYPTO_ALG_TYPE_AEAD: 3203 3193 alg = &t_alg->algt.alg.aead.base;