From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 68950CF07 for ; Fri, 17 Jun 2016 13:18:45 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 17 Jun 2016 04:18:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,483,1459839600"; d="scan'208";a="123835091" Received: from sie-lab-212-116.ir.intel.com (HELO silpixa00378492.ir.intel.com) ([10.237.212.116]) by fmsmga004.fm.intel.com with ESMTP; 17 Jun 2016 04:18:42 -0700 From: Pablo de Lara To: dev@dpdk.org Cc: declan.doherty@intel.com, Pablo de Lara Date: Fri, 17 Jun 2016 12:24:47 +0100 Message-Id: <1466162692-24654-7-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1466162692-24654-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1462543429-26741-1-git-send-email-pablo.de.lara.guarch@intel.com> <1466162692-24654-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2 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: Fri, 17 Jun 2016 11:18:46 -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 --- 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