From: Ankur Dwivedi Date: Fri, 3 Jul 2020 05:41:37 +0000 (+0530) Subject: common/cpt: fix encryption offset X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=0058f30514f13e5d5412e97973a9c9254e36edb1;hp=d4a131a9498db198ad8ca31664da13dbb9cbbc6c;p=dpdk.git common/cpt: fix encryption offset In case of gmac auth the encryption offset should be set to zero. Fixes: b74652f3a91f ("common/cpt: add microcode interface for encryption") Fixes: 177b41ceee61 ("common/cpt: add microcode interface for decryption") Cc: stable@dpdk.org Signed-off-by: Ankur Dwivedi --- diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h index 34ccd08a40..ab595eb580 100644 --- a/drivers/common/cpt/cpt_ucode.h +++ b/drivers/common/cpt/cpt_ucode.h @@ -682,9 +682,6 @@ cpt_enc_hmac_prep(uint32_t flags, m_vaddr = (uint8_t *)m_vaddr + size; m_dma += size; - if (hash_type == GMAC_TYPE) - encr_data_len = 0; - if (unlikely(!(flags & VALID_IV_BUF))) { iv_len = 0; iv_offset = ENCR_IV_OFFSET(d_offs); @@ -716,6 +713,11 @@ cpt_enc_hmac_prep(uint32_t flags, opcode.s.major = CPT_MAJOR_OP_FC; opcode.s.minor = 0; + if (hash_type == GMAC_TYPE) { + encr_offset = 0; + encr_data_len = 0; + } + auth_dlen = auth_offset + auth_data_len; enc_dlen = encr_data_len + encr_offset; if (unlikely(encr_data_len & 0xf)) { @@ -726,11 +728,6 @@ cpt_enc_hmac_prep(uint32_t flags, enc_dlen = ROUNDUP16(encr_data_len) + encr_offset; } - if (unlikely(hash_type == GMAC_TYPE)) { - encr_offset = auth_dlen; - enc_dlen = 0; - } - if (unlikely(auth_dlen > enc_dlen)) { inputlen = auth_dlen; outputlen = auth_dlen + mac_len; @@ -1033,9 +1030,6 @@ cpt_dec_hmac_prep(uint32_t flags, hash_type = cpt_ctx->hash_type; mac_len = cpt_ctx->mac_len; - if (hash_type == GMAC_TYPE) - encr_data_len = 0; - if (unlikely(!(flags & VALID_IV_BUF))) { iv_len = 0; iv_offset = ENCR_IV_OFFSET(d_offs); @@ -1092,6 +1086,11 @@ cpt_dec_hmac_prep(uint32_t flags, opcode.s.major = CPT_MAJOR_OP_FC; opcode.s.minor = 1; + if (hash_type == GMAC_TYPE) { + encr_offset = 0; + encr_data_len = 0; + } + enc_dlen = encr_offset + encr_data_len; auth_dlen = auth_offset + auth_data_len; @@ -1103,9 +1102,6 @@ cpt_dec_hmac_prep(uint32_t flags, outputlen = enc_dlen; } - if (hash_type == GMAC_TYPE) - encr_offset = inputlen; - vq_cmd_w0.u64 = 0; vq_cmd_w0.s.param1 = encr_data_len; vq_cmd_w0.s.param2 = auth_data_len;