[dpdk-dev] examples/l2fwd-crypto: fix AEAD tests when AAD is zero

Message ID 1492431817-50565-1-git-send-email-pablo.de.lara.guarch@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Pablo de Lara Guarch
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

De Lara Guarch, Pablo April 17, 2017, 12:23 p.m. UTC
  For AEAD algorithms, additional authenticated data (AAD)
can be passed, but it is optional, so its size can be zero.
However, it is required to set this length to zero in the crypto
operation to avoid undefined behaviour.

Fixes: 617a7949c98a ("examples/l2fwd-crypto: parse AAD parameter")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 examples/l2fwd-crypto/main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Comments

De Lara Guarch, Pablo April 18, 2017, 8:45 p.m. UTC | #1
> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Monday, April 17, 2017 1:24 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; De Lara Guarch, Pablo
> Subject: [PATCH] examples/l2fwd-crypto: fix AEAD tests when AAD is zero
> 
> For AEAD algorithms, additional authenticated data (AAD)
> can be passed, but it is optional, so its size can be zero.
> However, it is required to set this length to zero in the crypto
> operation to avoid undefined behaviour.
> 
> Fixes: 617a7949c98a ("examples/l2fwd-crypto: parse AAD parameter")
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Applied to dpdk-next-crypto.

Pablo
  

Patch

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 15fab10..2eb14c1 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -470,6 +470,10 @@  l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
 			op->sym->auth.aad.data = cparams->aad.data;
 			op->sym->auth.aad.phys_addr = cparams->aad.phys_addr;
 			op->sym->auth.aad.length = cparams->aad.length;
+		} else {
+			op->sym->auth.aad.data = NULL;
+			op->sym->auth.aad.phys_addr = 0;
+			op->sym->auth.aad.length = 0;
 		}
 	}
 
@@ -670,7 +674,8 @@  l2fwd_main_loop(struct l2fwd_crypto_options *options)
 					generate_random_key(port_cparams[i].aad.data,
 						port_cparams[i].aad.length);
 
-			}
+			} else
+				port_cparams[i].aad.length = 0;
 
 			if (options->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY)
 				port_cparams[i].hash_verify = 1;