Skip to content

Commit

Permalink
crypto/qat: fix NULL algorithm digest placement
Browse files Browse the repository at this point in the history
[ upstream commit 8b4618a ]

QAT HW generates bytes of 0x00 digest, even when a digest of len 0 is
requested for NULL. This caused test failures when the test vector had
digest len 0, as the buffer has unexpected changed bytes.

By placing the digest into the cookie for NULL authentication,
the buffer remains unchanged as expected, and the digest
is placed to the side, as it won't be used anyway.

Fixes: db0e952 ("crypto/qat: add NULL capability")

Signed-off-by: Ciara Power <[email protected]>
  • Loading branch information
ciarapow authored and kevintraynor committed Nov 16, 2023
1 parent d3eaf07 commit 75d383a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/crypto/qat/qat_sym.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,

}
min_ofs = auth_ofs;

if (ctx->qat_hash_alg != ICP_QAT_HW_AUTH_ALGO_NULL ||
ctx->auth_op == ICP_QAT_HW_AUTH_VERIFY)
if (ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_NULL)
auth_param->auth_res_addr = cookie->digest_null_phys_addr;
else
auth_param->auth_res_addr =
op->sym->auth.digest.phys_addr;

Expand Down
2 changes: 2 additions & 0 deletions drivers/crypto/qat/qat_sym.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ struct qat_sym_op_cookie {
phys_addr_t cd_phys_addr;
} spc_gmac;
} opt;
uint8_t digest_null[4];
phys_addr_t digest_null_phys_addr;
};

int
Expand Down
5 changes: 5 additions & 0 deletions drivers/crypto/qat/qat_sym_pmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ qat_sym_init_op_cookie(void *op_cookie)
rte_mempool_virt2iova(cookie) +
offsetof(struct qat_sym_op_cookie,
opt.spc_gmac.cd_cipher);

cookie->digest_null_phys_addr =
rte_mempool_virt2iova(cookie) +
offsetof(struct qat_sym_op_cookie,
digest_null);
}

static uint16_t
Expand Down

0 comments on commit 75d383a

Please sign in to comment.