Digest size for CCM was being checked for other algorithms apart from CCM. Fixes: c4c0c312a823 ("crypto/aesni_mb: check for invalid digest size") Cc: sta...@dpdk.org
Signed-off-by: Pablo de Lara <pablo.de.lara.gua...@intel.com> --- Changes: This patchset depends on series http://patches.dpdk.org/project/dpdk/list/?series=12820. -v2 : rebased on top of crypto subtree --- drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c index 34a39ca99..ba2882d27 100644 --- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c +++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c @@ -661,6 +661,14 @@ aesni_mb_set_session_aead_parameters(const MB_MGR *mb_mgr, return -EINVAL; } + /* Set IV parameters */ + sess->iv.offset = xform->aead.iv.offset; + sess->iv.length = xform->aead.iv.length; + + /* Set digest sizes */ + sess->auth.req_digest_len = xform->aead.digest_length; + sess->auth.gen_digest_len = sess->auth.req_digest_len; + switch (xform->aead.algo) { case RTE_CRYPTO_AEAD_AES_CCM: sess->cipher.mode = CCM; @@ -679,6 +687,13 @@ aesni_mb_set_session_aead_parameters(const MB_MGR *mb_mgr, return -EINVAL; } + /* CCM digests must be between 4 and 16 and an even number */ + if (sess->auth.req_digest_len < AES_CCM_DIGEST_MIN_LEN || + sess->auth.req_digest_len > AES_CCM_DIGEST_MAX_LEN || + (sess->auth.req_digest_len & 1) == 1) { + AESNI_MB_LOG(ERR, "Invalid digest size\n"); + return -EINVAL; + } break; case RTE_CRYPTO_AEAD_AES_GCM: @@ -713,20 +728,6 @@ aesni_mb_set_session_aead_parameters(const MB_MGR *mb_mgr, return -ENOTSUP; } - /* Set IV parameters */ - sess->iv.offset = xform->aead.iv.offset; - sess->iv.length = xform->aead.iv.length; - - sess->auth.req_digest_len = xform->aead.digest_length; - /* CCM digests must be between 4 and 16 and an even number */ - if (sess->auth.req_digest_len < AES_CCM_DIGEST_MIN_LEN || - sess->auth.req_digest_len > AES_CCM_DIGEST_MAX_LEN || - (sess->auth.req_digest_len & 1) == 1) { - AESNI_MB_LOG(ERR, "Invalid digest size\n"); - return -EINVAL; - } - sess->auth.gen_digest_len = sess->auth.req_digest_len; - return 0; } -- 2.25.1