diff mbox series

test/crypto: fix auth-cipher compare length in oop

Message ID 20210504141941.25098-1-kai.ji@intel.com (mailing list archive)
State Accepted
Delegated to: akhil goyal
Headers show
Series test/crypto: fix auth-cipher compare length in oop | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing fail Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/github-robot success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/checkpatch success coding style OK

Commit Message

Kai Ji May 4, 2021, 2:19 p.m. UTC
For out-of-place operations, comparing expected ciphertext with
the operation result should skip cipher_offset bytes, as those
will not be copied from source to the destination buffer, making
the tests fail.

Fixes: 02ed7b3871d6 ("test/crypto: add SNOW3G test cases for auth-cipher")
Cc: damianx.nowak@intel.com

Signed-off-by: Kai Ji <kai.ji@intel.com>
Signed-off-by: Damian Nowak <damianx.nowak@intel.com>
---
 app/test/test_cryptodev.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

Comments

Zhang, Roy Fan May 4, 2021, 4:10 p.m. UTC | #1
> -----Original Message-----
> From: Ji, Kai <kai.ji@intel.com>
> Sent: Tuesday, May 4, 2021 3:20 PM
> To: dev@dpdk.org
> Cc: damianx.nowak@intel.com; Zhang, Roy Fan <roy.fan.zhang@intel.com>;
> Ji, Kai <kai.ji@intel.com>
> Subject: [dpdk-dev] test/crypto: fix auth-cipher compare length in oop
> 
> For out-of-place operations, comparing expected ciphertext with
> the operation result should skip cipher_offset bytes, as those
> will not be copied from source to the destination buffer, making
> the tests fail.
> 
> Fixes: 02ed7b3871d6 ("test/crypto: add SNOW3G test cases for auth-cipher")
> Cc: damianx.nowak@intel.com
> 
> Signed-off-by: Kai Ji <kai.ji@intel.com>
> Signed-off-by: Damian Nowak <damianx.nowak@intel.com>
> ---
>  app/test/test_cryptodev.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 

Welcome Kai! 

Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
Akhil Goyal May 5, 2021, 3:14 p.m. UTC | #2
> > Subject: [dpdk-dev] test/crypto: fix auth-cipher compare length in oop
> >
> > For out-of-place operations, comparing expected ciphertext with
> > the operation result should skip cipher_offset bytes, as those
> > will not be copied from source to the destination buffer, making
> > the tests fail.
> >
> > Fixes: 02ed7b3871d6 ("test/crypto: add SNOW3G test cases for auth-
> cipher")
> > Cc: damianx.nowak@intel.com
> >
> > Signed-off-by: Kai Ji <kai.ji@intel.com>
> > Signed-off-by: Damian Nowak <damianx.nowak@intel.com>
> > ---
> >  app/test/test_cryptodev.c | 24 ++++++++++++++++--------
> >  1 file changed, 16 insertions(+), 8 deletions(-)
> >
> 
> Welcome Kai!
> 
> Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

Applied to dpdk-next-crypto

Thanks.
PS. This patch was posted twice without superseding. Please take care next time to avoid confusion.
diff mbox series

Patch

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 70bf6fe2c..d6956f9c2 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -4200,16 +4200,20 @@  test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
 
 	/* Validate obuf */
 	if (verify) {
-		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
+		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
 			plaintext,
 			tdata->plaintext.data,
-			tdata->plaintext.len >> 3,
+			(tdata->plaintext.len - tdata->cipher.offset_bits -
+			 (tdata->digest.len << 3)),
+			tdata->cipher.offset_bits,
 			"SNOW 3G Plaintext data not as expected");
 	} else {
-		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
+		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
 			ciphertext,
 			tdata->ciphertext.data,
-			tdata->validDataLenInBits.len,
+			(tdata->validDataLenInBits.len -
+			 tdata->cipher.offset_bits),
+			tdata->cipher.offset_bits,
 			"SNOW 3G Ciphertext data not as expected");
 
 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -4397,16 +4401,20 @@  test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
 
 	/* Validate obuf */
 	if (verify) {
-		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
+		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
 			plaintext,
 			tdata->plaintext.data,
-			tdata->plaintext.len >> 3,
+			(tdata->plaintext.len - tdata->cipher.offset_bits -
+			 (tdata->digest.len << 3)),
+			tdata->cipher.offset_bits,
 			"SNOW 3G Plaintext data not as expected");
 	} else {
-		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
+		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
 			ciphertext,
 			tdata->ciphertext.data,
-			tdata->validDataLenInBits.len,
+			(tdata->validDataLenInBits.len -
+			 tdata->cipher.offset_bits),
+			tdata->cipher.offset_bits,
 			"SNOW 3G Ciphertext data not as expected");
 
 		TEST_ASSERT_BUFFERS_ARE_EQUAL(