From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 947BFA24C for ; Mon, 20 Jun 2016 16:38:49 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 20 Jun 2016 07:38:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,499,1459839600"; d="scan'208";a="991434866" Received: from sie-lab-212-116.ir.intel.com (HELO silpixa00378492.ir.intel.com) ([10.237.212.116]) by fmsmga001.fm.intel.com with ESMTP; 20 Jun 2016 07:38:47 -0700 From: Pablo de Lara To: dev@dpdk.org Cc: declan.doherty@intel.com, deepak.k.jain@intel.com, Pablo de Lara Date: Mon, 20 Jun 2016 15:44:57 +0100 Message-Id: <1466433902-27644-7-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1466433902-27644-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1466414873-23506-1-git-send-email-pablo.de.lara.guarch@intel.com> <1466433902-27644-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v4 06/11] test: use new bit-level memcmp macro X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2016 14:38:50 -0000 Instead of modifying the content of the buffers, to compare them at bit-level, use the new macro TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT, which does not make any modifications in the buffers. Signed-off-by: Pablo de Lara Acked-by: Jain, Deepak K --- app/test/test_cryptodev.c | 68 +++++++++-------------------------------------- 1 file changed, 12 insertions(+), 56 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 3199d6e..3ff74cd 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -2387,8 +2387,6 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata) int retval; uint8_t *plaintext, *ciphertext; uint8_t plaintext_pad_len; - uint8_t lastByteValidBits = 8; - uint8_t lastByteMask = 0xFF; /* Create SNOW3G session */ retval = create_snow3g_cipher_session(ts_params->valid_devs[0], @@ -2434,19 +2432,13 @@ test_snow3g_encryption(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - lastByteValidBits = (tdata->validDataLenInBits.len % 8); - if (lastByteValidBits == 0) - lastByteValidBits = 8; - lastByteMask = lastByteMask << (8 - lastByteValidBits); - (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); /* Validate obuf */ - TEST_ASSERT_BUFFERS_ARE_EQUAL( + TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( ciphertext, tdata->ciphertext.data, - tdata->ciphertext.len >> 3, + tdata->validDataLenInBits.len, "Snow3G Ciphertext data not as expected"); return 0; } @@ -2461,8 +2453,6 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata) int retval; uint8_t plaintext_pad_len; - uint8_t lastByteValidBits = 8; - uint8_t lastByteMask = 0xFF; /* Create SNOW3G session */ retval = create_snow3g_cipher_session(ts_params->valid_devs[0], @@ -2519,19 +2509,13 @@ test_snow3g_encryption_oop(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - lastByteValidBits = (tdata->validDataLenInBits.len % 8); - if (lastByteValidBits == 0) - lastByteValidBits = 8; - lastByteMask = lastByteMask << (8 - lastByteValidBits); - (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask; - TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); /* Validate obuf */ - TEST_ASSERT_BUFFERS_ARE_EQUAL( + TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( ciphertext, tdata->ciphertext.data, - tdata->ciphertext.len >> 3, + tdata->validDataLenInBits.len, "Snow3G Ciphertext data not as expected"); return 0; } @@ -2546,8 +2530,6 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata) uint8_t *plaintext, *ciphertext; uint8_t ciphertext_pad_len; - uint8_t lastByteValidBits = 8; - uint8_t lastByteMask = 0xFF; /* Create SNOW3G session */ retval = create_snow3g_cipher_session(ts_params->valid_devs[0], @@ -2590,18 +2572,13 @@ static int test_snow3g_decryption(const struct snow3g_test_data *tdata) + tdata->iv.len; else plaintext = ciphertext; - lastByteValidBits = (tdata->validDataLenInBits.len % 8); - if (lastByteValidBits == 0) - lastByteValidBits = 8; - lastByteMask = lastByteMask << (8 - lastByteValidBits); - (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask; TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); /* Validate obuf */ - TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext, + TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext, tdata->plaintext.data, - tdata->plaintext.len >> 3, + tdata->validDataLenInBits.len, "Snow3G Plaintext data not as expected"); return 0; } @@ -2615,8 +2592,6 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata) uint8_t *plaintext, *ciphertext; uint8_t ciphertext_pad_len; - uint8_t lastByteValidBits = 8; - uint8_t lastByteMask = 0xFF; /* Create SNOW3G session */ retval = create_snow3g_cipher_session(ts_params->valid_devs[0], @@ -2673,18 +2648,13 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata) + tdata->iv.len; else plaintext = ciphertext; - lastByteValidBits = (tdata->validDataLenInBits.len % 8); - if (lastByteValidBits == 0) - lastByteValidBits = 8; - lastByteMask = lastByteMask << (8 - lastByteValidBits); - (*(plaintext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask; TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len); /* Validate obuf */ - TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext, + TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext, tdata->plaintext.data, - tdata->plaintext.len >> 3, + tdata->validDataLenInBits.len, "Snow3G Plaintext data not as expected"); return 0; } @@ -2699,8 +2669,6 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata) uint8_t *plaintext, *ciphertext; uint8_t plaintext_pad_len; - uint8_t lastByteValidBits = 8; - uint8_t lastByteMask = 0xFF; /* Create SNOW3G session */ retval = create_snow3g_cipher_auth_session(ts_params->valid_devs[0], @@ -2748,19 +2716,14 @@ test_snow3g_authenticated_encryption(const struct snow3g_test_data *tdata) + tdata->iv.len; else ciphertext = plaintext; - lastByteValidBits = (tdata->validDataLenInBits.len % 8); - if (lastByteValidBits == 0) - lastByteValidBits = 8; - lastByteMask = lastByteMask << (8-lastByteValidBits); - (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask; TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); /* Validate obuf */ - TEST_ASSERT_BUFFERS_ARE_EQUAL( + TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( ciphertext, tdata->ciphertext.data, - tdata->ciphertext.len >> 3, + tdata->validDataLenInBits.len, "Snow3G Ciphertext data not as expected"); ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) @@ -2784,8 +2747,6 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata) uint8_t *plaintext, *ciphertext; uint8_t plaintext_pad_len; - uint8_t lastByteValidBits = 8; - uint8_t lastByteMask = 0xFF; /* Create SNOW3G session */ retval = create_snow3g_auth_cipher_session(ts_params->valid_devs[0], @@ -2837,20 +2798,15 @@ test_snow3g_encrypted_authentication(const struct snow3g_test_data *tdata) else ciphertext = plaintext; - lastByteValidBits = (tdata->validDataLenInBits.len % 8); - if (lastByteValidBits == 0) - lastByteValidBits = 8; - lastByteMask = lastByteMask << (8-lastByteValidBits); - (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask; ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) + plaintext_pad_len + tdata->aad.len + tdata->iv.len; TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); /* Validate obuf */ - TEST_ASSERT_BUFFERS_ARE_EQUAL( + TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( ciphertext, tdata->ciphertext.data, - tdata->ciphertext.len >> 3, + tdata->validDataLenInBits.len, "Snow3G Ciphertext data not as expected"); /* Validate obuf */ -- 2.5.0