From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 2F5762BEF for ; Sun, 18 Sep 2016 05:22:20 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 17 Sep 2016 20:22:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,354,1470726000"; d="scan'208";a="762664300" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 17 Sep 2016 20:22:18 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id u8I3MGwT011645; Sun, 18 Sep 2016 11:22:16 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u8I3MDYq006949; Sun, 18 Sep 2016 11:22:15 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id u8I3MDUP006945; Sun, 18 Sep 2016 11:22:13 +0800 From: Marvin Liu To: dts@dpdk.org Cc: Marvin Liu Date: Sun, 18 Sep 2016 11:22:12 +0800 Message-Id: <1474168932-6913-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] tests l2fwd_crypto: add md5 hmac algorithm check X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Sep 2016 03:22:20 -0000 Support md5 hmac algorithm output hash value check. Reduce dut port requirement to only one port. When md5 hmac value is None, calculate it by hmac library. Signed-off-by: Marvin Liu diff --git a/tests/TestSuite_l2fwd_crypto.py b/tests/TestSuite_l2fwd_crypto.py index 0d6a52a..76f60ba 100644 --- a/tests/TestSuite_l2fwd_crypto.py +++ b/tests/TestSuite_l2fwd_crypto.py @@ -29,6 +29,10 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +import hmac +import hashlib +import binascii + import dts import time @@ -39,8 +43,8 @@ class TestL2fwdCrypto(TestCase): def set_up_all(self): - self.core_config = "1S/4C/1T" - self.number_of_ports = 2 + self.core_config = "1S/2C/1T" + self.number_of_ports = 1 self.dut_ports = self.dut.get_ports(self.nic) self.verify(len(self.dut_ports) >= self.number_of_ports, "Not enough ports for " + self.nic) @@ -54,11 +58,10 @@ class TestL2fwdCrypto(TestCase): self.core_mask = dts.create_mask(self.dut.get_core_list( self.core_config, socket=self.ports_socket)) - self.port_mask = dts.create_mask([self.dut_ports[0], - self.dut_ports[1]]) + self.port_mask = dts.create_mask([self.dut_ports[0]]) self.tx_port = self.tester.get_local_port(self.dut_ports[0]) - self.rx_port = self.tester.get_local_port(self.dut_ports[1]) + self.rx_port = self.tester.get_local_port(self.dut_ports[0]) self.tx_interface = self.tester.get_interface(self.tx_port) self.rx_interface = self.tester.get_interface(self.rx_port) @@ -77,6 +80,7 @@ class TestL2fwdCrypto(TestCase): self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=n$/CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y/' config/common_base", "# ") self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_SNOW3G=n$/CONFIG_RTE_LIBRTE_PMD_SNOW3G=y/' config/common_base", "# ") self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_KASUMI=n$/CONFIG_RTE_LIBRTE_PMD_KASUMI=y/' config/common_base", "# ") + self.dut.skip_setup = False self.dut.build_install_dpdk(self.dut.target) # l2fwd-crypto compile @@ -117,6 +121,28 @@ class TestL2fwdCrypto(TestCase): self.verify(result, True) + def test_qat_MD5(self): + """ + Validate MD5 HMAC digest with Intel QuickAssist device + """ + + result = True + + self.logger.info("Test qat_h_MD5_HMAC_01") + + # if output_hash not existed, calculate it automatically + vector = test_vectors['qat_h_MD5_HMAC_01'] + if not vector['output_hash']: + key = binascii.a2b_hex(vector['auth_key']) + msg = binascii.a2b_hex(vector['input']) + digest = hmac.new(key, msg, hashlib.md5).digest() + vector['output_hash'] = binascii.b2a_hex(digest) + + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_h_MD5_HMAC_01"): + result = False + self.verify(result, True) + def test_qat_SHA(self): result = True @@ -246,7 +272,7 @@ class TestL2fwdCrypto(TestCase): self.dut.send_expect(cmd_str, "==", 30) self.tester.send_expect("rm -rf %s.pcap" % (self.rx_interface), "#") - self.tester.send_expect("tcpdump -w %s.pcap -i %s &" % (self.rx_interface, self.rx_interface), "#") + self.tester.send_expect("tcpdump -P in -w %s.pcap -i %s &" % (self.rx_interface, self.rx_interface), "#") # Wait 5 sec for tcpdump stable time.sleep(5) @@ -483,6 +509,25 @@ test_vectors = { "output_hash": "", }, + "qat_h_MD5_HMAC_01": { + "vdev": "", + "chain": "HASH_ONLY", + "cdev_type": "ANY", + "cipher_algo": "", + "cipher_op": "", + "cipher_key": "", + "iv": "", + "auth_algo": "MD5_HMAC", + "auth_op": "GENERATE", + "auth_key": "000102030405060708090a0b0c0d0e0f", + "auth_key_random_size": "", + "aad": "", + "aad_random_size": "", + "input": "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000", + "output_cipher": "", + "output_hash": None + }, + "qat_h_SHA1_HMAC_01": { "vdev": "", "chain": "HASH_ONLY", -- 1.9.3