diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-05-11 05:47:50 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-05-12 22:31:35 -0400 |
commit | add86d55768e5e301be38b2961df35f26f9d5fbe (patch) | |
tree | fcdd341eae6f257d520f64b1794b691b3285c2d7 /drivers/crypto/caam | |
parent | d1a2fd500cc7c90504df52017edbb9f1f7763449 (diff) |
crypto: caam - Remove unnecessary reference to crt_aead
crt_aead is an internal implementation detail and must not be
used outside of the crypto API itself. This patch replaces the
unnecessary uses of crt_aead with crypto_aead_ivsize.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/caam')
-rw-r--r-- | drivers/crypto/caam/caamalg.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 3c025d407aff..a34fc95ab8dc 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c | |||
@@ -258,7 +258,7 @@ static void init_sh_desc_key_aead(u32 *desc, struct caam_ctx *ctx, | |||
258 | 258 | ||
259 | static int aead_null_set_sh_desc(struct crypto_aead *aead) | 259 | static int aead_null_set_sh_desc(struct crypto_aead *aead) |
260 | { | 260 | { |
261 | struct aead_tfm *tfm = &aead->base.crt_aead; | 261 | unsigned int ivsize = crypto_aead_ivsize(aead); |
262 | struct caam_ctx *ctx = crypto_aead_ctx(aead); | 262 | struct caam_ctx *ctx = crypto_aead_ctx(aead); |
263 | struct device *jrdev = ctx->jrdev; | 263 | struct device *jrdev = ctx->jrdev; |
264 | bool keys_fit_inline = false; | 264 | bool keys_fit_inline = false; |
@@ -383,7 +383,7 @@ static int aead_null_set_sh_desc(struct crypto_aead *aead) | |||
383 | 383 | ||
384 | /* assoclen + cryptlen = seqinlen - ivsize - authsize */ | 384 | /* assoclen + cryptlen = seqinlen - ivsize - authsize */ |
385 | append_math_sub_imm_u32(desc, REG3, SEQINLEN, IMM, | 385 | append_math_sub_imm_u32(desc, REG3, SEQINLEN, IMM, |
386 | ctx->authsize + tfm->ivsize); | 386 | ctx->authsize + ivsize); |
387 | /* assoclen = (assoclen + cryptlen) - cryptlen */ | 387 | /* assoclen = (assoclen + cryptlen) - cryptlen */ |
388 | append_math_sub(desc, REG2, SEQOUTLEN, REG0, CAAM_CMD_SZ); | 388 | append_math_sub(desc, REG2, SEQOUTLEN, REG0, CAAM_CMD_SZ); |
389 | append_math_sub(desc, VARSEQINLEN, REG3, REG2, CAAM_CMD_SZ); | 389 | append_math_sub(desc, VARSEQINLEN, REG3, REG2, CAAM_CMD_SZ); |
@@ -449,7 +449,7 @@ static int aead_null_set_sh_desc(struct crypto_aead *aead) | |||
449 | 449 | ||
450 | static int aead_set_sh_desc(struct crypto_aead *aead) | 450 | static int aead_set_sh_desc(struct crypto_aead *aead) |
451 | { | 451 | { |
452 | struct aead_tfm *tfm = &aead->base.crt_aead; | 452 | unsigned int ivsize = crypto_aead_ivsize(aead); |
453 | struct caam_ctx *ctx = crypto_aead_ctx(aead); | 453 | struct caam_ctx *ctx = crypto_aead_ctx(aead); |
454 | struct crypto_tfm *ctfm = crypto_aead_tfm(aead); | 454 | struct crypto_tfm *ctfm = crypto_aead_tfm(aead); |
455 | const char *alg_name = crypto_tfm_alg_name(ctfm); | 455 | const char *alg_name = crypto_tfm_alg_name(ctfm); |
@@ -510,7 +510,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
510 | append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize); | 510 | append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize); |
511 | 511 | ||
512 | /* assoclen + cryptlen = seqinlen - ivsize */ | 512 | /* assoclen + cryptlen = seqinlen - ivsize */ |
513 | append_math_sub_imm_u32(desc, REG2, SEQINLEN, IMM, tfm->ivsize); | 513 | append_math_sub_imm_u32(desc, REG2, SEQINLEN, IMM, ivsize); |
514 | 514 | ||
515 | /* assoclen = (assoclen + cryptlen) - cryptlen */ | 515 | /* assoclen = (assoclen + cryptlen) - cryptlen */ |
516 | append_math_sub(desc, VARSEQINLEN, REG2, REG3, CAAM_CMD_SZ); | 516 | append_math_sub(desc, VARSEQINLEN, REG2, REG3, CAAM_CMD_SZ); |
@@ -518,7 +518,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
518 | /* read assoc before reading payload */ | 518 | /* read assoc before reading payload */ |
519 | append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS2 | FIFOLD_TYPE_MSG | | 519 | append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS2 | FIFOLD_TYPE_MSG | |
520 | KEY_VLF); | 520 | KEY_VLF); |
521 | aead_append_ld_iv(desc, tfm->ivsize, ctx1_iv_off); | 521 | aead_append_ld_iv(desc, ivsize, ctx1_iv_off); |
522 | 522 | ||
523 | /* Load Counter into CONTEXT1 reg */ | 523 | /* Load Counter into CONTEXT1 reg */ |
524 | if (is_rfc3686) | 524 | if (is_rfc3686) |
@@ -577,7 +577,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
577 | 577 | ||
578 | /* assoclen + cryptlen = seqinlen - ivsize - authsize */ | 578 | /* assoclen + cryptlen = seqinlen - ivsize - authsize */ |
579 | append_math_sub_imm_u32(desc, REG3, SEQINLEN, IMM, | 579 | append_math_sub_imm_u32(desc, REG3, SEQINLEN, IMM, |
580 | ctx->authsize + tfm->ivsize); | 580 | ctx->authsize + ivsize); |
581 | /* assoclen = (assoclen + cryptlen) - cryptlen */ | 581 | /* assoclen = (assoclen + cryptlen) - cryptlen */ |
582 | append_math_sub(desc, REG2, SEQOUTLEN, REG0, CAAM_CMD_SZ); | 582 | append_math_sub(desc, REG2, SEQOUTLEN, REG0, CAAM_CMD_SZ); |
583 | append_math_sub(desc, VARSEQINLEN, REG3, REG2, CAAM_CMD_SZ); | 583 | append_math_sub(desc, VARSEQINLEN, REG3, REG2, CAAM_CMD_SZ); |
@@ -586,7 +586,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
586 | append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS2 | FIFOLD_TYPE_MSG | | 586 | append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS2 | FIFOLD_TYPE_MSG | |
587 | KEY_VLF); | 587 | KEY_VLF); |
588 | 588 | ||
589 | aead_append_ld_iv(desc, tfm->ivsize, ctx1_iv_off); | 589 | aead_append_ld_iv(desc, ivsize, ctx1_iv_off); |
590 | 590 | ||
591 | /* Load Counter into CONTEXT1 reg */ | 591 | /* Load Counter into CONTEXT1 reg */ |
592 | if (is_rfc3686) | 592 | if (is_rfc3686) |
@@ -645,20 +645,20 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
645 | /* Generate IV */ | 645 | /* Generate IV */ |
646 | geniv = NFIFOENTRY_STYPE_PAD | NFIFOENTRY_DEST_DECO | | 646 | geniv = NFIFOENTRY_STYPE_PAD | NFIFOENTRY_DEST_DECO | |
647 | NFIFOENTRY_DTYPE_MSG | NFIFOENTRY_LC1 | | 647 | NFIFOENTRY_DTYPE_MSG | NFIFOENTRY_LC1 | |
648 | NFIFOENTRY_PTYPE_RND | (tfm->ivsize << NFIFOENTRY_DLEN_SHIFT); | 648 | NFIFOENTRY_PTYPE_RND | (ivsize << NFIFOENTRY_DLEN_SHIFT); |
649 | append_load_imm_u32(desc, geniv, LDST_CLASS_IND_CCB | | 649 | append_load_imm_u32(desc, geniv, LDST_CLASS_IND_CCB | |
650 | LDST_SRCDST_WORD_INFO_FIFO | LDST_IMM); | 650 | LDST_SRCDST_WORD_INFO_FIFO | LDST_IMM); |
651 | append_cmd(desc, CMD_LOAD | DISABLE_AUTO_INFO_FIFO); | 651 | append_cmd(desc, CMD_LOAD | DISABLE_AUTO_INFO_FIFO); |
652 | append_move(desc, MOVE_WAITCOMP | | 652 | append_move(desc, MOVE_WAITCOMP | |
653 | MOVE_SRC_INFIFO | MOVE_DEST_CLASS1CTX | | 653 | MOVE_SRC_INFIFO | MOVE_DEST_CLASS1CTX | |
654 | (ctx1_iv_off << MOVE_OFFSET_SHIFT) | | 654 | (ctx1_iv_off << MOVE_OFFSET_SHIFT) | |
655 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 655 | (ivsize << MOVE_LEN_SHIFT)); |
656 | append_cmd(desc, CMD_LOAD | ENABLE_AUTO_INFO_FIFO); | 656 | append_cmd(desc, CMD_LOAD | ENABLE_AUTO_INFO_FIFO); |
657 | 657 | ||
658 | /* Copy IV to class 1 context */ | 658 | /* Copy IV to class 1 context */ |
659 | append_move(desc, MOVE_SRC_CLASS1CTX | MOVE_DEST_OUTFIFO | | 659 | append_move(desc, MOVE_SRC_CLASS1CTX | MOVE_DEST_OUTFIFO | |
660 | (ctx1_iv_off << MOVE_OFFSET_SHIFT) | | 660 | (ctx1_iv_off << MOVE_OFFSET_SHIFT) | |
661 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 661 | (ivsize << MOVE_LEN_SHIFT)); |
662 | 662 | ||
663 | /* Return to encryption */ | 663 | /* Return to encryption */ |
664 | append_operation(desc, ctx->class2_alg_type | | 664 | append_operation(desc, ctx->class2_alg_type | |
@@ -676,10 +676,10 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
676 | 676 | ||
677 | /* Copy iv from outfifo to class 2 fifo */ | 677 | /* Copy iv from outfifo to class 2 fifo */ |
678 | moveiv = NFIFOENTRY_STYPE_OFIFO | NFIFOENTRY_DEST_CLASS2 | | 678 | moveiv = NFIFOENTRY_STYPE_OFIFO | NFIFOENTRY_DEST_CLASS2 | |
679 | NFIFOENTRY_DTYPE_MSG | (tfm->ivsize << NFIFOENTRY_DLEN_SHIFT); | 679 | NFIFOENTRY_DTYPE_MSG | (ivsize << NFIFOENTRY_DLEN_SHIFT); |
680 | append_load_imm_u32(desc, moveiv, LDST_CLASS_IND_CCB | | 680 | append_load_imm_u32(desc, moveiv, LDST_CLASS_IND_CCB | |
681 | LDST_SRCDST_WORD_INFO_FIFO | LDST_IMM); | 681 | LDST_SRCDST_WORD_INFO_FIFO | LDST_IMM); |
682 | append_load_imm_u32(desc, tfm->ivsize, LDST_CLASS_2_CCB | | 682 | append_load_imm_u32(desc, ivsize, LDST_CLASS_2_CCB | |
683 | LDST_SRCDST_WORD_DATASZ_REG | LDST_IMM); | 683 | LDST_SRCDST_WORD_DATASZ_REG | LDST_IMM); |
684 | 684 | ||
685 | /* Load Counter into CONTEXT1 reg */ | 685 | /* Load Counter into CONTEXT1 reg */ |
@@ -698,7 +698,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead) | |||
698 | append_math_add(desc, VARSEQOUTLEN, SEQINLEN, REG0, CAAM_CMD_SZ); | 698 | append_math_add(desc, VARSEQOUTLEN, SEQINLEN, REG0, CAAM_CMD_SZ); |
699 | 699 | ||
700 | /* Not need to reload iv */ | 700 | /* Not need to reload iv */ |
701 | append_seq_fifo_load(desc, tfm->ivsize, | 701 | append_seq_fifo_load(desc, ivsize, |
702 | FIFOLD_CLASS_SKIP); | 702 | FIFOLD_CLASS_SKIP); |
703 | 703 | ||
704 | /* Will read cryptlen */ | 704 | /* Will read cryptlen */ |
@@ -738,7 +738,7 @@ static int aead_setauthsize(struct crypto_aead *authenc, | |||
738 | 738 | ||
739 | static int gcm_set_sh_desc(struct crypto_aead *aead) | 739 | static int gcm_set_sh_desc(struct crypto_aead *aead) |
740 | { | 740 | { |
741 | struct aead_tfm *tfm = &aead->base.crt_aead; | 741 | unsigned int ivsize = crypto_aead_ivsize(aead); |
742 | struct caam_ctx *ctx = crypto_aead_ctx(aead); | 742 | struct caam_ctx *ctx = crypto_aead_ctx(aead); |
743 | struct device *jrdev = ctx->jrdev; | 743 | struct device *jrdev = ctx->jrdev; |
744 | bool keys_fit_inline = false; | 744 | bool keys_fit_inline = false; |
@@ -781,7 +781,7 @@ static int gcm_set_sh_desc(struct crypto_aead *aead) | |||
781 | append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize); | 781 | append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize); |
782 | 782 | ||
783 | /* assoclen + cryptlen = seqinlen - ivsize */ | 783 | /* assoclen + cryptlen = seqinlen - ivsize */ |
784 | append_math_sub_imm_u32(desc, REG2, SEQINLEN, IMM, tfm->ivsize); | 784 | append_math_sub_imm_u32(desc, REG2, SEQINLEN, IMM, ivsize); |
785 | 785 | ||
786 | /* assoclen = (assoclen + cryptlen) - cryptlen */ | 786 | /* assoclen = (assoclen + cryptlen) - cryptlen */ |
787 | append_math_sub(desc, REG1, REG2, REG3, CAAM_CMD_SZ); | 787 | append_math_sub(desc, REG1, REG2, REG3, CAAM_CMD_SZ); |
@@ -791,7 +791,7 @@ static int gcm_set_sh_desc(struct crypto_aead *aead) | |||
791 | zero_payload_jump_cmd = append_jump(desc, JUMP_TEST_ALL | | 791 | zero_payload_jump_cmd = append_jump(desc, JUMP_TEST_ALL | |
792 | JUMP_COND_MATH_Z); | 792 | JUMP_COND_MATH_Z); |
793 | /* read IV */ | 793 | /* read IV */ |
794 | append_seq_fifo_load(desc, tfm->ivsize, FIFOLD_CLASS_CLASS1 | | 794 | append_seq_fifo_load(desc, ivsize, FIFOLD_CLASS_CLASS1 | |
795 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1); | 795 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1); |
796 | 796 | ||
797 | /* if assoclen is ZERO, skip reading the assoc data */ | 797 | /* if assoclen is ZERO, skip reading the assoc data */ |
@@ -824,7 +824,7 @@ static int gcm_set_sh_desc(struct crypto_aead *aead) | |||
824 | zero_assoc_jump_cmd2 = append_jump(desc, JUMP_TEST_ALL | | 824 | zero_assoc_jump_cmd2 = append_jump(desc, JUMP_TEST_ALL | |
825 | JUMP_COND_MATH_Z); | 825 | JUMP_COND_MATH_Z); |
826 | /* read IV */ | 826 | /* read IV */ |
827 | append_seq_fifo_load(desc, tfm->ivsize, FIFOLD_CLASS_CLASS1 | | 827 | append_seq_fifo_load(desc, ivsize, FIFOLD_CLASS_CLASS1 | |
828 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1); | 828 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1); |
829 | 829 | ||
830 | /* read assoc data */ | 830 | /* read assoc data */ |
@@ -836,7 +836,7 @@ static int gcm_set_sh_desc(struct crypto_aead *aead) | |||
836 | 836 | ||
837 | /* read IV - is the only input data */ | 837 | /* read IV - is the only input data */ |
838 | set_jump_tgt_here(desc, zero_assoc_jump_cmd2); | 838 | set_jump_tgt_here(desc, zero_assoc_jump_cmd2); |
839 | append_seq_fifo_load(desc, tfm->ivsize, FIFOLD_CLASS_CLASS1 | | 839 | append_seq_fifo_load(desc, ivsize, FIFOLD_CLASS_CLASS1 | |
840 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1 | | 840 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1 | |
841 | FIFOLD_TYPE_LAST1); | 841 | FIFOLD_TYPE_LAST1); |
842 | 842 | ||
@@ -888,14 +888,14 @@ static int gcm_set_sh_desc(struct crypto_aead *aead) | |||
888 | 888 | ||
889 | /* assoclen + cryptlen = seqinlen - ivsize - icvsize */ | 889 | /* assoclen + cryptlen = seqinlen - ivsize - icvsize */ |
890 | append_math_sub_imm_u32(desc, REG3, SEQINLEN, IMM, | 890 | append_math_sub_imm_u32(desc, REG3, SEQINLEN, IMM, |
891 | ctx->authsize + tfm->ivsize); | 891 | ctx->authsize + ivsize); |
892 | 892 | ||
893 | /* assoclen = (assoclen + cryptlen) - cryptlen */ | 893 | /* assoclen = (assoclen + cryptlen) - cryptlen */ |
894 | append_math_sub(desc, REG2, SEQOUTLEN, REG0, CAAM_CMD_SZ); | 894 | append_math_sub(desc, REG2, SEQOUTLEN, REG0, CAAM_CMD_SZ); |
895 | append_math_sub(desc, REG1, REG3, REG2, CAAM_CMD_SZ); | 895 | append_math_sub(desc, REG1, REG3, REG2, CAAM_CMD_SZ); |
896 | 896 | ||
897 | /* read IV */ | 897 | /* read IV */ |
898 | append_seq_fifo_load(desc, tfm->ivsize, FIFOLD_CLASS_CLASS1 | | 898 | append_seq_fifo_load(desc, ivsize, FIFOLD_CLASS_CLASS1 | |
899 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1); | 899 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1); |
900 | 900 | ||
901 | /* jump to zero-payload command if cryptlen is zero */ | 901 | /* jump to zero-payload command if cryptlen is zero */ |
@@ -968,7 +968,7 @@ static int gcm_setauthsize(struct crypto_aead *authenc, unsigned int authsize) | |||
968 | 968 | ||
969 | static int rfc4106_set_sh_desc(struct crypto_aead *aead) | 969 | static int rfc4106_set_sh_desc(struct crypto_aead *aead) |
970 | { | 970 | { |
971 | struct aead_tfm *tfm = &aead->base.crt_aead; | 971 | unsigned int ivsize = crypto_aead_ivsize(aead); |
972 | struct caam_ctx *ctx = crypto_aead_ctx(aead); | 972 | struct caam_ctx *ctx = crypto_aead_ctx(aead); |
973 | struct device *jrdev = ctx->jrdev; | 973 | struct device *jrdev = ctx->jrdev; |
974 | bool keys_fit_inline = false; | 974 | bool keys_fit_inline = false; |
@@ -1012,7 +1012,7 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead) | |||
1012 | append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ); | 1012 | append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ); |
1013 | 1013 | ||
1014 | /* assoclen + cryptlen = seqinlen - ivsize */ | 1014 | /* assoclen + cryptlen = seqinlen - ivsize */ |
1015 | append_math_sub_imm_u32(desc, REG2, SEQINLEN, IMM, tfm->ivsize); | 1015 | append_math_sub_imm_u32(desc, REG2, SEQINLEN, IMM, ivsize); |
1016 | 1016 | ||
1017 | /* assoclen = (assoclen + cryptlen) - cryptlen */ | 1017 | /* assoclen = (assoclen + cryptlen) - cryptlen */ |
1018 | append_math_sub(desc, VARSEQINLEN, REG2, REG3, CAAM_CMD_SZ); | 1018 | append_math_sub(desc, VARSEQINLEN, REG2, REG3, CAAM_CMD_SZ); |
@@ -1021,7 +1021,7 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead) | |||
1021 | append_fifo_load_as_imm(desc, (void *)(ctx->key + ctx->enckeylen), | 1021 | append_fifo_load_as_imm(desc, (void *)(ctx->key + ctx->enckeylen), |
1022 | 4, FIFOLD_CLASS_CLASS1 | FIFOLD_TYPE_IV); | 1022 | 4, FIFOLD_CLASS_CLASS1 | FIFOLD_TYPE_IV); |
1023 | /* Read AES-GCM-ESP IV */ | 1023 | /* Read AES-GCM-ESP IV */ |
1024 | append_seq_fifo_load(desc, tfm->ivsize, FIFOLD_CLASS_CLASS1 | | 1024 | append_seq_fifo_load(desc, ivsize, FIFOLD_CLASS_CLASS1 | |
1025 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1); | 1025 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1); |
1026 | 1026 | ||
1027 | /* Read assoc data */ | 1027 | /* Read assoc data */ |
@@ -1085,7 +1085,7 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead) | |||
1085 | 1085 | ||
1086 | /* assoclen + cryptlen = seqinlen - ivsize - icvsize */ | 1086 | /* assoclen + cryptlen = seqinlen - ivsize - icvsize */ |
1087 | append_math_sub_imm_u32(desc, REG3, SEQINLEN, IMM, | 1087 | append_math_sub_imm_u32(desc, REG3, SEQINLEN, IMM, |
1088 | ctx->authsize + tfm->ivsize); | 1088 | ctx->authsize + ivsize); |
1089 | 1089 | ||
1090 | /* assoclen = (assoclen + cryptlen) - cryptlen */ | 1090 | /* assoclen = (assoclen + cryptlen) - cryptlen */ |
1091 | append_math_sub(desc, REG2, SEQOUTLEN, REG0, CAAM_CMD_SZ); | 1091 | append_math_sub(desc, REG2, SEQOUTLEN, REG0, CAAM_CMD_SZ); |
@@ -1098,7 +1098,7 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead) | |||
1098 | append_fifo_load_as_imm(desc, (void *)(ctx->key + ctx->enckeylen), | 1098 | append_fifo_load_as_imm(desc, (void *)(ctx->key + ctx->enckeylen), |
1099 | 4, FIFOLD_CLASS_CLASS1 | FIFOLD_TYPE_IV); | 1099 | 4, FIFOLD_CLASS_CLASS1 | FIFOLD_TYPE_IV); |
1100 | /* Read AES-GCM-ESP IV */ | 1100 | /* Read AES-GCM-ESP IV */ |
1101 | append_seq_fifo_load(desc, tfm->ivsize, FIFOLD_CLASS_CLASS1 | | 1101 | append_seq_fifo_load(desc, ivsize, FIFOLD_CLASS_CLASS1 | |
1102 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1); | 1102 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1); |
1103 | 1103 | ||
1104 | /* Read assoc data */ | 1104 | /* Read assoc data */ |
@@ -1161,17 +1161,17 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead) | |||
1161 | /* Generate IV */ | 1161 | /* Generate IV */ |
1162 | geniv = NFIFOENTRY_STYPE_PAD | NFIFOENTRY_DEST_DECO | | 1162 | geniv = NFIFOENTRY_STYPE_PAD | NFIFOENTRY_DEST_DECO | |
1163 | NFIFOENTRY_DTYPE_MSG | NFIFOENTRY_LC1 | | 1163 | NFIFOENTRY_DTYPE_MSG | NFIFOENTRY_LC1 | |
1164 | NFIFOENTRY_PTYPE_RND | (tfm->ivsize << NFIFOENTRY_DLEN_SHIFT); | 1164 | NFIFOENTRY_PTYPE_RND | (ivsize << NFIFOENTRY_DLEN_SHIFT); |
1165 | append_load_imm_u32(desc, geniv, LDST_CLASS_IND_CCB | | 1165 | append_load_imm_u32(desc, geniv, LDST_CLASS_IND_CCB | |
1166 | LDST_SRCDST_WORD_INFO_FIFO | LDST_IMM); | 1166 | LDST_SRCDST_WORD_INFO_FIFO | LDST_IMM); |
1167 | append_cmd(desc, CMD_LOAD | DISABLE_AUTO_INFO_FIFO); | 1167 | append_cmd(desc, CMD_LOAD | DISABLE_AUTO_INFO_FIFO); |
1168 | move_cmd = append_move(desc, MOVE_SRC_INFIFO | MOVE_DEST_DESCBUF | | 1168 | move_cmd = append_move(desc, MOVE_SRC_INFIFO | MOVE_DEST_DESCBUF | |
1169 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 1169 | (ivsize << MOVE_LEN_SHIFT)); |
1170 | append_cmd(desc, CMD_LOAD | ENABLE_AUTO_INFO_FIFO); | 1170 | append_cmd(desc, CMD_LOAD | ENABLE_AUTO_INFO_FIFO); |
1171 | 1171 | ||
1172 | /* Copy generated IV to OFIFO */ | 1172 | /* Copy generated IV to OFIFO */ |
1173 | write_iv_cmd = append_move(desc, MOVE_SRC_DESCBUF | MOVE_DEST_OUTFIFO | | 1173 | write_iv_cmd = append_move(desc, MOVE_SRC_DESCBUF | MOVE_DEST_OUTFIFO | |
1174 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 1174 | (ivsize << MOVE_LEN_SHIFT)); |
1175 | 1175 | ||
1176 | /* Class 1 operation */ | 1176 | /* Class 1 operation */ |
1177 | append_operation(desc, ctx->class1_alg_type | | 1177 | append_operation(desc, ctx->class1_alg_type | |
@@ -1199,7 +1199,7 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead) | |||
1199 | /* End of blank commands */ | 1199 | /* End of blank commands */ |
1200 | 1200 | ||
1201 | /* No need to reload iv */ | 1201 | /* No need to reload iv */ |
1202 | append_seq_fifo_load(desc, tfm->ivsize, FIFOLD_CLASS_SKIP); | 1202 | append_seq_fifo_load(desc, ivsize, FIFOLD_CLASS_SKIP); |
1203 | 1203 | ||
1204 | /* Read assoc data */ | 1204 | /* Read assoc data */ |
1205 | append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS1 | FIFOLDST_VLF | | 1205 | append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS1 | FIFOLDST_VLF | |
@@ -1249,7 +1249,7 @@ static int rfc4106_setauthsize(struct crypto_aead *authenc, | |||
1249 | 1249 | ||
1250 | static int rfc4543_set_sh_desc(struct crypto_aead *aead) | 1250 | static int rfc4543_set_sh_desc(struct crypto_aead *aead) |
1251 | { | 1251 | { |
1252 | struct aead_tfm *tfm = &aead->base.crt_aead; | 1252 | unsigned int ivsize = crypto_aead_ivsize(aead); |
1253 | struct caam_ctx *ctx = crypto_aead_ctx(aead); | 1253 | struct caam_ctx *ctx = crypto_aead_ctx(aead); |
1254 | struct device *jrdev = ctx->jrdev; | 1254 | struct device *jrdev = ctx->jrdev; |
1255 | bool keys_fit_inline = false; | 1255 | bool keys_fit_inline = false; |
@@ -1291,7 +1291,7 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1291 | 1291 | ||
1292 | /* Load AES-GMAC ESP IV into Math1 register */ | 1292 | /* Load AES-GMAC ESP IV into Math1 register */ |
1293 | append_cmd(desc, CMD_SEQ_LOAD | LDST_SRCDST_WORD_DECO_MATH1 | | 1293 | append_cmd(desc, CMD_SEQ_LOAD | LDST_SRCDST_WORD_DECO_MATH1 | |
1294 | LDST_CLASS_DECO | tfm->ivsize); | 1294 | LDST_CLASS_DECO | ivsize); |
1295 | 1295 | ||
1296 | /* Wait the DMA transaction to finish */ | 1296 | /* Wait the DMA transaction to finish */ |
1297 | append_jump(desc, JUMP_TEST_ALL | JUMP_COND_CALM | | 1297 | append_jump(desc, JUMP_TEST_ALL | JUMP_COND_CALM | |
@@ -1299,11 +1299,11 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1299 | 1299 | ||
1300 | /* Overwrite blank immediate AES-GMAC ESP IV data */ | 1300 | /* Overwrite blank immediate AES-GMAC ESP IV data */ |
1301 | write_iv_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | | 1301 | write_iv_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | |
1302 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 1302 | (ivsize << MOVE_LEN_SHIFT)); |
1303 | 1303 | ||
1304 | /* Overwrite blank immediate AAD data */ | 1304 | /* Overwrite blank immediate AAD data */ |
1305 | write_aad_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | | 1305 | write_aad_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | |
1306 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 1306 | (ivsize << MOVE_LEN_SHIFT)); |
1307 | 1307 | ||
1308 | /* cryptlen = seqoutlen - authsize */ | 1308 | /* cryptlen = seqoutlen - authsize */ |
1309 | append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize); | 1309 | append_math_sub_imm_u32(desc, REG3, SEQOUTLEN, IMM, ctx->authsize); |
@@ -1313,7 +1313,7 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1313 | 1313 | ||
1314 | /* Read Salt and AES-GMAC ESP IV */ | 1314 | /* Read Salt and AES-GMAC ESP IV */ |
1315 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | | 1315 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | |
1316 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1 | (4 + tfm->ivsize)); | 1316 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1 | (4 + ivsize)); |
1317 | /* Append Salt */ | 1317 | /* Append Salt */ |
1318 | append_data(desc, (void *)(ctx->key + ctx->enckeylen), 4); | 1318 | append_data(desc, (void *)(ctx->key + ctx->enckeylen), 4); |
1319 | set_move_tgt_here(desc, write_iv_cmd); | 1319 | set_move_tgt_here(desc, write_iv_cmd); |
@@ -1344,7 +1344,7 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1344 | 1344 | ||
1345 | /* Authenticate AES-GMAC ESP IV */ | 1345 | /* Authenticate AES-GMAC ESP IV */ |
1346 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | | 1346 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | |
1347 | FIFOLD_TYPE_AAD | tfm->ivsize); | 1347 | FIFOLD_TYPE_AAD | ivsize); |
1348 | set_move_tgt_here(desc, write_aad_cmd); | 1348 | set_move_tgt_here(desc, write_aad_cmd); |
1349 | /* Blank commands. Will be overwritten by AES-GMAC ESP IV. */ | 1349 | /* Blank commands. Will be overwritten by AES-GMAC ESP IV. */ |
1350 | append_cmd(desc, 0x00000000); | 1350 | append_cmd(desc, 0x00000000); |
@@ -1407,7 +1407,7 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1407 | 1407 | ||
1408 | /* Load AES-GMAC ESP IV into Math1 register */ | 1408 | /* Load AES-GMAC ESP IV into Math1 register */ |
1409 | append_cmd(desc, CMD_SEQ_LOAD | LDST_SRCDST_WORD_DECO_MATH1 | | 1409 | append_cmd(desc, CMD_SEQ_LOAD | LDST_SRCDST_WORD_DECO_MATH1 | |
1410 | LDST_CLASS_DECO | tfm->ivsize); | 1410 | LDST_CLASS_DECO | ivsize); |
1411 | 1411 | ||
1412 | /* Wait the DMA transaction to finish */ | 1412 | /* Wait the DMA transaction to finish */ |
1413 | append_jump(desc, JUMP_TEST_ALL | JUMP_COND_CALM | | 1413 | append_jump(desc, JUMP_TEST_ALL | JUMP_COND_CALM | |
@@ -1418,11 +1418,11 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1418 | 1418 | ||
1419 | /* Overwrite blank immediate AES-GMAC ESP IV data */ | 1419 | /* Overwrite blank immediate AES-GMAC ESP IV data */ |
1420 | write_iv_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | | 1420 | write_iv_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | |
1421 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 1421 | (ivsize << MOVE_LEN_SHIFT)); |
1422 | 1422 | ||
1423 | /* Overwrite blank immediate AAD data */ | 1423 | /* Overwrite blank immediate AAD data */ |
1424 | write_aad_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | | 1424 | write_aad_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | |
1425 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 1425 | (ivsize << MOVE_LEN_SHIFT)); |
1426 | 1426 | ||
1427 | /* assoclen = (assoclen + cryptlen) - cryptlen */ | 1427 | /* assoclen = (assoclen + cryptlen) - cryptlen */ |
1428 | append_math_sub(desc, REG2, SEQOUTLEN, REG0, CAAM_CMD_SZ); | 1428 | append_math_sub(desc, REG2, SEQOUTLEN, REG0, CAAM_CMD_SZ); |
@@ -1440,7 +1440,7 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1440 | 1440 | ||
1441 | /* Read Salt and AES-GMAC ESP IV */ | 1441 | /* Read Salt and AES-GMAC ESP IV */ |
1442 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | | 1442 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | |
1443 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1 | (4 + tfm->ivsize)); | 1443 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1 | (4 + ivsize)); |
1444 | /* Append Salt */ | 1444 | /* Append Salt */ |
1445 | append_data(desc, (void *)(ctx->key + ctx->enckeylen), 4); | 1445 | append_data(desc, (void *)(ctx->key + ctx->enckeylen), 4); |
1446 | set_move_tgt_here(desc, write_iv_cmd); | 1446 | set_move_tgt_here(desc, write_iv_cmd); |
@@ -1461,7 +1461,7 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1461 | 1461 | ||
1462 | /* Authenticate AES-GMAC ESP IV */ | 1462 | /* Authenticate AES-GMAC ESP IV */ |
1463 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | | 1463 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | |
1464 | FIFOLD_TYPE_AAD | tfm->ivsize); | 1464 | FIFOLD_TYPE_AAD | ivsize); |
1465 | set_move_tgt_here(desc, write_aad_cmd); | 1465 | set_move_tgt_here(desc, write_aad_cmd); |
1466 | /* Blank commands. Will be overwritten by AES-GMAC ESP IV. */ | 1466 | /* Blank commands. Will be overwritten by AES-GMAC ESP IV. */ |
1467 | append_cmd(desc, 0x00000000); | 1467 | append_cmd(desc, 0x00000000); |
@@ -1527,26 +1527,26 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1527 | /* Generate IV */ | 1527 | /* Generate IV */ |
1528 | geniv = NFIFOENTRY_STYPE_PAD | NFIFOENTRY_DEST_DECO | | 1528 | geniv = NFIFOENTRY_STYPE_PAD | NFIFOENTRY_DEST_DECO | |
1529 | NFIFOENTRY_DTYPE_MSG | NFIFOENTRY_LC1 | | 1529 | NFIFOENTRY_DTYPE_MSG | NFIFOENTRY_LC1 | |
1530 | NFIFOENTRY_PTYPE_RND | (tfm->ivsize << NFIFOENTRY_DLEN_SHIFT); | 1530 | NFIFOENTRY_PTYPE_RND | (ivsize << NFIFOENTRY_DLEN_SHIFT); |
1531 | append_load_imm_u32(desc, geniv, LDST_CLASS_IND_CCB | | 1531 | append_load_imm_u32(desc, geniv, LDST_CLASS_IND_CCB | |
1532 | LDST_SRCDST_WORD_INFO_FIFO | LDST_IMM); | 1532 | LDST_SRCDST_WORD_INFO_FIFO | LDST_IMM); |
1533 | append_cmd(desc, CMD_LOAD | DISABLE_AUTO_INFO_FIFO); | 1533 | append_cmd(desc, CMD_LOAD | DISABLE_AUTO_INFO_FIFO); |
1534 | /* Move generated IV to Math1 register */ | 1534 | /* Move generated IV to Math1 register */ |
1535 | append_move(desc, MOVE_SRC_INFIFO | MOVE_DEST_MATH1 | | 1535 | append_move(desc, MOVE_SRC_INFIFO | MOVE_DEST_MATH1 | |
1536 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 1536 | (ivsize << MOVE_LEN_SHIFT)); |
1537 | append_cmd(desc, CMD_LOAD | ENABLE_AUTO_INFO_FIFO); | 1537 | append_cmd(desc, CMD_LOAD | ENABLE_AUTO_INFO_FIFO); |
1538 | 1538 | ||
1539 | /* Overwrite blank immediate AES-GMAC IV data */ | 1539 | /* Overwrite blank immediate AES-GMAC IV data */ |
1540 | write_iv_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | | 1540 | write_iv_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | |
1541 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 1541 | (ivsize << MOVE_LEN_SHIFT)); |
1542 | 1542 | ||
1543 | /* Overwrite blank immediate AAD data */ | 1543 | /* Overwrite blank immediate AAD data */ |
1544 | write_aad_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | | 1544 | write_aad_cmd = append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_DESCBUF | |
1545 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 1545 | (ivsize << MOVE_LEN_SHIFT)); |
1546 | 1546 | ||
1547 | /* Copy generated IV to OFIFO */ | 1547 | /* Copy generated IV to OFIFO */ |
1548 | append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_OUTFIFO | | 1548 | append_move(desc, MOVE_SRC_MATH1 | MOVE_DEST_OUTFIFO | |
1549 | (tfm->ivsize << MOVE_LEN_SHIFT)); | 1549 | (ivsize << MOVE_LEN_SHIFT)); |
1550 | 1550 | ||
1551 | /* Class 1 operation */ | 1551 | /* Class 1 operation */ |
1552 | append_operation(desc, ctx->class1_alg_type | | 1552 | append_operation(desc, ctx->class1_alg_type | |
@@ -1573,7 +1573,7 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1573 | 1573 | ||
1574 | /* Read Salt and AES-GMAC generated IV */ | 1574 | /* Read Salt and AES-GMAC generated IV */ |
1575 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | | 1575 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | |
1576 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1 | (4 + tfm->ivsize)); | 1576 | FIFOLD_TYPE_IV | FIFOLD_TYPE_FLUSH1 | (4 + ivsize)); |
1577 | /* Append Salt */ | 1577 | /* Append Salt */ |
1578 | append_data(desc, (void *)(ctx->key + ctx->enckeylen), 4); | 1578 | append_data(desc, (void *)(ctx->key + ctx->enckeylen), 4); |
1579 | set_move_tgt_here(desc, write_iv_cmd); | 1579 | set_move_tgt_here(desc, write_iv_cmd); |
@@ -1583,7 +1583,7 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1583 | /* End of blank commands */ | 1583 | /* End of blank commands */ |
1584 | 1584 | ||
1585 | /* No need to reload iv */ | 1585 | /* No need to reload iv */ |
1586 | append_seq_fifo_load(desc, tfm->ivsize, FIFOLD_CLASS_SKIP); | 1586 | append_seq_fifo_load(desc, ivsize, FIFOLD_CLASS_SKIP); |
1587 | 1587 | ||
1588 | /* Read assoc data */ | 1588 | /* Read assoc data */ |
1589 | append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS1 | FIFOLDST_VLF | | 1589 | append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS1 | FIFOLDST_VLF | |
@@ -1594,7 +1594,7 @@ static int rfc4543_set_sh_desc(struct crypto_aead *aead) | |||
1594 | 1594 | ||
1595 | /* Authenticate AES-GMAC IV */ | 1595 | /* Authenticate AES-GMAC IV */ |
1596 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | | 1596 | append_cmd(desc, CMD_FIFO_LOAD | FIFOLD_CLASS_CLASS1 | IMMEDIATE | |
1597 | FIFOLD_TYPE_AAD | tfm->ivsize); | 1597 | FIFOLD_TYPE_AAD | ivsize); |
1598 | set_move_tgt_here(desc, write_aad_cmd); | 1598 | set_move_tgt_here(desc, write_aad_cmd); |
1599 | /* Blank commands. Will be overwritten by AES-GMAC IV. */ | 1599 | /* Blank commands. Will be overwritten by AES-GMAC IV. */ |
1600 | append_cmd(desc, 0x00000000); | 1600 | append_cmd(desc, 0x00000000); |