diff options
author | Harsh Jain <harsh@chelsio.com> | 2018-01-11 06:15:52 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-01-18 06:52:29 -0500 |
commit | e1a018e607a33dc9f987c761daf1792082fb9ca7 (patch) | |
tree | 828e79ba8ba9f2b3418b9e1dfa9fc9709028ff8d | |
parent | 3d64bd670269b1391c924a04722441fc5cb3fc3a (diff) |
crypto: chelsio - Remove dst sg size zero check
sg_nents_xlen will take care of zero length sg list.
Remove Destination sg list size zero check.
Signed-off-by: Harsh Jain <harsh@chelsio.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/chelsio/chcr_algo.c | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c index 5cc84c459526..a9c894bf9c01 100644 --- a/drivers/crypto/chelsio/chcr_algo.c +++ b/drivers/crypto/chelsio/chcr_algo.c | |||
@@ -2109,20 +2109,14 @@ static struct sk_buff *create_authenc_wr(struct aead_request *req, | |||
2109 | null = 1; | 2109 | null = 1; |
2110 | assoclen = 0; | 2110 | assoclen = 0; |
2111 | } | 2111 | } |
2112 | dst_size = assoclen + req->cryptlen + (op_type ? -authsize : | ||
2113 | authsize); | ||
2114 | error = chcr_aead_common_init(req, op_type); | 2112 | error = chcr_aead_common_init(req, op_type); |
2115 | if (error) | 2113 | if (error) |
2116 | return ERR_PTR(error); | 2114 | return ERR_PTR(error); |
2117 | if (dst_size) { | ||
2118 | dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0); | 2115 | dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0); |
2119 | dnents += sg_nents_xlen(req->dst, req->cryptlen + | 2116 | dnents += sg_nents_xlen(req->dst, req->cryptlen + |
2120 | (op_type ? -authsize : authsize), CHCR_DST_SG_SIZE, | 2117 | (op_type ? -authsize : authsize), CHCR_DST_SG_SIZE, |
2121 | req->assoclen); | 2118 | req->assoclen); |
2122 | dnents += MIN_AUTH_SG; // For IV | 2119 | dnents += MIN_AUTH_SG; // For IV |
2123 | } else { | ||
2124 | dnents = 0; | ||
2125 | } | ||
2126 | 2120 | ||
2127 | dst_size = get_space_for_phys_dsgl(dnents); | 2121 | dst_size = get_space_for_phys_dsgl(dnents); |
2128 | kctx_len = (ntohl(KEY_CONTEXT_CTX_LEN_V(aeadctx->key_ctx_hdr)) << 4) | 2122 | kctx_len = (ntohl(KEY_CONTEXT_CTX_LEN_V(aeadctx->key_ctx_hdr)) << 4) |
@@ -2687,8 +2681,6 @@ static struct sk_buff *create_aead_ccm_wr(struct aead_request *req, | |||
2687 | sub_type = get_aead_subtype(tfm); | 2681 | sub_type = get_aead_subtype(tfm); |
2688 | if (sub_type == CRYPTO_ALG_SUB_TYPE_AEAD_RFC4309) | 2682 | if (sub_type == CRYPTO_ALG_SUB_TYPE_AEAD_RFC4309) |
2689 | assoclen -= 8; | 2683 | assoclen -= 8; |
2690 | dst_size = assoclen + req->cryptlen + (op_type ? -authsize : | ||
2691 | authsize); | ||
2692 | error = chcr_aead_common_init(req, op_type); | 2684 | error = chcr_aead_common_init(req, op_type); |
2693 | if (error) | 2685 | if (error) |
2694 | return ERR_PTR(error); | 2686 | return ERR_PTR(error); |
@@ -2698,15 +2690,11 @@ static struct sk_buff *create_aead_ccm_wr(struct aead_request *req, | |||
2698 | error = aead_ccm_validate_input(op_type, req, aeadctx, sub_type); | 2690 | error = aead_ccm_validate_input(op_type, req, aeadctx, sub_type); |
2699 | if (error) | 2691 | if (error) |
2700 | goto err; | 2692 | goto err; |
2701 | if (dst_size) { | 2693 | dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0); |
2702 | dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0); | 2694 | dnents += sg_nents_xlen(req->dst, req->cryptlen |
2703 | dnents += sg_nents_xlen(req->dst, req->cryptlen | 2695 | + (op_type ? -authsize : authsize), |
2704 | + (op_type ? -authsize : authsize), | 2696 | CHCR_DST_SG_SIZE, req->assoclen); |
2705 | CHCR_DST_SG_SIZE, req->assoclen); | 2697 | dnents += MIN_CCM_SG; // For IV and B0 |
2706 | dnents += MIN_CCM_SG; // For IV and B0 | ||
2707 | } else { | ||
2708 | dnents = 0; | ||
2709 | } | ||
2710 | dst_size = get_space_for_phys_dsgl(dnents); | 2698 | dst_size = get_space_for_phys_dsgl(dnents); |
2711 | kctx_len = ((DIV_ROUND_UP(aeadctx->enckey_len, 16)) << 4) * 2; | 2699 | kctx_len = ((DIV_ROUND_UP(aeadctx->enckey_len, 16)) << 4) * 2; |
2712 | transhdr_len = CIPHER_TRANSHDR_SIZE(kctx_len, dst_size); | 2700 | transhdr_len = CIPHER_TRANSHDR_SIZE(kctx_len, dst_size); |
@@ -2801,19 +2789,14 @@ static struct sk_buff *create_gcm_wr(struct aead_request *req, | |||
2801 | assoclen = req->assoclen - 8; | 2789 | assoclen = req->assoclen - 8; |
2802 | 2790 | ||
2803 | reqctx->b0_dma = 0; | 2791 | reqctx->b0_dma = 0; |
2804 | dst_size = assoclen + req->cryptlen + (op_type ? -authsize : authsize); | ||
2805 | error = chcr_aead_common_init(req, op_type); | 2792 | error = chcr_aead_common_init(req, op_type); |
2806 | if (error) | 2793 | if (error) |
2807 | return ERR_PTR(error); | 2794 | return ERR_PTR(error); |
2808 | if (dst_size) { | 2795 | dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0); |
2809 | dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0); | 2796 | dnents += sg_nents_xlen(req->dst, req->cryptlen + |
2810 | dnents += sg_nents_xlen(req->dst, | 2797 | (op_type ? -authsize : authsize), |
2811 | req->cryptlen + (op_type ? -authsize : authsize), | ||
2812 | CHCR_DST_SG_SIZE, req->assoclen); | 2798 | CHCR_DST_SG_SIZE, req->assoclen); |
2813 | dnents += MIN_GCM_SG; // For IV | 2799 | dnents += MIN_GCM_SG; // For IV |
2814 | } else { | ||
2815 | dnents = 0; | ||
2816 | } | ||
2817 | dst_size = get_space_for_phys_dsgl(dnents); | 2800 | dst_size = get_space_for_phys_dsgl(dnents); |
2818 | kctx_len = ((DIV_ROUND_UP(aeadctx->enckey_len, 16)) << 4) + | 2801 | kctx_len = ((DIV_ROUND_UP(aeadctx->enckey_len, 16)) << 4) + |
2819 | AEAD_H_SIZE; | 2802 | AEAD_H_SIZE; |
@@ -2850,10 +2833,10 @@ static struct sk_buff *create_gcm_wr(struct aead_request *req, | |||
2850 | chcr_req->sec_cpl.aadstart_cipherstop_hi = FILL_SEC_CPL_CIPHERSTOP_HI( | 2833 | chcr_req->sec_cpl.aadstart_cipherstop_hi = FILL_SEC_CPL_CIPHERSTOP_HI( |
2851 | assoclen ? 1 : 0, assoclen, | 2834 | assoclen ? 1 : 0, assoclen, |
2852 | assoclen + IV + 1, 0); | 2835 | assoclen + IV + 1, 0); |
2853 | chcr_req->sec_cpl.cipherstop_lo_authinsert = | 2836 | chcr_req->sec_cpl.cipherstop_lo_authinsert = |
2854 | FILL_SEC_CPL_AUTHINSERT(0, assoclen + IV + 1, | 2837 | FILL_SEC_CPL_AUTHINSERT(0, assoclen + IV + 1, |
2855 | temp, temp); | 2838 | temp, temp); |
2856 | chcr_req->sec_cpl.seqno_numivs = | 2839 | chcr_req->sec_cpl.seqno_numivs = |
2857 | FILL_SEC_CPL_SCMD0_SEQNO(op_type, (op_type == | 2840 | FILL_SEC_CPL_SCMD0_SEQNO(op_type, (op_type == |
2858 | CHCR_ENCRYPT_OP) ? 1 : 0, | 2841 | CHCR_ENCRYPT_OP) ? 1 : 0, |
2859 | CHCR_SCMD_CIPHER_MODE_AES_GCM, | 2842 | CHCR_SCMD_CIPHER_MODE_AES_GCM, |