|
@@ -2109,20 +2109,14 @@ static struct sk_buff *create_authenc_wr(struct aead_request *req,
|
|
null = 1;
|
|
null = 1;
|
|
assoclen = 0;
|
|
assoclen = 0;
|
|
}
|
|
}
|
|
- dst_size = assoclen + req->cryptlen + (op_type ? -authsize :
|
|
|
|
- authsize);
|
|
|
|
error = chcr_aead_common_init(req, op_type);
|
|
error = chcr_aead_common_init(req, op_type);
|
|
if (error)
|
|
if (error)
|
|
return ERR_PTR(error);
|
|
return ERR_PTR(error);
|
|
- if (dst_size) {
|
|
|
|
dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0);
|
|
dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0);
|
|
dnents += sg_nents_xlen(req->dst, req->cryptlen +
|
|
dnents += sg_nents_xlen(req->dst, req->cryptlen +
|
|
(op_type ? -authsize : authsize), CHCR_DST_SG_SIZE,
|
|
(op_type ? -authsize : authsize), CHCR_DST_SG_SIZE,
|
|
req->assoclen);
|
|
req->assoclen);
|
|
dnents += MIN_AUTH_SG; // For IV
|
|
dnents += MIN_AUTH_SG; // For IV
|
|
- } else {
|
|
|
|
- dnents = 0;
|
|
|
|
- }
|
|
|
|
|
|
|
|
dst_size = get_space_for_phys_dsgl(dnents);
|
|
dst_size = get_space_for_phys_dsgl(dnents);
|
|
kctx_len = (ntohl(KEY_CONTEXT_CTX_LEN_V(aeadctx->key_ctx_hdr)) << 4)
|
|
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,
|
|
sub_type = get_aead_subtype(tfm);
|
|
sub_type = get_aead_subtype(tfm);
|
|
if (sub_type == CRYPTO_ALG_SUB_TYPE_AEAD_RFC4309)
|
|
if (sub_type == CRYPTO_ALG_SUB_TYPE_AEAD_RFC4309)
|
|
assoclen -= 8;
|
|
assoclen -= 8;
|
|
- dst_size = assoclen + req->cryptlen + (op_type ? -authsize :
|
|
|
|
- authsize);
|
|
|
|
error = chcr_aead_common_init(req, op_type);
|
|
error = chcr_aead_common_init(req, op_type);
|
|
if (error)
|
|
if (error)
|
|
return ERR_PTR(error);
|
|
return ERR_PTR(error);
|
|
@@ -2698,15 +2690,11 @@ static struct sk_buff *create_aead_ccm_wr(struct aead_request *req,
|
|
error = aead_ccm_validate_input(op_type, req, aeadctx, sub_type);
|
|
error = aead_ccm_validate_input(op_type, req, aeadctx, sub_type);
|
|
if (error)
|
|
if (error)
|
|
goto err;
|
|
goto err;
|
|
- if (dst_size) {
|
|
|
|
- dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0);
|
|
|
|
- dnents += sg_nents_xlen(req->dst, req->cryptlen
|
|
|
|
- + (op_type ? -authsize : authsize),
|
|
|
|
- CHCR_DST_SG_SIZE, req->assoclen);
|
|
|
|
- dnents += MIN_CCM_SG; // For IV and B0
|
|
|
|
- } else {
|
|
|
|
- dnents = 0;
|
|
|
|
- }
|
|
|
|
|
|
+ dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0);
|
|
|
|
+ dnents += sg_nents_xlen(req->dst, req->cryptlen
|
|
|
|
+ + (op_type ? -authsize : authsize),
|
|
|
|
+ CHCR_DST_SG_SIZE, req->assoclen);
|
|
|
|
+ dnents += MIN_CCM_SG; // For IV and B0
|
|
dst_size = get_space_for_phys_dsgl(dnents);
|
|
dst_size = get_space_for_phys_dsgl(dnents);
|
|
kctx_len = ((DIV_ROUND_UP(aeadctx->enckey_len, 16)) << 4) * 2;
|
|
kctx_len = ((DIV_ROUND_UP(aeadctx->enckey_len, 16)) << 4) * 2;
|
|
transhdr_len = CIPHER_TRANSHDR_SIZE(kctx_len, dst_size);
|
|
transhdr_len = CIPHER_TRANSHDR_SIZE(kctx_len, dst_size);
|
|
@@ -2801,19 +2789,14 @@ static struct sk_buff *create_gcm_wr(struct aead_request *req,
|
|
assoclen = req->assoclen - 8;
|
|
assoclen = req->assoclen - 8;
|
|
|
|
|
|
reqctx->b0_dma = 0;
|
|
reqctx->b0_dma = 0;
|
|
- dst_size = assoclen + req->cryptlen + (op_type ? -authsize : authsize);
|
|
|
|
error = chcr_aead_common_init(req, op_type);
|
|
error = chcr_aead_common_init(req, op_type);
|
|
- if (error)
|
|
|
|
- return ERR_PTR(error);
|
|
|
|
- if (dst_size) {
|
|
|
|
- dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0);
|
|
|
|
- dnents += sg_nents_xlen(req->dst,
|
|
|
|
- req->cryptlen + (op_type ? -authsize : authsize),
|
|
|
|
|
|
+ if (error)
|
|
|
|
+ return ERR_PTR(error);
|
|
|
|
+ dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0);
|
|
|
|
+ dnents += sg_nents_xlen(req->dst, req->cryptlen +
|
|
|
|
+ (op_type ? -authsize : authsize),
|
|
CHCR_DST_SG_SIZE, req->assoclen);
|
|
CHCR_DST_SG_SIZE, req->assoclen);
|
|
- dnents += MIN_GCM_SG; // For IV
|
|
|
|
- } else {
|
|
|
|
- dnents = 0;
|
|
|
|
- }
|
|
|
|
|
|
+ dnents += MIN_GCM_SG; // For IV
|
|
dst_size = get_space_for_phys_dsgl(dnents);
|
|
dst_size = get_space_for_phys_dsgl(dnents);
|
|
kctx_len = ((DIV_ROUND_UP(aeadctx->enckey_len, 16)) << 4) +
|
|
kctx_len = ((DIV_ROUND_UP(aeadctx->enckey_len, 16)) << 4) +
|
|
AEAD_H_SIZE;
|
|
AEAD_H_SIZE;
|
|
@@ -2850,10 +2833,10 @@ static struct sk_buff *create_gcm_wr(struct aead_request *req,
|
|
chcr_req->sec_cpl.aadstart_cipherstop_hi = FILL_SEC_CPL_CIPHERSTOP_HI(
|
|
chcr_req->sec_cpl.aadstart_cipherstop_hi = FILL_SEC_CPL_CIPHERSTOP_HI(
|
|
assoclen ? 1 : 0, assoclen,
|
|
assoclen ? 1 : 0, assoclen,
|
|
assoclen + IV + 1, 0);
|
|
assoclen + IV + 1, 0);
|
|
- chcr_req->sec_cpl.cipherstop_lo_authinsert =
|
|
|
|
|
|
+ chcr_req->sec_cpl.cipherstop_lo_authinsert =
|
|
FILL_SEC_CPL_AUTHINSERT(0, assoclen + IV + 1,
|
|
FILL_SEC_CPL_AUTHINSERT(0, assoclen + IV + 1,
|
|
temp, temp);
|
|
temp, temp);
|
|
- chcr_req->sec_cpl.seqno_numivs =
|
|
|
|
|
|
+ chcr_req->sec_cpl.seqno_numivs =
|
|
FILL_SEC_CPL_SCMD0_SEQNO(op_type, (op_type ==
|
|
FILL_SEC_CPL_SCMD0_SEQNO(op_type, (op_type ==
|
|
CHCR_ENCRYPT_OP) ? 1 : 0,
|
|
CHCR_ENCRYPT_OP) ? 1 : 0,
|
|
CHCR_SCMD_CIPHER_MODE_AES_GCM,
|
|
CHCR_SCMD_CIPHER_MODE_AES_GCM,
|