aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/caam/caamalg.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/crypto/caam/caamalg.c')
-rw-r--r--drivers/crypto/caam/caamalg.c51
1 files changed, 37 insertions, 14 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index 0c1ea8492eff..b2a0a0726a54 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -205,7 +205,7 @@ static void init_sh_desc_key_aead(u32 *desc, struct caam_ctx *ctx,
205{ 205{
206 u32 *key_jump_cmd; 206 u32 *key_jump_cmd;
207 207
208 init_sh_desc(desc, HDR_SHARE_WAIT); 208 init_sh_desc(desc, HDR_SHARE_SERIAL);
209 209
210 /* Skip if already shared */ 210 /* Skip if already shared */
211 key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | 211 key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
@@ -224,7 +224,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
224 struct aead_tfm *tfm = &aead->base.crt_aead; 224 struct aead_tfm *tfm = &aead->base.crt_aead;
225 struct caam_ctx *ctx = crypto_aead_ctx(aead); 225 struct caam_ctx *ctx = crypto_aead_ctx(aead);
226 struct device *jrdev = ctx->jrdev; 226 struct device *jrdev = ctx->jrdev;
227 bool keys_fit_inline = 0; 227 bool keys_fit_inline = false;
228 u32 *key_jump_cmd, *jump_cmd; 228 u32 *key_jump_cmd, *jump_cmd;
229 u32 geniv, moveiv; 229 u32 geniv, moveiv;
230 u32 *desc; 230 u32 *desc;
@@ -239,7 +239,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
239 if (DESC_AEAD_ENC_LEN + DESC_JOB_IO_LEN + 239 if (DESC_AEAD_ENC_LEN + DESC_JOB_IO_LEN +
240 ctx->split_key_pad_len + ctx->enckeylen <= 240 ctx->split_key_pad_len + ctx->enckeylen <=
241 CAAM_DESC_BYTES_MAX) 241 CAAM_DESC_BYTES_MAX)
242 keys_fit_inline = 1; 242 keys_fit_inline = true;
243 243
244 /* aead_encrypt shared descriptor */ 244 /* aead_encrypt shared descriptor */
245 desc = ctx->sh_desc_enc; 245 desc = ctx->sh_desc_enc;
@@ -297,12 +297,12 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
297 if (DESC_AEAD_DEC_LEN + DESC_JOB_IO_LEN + 297 if (DESC_AEAD_DEC_LEN + DESC_JOB_IO_LEN +
298 ctx->split_key_pad_len + ctx->enckeylen <= 298 ctx->split_key_pad_len + ctx->enckeylen <=
299 CAAM_DESC_BYTES_MAX) 299 CAAM_DESC_BYTES_MAX)
300 keys_fit_inline = 1; 300 keys_fit_inline = true;
301 301
302 desc = ctx->sh_desc_dec; 302 desc = ctx->sh_desc_dec;
303 303
304 /* aead_decrypt shared descriptor */ 304 /* aead_decrypt shared descriptor */
305 init_sh_desc(desc, HDR_SHARE_WAIT); 305 init_sh_desc(desc, HDR_SHARE_SERIAL);
306 306
307 /* Skip if already shared */ 307 /* Skip if already shared */
308 key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | 308 key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
@@ -365,7 +365,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead)
365 if (DESC_AEAD_GIVENC_LEN + DESC_JOB_IO_LEN + 365 if (DESC_AEAD_GIVENC_LEN + DESC_JOB_IO_LEN +
366 ctx->split_key_pad_len + ctx->enckeylen <= 366 ctx->split_key_pad_len + ctx->enckeylen <=
367 CAAM_DESC_BYTES_MAX) 367 CAAM_DESC_BYTES_MAX)
368 keys_fit_inline = 1; 368 keys_fit_inline = true;
369 369
370 /* aead_givencrypt shared descriptor */ 370 /* aead_givencrypt shared descriptor */
371 desc = ctx->sh_desc_givenc; 371 desc = ctx->sh_desc_givenc;
@@ -564,7 +564,7 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
564 564
565 /* ablkcipher_encrypt shared descriptor */ 565 /* ablkcipher_encrypt shared descriptor */
566 desc = ctx->sh_desc_enc; 566 desc = ctx->sh_desc_enc;
567 init_sh_desc(desc, HDR_SHARE_WAIT); 567 init_sh_desc(desc, HDR_SHARE_SERIAL);
568 /* Skip if already shared */ 568 /* Skip if already shared */
569 key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | 569 key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
570 JUMP_COND_SHRD); 570 JUMP_COND_SHRD);
@@ -605,7 +605,7 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
605 /* ablkcipher_decrypt shared descriptor */ 605 /* ablkcipher_decrypt shared descriptor */
606 desc = ctx->sh_desc_dec; 606 desc = ctx->sh_desc_dec;
607 607
608 init_sh_desc(desc, HDR_SHARE_WAIT); 608 init_sh_desc(desc, HDR_SHARE_SERIAL);
609 /* Skip if already shared */ 609 /* Skip if already shared */
610 key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | 610 key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL |
611 JUMP_COND_SHRD); 611 JUMP_COND_SHRD);
@@ -1354,10 +1354,10 @@ static struct aead_edesc *aead_giv_edesc_alloc(struct aead_givcrypt_request
1354 contig &= ~GIV_SRC_CONTIG; 1354 contig &= ~GIV_SRC_CONTIG;
1355 if (dst_nents || iv_dma + ivsize != sg_dma_address(req->dst)) 1355 if (dst_nents || iv_dma + ivsize != sg_dma_address(req->dst))
1356 contig &= ~GIV_DST_CONTIG; 1356 contig &= ~GIV_DST_CONTIG;
1357 if (unlikely(req->src != req->dst)) { 1357 if (unlikely(req->src != req->dst)) {
1358 dst_nents = dst_nents ? : 1; 1358 dst_nents = dst_nents ? : 1;
1359 sec4_sg_len += 1; 1359 sec4_sg_len += 1;
1360 } 1360 }
1361 if (!(contig & GIV_SRC_CONTIG)) { 1361 if (!(contig & GIV_SRC_CONTIG)) {
1362 assoc_nents = assoc_nents ? : 1; 1362 assoc_nents = assoc_nents ? : 1;
1363 src_nents = src_nents ? : 1; 1363 src_nents = src_nents ? : 1;
@@ -1650,7 +1650,11 @@ struct caam_alg_template {
1650}; 1650};
1651 1651
1652static struct caam_alg_template driver_algs[] = { 1652static struct caam_alg_template driver_algs[] = {
1653 /* single-pass ipsec_esp descriptor */ 1653 /*
1654 * single-pass ipsec_esp descriptor
1655 * authencesn(*,*) is also registered, although not present
1656 * explicitly here.
1657 */
1654 { 1658 {
1655 .name = "authenc(hmac(md5),cbc(aes))", 1659 .name = "authenc(hmac(md5),cbc(aes))",
1656 .driver_name = "authenc-hmac-md5-cbc-aes-caam", 1660 .driver_name = "authenc-hmac-md5-cbc-aes-caam",
@@ -2213,7 +2217,9 @@ static int __init caam_algapi_init(void)
2213 for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { 2217 for (i = 0; i < ARRAY_SIZE(driver_algs); i++) {
2214 /* TODO: check if h/w supports alg */ 2218 /* TODO: check if h/w supports alg */
2215 struct caam_crypto_alg *t_alg; 2219 struct caam_crypto_alg *t_alg;
2220 bool done = false;
2216 2221
2222authencesn:
2217 t_alg = caam_alg_alloc(ctrldev, &driver_algs[i]); 2223 t_alg = caam_alg_alloc(ctrldev, &driver_algs[i]);
2218 if (IS_ERR(t_alg)) { 2224 if (IS_ERR(t_alg)) {
2219 err = PTR_ERR(t_alg); 2225 err = PTR_ERR(t_alg);
@@ -2227,8 +2233,25 @@ static int __init caam_algapi_init(void)
2227 dev_warn(ctrldev, "%s alg registration failed\n", 2233 dev_warn(ctrldev, "%s alg registration failed\n",
2228 t_alg->crypto_alg.cra_driver_name); 2234 t_alg->crypto_alg.cra_driver_name);
2229 kfree(t_alg); 2235 kfree(t_alg);
2230 } else 2236 } else {
2231 list_add_tail(&t_alg->entry, &priv->alg_list); 2237 list_add_tail(&t_alg->entry, &priv->alg_list);
2238 if (driver_algs[i].type == CRYPTO_ALG_TYPE_AEAD &&
2239 !memcmp(driver_algs[i].name, "authenc", 7) &&
2240 !done) {
2241 char *name;
2242
2243 name = driver_algs[i].name;
2244 memmove(name + 10, name + 7, strlen(name) - 7);
2245 memcpy(name + 7, "esn", 3);
2246
2247 name = driver_algs[i].driver_name;
2248 memmove(name + 10, name + 7, strlen(name) - 7);
2249 memcpy(name + 7, "esn", 3);
2250
2251 done = true;
2252 goto authencesn;
2253 }
2254 }
2232 } 2255 }
2233 if (!list_empty(&priv->alg_list)) 2256 if (!list_empty(&priv->alg_list))
2234 dev_info(ctrldev, "%s algorithms registered in /proc/crypto\n", 2257 dev_info(ctrldev, "%s algorithms registered in /proc/crypto\n",