From 22918d8400dc9e69ce889aed03066c4547e3fae6 Mon Sep 17 00:00:00 2001 From: Dana Vardi Date: Thu, 1 Jul 2021 09:58:12 +0300 Subject: [PATCH] crypto/mvsam: fix AES-GCM session parameters For AEAD session and AES-GCM mode, IV offset will set to include the Nonce. In addition, the following operations order will define: first encryption and then authentication. Fixes: 8a61c83af2fa ("crypto/mrvl: add mrvl crypto driver") Cc: stable@dpdk.org Signed-off-by: Dana Vardi Reviewed-by: Liron Himi Tested-by: Liron Himi --- drivers/crypto/mvsam/rte_mrvl_pmd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c index b2cfa710f5..ba5cb28654 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c @@ -360,6 +360,14 @@ mrvl_crypto_set_aead_session_parameters(struct mrvl_crypto_session *sess, sess->sam_sess_params.cipher_mode = aead_map[aead_xform->aead.algo].cipher_mode; + if (sess->sam_sess_params.cipher_mode == SAM_CIPHER_GCM) { + /* IV must include nonce for all counter modes */ + sess->cipher_iv_offset = aead_xform->cipher.iv.offset; + + /* Set order of authentication then encryption to 0 in GCM */ + sess->sam_sess_params.u.basic.auth_then_encrypt = 0; + } + /* Assume IV will be passed together with data. */ sess->sam_sess_params.cipher_iv = NULL; -- 2.20.1