diff options
Diffstat (limited to 'drivers/crypto/caam/caamalg.c')
-rw-r--r-- | drivers/crypto/caam/caamalg.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index ea8189f4b021..6dc597126b79 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c | |||
@@ -441,6 +441,9 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
441 | OP_ALG_AAI_CTR_MOD128); | 441 | OP_ALG_AAI_CTR_MOD128); |
442 | const bool is_rfc3686 = alg->caam.rfc3686; | 442 | const bool is_rfc3686 = alg->caam.rfc3686; |
443 | 443 | ||
444 | if (!ctx->authsize) | ||
445 | return 0; | ||
446 | |||
444 | /* NULL encryption / decryption */ | 447 | /* NULL encryption / decryption */ |
445 | if (!ctx->enckeylen) | 448 | if (!ctx->enckeylen) |
446 | return aead_null_set_sh_desc(aead); | 449 | return aead_null_set_sh_desc(aead); |
@@ -614,7 +617,7 @@ skip_enc: | |||
614 | keys_fit_inline = true; | 617 | keys_fit_inline = true; |
615 | 618 | ||
616 | /* aead_givencrypt shared descriptor */ | 619 | /* aead_givencrypt shared descriptor */ |
617 | desc = ctx->sh_desc_givenc; | 620 | desc = ctx->sh_desc_enc; |
618 | 621 | ||
619 | /* Note: Context registers are saved. */ | 622 | /* Note: Context registers are saved. */ |
620 | init_sh_desc_key_aead(desc, ctx, keys_fit_inline, is_rfc3686); | 623 | init_sh_desc_key_aead(desc, ctx, keys_fit_inline, is_rfc3686); |
@@ -645,13 +648,13 @@ copy_iv: | |||
645 | append_operation(desc, ctx->class2_alg_type | | 648 | append_operation(desc, ctx->class2_alg_type | |
646 | OP_ALG_AS_INITFINAL | OP_ALG_ENCRYPT); | 649 | OP_ALG_AS_INITFINAL | OP_ALG_ENCRYPT); |
647 | 650 | ||
648 | /* ivsize + cryptlen = seqoutlen - authsize */ | ||
649 | append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize); | ||
650 | |||
651 | /* Read and write assoclen bytes */ | 651 | /* Read and write assoclen bytes */ |
652 | append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ); | 652 | append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ); |
653 | append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ); | 653 | append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ); |
654 | 654 | ||
655 | /* ivsize + cryptlen = seqoutlen - authsize */ | ||
656 | append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize); | ||
657 | |||
655 | /* Skip assoc data */ | 658 | /* Skip assoc data */ |
656 | append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF); | 659 | append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF); |
657 | 660 | ||
@@ -697,7 +700,7 @@ copy_iv: | |||
697 | ctx->sh_desc_enc_dma = dma_map_single(jrdev, desc, | 700 | ctx->sh_desc_enc_dma = dma_map_single(jrdev, desc, |
698 | desc_bytes(desc), | 701 | desc_bytes(desc), |
699 | DMA_TO_DEVICE); | 702 | DMA_TO_DEVICE); |
700 | if (dma_mapping_error(jrdev, ctx->sh_desc_givenc_dma)) { | 703 | if (dma_mapping_error(jrdev, ctx->sh_desc_enc_dma)) { |
701 | dev_err(jrdev, "unable to map shared descriptor\n"); | 704 | dev_err(jrdev, "unable to map shared descriptor\n"); |
702 | return -ENOMEM; | 705 | return -ENOMEM; |
703 | } | 706 | } |