Fixing selftests failure on Talitos driver
cover Fixing selftests failure on Talitos driver
Several test failures have popped up following recent changes to crypto selftests.
This series fixes (most of) them.
The last three patches are trivial cleanups.
Christophe Leroy (15):
crypto: talitos - fix skcipher failure due to wrong output IV
crypto: talitos - rename alternative AEAD algos.
crypto: talitos - reduce max key size for SEC1
crypto: talitos - check AES key size
crypto: talitos - fix CTR alg blocksize
crypto: talitos - check data blocksize in ablkcipher.
crypto: talitos - fix ECB algs ivsize
crypto: talitos - Do not modify req->cryptlen on decryption.
crypto: talitos - HMAC SNOOP NO AFEU mode requires SW icv checking.
crypto: talitos - properly handle split ICV.
crypto: talitos - Align SEC1 accesses to 32 bits boundaries.
crypto: talitos - fix AEAD processing.
Revert "crypto: talitos - export the talitos_submit function"
crypto: talitos - use IS_ENABLED() in has_ftr_sec1()
crypto: talitos - use SPDX-License-Identifier
drivers/crypto/talitos.c | 281 ++++++++++++++++++++++------------------------- drivers/crypto/talitos.h | 45 ++------ 2 files changed, 139 insertions(+), 187 deletions(-)
Signature · 1 line
2.13.3
PATCH 1/15 crypto: talitos - fix skcipher failure due to wrong output IV
Selftests report the following:
[ 2.984845] alg: skcipher: cbc-aes-talitos encryption test failed (wrong output IV) on test vector 0, cfg="in-place" [ 2.995377] 00000000: 3d af ba 42 9d 9e b4 30 b4 22 da 80 2c 9f ac 41 [ 3.032673] alg: skcipher: cbc-des-talitos encryption test failed (wrong output IV) on test vector 0, cfg="in-place" [ 3.043185] 00000000: fe dc ba 98 76 54 32 10 [ 3.063238] alg: skcipher: cbc-3des-talitos encryption test failed (wrong output IV) on test vector 0, cfg="in-place" [ 3.073818] 00000000: 7d 33 88 93 0f 93 b2 42
This above dumps show that the actual output IV is indeed the input IV. This is due to the IV not being copied back into the request.
This patch fixes that.
--- drivers/crypto/talitos.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/crypto/talitos.c +4 -0
@@ -1637,11 +1637,15 @@ static void ablkcipher_done(struct device *dev, int err) {struct ablkcipher_request *areq = context; +struct crypto_ablkcipher *cipher =crypto_ablkcipher_reqtfm (areq); +struct talitos_ctx *ctx =crypto_ablkcipher_ctx (cipher); +unsigned int ivsize =crypto_ablkcipher_ivsize (cipher);struct talitos_edesc *edesc; edesc = container_of(desc, struct talitos_edesc, desc);common_nonsnoop_unmap (dev, edesc, areq); +memcpy (areq->info, ctx->iv, ivsize);kfree (edesc);
Signature · 1 line
2.13.3
PATCH 2/15 crypto: talitos - rename alternative AEAD algos.
In reply to Christophe LeroyThe talitos driver has two ways to perform AEAD depending on the HW capability. Some HW support both. It is needed to give them different names to distingish which one it is for instance when a test fails.
--- drivers/crypto/talitos.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/crypto/talitos.c +8 -8
@@ -2356,7 +2356,7 @@ static struct talitos_alg_template driver_algs[] = { .base = { .cra_name = "authenc(hmac(sha1),cbc(aes))", .cra_driver_name ="authenc-hmac-sha1-" - "cbc-aes-talitos", + "cbc-aes-talitos-hsna", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },
@@ -2401,7 +2401,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_name = "authenc(hmac(sha1)," "cbc(des3_ede))", .cra_driver_name ="authenc-hmac-sha1-" - "cbc-3des-talitos", + "cbc-3des-talitos-hsna", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },
@@ -2444,7 +2444,7 @@ static struct talitos_alg_template driver_algs[] = { .base = { .cra_name = "authenc(hmac(sha224),cbc(aes))", .cra_driver_name ="authenc-hmac-sha224-" - "cbc-aes-talitos", + "cbc-aes-talitos-hsna", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },
@@ -2489,7 +2489,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_name = "authenc(hmac(sha224)," "cbc(des3_ede))", .cra_driver_name ="authenc-hmac-sha224-" - "cbc-3des-talitos", + "cbc-3des-talitos-hsna", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },
@@ -2532,7 +2532,7 @@ static struct talitos_alg_template driver_algs[] = { .base = { .cra_name = "authenc(hmac(sha256),cbc(aes))", .cra_driver_name ="authenc-hmac-sha256-" - "cbc-aes-talitos", + "cbc-aes-talitos-hsna", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },
@@ -2577,7 +2577,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_name = "authenc(hmac(sha256)," "cbc(des3_ede))", .cra_driver_name ="authenc-hmac-sha256-" - "cbc-3des-talitos", + "cbc-3des-talitos-hsna", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },
@@ -2706,7 +2706,7 @@ static struct talitos_alg_template driver_algs[] = { .base = { .cra_name = "authenc(hmac(md5),cbc(aes))", .cra_driver_name ="authenc-hmac-md5-" - "cbc-aes-talitos", + "cbc-aes-talitos-hsna", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },
@@ -2749,7 +2749,7 @@ static struct talitos_alg_template driver_algs[] = { .base = { .cra_name = "authenc(hmac(md5),cbc(des3_ede))", .cra_driver_name ="authenc-hmac-md5-" - "cbc-3des-talitos", + "cbc-3des-talitos-hsna", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },
Signature · 1 line
2.13.3
Re: [PATCH v1 02/15] crypto: talitos - rename alternative AEAD algos.
Hi Joe & Andy
Quoted 17 lines · Christophe Leroy
The talitos driver has two ways to perform AEAD depending on the HW capability. Some HW support both. It is needed to give them different names to distingish which one it is for instance when a test fails.
Signed-off-by Christophe Leroy <[email protected]>Fixes 7405c8d7ff97 ("crypto: talitos - templates for AEAD using HMAC_SNOOP_NO_AFEU")--- drivers/crypto/talitos.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/crypto/talitos.c +0
-0
drivers/crypto/talitos.c static struct talitos_alg_template driver_algs[] = { · line 2359
Quoted 5 lines
drivers/crypto/talitos.c +1
-1@@ -2356,7 +2356,7 @@ static struct talitos_alg_template driver_algs[] = { .base = { .cra_name = "authenc(hmac(sha1),cbc(aes))", .cra_driver_name ="authenc-hmac-sha1-" - "cbc-aes-talitos", + "cbc-aes-talitos-hsna",
checkpatch reports the following warning on the above:
WARNING: quoted string split across lines
#27: FILE: drivers/crypto/talitos.c:2359:
.cra_driver_name = "authenc-hmac-sha1-"
+ "cbc-aes-talitos-hsna",
But when I fixes the patch as follows, I get another warning:
@@ -2355,8 +2355,7 @@ static struct talitos_alg_template driver_algs[] = {
.alg.aead = {
.base = {
.cra_name = "authenc(hmac(sha1),cbc(aes))",
- .cra_driver_name = "authenc-hmac-sha1-"
- "cbc-aes-talitos",
+ .cra_driver_name = "authenc-hmac-sha1-cbc-aes-talitos-hsna",
.cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC,
},
WARNING: line over 80 characters
#28: FILE: drivers/crypto/talitos.c:2358:
+ .cra_driver_name = "authenc-hmac-sha1-cbc-aes-talitos-hsna",
So, how should this be fixed ?
Thanks
Christophe
Quoted 67 lines
drivers/crypto/talitos.c +7
-7.cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },@@ -2401,7 +2401,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_name = "authenc(hmac(sha1)," "cbc(des3_ede))", .cra_driver_name ="authenc-hmac-sha1-" - "cbc-3des-talitos", + "cbc-3des-talitos-hsna", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },@@ -2444,7 +2444,7 @@ static struct talitos_alg_template driver_algs[] = { .base = { .cra_name = "authenc(hmac(sha224),cbc(aes))", .cra_driver_name ="authenc-hmac-sha224-" - "cbc-aes-talitos", + "cbc-aes-talitos-hsna", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },@@ -2489,7 +2489,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_name = "authenc(hmac(sha224)," "cbc(des3_ede))", .cra_driver_name ="authenc-hmac-sha224-" - "cbc-3des-talitos", + "cbc-3des-talitos-hsna", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },@@ -2532,7 +2532,7 @@ static struct talitos_alg_template driver_algs[] = { .base = { .cra_name = "authenc(hmac(sha256),cbc(aes))", .cra_driver_name ="authenc-hmac-sha256-" - "cbc-aes-talitos", + "cbc-aes-talitos-hsna", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },@@ -2577,7 +2577,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_name = "authenc(hmac(sha256)," "cbc(des3_ede))", .cra_driver_name ="authenc-hmac-sha256-" - "cbc-3des-talitos", + "cbc-3des-talitos-hsna", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },@@ -2706,7 +2706,7 @@ static struct talitos_alg_template driver_algs[] = { .base = { .cra_name = "authenc(hmac(md5),cbc(aes))", .cra_driver_name ="authenc-hmac-md5-" - "cbc-aes-talitos", + "cbc-aes-talitos-hsna", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },@@ -2749,7 +2749,7 @@ static struct talitos_alg_template driver_algs[] = { .base = { .cra_name = "authenc(hmac(md5),cbc(des3_ede))", .cra_driver_name ="authenc-hmac-md5-" - "cbc-3des-talitos", + "cbc-3des-talitos-hsna", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },
Re: [PATCH v1 02/15] crypto: talitos - rename alternative AEAD algos.
Quoted 1 line · Christophe Leroy
Hi Joe & Andy
[]
drivers/crypto/talitos.c
Quoted 1 line
drivers/crypto/talitos.c +0
-0
[]
Quoted 35 lines
drivers/crypto/talitos.c static struct talitos_alg_template driver_algs[] = { · line 2359
Quoted 6 lines
drivers/crypto/talitos.c +1
-1@@ -2356,7 +2356,7 @@ static struct talitos_alg_template driver_algs[] = { .base = { .cra_name = "authenc(hmac(sha1),cbc(aes))", .cra_driver_name ="authenc-hmac-sha1-" - "cbc-aes-talitos", + "cbc-aes-talitos-hsna",checkpatch reports the following warning on the above:
WARNING: quoted string split across lines
#27: FILE:drivers/crypto/talitos.c:2359:
.cra_driver_name = "authenc-hmac-sha1-"drivers/crypto/talitos.c +1
-0+ "cbc-aes-talitos-hsna",But when I fixes the patch as follows, I get another warning:
drivers/crypto/talitos.c +1
-2@@ -2355,8 +2355,7 @@ static struct talitos_alg_template driver_algs[] = { .alg.aead = { .base = { .cra_name = "authenc(hmac(sha1),cbc(aes))", - .cra_driver_name ="authenc-hmac-sha1-" - "cbc-aes-talitos", + .cra_driver_name = "authenc-hmac-sha1-cbc-aes-talitos-hsna", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_ASYNC, },WARNING: line over 80 characters
#28: FILE:drivers/crypto/talitos.c:2358:drivers/crypto/talitos.c +1
-0+ .cra_driver_name = "authenc-hmac-sha1-cbc-aes-talitos-hsna",
Quoted 1 line
So, how should this be fixed ?
For at least now, by ignoring this checkpatch message.
It's a brainless script. You are not brainless.
PATCH 3/15 crypto: talitos - reduce max key size for SEC1
In reply to Christophe LeroySEC1 doesn't support SHA384/512, so it doesn't require longer keys.
This patch reduces the max key size when the driver is built for SEC1 only.
--- drivers/crypto/talitos.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/crypto/talitos.c +4 -0
@@ -837,7 +837,11 @@ static void talitos_unregister_rng(struct device *dev)* HMAC_SNOOP_NO_AFEA (HSNA) instead of type IPSEC_ESP */ #define TALITOS_CRA_PRIORITY_AEAD_HSNA (TALITOS_CRA_PRIORITY - 1) +#ifdef CONFIG_CRYPTO_DEV_TALITOS_SEC2 #define TALITOS_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + SHA512_BLOCK_SIZE) +#else +#define TALITOS_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + SHA256_BLOCK_SIZE) +#endif #define TALITOS_MAX_IV_LENGTH 16/* max of AES_BLOCK_SIZE, DES3_EDE_BLOCK_SIZE */ struct talitos_ctx {
Signature · 1 line
2.13.3
PATCH 4/15 crypto: talitos - check AES key size
In reply to Christophe LeroyAlthough the HW accepts any size and silently truncates it to the correct length, the extra tests expects EINVAL to be returned when the key size is not valid.
--- drivers/crypto/talitos.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/crypto/talitos.c +15 -0
@@ -1622,6 +1622,18 @@ static int ablkcipher_des3_setkey(struct crypto_ablkcipher *cipher,return ablkcipher_setkey (cipher, key, keylen); } +static int ablkcipher_aes_setkey (struct crypto_ablkcipher *cipher, +const u8 *key,unsigned int keylen) +{ +if (keylen ==AES_KEYSIZE_128 || keylen ==AES_KEYSIZE_192 || + keylen ==AES_KEYSIZE_256 ) +return ablkcipher_setkey (cipher, key, keylen); + +crypto_ablkcipher_set_flags (cipher,CRYPTO_TFM_RES_BAD_KEY_LEN ); + +return -EINVAL ; +} +static void common_nonsnoop_unmap (struct device *dev,struct talitos_edesc *edesc,struct ablkcipher_request *areq)
@@ -2782,6 +2794,7 @@ static struct talitos_alg_template driver_algs[] = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, + .setkey = ablkcipher_aes_setkey, } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2798,6 +2811,7 @@ static struct talitos_alg_template driver_algs[] = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, + .setkey = ablkcipher_aes_setkey, } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
@@ -2815,6 +2829,7 @@ static struct talitos_alg_template driver_algs[] = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, + .setkey = ablkcipher_aes_setkey, } }, .desc_hdr_template = DESC_HDR_TYPE_AESU_CTR_NONSNOOP |
Signature · 1 line
2.13.3
PATCH 5/15 crypto: talitos - fix CTR alg blocksize
In reply to Christophe LeroyCTR has a blocksize of 1.
--- drivers/crypto/talitos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/talitos.c +1 -1
@@ -2822,7 +2822,7 @@ static struct talitos_alg_template driver_algs[] = { .alg.crypto = { .cra_name = "ctr(aes)", .cra_driver_name = "ctr-aes-talitos", - .cra_blocksize = AES_BLOCK_SIZE, + .cra_blocksize = 1, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, .cra_ablkcipher = {
Signature · 1 line
2.13.3
PATCH 6/15 crypto: talitos - check data blocksize in ablkcipher.
In reply to Christophe LeroyWhen data size is not a multiple of the alg's block size, the SEC generates an error interrupt and dumps the registers. And for NULL size, the SEC does just nothing and the interrupt is awaited forever.
This patch ensures the data size is correct before submitting the request to the SEC engine.
--- drivers/crypto/talitos.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/crypto/talitos.c +16 -0
@@ -1756,6 +1756,14 @@ static int ablkcipher_encrypt(struct ablkcipher_request *areq)struct crypto_ablkcipher *cipher =crypto_ablkcipher_reqtfm (areq);struct talitos_ctx *ctx =crypto_ablkcipher_ctx (cipher);struct talitos_edesc *edesc; +unsigned int blocksize = +crypto_tfm_alg_blocksize (crypto_ablkcipher_tfm (cipher)); + +if (!areq->nbytes) +return 0 ; + +if (areq->nbytes % blocksize) +return -EINVAL ;/* allocate extended descriptor */ edesc =ablkcipher_edesc_alloc (areq, true);
@@ -1773,6 +1781,14 @@ static int ablkcipher_decrypt(struct ablkcipher_request *areq)struct crypto_ablkcipher *cipher =crypto_ablkcipher_reqtfm (areq);struct talitos_ctx *ctx =crypto_ablkcipher_ctx (cipher);struct talitos_edesc *edesc; +unsigned int blocksize = +crypto_tfm_alg_blocksize (crypto_ablkcipher_tfm (cipher)); + +if (!areq->nbytes) +return 0 ; + +if (areq->nbytes % blocksize) +return -EINVAL ;/* allocate extended descriptor */ edesc =ablkcipher_edesc_alloc (areq, false);
Signature · 1 line
2.13.3
PATCH 7/15 crypto: talitos - fix ECB algs ivsize
In reply to Christophe LeroyECB's ivsize must be 0.
--- drivers/crypto/talitos.c | 3 --- 1 file changed, 3 deletions(-)
drivers/crypto/talitos.c +0 -3
@@ -2809,7 +2809,6 @@ static struct talitos_alg_template driver_algs[] = { .cra_ablkcipher = { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, - .ivsize = AES_BLOCK_SIZE, .setkey = ablkcipher_aes_setkey, } },
@@ -2862,7 +2861,6 @@ static struct talitos_alg_template driver_algs[] = { .cra_ablkcipher = { .min_keysize = DES_KEY_SIZE, .max_keysize = DES_KEY_SIZE, - .ivsize = DES_BLOCK_SIZE, .setkey = ablkcipher_des_setkey, } },
@@ -2897,7 +2895,6 @@ static struct talitos_alg_template driver_algs[] = { .cra_ablkcipher = { .min_keysize = DES3_EDE_KEY_SIZE, .max_keysize = DES3_EDE_KEY_SIZE, - .ivsize = DES3_EDE_BLOCK_SIZE, .setkey = ablkcipher_des3_setkey, } },
Signature · 1 line
2.13.3
PATCH 8/15 crypto: talitos - Do not modify req->cryptlen on decryption.
In reply to Christophe LeroyFor decrypt, req->cryptlen includes the size of the authentication part while all functions of the driver expect cryptlen to be the size of the encrypted data.
As it is not expected to change req->cryptlen, this patch implements local calculation of cryptlen.
--- drivers/crypto/talitos.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/crypto/talitos.c +17 -14
@@ -1025,11 +1025,13 @@ static void talitos_sg_unmap(struct device *dev,static void ipsec_esp_unmap (struct device *dev,struct talitos_edesc *edesc, -struct aead_request *areq) +struct aead_request *areq,bool encrypt) {struct crypto_aead *aead =crypto_aead_reqtfm (areq);struct talitos_ctx *ctx =crypto_aead_ctx (aead);unsigned int ivsize =crypto_aead_ivsize (aead); +unsigned int authsize =crypto_aead_authsize (aead); +unsigned int cryptlen = areq->cryptlen - (encrypt ?0 : authsize);bool is_ipsec_esp = edesc->desc.hdr &DESC_HDR_TYPE_IPSEC_ESP ;struct talitos_ptr *civ_ptr = &edesc->desc.ptr[is_ipsec_esp ?2 :3 ];
@@ -1038,7 +1040,7 @@ static void ipsec_esp_unmap(struct device *dev, DMA_FROM_DEVICE);unmap_single_talitos_ptr (dev, civ_ptr,DMA_TO_DEVICE ); -talitos_sg_unmap (dev, edesc, areq->src, areq->dst, areq->cryptlen, +talitos_sg_unmap (dev, edesc, areq->src, areq->dst, cryptlen, areq->assoclen);if (edesc->dma_len)
@@ -1049,7 +1051,7 @@ static void ipsec_esp_unmap(struct device *dev,unsigned int dst_nents = edesc->dst_nents ? :1 ;sg_pcopy_to_buffer (areq->dst, dst_nents, ctx->iv, ivsize, - areq->assoclen + areq->cryptlen - ivsize); + areq->assoclen + cryptlen - ivsize); } }
@@ -1072,7 +1074,7 @@ static void ipsec_esp_encrypt_done(struct device *dev, edesc = container_of(desc, struct talitos_edesc, desc); -ipsec_esp_unmap (dev, edesc, areq); +ipsec_esp_unmap (dev, edesc, areq, true);/* copy the generated ICV to dst */ if (edesc->icv_ool) {
@@ -1108,7 +1110,7 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev, edesc = container_of(desc, struct talitos_edesc, desc); -ipsec_esp_unmap (dev, edesc, req); +ipsec_esp_unmap (dev, edesc, req, false);if (!err) {/* auth check */
@@ -1145,7 +1147,7 @@ static void ipsec_esp_decrypt_hwauth_done(struct device *dev, edesc = container_of(desc, struct talitos_edesc, desc); -ipsec_esp_unmap (dev, edesc, req); +ipsec_esp_unmap (dev, edesc, req, false);/* check ICV auth status */ if (!err && ((desc->hdr_lo & DESC_HDR_LO_ICCR1_MASK) !=
@@ -1248,6 +1250,7 @@ static int talitos_sg_map(struct device *dev, struct scatterlist *src,* fill in and submit ipsec_esp descriptor */ static int ipsec_esp (struct talitos_edesc *edesc,struct aead_request *areq, +bool encrypt,void (*callback)(struct device *dev,struct talitos_desc *desc,void *context,int error))
@@ -1257,7 +1260,7 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,struct talitos_ctx *ctx =crypto_aead_ctx (aead);struct device *dev = ctx->dev;struct talitos_desc *desc = &edesc->desc; -unsigned int cryptlen = areq->cryptlen; +unsigned int cryptlen = areq->cryptlen - (encrypt ?0 : authsize);unsigned int ivsize =crypto_aead_ivsize (aead);int tbl_off =0 ;int sg_count, ret;
@@ -1384,7 +1387,7 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, ret =talitos_submit (dev, ctx->ch, desc, callback, areq);if (ret != -EINPROGRESS ) { -ipsec_esp_unmap (dev, edesc, areq); +ipsec_esp_unmap (dev, edesc, areq, encrypt);kfree (edesc); }return ret;
@@ -1502,9 +1505,10 @@ static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, u8 *iv,unsigned int authsize =crypto_aead_authsize (authenc);struct talitos_ctx *ctx =crypto_aead_ctx (authenc);unsigned int ivsize =crypto_aead_ivsize (authenc); +unsigned int cryptlen = areq->cryptlen - (encrypt ?0 : authsize);return talitos_edesc_alloc (ctx->dev, areq->src, areq->dst, - iv, areq->assoclen, areq->cryptlen, + iv, areq->assoclen, cryptlen, authsize, ivsize, icv_stashing, areq->base.flags, encrypt); }
@@ -1523,7 +1527,7 @@ static int aead_encrypt(struct aead_request *req)/* set encrypt */ edesc->desc.hdr = ctx->desc_hdr_template |DESC_HDR_MODE0_ENCRYPT ; -return ipsec_esp (edesc, req, ipsec_esp_encrypt_done); +return ipsec_esp (edesc, req, true, ipsec_esp_encrypt_done); }static int aead_decrypt (struct aead_request *req)
@@ -1536,8 +1540,6 @@ static int aead_decrypt(struct aead_request *req)struct scatterlist *sg;void *icvdata; - req->cryptlen -= authsize; -/* allocate extended descriptor */ edesc =aead_edesc_alloc (req, req->iv,1 , false);if (IS_ERR (edesc))
@@ -1554,7 +1556,8 @@ static int aead_decrypt(struct aead_request *req)/* reset integrity check result bits */ -return ipsec_esp (edesc, req, ipsec_esp_decrypt_hwauth_done); +return ipsec_esp (edesc, req, false, + ipsec_esp_decrypt_hwauth_done); }/* Have to check the ICV with software */
@@ -1571,7 +1574,7 @@ static int aead_decrypt(struct aead_request *req)memcpy (icvdata, (char *)sg_virt (sg) + sg->length - authsize, authsize); -return ipsec_esp (edesc, req, ipsec_esp_decrypt_swauth_done); +return ipsec_esp (edesc, req, false, ipsec_esp_decrypt_swauth_done); } static int ablkcipher_setkey(struct crypto_ablkcipher *cipher,
Signature · 1 line
2.13.3
Re: [PATCH v1 08/15] crypto: talitos - Do not modify req->cryptlen on decryption.
Quoted 7 lines · Christophe Leroy
For decrypt,
req->cryptlenincludes the size of the authentication part while all functions of the driver expect cryptlen to be the size of the encrypted data.As it is not expected to change
req->cryptlen, this patch implements local calculation of cryptlen.
An alternative would be to restore req->cryptlen in the *_done() callback. It would be easier to implement, though probably less intuitive.
Horia
PATCH 9/15 crypto: talitos - HMAC SNOOP NO AFEU mode requires SW icv checking.
In reply to Christophe LeroyIn that mode, hardware ICV verification is not supported.
--- drivers/crypto/talitos.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/talitos.c +2 -1
@@ -1545,7 +1545,8 @@ static int aead_decrypt(struct aead_request *req)if (IS_ERR (edesc))return PTR_ERR (edesc); -if ((priv->features &TALITOS_FTR_HW_AUTH_CHECK ) && +if ((edesc->desc.hdr &DESC_HDR_TYPE_IPSEC_ESP ) && + (priv->features &TALITOS_FTR_HW_AUTH_CHECK ) && ((!edesc->src_nents && !edesc->dst_nents) || priv->features &TALITOS_FTR_SRC_LINK_TBL_LEN_INCLUDES_EXTENT )) {
Signature · 1 line
2.13.3
PATCH 10/15 crypto: talitos - properly handle split ICV.
In reply to Christophe LeroyThe driver assumes that the ICV is as a single piece in the last element of the scatterlist. This assumption is wrong.
This patch ensures that the ICV is properly handled regardless of the scatterlist layout.
--- drivers/crypto/talitos.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/crypto/talitos.c +15 -11
@@ -1069,7 +1069,6 @@ static void ipsec_esp_encrypt_done(struct device *dev,unsigned int authsize =crypto_aead_authsize (authenc);unsigned int ivsize =crypto_aead_ivsize (authenc);struct talitos_edesc *edesc; -struct scatterlist *sg;void *icvdata; edesc = container_of(desc, struct talitos_edesc, desc);
@@ -1083,9 +1082,8 @@ static void ipsec_esp_encrypt_done(struct device *dev,else icvdata = &edesc->link_tbl[edesc->src_nents + edesc->dst_nents +2 ]; - sg =sg_last (areq->dst, edesc->dst_nents); -memcpy ((char *)sg_virt (sg) + sg->length - authsize, - icvdata, authsize); +sg_pcopy_from_buffer (areq->dst, edesc->dst_nents ? :1 , icvdata, + authsize, areq->assoclen + areq->cryptlen); }dma_unmap_single (dev, edesc->iv_dma, ivsize,DMA_TO_DEVICE );
@@ -1103,7 +1101,6 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev,struct crypto_aead *authenc =crypto_aead_reqtfm (req);unsigned int authsize =crypto_aead_authsize (authenc);struct talitos_edesc *edesc; -struct scatterlist *sg;char *oicv, *icv;struct talitos_private *priv =dev_get_drvdata (dev);bool is_sec1 =has_ftr_sec1 (priv);
@@ -1113,9 +1110,18 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev,ipsec_esp_unmap (dev, edesc, req, false);if (!err) { +char icvdata[SHA512_DIGEST_SIZE ]; +int nents = edesc->dst_nents ? :1 ; +unsigned int len = req->assoclen + req->cryptlen; +/* auth check */ - sg =sg_last (req->dst, edesc->dst_nents ? :1 ); - icv = (char *)sg_virt (sg) + sg->length - authsize; +if (nents >1 ) { +sg_pcopy_to_buffer (req->dst, nents, icvdata, authsize, + len - authsize); + icv = icvdata; + }else { + icv = (char *)sg_virt (req->dst) + len - authsize; + }if (edesc->dma_len) {if (is_sec1)
@@ -1537,7 +1543,6 @@ static int aead_decrypt(struct aead_request *req)struct talitos_ctx *ctx =crypto_aead_ctx (authenc);struct talitos_private *priv =dev_get_drvdata (ctx->dev);struct talitos_edesc *edesc; -struct scatterlist *sg;void *icvdata;/* allocate extended descriptor */
@@ -1571,9 +1576,8 @@ static int aead_decrypt(struct aead_request *req)else icvdata = &edesc->link_tbl[0 ]; - sg =sg_last (req->src, edesc->src_nents ? :1 ); - -memcpy (icvdata, (char *)sg_virt (sg) + sg->length - authsize, authsize); +sg_pcopy_to_buffer (req->src, edesc->src_nents ? :1 , icvdata, authsize, + req->assoclen + req->cryptlen - authsize);return ipsec_esp (edesc, req, false, ipsec_esp_decrypt_swauth_done); }
Signature · 1 line
2.13.3
PATCH 11/15 crypto: talitos - Align SEC1 accesses to 32 bits boundaries.
In reply to Christophe LeroyThe MPC885 reference manual states:
SEC Lite-initiated 8xx writes can occur only on 32-bit-word boundaries, but reads can occur on any byte boundary. Writing back a header read from a non-32-bit-word boundary will yield unpredictable results.
In order to ensure that, cra_alignmask is set to 3 for SEC1.
--- drivers/crypto/talitos.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/crypto/talitos.c +4 -1
@@ -3327,7 +3327,10 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev, alg->cra_priority = t_alg->algt.priority; else alg->cra_priority = TALITOS_CRA_PRIORITY; - alg->cra_alignmask =0 ; +if (has_ftr_sec1 (priv)) + alg->cra_alignmask =3 ; +else + alg->cra_alignmask =0 ; alg->cra_ctxsize =sizeof (struct talitos_ctx ); alg->cra_flags |=CRYPTO_ALG_KERN_DRIVER_ONLY ;
Signature · 1 line
2.13.3
PATCH 12/15 crypto: talitos - fix AEAD processing.
In reply to Christophe LeroyThis driver is working well in 'simple cases', but as soon as more exotic SG lists are provided (dst different from src, auth part not in a single SG fragment, ...) there are wrong results, overruns, etc ...
This patch cleans up the AEAD processing by:
- Simplifying the location of 'out of line' ICV
- Never using 'out of line' ICV on encryp
- Always using 'out of line' ICV on decrypt
- Forcing the generation of a SG table on decrypt
--- drivers/crypto/talitos.c | 158 ++++++++++++++++------------------------------- drivers/crypto/talitos.h | 2 +- 2 files changed, 55 insertions(+), 105 deletions(-)
drivers/crypto/talitos.c +54 -104
@@ -1040,8 +1040,8 @@ static void ipsec_esp_unmap(struct device *dev, DMA_FROM_DEVICE);unmap_single_talitos_ptr (dev, civ_ptr,DMA_TO_DEVICE ); -talitos_sg_unmap (dev, edesc, areq->src, areq->dst, cryptlen, - areq->assoclen); +talitos_sg_unmap (dev, edesc, areq->src, areq->dst, + cryptlen + authsize, areq->assoclen);if (edesc->dma_len) dma_unmap_single(dev, edesc->dma_link_tbl, edesc->dma_len,
@@ -1062,30 +1062,15 @@ static void ipsec_esp_encrypt_done(struct device *dev, struct talitos_desc *desc, void *context, int err) { - struct talitos_private *priv = dev_get_drvdata(dev); -bool is_sec1 =has_ftr_sec1 (priv); struct aead_request *areq = context;struct crypto_aead *authenc =crypto_aead_reqtfm (areq); -unsigned int authsize =crypto_aead_authsize (authenc);unsigned int ivsize =crypto_aead_ivsize (authenc);struct talitos_edesc *edesc; -void *icvdata; edesc = container_of(desc, struct talitos_edesc, desc);ipsec_esp_unmap (dev, edesc, areq, true); -/* copy the generated ICV to dst */ -if (edesc->icv_ool) { -if (is_sec1) - icvdata = edesc->buf + areq->assoclen + areq->cryptlen; -else - icvdata = &edesc->link_tbl[edesc->src_nents + - edesc->dst_nents +2 ]; -sg_pcopy_from_buffer (areq->dst, edesc->dst_nents ? :1 , icvdata, - authsize, areq->assoclen + areq->cryptlen); - } -dma_unmap_single (dev, edesc->iv_dma, ivsize,DMA_TO_DEVICE );kfree (edesc);
@@ -1102,39 +1087,15 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev,unsigned int authsize =crypto_aead_authsize (authenc);struct talitos_edesc *edesc;char *oicv, *icv; -struct talitos_private *priv =dev_get_drvdata (dev); -bool is_sec1 =has_ftr_sec1 (priv); edesc = container_of(desc, struct talitos_edesc, desc);ipsec_esp_unmap (dev, edesc, req, false);if (!err) { -char icvdata[SHA512_DIGEST_SIZE ]; -int nents = edesc->dst_nents ? :1 ; -unsigned int len = req->assoclen + req->cryptlen; -/* auth check */ -if (nents >1 ) { -sg_pcopy_to_buffer (req->dst, nents, icvdata, authsize, - len - authsize); - icv = icvdata; - }else { - icv = (char *)sg_virt (req->dst) + len - authsize; - } - -if (edesc->dma_len) { -if (is_sec1) - oicv = (char *)&edesc->dma_link_tbl + - req->assoclen + req->cryptlen; -else - oicv = (char *) - &edesc->link_tbl[edesc->src_nents + - edesc->dst_nents +2 ]; -if (edesc->icv_ool) - icv = oicv + authsize; - }else - oicv = (char *)&edesc->link_tbl[0 ]; + oicv = edesc->buf + edesc->dma_len; + icv = oicv - authsize; err =crypto_memneq (oicv, icv, authsize) ? -EBADMSG :0 ; }
@@ -1170,11 +1131,12 @@ static void ipsec_esp_decrypt_hwauth_done(struct device *dev,* stop at cryptlen bytes */ static int sg_to_link_tbl_offset (struct scatterlist *sg,int sg_count, -unsigned int offset,int cryptlen, +unsigned int offset,int datalen,int elen,struct talitos_ptr *link_tbl_ptr) { -int n_sg = sg_count; +int n_sg = elen ? sg_count +1 : sg_count;int count =0 ; +int cryptlen = datalen + elen;while (cryptlen && sg && n_sg--) {unsigned int len =sg_dma_len (sg);
@@ -1189,11 +1151,20 @@ static int sg_to_link_tbl_offset(struct scatterlist *sg, int sg_count,if (len > cryptlen) len = cryptlen; +if (datalen >0 && len > datalen) { +to_talitos_ptr (link_tbl_ptr + count, +sg_dma_address (sg) + offset, datalen,0 ); +to_talitos_ptr_ext_set (link_tbl_ptr + count,0 ,0 ); + count++; + len -= datalen; + offset += datalen; + }to_talitos_ptr (link_tbl_ptr + count,sg_dma_address (sg) + offset, len,0 );to_talitos_ptr_ext_set (link_tbl_ptr + count,0 ,0 ); count++; cryptlen -= len; + datalen -= len; offset =0 ; next:
@@ -1203,7 +1174,7 @@ static int sg_to_link_tbl_offset(struct scatterlist *sg, int sg_count,/* tag end of link table */ if (count >0 )to_talitos_ptr_ext_set (link_tbl_ptr + count -1 , -DESC_PTR_LNKTBL_RETURN ,0 ); +DESC_PTR_LNKTBL_RET ,0 );return count; }
@@ -1211,7 +1182,8 @@ static int sg_to_link_tbl_offset(struct scatterlist *sg, int sg_count,static int talitos_sg_map_ext (struct device *dev,struct scatterlist *src,unsigned int len,struct talitos_edesc *edesc,struct talitos_ptr *ptr,int sg_count, -unsigned int offset,int tbl_off,int elen) +unsigned int offset,int tbl_off,int elen, +bool force) {struct talitos_private *priv =dev_get_drvdata (dev);bool is_sec1 =has_ftr_sec1 (priv);
@@ -1221,7 +1193,7 @@ static int talitos_sg_map_ext(struct device *dev, struct scatterlist *src,return 1 ; }to_talitos_ptr_ext_set (ptr, elen, is_sec1); -if (sg_count ==1 ) { +if (sg_count ==1 && !force) {to_talitos_ptr (ptr,sg_dma_address (src) + offset, len, is_sec1);return sg_count; }
@@ -1229,9 +1201,9 @@ static int talitos_sg_map_ext(struct device *dev, struct scatterlist *src,to_talitos_ptr (ptr, edesc->dma_link_tbl + offset, len, is_sec1);return sg_count; } - sg_count =sg_to_link_tbl_offset (src, sg_count, offset, len + elen, + sg_count =sg_to_link_tbl_offset (src, sg_count, offset, len, elen, &edesc->link_tbl[tbl_off]); -if (sg_count ==1 ) { +if (sg_count ==1 && !force) {/* Only one segment now, so no link tbl needed*/ copy_talitos_ptr (ptr, &edesc->link_tbl[tbl_off], is_sec1);return sg_count;
@@ -1249,7 +1221,7 @@ static int talitos_sg_map(struct device *dev, struct scatterlist *src, unsigned int offset, int tbl_off) {return talitos_sg_map_ext (dev, src, len, edesc, ptr, sg_count, offset, - tbl_off,0 ); + tbl_off,0 , false); }/*
@@ -1277,6 +1249,7 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,bool is_ipsec_esp = desc->hdr &DESC_HDR_TYPE_IPSEC_ESP ;struct talitos_ptr *civ_ptr = &desc->ptr[is_ipsec_esp ?2 :3 ];struct talitos_ptr *ckey_ptr = &desc->ptr[is_ipsec_esp ?3 :2 ]; +dma_addr_t dma_icv = edesc->dma_link_tbl + edesc->dma_len - authsize;/* hmac key */ to_talitos_ptr (&desc->ptr[0 ], ctx->dma_key, ctx->authkeylen, is_sec1);
@@ -1316,7 +1289,8 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, elen = authsize; ret =talitos_sg_map_ext (dev, areq->src, cryptlen, edesc, &desc->ptr[4 ], - sg_count, areq->assoclen, tbl_off, elen); + sg_count, areq->assoclen, tbl_off, elen, + false);if (ret >1 ) { tbl_off += ret;
@@ -1330,55 +1304,35 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,dma_map_sg (dev, areq->dst, sg_count,DMA_FROM_DEVICE ); } - ret =talitos_sg_map (dev, areq->dst, cryptlen, edesc, &desc->ptr[5 ], - sg_count, areq->assoclen, tbl_off); - -if (is_ipsec_esp) -to_talitos_ptr_ext_or (&desc->ptr[5 ], authsize, is_sec1); +if (is_ipsec_esp && encrypt) + elen = authsize; +else + elen =0 ; + ret =talitos_sg_map_ext (dev, areq->dst, cryptlen, edesc, &desc->ptr[5 ], + sg_count, areq->assoclen, tbl_off, elen, + is_ipsec_esp && !encrypt); + tbl_off += ret;/* ICV data */ -if (ret >1 ) { - tbl_off += ret; - edesc->icv_ool = true; - sync_needed = true; + edesc->icv_ool = !encrypt; -if (is_ipsec_esp) { -struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off]; -int offset = (edesc->src_nents + edesc->dst_nents +2 ) * -sizeof (struct talitos_ptr ) + authsize; +if (!encrypt && is_ipsec_esp) { +struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off]; -/* Add an entry to the link table for ICV data */ -to_talitos_ptr_ext_set (tbl_ptr -1 ,0 , is_sec1); -to_talitos_ptr_ext_set (tbl_ptr,DESC_PTR_LNKTBL_RETURN , - is_sec1); +/* Add an entry to the link table for ICV data */ +to_talitos_ptr_ext_set (tbl_ptr -1 ,0 , is_sec1); +to_talitos_ptr_ext_set (tbl_ptr,DESC_PTR_LNKTBL_RET , is_sec1); -/* icv data follows link tables */ -to_talitos_ptr (tbl_ptr, edesc->dma_link_tbl + offset, - authsize, is_sec1); - }else { -dma_addr_t addr = edesc->dma_link_tbl; - -if (is_sec1) - addr += areq->assoclen + cryptlen; -else - addr +=sizeof (struct talitos_ptr ) * tbl_off; - -to_talitos_ptr (&desc->ptr[6 ], addr, authsize, is_sec1); - } +/* icv data follows link tables */ +to_talitos_ptr (tbl_ptr, dma_icv, authsize, is_sec1); +to_talitos_ptr_ext_or (&desc->ptr[5 ], authsize, is_sec1); + sync_needed = true; + }else if (!encrypt) { +to_talitos_ptr (&desc->ptr[6 ], dma_icv, authsize, is_sec1); + sync_needed = true; }else if (!is_ipsec_esp) { - ret =talitos_sg_map (dev, areq->dst, authsize, edesc, - &desc->ptr[6 ], sg_count, areq->assoclen + - cryptlen, - tbl_off); -if (ret >1 ) { - tbl_off += ret; - edesc->icv_ool = true; - sync_needed = true; - }else { - edesc->icv_ool = false; - } - }else { - edesc->icv_ool = false; +talitos_sg_map (dev, areq->dst, authsize, edesc, &desc->ptr[6 ], + sg_count, areq->assoclen + cryptlen, tbl_off); }/* iv out */
@@ -1461,18 +1415,18 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,* and space for two sets of ICVs (stashed and generated) */ alloc_len =sizeof (struct talitos_edesc ); -if (src_nents || dst_nents) { +if (src_nents || dst_nents || !encrypt) {if (is_sec1) dma_len = (src_nents ? src_len :0 ) + - (dst_nents ? dst_len :0 ); + (dst_nents ? dst_len :0 ) + authsize;else dma_len = (src_nents + dst_nents +2 ) * -sizeof (struct talitos_ptr ) + authsize *2 ; +sizeof (struct talitos_ptr ) + authsize; alloc_len += dma_len; }else { dma_len =0 ; - alloc_len += icv_stashing ? authsize :0 ; } + alloc_len += icv_stashing ? authsize :0 ;/* if its a ahash, add space for a second desc next to the first one */ if (is_sec1 && !dst)
@@ -1570,11 +1524,7 @@ static int aead_decrypt(struct aead_request *req) edesc->desc.hdr = ctx->desc_hdr_template |DESC_HDR_DIR_INBOUND ;/* stash incoming ICV for later cmp with ICV generated by the h/w */ -if (edesc->dma_len) - icvdata = (char *)&edesc->link_tbl[edesc->src_nents + - edesc->dst_nents +2 ]; -else - icvdata = &edesc->link_tbl[0 ]; + icvdata = edesc->buf + edesc->dma_len;sg_pcopy_to_buffer (req->src, edesc->src_nents ? :1 , icvdata, authsize, req->assoclen + req->cryptlen - authsize);
drivers/crypto/talitos.h +1 -1
@@ -412,5 +412,5 @@ static inline bool has_ftr_sec1(struct talitos_private *priv)/* link table extent field bits */ #define DESC_PTR_LNKTBL_JUMP 0x80 -#define DESC_PTR_LNKTBL_RETURN 0x02 +#define DESC_PTR_LNKTBL_RET 0x02#define DESC_PTR_LNKTBL_NEXT 0x01
Signature · 1 line
2.13.3
PATCH 13/15 Revert "crypto: talitos - export the talitos_submit function"
In reply to Christophe LeroyThere is no other file using talitos_submit in the kernel tree, so it doesn't need to be exported nor made global.
This reverts commit 865d506155b117edc7e668ced373030ce7108ce9.
--- drivers/crypto/talitos.c | 11 +++++------ drivers/crypto/talitos.h | 6 ------ 2 files changed, 5 insertions(+), 12 deletions(-)
drivers/crypto/talitos.c +5 -6
@@ -278,11 +278,11 @@ static int init_device(struct device *dev)* callback must check err and feedback in descriptor header * for device processing status. */ -int talitos_submit (struct device *dev,int ch,struct talitos_desc *desc, -void (*callback)(struct device *dev, -struct talitos_desc *desc, -void *context,int error), -void *context) +static int talitos_submit (struct device *dev,int ch,struct talitos_desc *desc, +void (*callback)(struct device *dev, +struct talitos_desc *desc, +void *context,int error), +void *context) {struct talitos_private *priv =dev_get_drvdata (dev);struct talitos_request *request;
@@ -332,7 +332,6 @@ int talitos_submit(struct device *dev, int ch, struct talitos_desc *desc,return -EINPROGRESS ; } -EXPORT_SYMBOL (talitos_submit);/* * process what was done, notify callback of error if not
drivers/crypto/talitos.h +0 -6
@@ -150,12 +150,6 @@ struct talitos_private {bool rng_registered; }; -extern int talitos_submit (struct device *dev,int ch,struct talitos_desc *desc, -void (*callback)(struct device *dev, -struct talitos_desc *desc, -void *context,int error), -void *context); -/* .features flag */ #define TALITOS_FTR_SRC_LINK_TBL_LEN_INCLUDES_EXTENT 0x00000001#define TALITOS_FTR_HW_AUTH_CHECK 0x00000002
Signature · 1 line
2.13.3
PATCH 14/15 crypto: talitos - use IS_ENABLED() in has_ftr_sec1()
In reply to Christophe LeroyThis patch rewrites has_ftr_sec1() using IS_ENABLED() instead of #ifdefs
--- drivers/crypto/talitos.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/crypto/talitos.h +5 -7
@@ -164,13 +164,11 @@ struct talitos_private {*/ static inline bool has_ftr_sec1 (struct talitos_private *priv) { -#if defined(CONFIG_CRYPTO_DEV_TALITOS1 ) && defined(CONFIG_CRYPTO_DEV_TALITOS2 ) -return priv->features &TALITOS_FTR_SEC1 ? true : false; -#elif defined(CONFIG_CRYPTO_DEV_TALITOS1 ) -return true; -#else -return false; -#endif +if (IS_ENABLED (CONFIG_CRYPTO_DEV_TALITOS1 ) && +IS_ENABLED (CONFIG_CRYPTO_DEV_TALITOS2 )) +return priv->features &TALITOS_FTR_SEC1 ; + +return IS_ENABLED (CONFIG_CRYPTO_DEV_TALITOS1 ); }/*
Signature · 1 line
2.13.3
PATCH 15/15 crypto: talitos - use SPDX-License-Identifier
In reply to Christophe LeroyThis patch drops the license text and replaces it
with an SPDX-License-Identifier tag.
--- drivers/crypto/talitos.c | 15 +-------------- drivers/crypto/talitos.h | 25 +------------------------ 2 files changed, 2 insertions(+), 38 deletions(-)
drivers/crypto/talitos.c +1 -14
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * talitos - Freescale Integrated Security Engine (SEC) device driver *
@@ -9,20 +10,6 @@* Crypto algorithm registration code copied from hifn driver: * 2007+ Copyright (c) Evgeniy Polyakov <[email protected]> * All rights reserved. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/kernel.h>
drivers/crypto/talitos.h +1 -24
@@ -1,31 +1,8 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ /* * Freescale SEC (talitos) device register and descriptor header defines * * Copyright (c) 2006-2011 Freescale Semiconductor, Inc. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* 3. The name of the author may not be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* */ #define TALITOS_TIMEOUT 100000
Signature · 1 line
2.13.3
Quoted 7 lines · Christophe Leroy
Several test failures have popped up following recent changes to crypto selftests.
This series fixes (most of) them.
The last three patches are trivial cleanups.
Thanks Christophe.
For the series:
Have you validated the changes also on SEC 2.x+?
Asking since IIRC you mentioned having only HW with SEC 1 and changes in patch "crypto: talitos - fix AEAD processing." look quite complex.
Thanks,
Horia
Horia Geanta <[email protected]> a écrit :
Quoted 8 lines · Christophe Leroy
Quoted 7 lines
Several test failures have popped up following recent changes to crypto selftests.
This series fixes (most of) them.
The last three patches are trivial cleanups.
Quoted 8 lines
Thanks Christophe.
For the series:
Reviewed-by Horia Geantă <[email protected]>Have you validated the changes also on SEC 2.x+?
Asking since IIRC you mentioned having only HW with SEC 1 and changes in patch "crypto: talitos - fix AEAD processing." look quite complex.
When I ported the driver to SEC1 some years ago I only had a SEC 1.2 (mpc885) but I now have also a board with a mpc8321E which embeds a SEC 2.2 so I also tested the changes on it.
Christophe
Quoted 3 lines
Thanks,
Horia
Herbert Xu
maintainerQuoted 24 lines · Christophe Leroy
Several test failures have popped up following recent changes to crypto selftests.
This series fixes (most of) them.
The last three patches are trivial cleanups.
Christophe Leroy (15):
crypto: talitos - fix skcipher failure due to wrong output IV
crypto: talitos - rename alternative AEAD algos.
crypto: talitos - reduce max key size for SEC1
crypto: talitos - check AES key size
crypto: talitos - fix CTR alg blocksize
crypto: talitos - check data blocksize in ablkcipher.
crypto: talitos - fix ECB algs ivsize
crypto: talitos - Do not modifyreq->cryptlenon decryption.
crypto: talitos - HMAC SNOOP NO AFEU mode requires SW icv checking.
crypto: talitos - properly handle split ICV.
crypto: talitos - Align SEC1 accesses to 32 bits boundaries.
crypto: talitos - fix AEAD processing.
Revert "crypto: talitos - export thetalitos_submitfunction"
crypto: talitos - useIS_ENABLED()inhas_ftr_sec1()
crypto: talitos - use SPDX-License-Identifier
Quoted 3 lines
drivers/crypto/talitos.c | 281 ++++++++++++++++++++++------------------------- drivers/crypto/talitos.h | 45 ++------ 2 files changed, 139 insertions(+), 187 deletions(-)
Patch 1 was already applied.
2-15 applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt