From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 7D347558D for ; Fri, 13 Jan 2017 02:05:38 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP; 12 Jan 2017 17:05:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,220,1477983600"; d="scan'208";a="1082384805" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.240.176.135]) by orsmga001.jf.intel.com with ESMTP; 12 Jan 2017 17:05:35 -0800 From: zhaoyanc To: dts@dpdk.org Cc: "Chen, Zhaoyan" Date: Fri, 13 Jan 2017 09:06:30 +0800 Message-Id: <1484269590-42853-1-git-send-email-zhaoyan.chen@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH] Enhanced cryptodev test cases to generate test data automatically and new unit test cases 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: Fri, 13 Jan 2017 01:05:41 -0000 From: "Chen, Zhaoyan" --- test_plans/unit_tests_cryptodev_test_plan.rst | 1 + tests/TestSuite_l2fwd_crypto.py | 2040 +++++++++++++++++++++---- tests/TestSuite_unit_tests_cryptodev.py | 172 +++ 3 files changed, 1889 insertions(+), 324 deletions(-) create mode 100755 test_plans/unit_tests_cryptodev_test_plan.rst create mode 100644 tests/TestSuite_unit_tests_cryptodev.py diff --git a/test_plans/unit_tests_cryptodev_test_plan.rst b/test_plans/unit_tests_cryptodev_test_plan.rst new file mode 100755 index 0000000..72943a1 --- /dev/null +++ b/test_plans/unit_tests_cryptodev_test_plan.rst @@ -0,0 +1 @@ +aaa diff --git a/tests/TestSuite_l2fwd_crypto.py b/tests/TestSuite_l2fwd_crypto.py index 9c78a6f..e2e8862 100644 --- a/tests/TestSuite_l2fwd_crypto.py +++ b/tests/TestSuite_l2fwd_crypto.py @@ -32,12 +32,14 @@ import hmac import hashlib import binascii - -import utils import time - +import os +import sys +import utils +import commands from test_case import TestCase - +from CryptoMobile.CM import * class TestL2fwdCrypto(TestCase): @@ -71,15 +73,19 @@ class TestL2fwdCrypto(TestCase): self.logger.info("tx interface = " + self.tx_interface) self.logger.info("rx interface = " + self.rx_interface) - # Rebuild the dpdk with cryptodev pmds + # Rebuild the dpdk with cryptodev pmds CONFIG_RTE_LIBRTE_PMD_ZUC=n self.dut.send_expect("export AESNI_MULTI_BUFFER_LIB_PATH=/root/ipsec_043/code/", "#") self.dut.send_expect("export LIBSSO_SNOW3G_PATH=/root/libsso_snow3g/snow3g/", "#") + self.dut.send_expect("export LIBSSO_ZUC_PATH=/root/libsso_zuc.1.0.1.1-8/zuc", "#") self.dut.send_expect("export LIBSSO_KASUMI_PATH=/root/LibSSO_0_3_1/isg_cid-wireless_libs/ciphers/kasumi/", "#") self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_QAT=n$/CONFIG_RTE_LIBRTE_PMD_QAT=y/' config/common_base", "# ") self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_AESNI_GCM=n$/CONFIG_RTE_LIBRTE_PMD_AESNI_GCM=y/' config/common_base", "# ") 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.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_OPENSSL=n$/CONFIG_RTE_LIBRTE_PMD_OPENSSL=y/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n$/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=y/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_ZUC=n$/CONFIG_RTE_LIBRTE_PMD_ZUC=y/' config/common_base", "# ") self.dut.skip_setup = False self.dut.build_install_dpdk(self.dut.target) @@ -100,262 +106,527 @@ class TestL2fwdCrypto(TestCase): def set_up(self): pass - def test_qat_AES(self): + def test_qat_AES_CBC_auto(self): + result = True + self.logger.info("Test qat_c_AES_CBC_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_c_AES_CBC_00"): + result = False + + def test_qat_AES_CTR_auto(self): + result = True + self.logger.info("Test qat_c_AES_CTR_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_c_AES_CTR_00"): + result = False + + def test_qat_AES_GCM_auto(self): + result = True + self.logger.info("Test qat_c_AES_GCM_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_c_AES_GCM_00"): + result = False + + def test_qat_h_MD_SHA_auto(self): + result = True + self.logger.info("Test qat_h_MD_SHA_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_h_MD_SHA_00"): + result = False + + def test_qat_h_AES_XCBC_MAC_auto(self): + result = True + self.logger.info("Test qat_h_AES_XCBC_MAC_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_h_AES_XCBC_MAC_01"): + result = False + + def test_qat_3DES_CBC_auto(self): + result = True + self.logger.info("Test qat_c_3DES_CBC_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_c_3DES_CBC_00"): + result = False + + def test_qat_3DES_CTR_auto(self): + result = True + self.logger.info("Test qat_c_3DES_CTR_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_c_3DES_CTR_00"): + result = False + + def test_qat_AES_GCM_AES_GCM(self): result = True - self.logger.info("Test qat_c_AES_CBC_01") + self.logger.info("Test qat_ch_AES_GCM_AES_GCM_01") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_c_AES_CBC_01"): + test_vectors, "qat_ch_AES_GCM_AES_GCM_01"): result = False - self.logger.info("Test qat_c_AES_CTR_01") + def test_qat_SNOW3G_auto(self): + + result = True + + self.logger.info("Test qat_c_UEA2_01") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_c_AES_CTR_01"): + test_vectors, "qat_c_UEA2_01"): result = False - self.logger.info("Test qat_c_AES_GCM_01") + self.logger.info("Test qat_h_UIA2_01") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_c_AES_GCM_01"): + test_vectors, "qat_h_UIA2_01"): result = False - + self.verify(result, True) - - def test_qat_MD5(self): - """ - Validate MD5 HMAC digest with Intel QuickAssist device - """ + + def test_qat_KASUMI_auto(self): result = True + self.logger.info("Test qat_kasumi_c_F8_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_kasumi_c_F8_01"): + result = False - self.logger.info("Test qat_h_MD5_HMAC_01") + self.logger.info("Test qat_kasumi_h_F9_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_kasumi_h_F9_01"): + result = False - # 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) + self.verify(result, True) + + def test_qat_c_NULL_auto(self): + result = True + + self.logger.info("Test qat_c_NULL_auto") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_h_MD5_HMAC_01"): + test_vectors, "null_c_NULL_auto"): result = False - self.verify(result, True) - def test_qat_SHA(self): + self.verify(result, True) + + def test_qat_h_NULL_auto(self): result = True - self.logger.info("Test qat_h_SHA1_HMAC_01") + self.logger.info("Test qat_h_NULL_auto") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_h_SHA1_HMAC_01"): + test_vectors, "qat_h_NULL_auto"): result = False - self.logger.info("Test qat_h_SHA224_HMAC_01") + self.verify(result, True) + + def test_aesni_mb_AES_CBC_auto(self): + result = True + self.logger.info("Test aesni_mb_c_AES_CBC_00") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_h_SHA224_HMAC_01"): + test_vectors, "aesni_mb_c_AES_CBC_00"): result = False + + def test_aesni_mb_AES_CTR_auto(self): + result = True + self.logger.info("Test aesni_mb_c_AES_CTR_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "aesni_mb_c_AES_CTR_00"): + result = False + + def test_aesni_AES_GCM_AES_GCM(self): - self.logger.info("Test qat_h_SHA256_HMAC_01") + result = True + import pdb + pdb.set_trace() + self.logger.info("Test aesni_gcm_ch_AES_GCM_AES_GCM_01") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_h_SHA256_HMAC_01"): + test_vectors, "aesni_gcm_ch_AES_GCM_AES_GCM_01"): result = False - self.logger.info("Test qat_h_SHA384_HMAC_01") + self.verify(result, True) + + def test_kasumi_KASUMI_auto(self): + + result = True + self.logger.info("Test kasumi_c_F8_01") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_h_SHA384_HMAC_01"): + test_vectors, "kasumi_c_F8_01"): result = False - self.logger.info("Test qat_h_SHA512_HMAC_01") + self.logger.info("Test kasumi_h_F9_01") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_h_SHA512_HMAC_01"): + test_vectors, "kasumi_h_F9_01"): result = False self.verify(result, True) - - def test_qat_AES_XCBC_MAC(self): + + def test_null_NULL_CIPHER(self): result = True - - self.logger.info("Test qat_h_AES_XCBC_MAC_01") + self.logger.info("Test null_c_NULL_auto") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_h_AES_XCBC_MAC_01"): + test_vectors, "null_c_NULL_auto"): result = False self.verify(result, True) - - def test_qat_SNOW3G(self): + + def test_null_NULL_HASH(self): result = True - self.logger.info("Test qat_c_UEA2_01") + self.logger.info("Test null_h_NULL_auto") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_c_UEA2_01"): + test_vectors, "null_h_NULL_auto"): result = False - self.logger.info("Test qat_h_UIA2_01") + self.verify(result, True) + + def test_null_c_NULL_auto(self): + + result = True + + self.logger.info("Test null_c_NULL_auto") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_h_UIA2_01"): + test_vectors, "null_c_NULL_auto"): result = False self.verify(result, True) - - def test_qat_AES_GCM_AES_GCM(self): + + def test_null_h_NULL_auto(self): result = True - self.logger.info("Test qat_ch_AES_GCM_AES_GCM_01") + self.logger.info("Test null_h_NULL_auto") if not self.__execute_l2fwd_crypto_test( - test_vectors, "qat_ch_AES_GCM_AES_GCM_01"): + test_vectors, "null_h_NULL_auto"): result = False self.verify(result, True) - def test_aesni_AES_GCM_AES_GCM(self): + + def test_snow3g_SNOW3G(self): result = True - self.logger.info("Test aesni_ch_AES_GCM_AES_GCM_01") + self.logger.info("Test snow3g_c_UEA2_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "snow3g_c_UEA2_01"): + result = False + + self.logger.info("Test snow3g_h_UIA2_01") if not self.__execute_l2fwd_crypto_test( - test_vectors, "aesni_ch_AES_GCM_AES_GCM_01"): + test_vectors, "snow3g_h_UIA2_01"): result = False self.verify(result, True) + + def test_zun_ZUC_auto(self): + + result = True + self.logger.info("Test zuc_c_EEA3_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "zuc_c_EEA3_01"): + result = False - def test_kasumi_KASUMI(self): + self.logger.info("Test zuc_h_EIA3_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "zuc_h_EIA3_01"): + result = False + + # openssl pmd cases + def test_openssl_3DES_CBC_auto(self): + result = True + self.logger.info("Test openssl_c_3DES_CBC_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "openssl_c_3DES_CBC_00"): + result = False + + def test_openssl_3DES_CTR_auto(self): + result = True + self.logger.info("Test openssl_c_3DES_CTR_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "openssl_c_3DES_CTR_00"): + result = False + + def test_openssl_AES_CBC_auto(self): + result = True + self.logger.info("Test openssl_c_AES_CBC_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "openssl_c_AES_CBC_00"): + result = False + + def test_openssl_AES_CTR_auto(self): + result = True + self.logger.info("Test openssl_c_AES_CTR_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "openssl_c_AES_CTR_00"): + result = False + + def test_openssl_AES_GCM_auto(self): + result = True + self.logger.info("Test openssl_c_AES_GCM_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "openssl_c_AES_GCM_00"): + result = False + + def test_openssl_h_MD_SHA_auto(self): + result = True + self.logger.info("Test openssl_h_MD_SHA_00") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "openssl_h_MD_SHA_00"): + result = False + + def test_qat_AES(self): result = True - self.logger.info("Test kasumi_c_F8_01") + self.logger.info("Test qat_c_AES_CBC_01") if not self.__execute_l2fwd_crypto_test( - test_vectors, "kasumi_c_F8_01"): + test_vectors, "qat_c_AES_CBC_01"): result = False - self.logger.info("Test kasumi_h_F9_01") + self.logger.info("Test qat_c_AES_CTR_01") if not self.__execute_l2fwd_crypto_test( - test_vectors, "kasumi_h_F9_01"): + test_vectors, "qat_c_AES_CTR_01"): + result = False + + self.logger.info("Test qat_c_AES_GCM_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_c_AES_GCM_01"): result = False self.verify(result, True) - def test_null_NULL(self): + def test_qat_MD5(self): + """ + Validate MD5 HMAC digest with Intel QuickAssist device + """ result = True - self.logger.info("Test null_c_NULL_01") + 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, "null_c_NULL_01"): + test_vectors, "qat_h_MD5_HMAC_01"): result = False - self.verify(result, True) - def test_snow3g_SNOW3G(self): + def test_qat_SHA(self): result = True - self.logger.info("Test snow3g_c_UEA2_01") + self.logger.info("Test qat_h_SHA1_HMAC_01") if not self.__execute_l2fwd_crypto_test( - test_vectors, "snow3g_c_UEA2_01"): + test_vectors, "qat_h_SHA1_HMAC_01"): result = False - self.logger.info("Test snow3g_h_UIA2_01") + self.logger.info("Test qat_h_SHA224_HMAC_01") if not self.__execute_l2fwd_crypto_test( - test_vectors, "snow3g_h_UIA2_01"): + test_vectors, "qat_h_SHA224_HMAC_01"): result = False - self.verify(result, True) - - def __execute_l2fwd_crypto_test(self, test_vectors, test_vector_name): - - if test_vector_name not in test_vectors: - self.logger.warn("SKIP : " + test_vector_name) - return True - - test_vector = test_vectors[test_vector_name] + self.logger.info("Test qat_h_SHA256_HMAC_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_h_SHA256_HMAC_01"): + result = False - result = True - cmd_str = self.__test_vector_to_cmd(test_vector, - core_mask=self.core_mask, - port_mask=self.port_mask) + self.logger.info("Test qat_h_SHA384_HMAC_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_h_SHA384_HMAC_01"): + result = False - self.dut.send_expect(cmd_str, "==", 30) + self.logger.info("Test qat_h_SHA512_HMAC_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_h_SHA512_HMAC_01"): + result = False - self.tester.send_expect("rm -rf %s.pcap" % (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) + self.verify(result, True) - payload = self.__format_hex_to_param(test_vector["input"], "\\x", "\\x") + def test_qat_AES_XCBC_MAC(self): - PACKET_COUNT = 65 + result = True - self.tester.scapy_foreground() - self.tester.scapy_append('sendp([Ether(src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/Raw(load=\"%s\")], iface="%s", count=%s)' % (payload, self.tx_interface, PACKET_COUNT)) + self.logger.info("Test qat_h_AES_XCBC_MAC_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "qat_h_AES_XCBC_MAC_01"): + result = False - self.tester.scapy_execute() + self.verify(result, True) - time.sleep(5) + def test_null_NULL(self): - self.tester.send_expect("killall tcpdump", "#") - self.tester.send_expect("^C", "#") + result = True - # Wait 5 secs for tcpdump exit - time.sleep(5) + self.logger.info("Test null_c_NULL_01") + if not self.__execute_l2fwd_crypto_test( + test_vectors, "null_c_NULL_01"): + result = False - self.tester.send_expect("scapy", ">>>") - self.tester.send_expect("p=rdpcap('%s.pcap', count=%s)" % (self.rx_interface, PACKET_COUNT), ">>>") + self.verify(result, True) + + def test_calculatr_case_number(self): + + self.__calculate_totall_cases_numb() + + def __calculate_totall_cases_numb(self): + alg_map = {} + pmd_map = {} + map_combine = {} + count = 0 + alg = "" + pmd = "" + alg_list = ["AES_CBC","AES_CTR","AES_GCM","3DES_CBC", \ + "3DES_CTR","SNOW3G","KASUMI","ZUC","NULL","MD_SHA"] + pmd_list = ["qat","aesni_mb","aesni_gcm","snow3g",\ + "kasumi","zuc","openssl","null"] + valid_map = { + "qat": ["AES_CBC", "AES_CTR","AES_GCM","3DES_CBC", \ + "3DES_CTR","SNOW3G","KASUMI","NULL","MD_SHA"], + "aesni_mb":["AES_CBC", "AES_CTR"], + "aesni_gcm":["AES_GCM"], + "snow3g":["SNOW3G"], + "kasumi":["KASUMI"], + "zuc":["ZUC"], + "openssl":["AES_CBC", "AES_CTR","AES_GCM","3DES_CBC","3DES_CTR","MD_SHA"], + "null":["NULL"] + } + + for index,value in test_vectors.iteritems(): + test_vector_list = self.__test_vector_to_vector_list(value, + core_mask="-1",port_mask=self.port_mask) + count = count + len(test_vector_list) + for i in alg_list: + alg = i + if (index.upper()).find(i) != -1: + if i in alg_map: + alg_map[i] += len(test_vector_list) + else: + alg_map[i] = len(test_vector_list) + for j in pmd_list: + pmd = j + if (index).find(i) != -1: + if i in pmd_map: + pmd_map[i] += len(test_vector_list) + else: + pmd_map[i] = len(test_vector_list) + if alg in valid_map[pmd]: + temp_str = pmd + "_" + alg + if temp_str in map_combine: + map_combine[temp_str] += len(test_vector_list) + else: + map_combine[temp_str] = len(test_vector_list) + for k,v in alg_map.iteritems(): + self.logger.info("Total {name} cases:\t\t\t{number}".format(name=k,number=v)) + for k,v in pmd_map.iteritems(): + self.logger.info("Total {name} cases:\t\t\t{number}".format(name=k,number=v)) + for k,v in map_combine.iteritems(): + self.logger.info("Total {name} cases:\t\t\t{number}".format(name=k,number=v)) + self.logger.info("Total cases:\t\t\t {0}".format(count)) + + + def __execute_l2fwd_crypto_test(self, test_vectors, test_vector_name): - hex_list = [] - for i in range(PACKET_COUNT): - cmd = "linehexdump(p[%s],onlyhex=1)" % i - hex_list.append(self.tester.send_expect(cmd, ">>>")) + if test_vector_name not in test_vectors: + self.logger.warn("SKIP : " + test_vector_name) + return True - # Exit the scapy - self.tester.send_expect("exit()", "#", 60) + test_vector = test_vectors[test_vector_name] - for hex_str in hex_list: - packet_hex = hex_str.split(" ") - # self.logger.info(hex_str) - # self.logger.info(packet_hex) + test_vector_list = self.__test_vector_to_vector_list(test_vector, + core_mask=self.core_mask, + port_mask=self.port_mask) - cipher_offset = 34 - cipher_length = len(test_vector["output_cipher"])/2 - if cipher_length == 0: - cipher_length = len(test_vector["input"])/2 - cipher_text = "".join(packet_hex[cipher_offset:cipher_offset+cipher_length]) - # self.logger.info("Cipher text in packet = " + cipher_text) - # self.logger.info("Ref Cipher text = " + test_vector["output_cipher"]) - if str.lower(cipher_text) == str.lower(test_vector["output_cipher"]): - self.logger.info("Cipher Matched.") - else: - if test_vector["output_cipher"] != "": - result = False - self.logger.info("Cipher NOT Matched.") - self.logger.info("Cipher text in packet = " + cipher_text) - self.logger.info("Ref Cipher text = " + test_vector["output_cipher"]) + result = True + self.logger.info("Total Generated {0} Tests".format(len(test_vector_list))) + for test_vector in test_vector_list: + self.logger.debug(test_vector) + cmd_str = self.__test_vector_to_cmd(test_vector, + core_mask=self.core_mask, + port_mask=self.port_mask) + self.dut.send_expect(cmd_str, "==", 30) + + self.tester.send_expect("rm -rf %s.pcap" % (self.rx_interface), "#") + self.tester.send_expect(self.__get_tcpdump_cmd(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) + + payload = self.__format_hex_to_param(test_vector["input"], "\\x", "\\x") + + PACKET_COUNT = 65 + + self.tester.scapy_foreground() + self.tester.scapy_append('sendp([Ether(src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/Raw(load=\"%s\")], iface="%s", count=%s)' % (payload, self.tx_interface, PACKET_COUNT)) + + self.tester.scapy_execute() + + time.sleep(5) + + self.tester.send_expect("killall tcpdump", "#") + self.tester.send_expect("^C", "#") + + # Wait 5 secs for tcpdump exit + time.sleep(5) + + self.tester.send_expect("scapy", ">>>") + self.tester.send_expect("p=rdpcap('%s.pcap', count=%s)" % (self.rx_interface, PACKET_COUNT), ">>>") + + hex_list = [] + for i in range(PACKET_COUNT): + cmd = "linehexdump(p[%s],onlyhex=1)" % i + hex_list.append(self.tester.send_expect(cmd, ">>>")) + + # Exit the scapy + self.tester.send_expect("exit()", "#", 60) + + for hex_str in hex_list: + packet_hex = hex_str.split(" ") + # self.logger.info(hex_str) + # self.logger.info(packet_hex) + + cipher_offset = 34 + cipher_length = len(test_vector["output_cipher"])/2 + if cipher_length == 0: + cipher_length = len(test_vector["input"])/2 + cipher_text = "".join(packet_hex[cipher_offset:cipher_offset+cipher_length]) + # self.logger.info("Cipher text in packet = " + cipher_text) + # self.logger.info("Ref Cipher text = " + test_vector["output_cipher"]) + if str.lower(cipher_text) == str.lower(test_vector["output_cipher"]): + self.logger.info("Cipher Matched.") else: - self.logger.info("Skip Cipher, Since no cipher text set") - - hash_offset = cipher_offset + cipher_length - hash_length = len(test_vector["output_hash"])/2 - if hash_length != 0: - hash_text = "".join(packet_hex[hash_offset:hash_offset+hash_length]) - # self.logger.info("Hash text in packet = " + hash_text) - # self.logger.info("Ref Hash text = " + test_vector["output_hash"]) - if str.lower(hash_text) == str.lower(test_vector["output_hash"]): - self.logger.info("Hash Matched") + if test_vector["output_cipher"] != "": + result = False + self.logger.info("Cipher NOT Matched.") + self.logger.info("Cipher text in packet = " + cipher_text) + self.logger.info("Ref Cipher text = " + test_vector["output_cipher"]) + else: + self.logger.info("Skip Cipher, Since no cipher text set") + + hash_offset = cipher_offset + cipher_length + hash_length = len(test_vector["output_hash"])/2 + if hash_length != 0: + hash_text = "".join(packet_hex[hash_offset:hash_offset+hash_length]) + # self.logger.info("Hash text in packet = " + hash_text) + # self.logger.info("Ref Hash text = " + test_vector["output_hash"]) + if str.lower(hash_text) == str.lower(test_vector["output_hash"]): + self.logger.info("Hash Matched") + else: + result = False + self.logger.info("Hash NOT Matched") + self.logger.info("Hash text in packet = " + hash_text) + self.logger.info("Ref Hash text = " + test_vector["output_hash"]) else: - result = False - self.logger.info("Hash NOT Matched") - self.logger.info("Hash text in packet = " + hash_text) - self.logger.info("Ref Hash text = " + test_vector["output_hash"]) - else: - self.logger.info("Skip Hash, Since no hash text set") + self.logger.info("Skip Hash, Since no hash text set") - # Close l2fwd-crypto - # self.dut.send_expect("killall -9 l2fwd-crypto", "# ", 15) - self.dut.send_expect("^C", "# ", 15) + # Close l2fwd-crypto + # self.dut.send_expect("killall -9 l2fwd-crypto", "# ", 15) + self.dut.send_expect("^C", "# ", 15) if result: self.logger.info("PASSED") @@ -373,11 +644,30 @@ class TestL2fwdCrypto(TestCase): self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y$/CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=n/' config/common_base", "# ") self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_SNOW3G=y$/CONFIG_RTE_LIBRTE_PMD_SNOW3G=n/' config/common_base", "# ") self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_KASUMI=y$/CONFIG_RTE_LIBRTE_PMD_KASUMI=n/' config/common_base", "# ") - + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_OPENSSL=y$/CONFIG_RTE_LIBRTE_PMD_OPENSSL=n/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=y$/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_ZUC=y$/CONFIG_RTE_LIBRTE_PMD_ZUC=n/' config/common_base", "# ") + + def __get_tcpdump_cmd(self,interface): + cmd = "" + + status, output = commands.getstatusoutput("tcpdump --version") + head = output.find('tcpdump version') + strlen = len("tcpdump version ") + tail = output.find("\nlibpcap version") + version = output[head + strlen : tail] + v = int(version.replace('.','')) + if v < 462 : + cmd = "".join("tcpdump -P in -w %s.pcap -i %s &"%(interface,interface)) + else: + cmd = "".join("tcpdump -Q in -w %s.pcap -i %s &"%(interface,interface)) + return cmd + def __test_vector_to_cmd(self, test_vector, core_mask="", port_mask=""): L2FWD_CRYPTO_APP = "./examples/l2fwd-crypto/build/app/l2fwd-crypto" EAL_CORE_MASK = " -cf" if core_mask == "" else " -c" + core_mask EAL_MM_CHANNEL = " -n4" + EAL_SOCKET_MEM = " --socket-mem=512,512 " EAL_SEP = " --" PORT_MASK = "" if port_mask == "" else " -p" + port_mask QUEUE_NUM = "" @@ -434,7 +724,7 @@ class TestL2fwdCrypto(TestCase): if self.__check_field_in_vector(test_vector, "aad_random_size"): aad_random_size = " --aad_random_size " + test_vector["aad_random_size"] - cmd_str = "".join([L2FWD_CRYPTO_APP, EAL_CORE_MASK, EAL_MM_CHANNEL, vdev, vdev, EAL_SEP, + cmd_str = "".join([L2FWD_CRYPTO_APP, EAL_CORE_MASK, EAL_MM_CHANNEL,EAL_SOCKET_MEM, vdev, vdev, EAL_SEP, PORT_MASK, QUEUE_NUM, chain, cdev_type, cipher_algo, cipher_op, cipher_key, iv, auth_algo, auth_op, auth_key, auth_key_random_size, aad, aad_random_size]) @@ -460,51 +750,1296 @@ class TestL2fwdCrypto(TestCase): return result -test_vectors = { + def __gen_input(self, length, pattern=None): + pattern = "11" + input_str = "" + for i in range(length): + input_str += pattern + return input_str + + def __gen_key(self, length, pattern=None, mask="000000"): + base_key = "000102030405060708090a0b0c0d0e0f" + key = "" + n = length // 16 + for i in range(n): + key = key + base_key + base_key = base_key[2:] + base_key[0:2] + m = length % 16 + key = key + base_key[0:2*m] + return key + + def __openssl_cipher(self, vector): + algo_map = { + "AES_CBC": { + 0: "-aes-128-cbc", + 16: "-aes-128-cbc", + 24: "-aes-192-cbc", + 32: "-aes-256-cbc", + }, + "AES_CTR": { + 0: "-aes-128-ctr", + 16: "-aes-128-ctr", + 24: "-aes-192-ctr", + 32: "-aes-256-ctr", + }, + "AES_GCM": { + 0: "-aes-128-gcm", + 16: "-aes-128-gcm", + 24: "-aes-192-gcm", + 32: "-aes-256-gcm", + }, + "3DES_CBC": { + 0: "-des-ede3-cbc", + 16: "-des-ede3-cbc", + 24: "-des-ede3-cbc", + }, + } + + bin_input = bytearray.fromhex(vector["input"]) + str_pid = str(os.getpid()) + input_filename = "cipher_input_{0}".format(str_pid) + output_filename = "cipher_output_{0}".format(str_pid) + with open(input_filename, "wb") as fv: + fv.write(bin_input) + cipher_algo = vector["cipher_algo"] + key_len = len(vector["cipher_key"])/2 + if cipher_algo in algo_map: + if key_len in algo_map[cipher_algo]: + openssl_algo = algo_map[cipher_algo][key_len] + else: + openssl_algo = algo_map[cipher_algo][0] + else: + raise "Openssl Not support this algo - " + cipher_algo + + openssl_cmd = "openssl enc {algo} -in {input_file} -out {output_file}"\ + + " -K {key} -iv {iv} -nosalt -nopad" + openssl_cmd = openssl_cmd.format( \ + algo = openssl_algo, \ + input_file = input_filename, \ + output_file = output_filename, \ + key = vector["cipher_key"], \ + iv = vector["iv"]) + if vector["cipher_op"] == "DECRYPT": + openssl_cmd += " -d" + + os.system(openssl_cmd) + + cipher_str = "" + with open(output_filename, "rb") as fv: + cipher_str = fv.read().encode("hex").upper() + + os.remove(input_filename) + os.remove(output_filename) + + return cipher_str + + def __CryptoMoble_cipher(self,vector): + # default is kasumi , kasumi alg we need to guarantee IV is :0001020304000000 + #so count is 66051 , dir =1 , bearer = 0 + #import pdb + #pdb.set_trace() + + cipher_str = "" + out_str = "" + cipher_algo = vector['cipher_algo'] + + mBitlen = 8 * (len(vector['input']) / 2) + bin_input = bytearray.fromhex(vector["input"]) + str_input = str(bin_input) + bin_key = binascii.a2b_hex(vector["cipher_key"]) + if ((cipher_algo.upper()).find("KASUMI") != -1): + vector["iv"] = vector["iv"][:10] + "000000" + out_str = UEA1(key=bin_key,count=66051, bearer=0, \ + dir=1,data=str_input,bitlen=mBitlen) + + elif ((cipher_algo.upper()).find("SNOW3G") != -1): + + vector["iv"] = "00000000000000000000000000000000" + out_str = UEA2(key=bin_key,count=0,bearer=0,dir=0, \ + data=str_input,bitlen=mBitlen) + + elif ((cipher_algo.upper()).find("ZUC") != -1): + vector["iv"] = "00010203040000000001020304000000" + out_str = EEA3(key=bin_key,count=0x10203,bearer=0,dir=1, \ + data=str_input,bitlen=mBitlen) + + cipher_str = out_str.encode("hex").upper() + + + return cipher_str + + def __gen_null_cipher_out(self,vector): + cipher_str = "" + if (vector['chain'] == "CIPHER_ONLY") or (vector['chain'] == "CIPHER_HASH"): + cipher_str = vector['input'] + elif (vector['chain'] == "HASH_CIPHER"): + cipher_str = vector['output_hash'] + return cipher_str + + def __gen_cipher_output(self, vector): + #import pdb + #pdb.set_trace() + if vector["chain"] == "HASH_ONLY": + vector["output_cipher"] == "" + return + + if vector["output_cipher"] != "*": + return + + cipher_str = "" + #### + if(((vector['cipher_algo']).upper()).find("KASUMI") != -1) or \ + (((vector['cipher_algo']).upper()).find("SNOW3G") != -1) or \ + (((vector['cipher_algo']).upper()).find("ZUC") != -1): + cipher_str = self.__CryptoMoble_cipher(vector) + elif (vector['cipher_algo'] == "NULL"): + cipher_str = self.__gen_null_cipher_out(vector) + else: + cipher_str = self.__openssl_cipher(vector) + vector["output_cipher"] = cipher_str.upper() + + def __gen_kasumi_hash(self,vector): + auth_str = "" + auth_algo = vector['auth_algo'] + mBitlen = 8 * (len(vector['input']) / 2) + bin_input = bytearray.fromhex(vector["input"]) + str_input = str(bin_input) + bin_key = binascii.a2b_hex(vector["auth_key"]) + + #vector["add"] = vector["add"][:6] + "000000" + #ADD IS 0001020304050607 + hash_out = UIA1(key=bin_key,count=0X10203, fresh=0X4050607,dir=0, \ + data=str_input) + auth_str = hash_out.encode("hex").upper() + + return auth_str + + def __gen_snow3g_hash(self,vector): + auth_str = "" + auth_algo = vector['auth_algo'] + mBitlen = 8 * (len(vector['input']) / 2) + bin_input = bytearray.fromhex(vector["input"]) + str_input = str(bin_input) + bin_key = binascii.a2b_hex(vector["auth_key"]) + #ADD IS 00010203040506070001020304050607 + vector["aad"] = "00000000000000000000000000000000" + #vector["aad"][:16] + vector["aad"][:16] + + hash_out = UIA2(key=bin_key,count=0, fresh=0,dir=0, \ + data=str_input) + + #hash_out = UIA2(key=bin_key,count=0x7060504, fresh=0x3020100,dir=0, \ + # data=str_input) + auth_str = hash_out.encode("hex").upper() + + return auth_str + + def __gen_zuc_hash(self,vector): + auth_str = "" + auth_algo = vector['auth_algo'] + mBitlen = 8 * (len(vector['input']) / 2) + bin_input = bytearray.fromhex(vector["input"]) + str_input = str(bin_input) + bin_key = binascii.a2b_hex(vector["auth_key"]) + + #add is 00010203080000000001020308000000 + #vector["aad"] = vector["aad"][:8] + "08000000" + vector["aad"][:8] + "08000000" + vector["aad"] = "00000000000000000000000000000000" + hash_out = EIA3(key=bin_key,count=0, bearer=0,dir=0,data=str_input,bitlen=mBitlen) + auth_str = hash_out.encode("hex").upper() + + return auth_str + + def __gen_null_hash(self,vector): + auth_str = "" + if (vector['chain'] == "HASH_ONLY") or (vector['chain'] == "HASH_CIPHER"): + auth_str = vector['input'] + elif (vector['chain'] == "CIPHER_HASH"): + auth_str = vector['output_cipher'] + return auth_str + + def __gen_hash_output(self, vector): + if vector["chain"] == "CIPHER_ONLY": + vector["output_hash"] == "" + return + + if vector["output_hash"] != "*": + return + + if vector["chain"] == "HASH_ONLY": + vector["output_cipher"] = "" + + hash_str = "" + + if vector["chain"] == "CIPHER_HASH": + input_str = vector["output_cipher"] + else: + input_str = vector["input"] + + auth_algo = vector["auth_algo"] + if auth_algo == "MD5_HMAC": + hash_str = hmac.new(binascii.a2b_hex(vector["auth_key"]),\ + binascii.a2b_hex(input_str), hashlib.md5).hexdigest() + elif auth_algo == "SHA1_HMAC": + hash_str = hmac.new(binascii.a2b_hex(vector["auth_key"]),\ + binascii.a2b_hex(input_str), hashlib.sha1).hexdigest() + elif auth_algo == "SH224_HMAC": + hash_str = hmac.new(binascii.a2b_hex(vector["auth_key"]),\ + binascii.a2b_hex(input_str), hashlib.sha224).hexdigest() + elif auth_algo == "SH256_HMAC": + hash_str = hmac.new(binascii.a2b_hex(vector["auth_key"]),\ + binascii.a2b_hex(input_str), hashlib.sha256).hexdigest() + elif auth_algo == "SHA384_HMAC": + hash_str = hmac.new(binascii.a2b_hex(vector["auth_key"]),\ + binascii.a2b_hex(input_str), hashlib.sha384).hexdigest() + elif auth_algo == "SHA512_HMAC": + hash_str = hmac.new(binascii.a2b_hex(vector["auth_key"]),\ + binascii.a2b_hex(input_str), hashlib.sha512).hexdigest() + elif auth_algo == "AES_XCBC_MAC": + pass + elif auth_algo == "AES_GCM": + pass + elif auth_algo == "AES_GMAC": + pass + elif auth_algo == "SNOW3G_UIA2": + hash_str = self.__gen_snow3g_hash(vector) + elif auth_algo == "ZUC_EIA3": + hash_str = self.__gen_zuc_hash(vector) + elif auth_algo == "KASUMI_F9": + hash_str = self.__gen_kasumi_hash(vector) + elif auth_algo == "NULL": + hash_str = self.__gen_null_hash(vector) + elif auth_algo == "MD5": + hash_str = hashlib.md5(binascii.a2b_hex(vector["auth_key"])).hexdigest() + elif auth_algo == "SHA1": + hash_str = hashlib.sha1(binascii.a2b_hex(vector["auth_key"])).hexdigest() + elif auth_algo == "SHA224": + hash_str = hashlib.sha224(binascii.a2b_hex(vector["auth_key"])).hexdigest() + elif auth_algo == "SHA256": + hash_str = hashlib.sha256(binascii.a2b_hex(vector["auth_key"])).hexdigest() + elif auth_algo == "SHA384": + hash_str = hashlib.sha384(binascii.a2b_hex(vector["auth_key"])).hexdigest() + elif auth_algo == "SHA512": + hash_str = hashlib.sha512(binascii.a2b_hex(vector["auth_key"])).hexdigest() + else: + pass + vector["output_hash"] = hash_str.upper() + self.__actually_aesni_mb_digest(vector) + + def __gen_output(self, vector, cmds, core_mask="", port_mask=""): + if core_mask != "-1": + self.__gen_cipher_output(vector) + self.__gen_hash_output(vector) + cmds.append(vector) + + def __var2list(self, var): + var_list = var if isinstance(var, list) else [var] + return var_list + + def __is_valid_op(self, chain, op): + chain_op_map = { + "CIPHER_ONLY": ["ENCRYPT", "DECRYPT"], + "HASH_ONLY": ["GENERATE", "VERIFY"], + "CIPHER_HASH": ["ENCRYPT", "GENERATE"], + "HASH_CIPHER": ["DECRYPT", "VERIFY"], + } + if op in chain_op_map[chain]: + return True + return False - "qat_c_AES_CBC_01": { - "vdev": "", - "chain": "CIPHER_ONLY", - "cdev_type": "ANY", - "cipher_algo": "AES_CBC", - "cipher_op": "ENCRYPT", - "cipher_key": "000102030405060708090a0b0c0d0e0f", - "iv": "000102030405060708090a0b0c0d0e0f", - "auth_algo": "", - "auth_op": "", - "auth_key": "", - "auth_key_random_size": "", - "aad": "", + def __is_valid_size(self, key_type, algo, size): + algo_size_map = { + "AES_CBC": { + "cipher_key": [16, 24, 32], + "iv": [16], + }, + "AES_CTR": { + "cipher_key": [16, 24, 32], + "iv": [16] + }, + "3DES_CBC": { + "cipher_key": [16, 24], + "iv": [8] + }, + "3DES_CTR": { + "cipher_key": [16, 24], + "iv": [8] + }, + "AES_GCM": { + "cipher_key": [16, 24, 32], + "auth_key": [16, 24, 32], + "aad": [0,1,2,3,4,5,6,8,9,12,16,24,32,64,128,155,256,1024,65535], + "iv": [12,16] + }, + "SNOW3G_UEA2": { + "cipher_key": [16], + "iv": [16] + }, + "KASUMI_F8": { + "cipher_key": [16], + "iv": [8] + }, + "ZUC_EEA3": { + "cipher_key": [16], + "iv": [16] + }, + "NULL": { + "cipher_key": [0], + "auth_key": [0], + "aad": [0], + "iv": [0] + }, + "MD5_HMAC": { + "auth_key": [64], + "aad": [0], + }, + "SHA1_HMAC": { + "auth_key": [64], + "aad": [0] + }, + "SHA224_HMAC": { + "auth_key": [64], + "aad": [0] + }, + "SHA256_HMAC": { + "auth_key": [64], + "aad": [0] + }, + "SHA384_HMAC": { + "auth_key": [128], + "aad": [0] + }, + "SHA512_HMAC": { + "auth_key": [128], + "aad": [0] + }, + "AES_XCBC_MAC": { + "auth_key": [16], + "aad": [0] + }, + "AES_GMAC": { + "auth_key": [16, 24, 32], + "aad": [1, 16, 64, 128, 256, 65535] + }, + "SNOW3G_UIA2": { + "auth_key": [16], + "aad": [16] + }, + "KASUMI_F9": { + "auth_key": [16], + "aad": [8] + }, + "ZUC_EIA3": { + "auth_key": [16], + "aad": [16] + }, + "MD5": { + "auth_key": [0], + "aad": [0], + }, + "SHA1": { + "auth_key": [0], + "aad": [0] + }, + "SHA224": { + "auth_key": [0], + "aad": [0] + }, + "SHA256": { + "auth_key": [0], + "aad": [0] + }, + "SHA384": { + "auth_key": [0], + "aad": [0] + }, + "SHA512": { + "auth_key": [0], + "aad": [0] + }, + } + result = False + if algo in algo_size_map: + if key_type in algo_size_map[algo]: + if size in algo_size_map[algo][key_type]: + result = True + return result + + def __actually_aesni_mb_digest(self,vector): + + if ((vector["vdev"]).find("crypto_aesni_mb") == -1): + return + + auth_algo_dgst_map = { + "MD5_HMAC": 12, + "SHA1_HMAC": 12, + "SHA224_HMAC": 14, + "SHA256_HMAC": 16, + "SHA384_HMAC": 24, + "SHA512_HMAC": 32, + "AES_XCBC_MAC": 12 + } + if vector["auth_algo"] in auth_algo_dgst_map: + digest = auth_algo_dgst_map[vector["auth_algo"]] + vector["output_hash"] = vector["output_hash"] if digest >= (len(vector["output_hash"]) / 2) \ + else (vector["output_hash"])[0:2*digest] + + + def __iter_cipher_algo(self, vector, vector_list, core_mask="", port_mask=""): + test_vector = vector.copy() + if test_vector["chain"] == "HASH_ONLY": + test_vector["cipher_algo"] = "" + self.__iter_cipher_op(test_vector, vector_list, core_mask, port_mask) + else: + cipher_algo_list = self.__var2list(test_vector["cipher_algo"]) + for cipher_algo in cipher_algo_list: + test_vector = vector.copy() + test_vector["cipher_algo"] = cipher_algo + self.__iter_cipher_op(test_vector, vector_list, core_mask, port_mask) + + def __iter_cipher_op(self, vector, vector_list, core_mask="", port_mask=""): + test_vector = vector.copy() + if test_vector["chain"] == "HASH_ONLY": + test_vector["cipher_op"] = "" + self.__iter_cipher_key(test_vector, vector_list, core_mask, port_mask) + else: + cipher_op_list = self.__var2list(test_vector["cipher_op"]) + for cipher_op in cipher_op_list: + if self.__is_valid_op(test_vector["chain"], cipher_op): + test_vector = vector.copy() + test_vector["cipher_op"] = cipher_op + self.__iter_cipher_key(test_vector, vector_list, \ + core_mask, port_mask) + + def __iter_cipher_key(self, vector, vector_list, core_mask="", port_mask=""): + test_vector = vector.copy() + if test_vector["chain"] == "HASH_ONLY": + test_vector["cipher_key"] = "" + self.__iter_iv(test_vector, vector_list, core_mask, port_mask) + else: + cipher_key_list = self.__var2list(test_vector["cipher_key"]) + for cipher_key in cipher_key_list: + test_vector = vector.copy() + if isinstance(cipher_key, int): + if self.__is_valid_size("cipher_key", \ + test_vector["cipher_algo"], \ + cipher_key): + test_vector["cipher_key"] = self.__gen_key(cipher_key) + self.__iter_iv(test_vector, vector_list, core_mask, port_mask) + else: + continue + else: + test_vector["cipher_key"] = cipher_key + self.__iter_iv(test_vector, vector_list, core_mask, port_mask) + + def __iter_iv(self, vector, vector_list, core_mask="", port_mask=""): + test_vector = vector.copy() + if test_vector["chain"] == "HASH_ONLY": + test_vector["iv"] = "" + self.__iter_auth_algo(test_vector, vector_list, core_mask, port_mask) + else: + iv_list = self.__var2list(test_vector["iv"]) + for iv in iv_list: + test_vector = vector.copy() + if isinstance(iv, int): + if self.__is_valid_size("iv", \ + test_vector["cipher_algo"], \ + iv): + test_vector["iv"] = self.__gen_key(iv) + self.__iter_auth_algo(test_vector, vector_list, \ + core_mask, port_mask) + else: + continue + else: + test_vector["iv"] = iv + self.__iter_auth_algo(test_vector, vector_list, \ + core_mask, port_mask) + + def __iter_auth_algo(self, vector, vector_list, core_mask="", port_mask=""): + test_vector = vector.copy() + if test_vector["chain"] == "CIPHER_ONLY": + test_vector["auth_algo"] = "" + self.__iter_auth_op(test_vector, vector_list, core_mask, port_mask) + else: + auth_algo_list = self.__var2list(test_vector["auth_algo"]) + for auth_algo in auth_algo_list: + test_vector = vector.copy() + test_vector["auth_algo"] = auth_algo + self.__iter_auth_op(test_vector, vector_list, core_mask, port_mask) + + def __iter_auth_op(self, vector, vector_list, core_mask="", port_mask=""): + test_vector = vector.copy() + if test_vector["chain"] == "CIPHER_ONLY": + test_vector["auth_op"] = "" + self.__iter_auth_key(test_vector, vector_list, core_mask, port_mask) + else: + auth_op_list = self.__var2list(test_vector["auth_op"]) + for auth_op in auth_op_list: + if self.__is_valid_op(test_vector["chain"], auth_op): + test_vector = vector.copy() + test_vector["auth_op"] = auth_op + self.__iter_auth_key(test_vector, vector_list, \ + core_mask, port_mask) + + def __iter_auth_key(self, vector, vector_list, core_mask="", port_mask=""): + test_vector = vector.copy() + if test_vector["chain"] == "CIPHER_ONLY": + test_vector["auth_key"] = "" + self.__iter_aad(test_vector, vector_list, core_mask, port_mask) + else: + auth_key_list = self.__var2list(test_vector["auth_key"]) + for auth_key in auth_key_list: + test_vector = vector.copy() + if isinstance(auth_key, int): + if self.__is_valid_size("auth_key", \ + test_vector["auth_algo"], \ + auth_key): + test_vector["auth_key"] = self.__gen_key(auth_key) + self.__iter_aad(test_vector, vector_list, core_mask, port_mask) + else: + continue + else: + test_vector["auth_key"] = auth_key + self.__iter_aad(test_vector, vector_list, core_mask, port_mask) + + def __iter_aad(self, vector, vector_list, core_mask="", port_mask=""): + test_vector = vector.copy() + if test_vector["chain"] == "CIPHER_ONLY": + test_vector["aad"] = "" + self.__iter_input(test_vector, vector_list, core_mask, port_mask) + else: + aad_list = self.__var2list(test_vector["aad"]) + for aad in aad_list: + test_vector = vector.copy() + if isinstance(aad, int): + if self.__is_valid_size("aad", \ + test_vector["auth_algo"], \ + aad): + test_vector["aad"] = self.__gen_key(aad) + self.__iter_input(test_vector, vector_list, \ + core_mask, port_mask) + else: + continue + else: + test_vector["aad"] = aad + self.__iter_input(test_vector, vector_list, \ + core_mask, port_mask) + + def __iter_input(self, vector, vector_list, core_mask="", port_mask=""): + input_list = self.__var2list(vector["input"]) + for input_data in input_list: + test_vector = vector.copy() + test_vector["input"] = self.__gen_input(input_data) \ + if isinstance(input_data, int) else input_data + + self.__gen_output(test_vector, vector_list, core_mask, port_mask) + + def __test_vector_to_vector_list(self, test_vector,core_mask="", port_mask=""): + vector_list = [] + + chain_list = self.__var2list(test_vector["chain"]) + + for chain in chain_list: + test_vector["chain"] = chain + self.__iter_cipher_algo(test_vector, vector_list, core_mask, port_mask) + return vector_list + + +test_vectors = { + + "qat_c_AES_CBC_00": { + "vdev": "", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["AES_CBC"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16, 24, 32], + "iv": [16], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], "aad_random_size": "", - "input": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", - "output_cipher": "96A702D1CC8DD6D625D971915FCE8C40B8C522042B7126D51BB204CECA048C13793B75FF84A4B524370A45534C2BC476", - "output_hash": "", + "input":[16,48,64, 128, 129,256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "qat_c_AES_CTR_00": { + "vdev": "", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["AES_CTR"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16, 24, 32], + "iv": [16], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128,129, 256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "qat_c_AES_GCM_00": { + "vdev": "", + "chain": ["CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["AES_GCM"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16], + "iv": [12,16], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128, 129,256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "qat_h_MD_SHA_00": { + "vdev": "", + "chain": ["HASH_ONLY"], + "cdev_type": "ANY", + "cipher_algo": "", + "cipher_op": "", + "cipher_key": "", + "iv": "", + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128,129, 256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "qat_h_AES_XCBC_MAC_01": { + "vdev": "", + "chain": "HASH_ONLY", + "cdev_type": "ANY", + "cipher_algo": "", + "cipher_op": "", + "cipher_key": "", + "iv": "", + "auth_algo": ["AES_XCBC_MAC"], + "auth_op": "GENERATE", + "auth_key": [16], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input": [16,48,64, 128, 129,256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "qat_c_3DES_CBC_00": { + "vdev": "", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["3DES_CBC"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16, 24], + "iv": [8], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128,129, 256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "qat_c_3DES_CTR_00": { + "vdev": "", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["3DES_CTR"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16, 24], + "iv": [8], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128,129, 256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "qat_c_AES_GCM_01": { + "vdev": "", + "chain": ["CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["AES_GCM"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16], + "iv": [12,16], + "auth_algo": ["AES_GCM"], + "auth_op": ["GENERATE"], + "auth_key": [16, 24, 32], + "auth_key_random_size": "", + "aad": [8,12], + "aad_random_size": "", + "input": [16,48,64, 128, 129,256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "qat_c_UEA2_01": { + "vdev": "", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["SNOW3G_UEA2"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16], + "iv": [16], + "auth_algo": ["SNOW3G_UIA2"], + "auth_op": ["GENERATE"], + "auth_key": [16], + "auth_key_random_size": "", + "aad": [16], + "aad_random_size": "", + "input": [16,48,64, 128, 129,256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" }, - "qat_c_AES_CTR_01": { + "qat_h_UIA2_01": { "vdev": "", - "chain": "CIPHER_ONLY", + "chain": ["HASH_ONLY"], "cdev_type": "ANY", - "cipher_algo": "AES_CTR", - "cipher_op": "ENCRYPT", + "cipher_algo": "", + "cipher_op": "", + "cipher_key": "", + "iv": "", + "auth_algo": ["SNOW3G_UIA2"], + "auth_op": ["GENERATE"], + "auth_key": [16], + "auth_key_random_size": "", + "aad": [16], + "aad_random_size": "", + "input": [16,48,64, 128,129, 256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "qat_kasumi_c_F8_01": { + "vdev": "", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["KASUMI_F8"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16], + "iv": [8], + "auth_algo": ["KASUMI_F9"], + "auth_op": ["GENERATE"], + "auth_key": [16], + "auth_key_random_size": "", + "aad": [8], + "aad_random_size": "", + "input": [16,48,64, 128, 129,256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "qat_kasumi_h_F9_01": { + "vdev": "", + "chain": ["HASH_ONLY"], + "cdev_type": "ANY", + "cipher_algo": "", + "cipher_op": "", + "cipher_key": "", + "iv": "", + "auth_algo": ["KASUMI_F9"], + "auth_op": ["GENERATE"], + "auth_key": [16], + "auth_key_random_size": "", + "aad": [8], + "aad_random_size": "", + "input": [16,48,64, 128,129, 256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "qat_c_NULL_auto": { + "vdev": "", + "chain": ["CIPHER_ONLY","CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["NULL"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [0], + "iv": "", + "auth_algo": ["NULL","MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC","SNOW3G_UIA2","KASUMI_F9"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "digest": "", + "input": [16,48,64, 128,129, 256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "qat_h_NULL_auto": { + "vdev": "", + "chain": ["CIPHER_ONLY","CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["NULL","AES_CBC","AES_CTR","3DES_CBC","SNOW3G_UEA2","KASUMI_F8"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [8, 16, 24, 32, 40, 48, 56, 64], + "iv": "", + "auth_algo": ["NULL"], + "auth_op": ["GENERATE"], + "auth_key": [0], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "digest": "", + "input": [16,48,64, 128,129, 256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "aesni_mb_c_AES_CBC_00": { + "vdev": "crypto_aesni_mb,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["AES_CBC"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16, 24, 32], + "iv": [16], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128,129, 256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "aesni_mb_c_AES_CTR_00": { + "vdev": "crypto_aesni_mb,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["AES_CTR"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16, 24, 32], + "iv": [16], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128, 129,256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "null_c_NULL_01": { + "vdev": "crypto_null_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_ONLY","CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": [""], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": ["0"], + "iv": "", + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "digest": "", + "input": [16,48,64, 128, 129,256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "null_h_NULL": { + "vdev": "crypto_null_pmd,socket_id=1,max_nb_sessions=128", + "chain": "HASH_ONLY", + "cdev_type": "ANY", + "cipher_algo": "", + "cipher_op": "", + "cipher_key": [0], + "iv": "", + "auth_algo": [""], + "auth_op": ["GENERATE"], + "auth_key": [0], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "digest": "", + "input": [16,48,64, 128,129, 256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "null_c_NULL_auto": { + "vdev": "crypto_null_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_ONLY","CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["NULL"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [0], + "iv": [0], + "auth_algo": ["NULL","MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [0,8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "digest": "", + "input": [16,48,64, 128, 129,256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "null_h_NULL_auto": { + "vdev": "crypto_null_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_ONLY","CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["NULL","AES_CBC","AES_CTR","3DES_CBC","SNOW3G_UEA2","KASUMI_F8","ZUC_EEA3"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [0,8, 16, 24, 32, 40, 48, 56, 64], + "iv": [0], + "auth_algo": ["NULL"], + "auth_op": ["GENERATE"], + "auth_key": [0], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "digest": "", + "input": [16,48,64, 128, 129,256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + + "aesni_gcm_ch_AES_GCM_AES_GCM_01": { + "vdev": "crypto_aesni_gcm_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["AES_GCM"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16], + "iv": [12,16], + "auth_algo": ["AES_GCM"], + "auth_op": ["GENERATE"], + "auth_key": [16, 24, 32], + "auth_key_random_size": "", + "aad": [8,12], + "aad_random_size": "", + "input": [16,48,64, 128, 129,256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "kasumi_c_F8_01": { + "vdev": "crypto_kasumi_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["KASUMI_F8"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16], + "iv": [8], + "auth_algo": ["KASUMI_F9"], + "auth_op": ["GENERATE"], + "auth_key": [16], + "auth_key_random_size": "", + "aad": [8], + "aad_random_size": "", + "input": [16,48,64, 128, 129,256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "kasumi_h_F9_01": { + "vdev": "crypto_kasumi_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["HASH_ONLY"], + "cdev_type": "ANY", + "cipher_algo": "", + "cipher_op": "", + "cipher_key": "", + "iv": "", + "auth_algo": ["KASUMI_F9"], + "auth_op": ["GENERATE"], + "auth_key": [16], + "auth_key_random_size": "", + "aad": [8], + "aad_random_size": "", + "input": [16,48,64, 128,129, 256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "snow3g_c_UEA2_01": { + "vdev": "crypto_snow3g_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["SNOW3G_UEA2"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16], + "iv": [16], + "auth_algo": ["SNOW3G_UIA2"], + "auth_op": ["GENERATE"], + "auth_key": [16], + "auth_key_random_size": "", + "aad": [16], + "aad_random_size": "", + "input": [16,48,64, 128,129, 256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "snow3g_h_UIA2_01": { + "vdev": "crypto_snow3g_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["HASH_ONLY"], + "cdev_type": "ANY", + "cipher_algo": "", + "cipher_op": "", + "cipher_key": "", + "iv": "", + "auth_algo": ["SNOW3G_UIA2"], + "auth_op": ["GENERATE"], + "auth_key": [16], + "auth_key_random_size": "", + "aad": [16], + "aad_random_size": "", + "input": [16,48,64, 128,129, 256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "zuc_c_EEA3_01": { + "vdev": "crypto_zuc_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["ZUC_EEA3"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16], + "iv": [16], + "auth_algo": ["ZUC_EIA3"], + "auth_op": ["GENERATE"], + "auth_key": [16], + "auth_key_random_size": "", + "aad": [16], + "aad_random_size": "", + "input": [16,48,64, 128,129, 256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "zuc_h_EIA3_01": { + "vdev": "crypto_zuc_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["HASH_ONLY"], + "cdev_type": "ANY", + "cipher_algo": "", + "cipher_op": "", + "cipher_key": "", + "iv": "", + "auth_algo": ["ZUC_EIA3"], + "auth_op": ["GENERATE"], + "auth_key": [16], + "auth_key_random_size": "", + "aad": [16], + "aad_random_size": "", + "input": [16,48,64, 128,129, 256, 512, 1024], + "output_cipher": "*", + "output_hash": "*" + }, + + "openssl_c_3DES_CBC_00": { + "vdev": "crypto_openssl_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["3DES_CBC"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16, 24], + "iv": [8], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128,129, 256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "openssl_c_3DES_CTR_00": { + "vdev": "crypto_openssl_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["3DES_CTR"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16, 24], + "iv": [8], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128, 129,256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "openssl_c_AES_CBC_00": { + "vdev": "crypto_openssl_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["AES_CBC"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16, 24, 32], + "iv": [16], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128,129, 256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "openssl_c_AES_CTR_00": { + "vdev": "crypto_openssl_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_ONLY", "CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["AES_CTR"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16, 24, 32], + "iv": [16], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128,129, 256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "openssl_c_AES_GCM_00": { + "vdev": "crypto_openssl_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["CIPHER_HASH"], + "cdev_type": "ANY", + "cipher_algo": ["AES_GCM"], + "cipher_op": ["ENCRYPT", "DECRYPT"], + "cipher_key": [16], + "iv": [12,16], + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128, 129,256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + "openssl_h_MD_SHA_00": { + "vdev": "crypto_openssl_pmd,socket_id=1,max_nb_sessions=128", + "chain": ["HASH_ONLY"], + "cdev_type": "ANY", + "cipher_algo": "", + "cipher_op": "", + "cipher_key": "", + "iv": "", + "auth_algo": ["MD5", "SHA1", "SHA224", "SHA256","SHA384", "SHA512", + "MD5_HMAC", "SHA1_HMAC", "SHA224_HMAC", "SHA256_HMAC", + "SHA384_HMAC", "SHA512_HMAC"], + "auth_op": ["GENERATE"], + "auth_key": [8, 16, 24, 32, 40, 48, 56, 64, 128], + "auth_key_random_size": "", + "aad": [0], + "aad_random_size": "", + "input":[16,48,64, 128,129, 256, 512, 1024], + "output_cipher":"*", + "output_hash": "*" + }, + + + "qat_c_AES_CBC_01": { + "vdev": "", + "chain": "HASH_CIPHER", + "cdev_type": "ANY", + "cipher_algo": "AES_CBC", + "cipher_op": "DECRYPT", "cipher_key": "000102030405060708090a0b0c0d0e0f", "iv": "000102030405060708090a0b0c0d0e0f", - "auth_algo": "", - "auth_op": "", - "auth_key": "", + "auth_algo": "MD5_HMAC", + "auth_op": "VERIFY", + "auth_key": "0001020304050607", "auth_key_random_size": "", "aad": "", "aad_random_size": "", "input": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", - "output_cipher": "1B851AA4507FE154E0D28549D742FB4B1372FD85770963878BCBEC1E5AB51ECD0B3C85A2000DB4E9ACD3D95CDD38FD56", + "output_cipher": "96A702D1CC8DD6D625D971915FCE8C40B8C522042B7126D51BB204CECA048C13793B75FF84A4B524370A45534C2BC476", "output_hash": "", }, - "qat_c_AES_GCM_01": { + "qat_c_AES_CTR_01": { "vdev": "", "chain": "CIPHER_ONLY", "cdev_type": "ANY", - "cipher_algo": "AES_GCM", + "cipher_algo": "AES_CTR", "cipher_op": "ENCRYPT", "cipher_key": "000102030405060708090a0b0c0d0e0f", "iv": "000102030405060708090a0b0c0d0e0f", @@ -515,10 +2050,11 @@ test_vectors = { "aad": "", "aad_random_size": "", "input": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", - "output_cipher": "1b851aa4507fe154e0d28549d742fb4b1372fd85770963878bcbec1e5ab51ecd0b3c85a2000db4e9acd3d95cdd38fd56", + "output_cipher": "1B851AA4507FE154E0D28549D742FB4B1372FD85770963878BCBEC1E5AB51ECD0B3C85A2000DB4E9ACD3D95CDD38FD56", "output_hash": "", }, + "qat_h_MD5_HMAC_01": { "vdev": "", "chain": "HASH_ONLY", @@ -634,24 +2170,7 @@ test_vectors = { "output_hash": "C8917E7490FC2CFF0CFDD0509C1C0D711CD27FFDFAAEA375E123F25F7532D4FA7D02D95CD52FAC8A27E21B3F5F734241897A37BB8953C52FFADB3B605A864569" }, - "qat_h_AES_XCBC_MAC_01": { - "vdev": "", - "chain": "HASH_ONLY", - "cdev_type": "ANY", - "cipher_algo": "", - "cipher_op": "", - "cipher_key": "", - "iv": "", - "auth_algo": "AES_XCBC_MAC", - "auth_op": "GENERATE", - "auth_key": "000102030405060708090a0b0c0d0e0f", - "auth_key_random_size": "", - "aad": "", - "aad_random_size": "", - "input": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", - "output_cipher": "", - "output_hash": "A7AD120ED744A9EC0618C0D9" - }, + "qat_ch_AES_CBC_SHA1_HMAC_01": { "vdev": "", @@ -672,120 +2191,11 @@ test_vectors = { "output_hash": "2D6EFD5929812460E2DE34A1BD768F209C985143BA7333E8D59EFED291517EF7" }, - "qat_c_UEA2_01": { - "vdev": "", - "chain": "CIPHER_ONLY", - "cdev_type": "ANY", - "cipher_algo": "SNOW3G_UEA2", - "cipher_op": "ENCRYPT", - "cipher_key": "000102030405060708090a0b0c0d0e0f", - "iv": "000102030405060708090a0b0c0d0e0f", - "auth_algo": "", - "auth_op": "", - "auth_key": "", - "auth_key_random_size": "", - "aad": "", - "aad_random_size": "", - "input": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", - "output_cipher": "fa0d2ff5dbf973e7082b128396fbc2c1ff5721099a1eb82918e66c1fa1b8fd52ce1763963f73859595d89b0b8d3907a8", - "output_hash": "" - }, + - "qat_h_UIA2_01": { - "vdev": "", - "chain": "HASH_ONLY", - "cdev_type": "ANY", - "cipher_algo": "", - "cipher_op": "", - "cipher_key": "", - "iv": "", - "auth_algo": "SNOW3G_UIA2", - "auth_op": "GENERATE", - "auth_key": "000102030405060708090a0b0c0d0e0f", - "auth_key_random_size": "", - "aad": "000102030405060708090a0b0c0d0e0f", - "aad_random_size": "", - "input": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", - "output_cipher": "", - "output_hash": "741D4316" - }, - - "snow3g_c_UEA2_01": { - "vdev": "cryptodev_snow3g_pmd,socket_id=1,max_nb_sessions=128", - "chain": "CIPHER_ONLY", - "cdev_type": "ANY", - "cipher_algo": "SNOW3G_UEA2", - "cipher_op": "ENCRYPT", - "cipher_key": "000102030405060708090a0b0c0d0e0f", - "iv": "000102030405060708090a0b0c0d0e0f", - "auth_algo": "", - "auth_op": "", - "auth_key": "", - "auth_key_random_size": "", - "aad": "", - "aad_random_size": "", - "input": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", - "output_cipher": "fa0d2ff5dbf973e7082b128396fbc2c1ff5721099a1eb82918e66c1fa1b8fd52ce1763963f73859595d89b0b8d3907a8", - "output_hash": "" - }, + - "snow3g_h_UIA2_01": { - "vdev": "cryptodev_snow3g_pmd,socket_id=1,max_nb_sessions=128", - "chain": "HASH_ONLY", - "cdev_type": "ANY", - "cipher_algo": "", - "cipher_op": "", - "cipher_key": "", - "iv": "", - "auth_algo": "SNOW3G_UIA2", - "auth_op": "GENERATE", - "auth_key": "000102030405060708090a0b0c0d0e0f", - "auth_key_random_size": "", - "aad": "000102030405060708090a0b0c0d0e0f", - "aad_random_size": "", - "input": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", - "output_cipher": "", - "output_hash": "741D4316" - }, - - "kasumi_c_F8_01": { - "vdev": "cryptodev_kasumi_pmd,socket_id=1,max_nb_sessions=128", - "chain": "CIPHER_ONLY", - "cdev_type": "ANY", - "cipher_algo": "KASUMI_F8", - "cipher_op": "ENCRYPT", - "cipher_key": "000102030405060708090a0b0c0d0e0f", - "iv": "0001020304050607", - "auth_algo": "", - "auth_op": "", - "auth_key": "", - "auth_key_random_size": "", - "aad": "", - "aad_random_size": "", - "input": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", - "output_cipher": "ede654ff0caab546b654cd7a3b0a4199e957579214f45bd7e25fcbbda41e38fc885fbbd6195cf8e22905480191b2f861", - "output_hash": "" - }, - - "kasumi_h_F9_01": { - "vdev": "cryptodev_kasumi_pmd,socket_id=1,max_nb_sessions=128", - "chain": "HASH_ONLY", - "cdev_type": "ANY", - "cipher_algo": "", - "cipher_op": "", - "cipher_key": "", - "iv": "", - "auth_algo": "KASUMI_F9", - "auth_op": "GENERATE", - "auth_key": "000102030405060708090a0b0c0d0e0f", - "auth_key_random_size": "", - # aad length min=8 max=8 - "aad": "0001020304050607", - "aad_random_size": "", - "input": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", - "output_cipher": "", - "output_hash": "D1C2BE1E" - }, + "null_c_NULL_01": { "vdev": "cryptodev_null_pmd,socket_id=1,max_nb_sessions=128", @@ -826,25 +2236,7 @@ test_vectors = { "output_hash": "00A2EBC33A8A1C8C" }, - "aesni_ch_AES_GCM_AES_GCM_01": { - "vdev": "cryptodev_aesni_gcm_pmd,socket_id=1,max_nb_sessions=128", - "chain": "CIPHER_HASH", - "cdev_type": "ANY", - "cipher_algo": "AES_GCM", - "cipher_op": "ENCRYPT", - "cipher_key": "000102030405060708090a0b0c0d0e0f", - "iv": "000102030405060708090a0b0c0d0e0f", - "auth_algo": "AES_GCM", - "auth_op": "GENERATE", - "auth_key": "000102030405060708090a0b0c0d0e0f", - "auth_key_random_size": "", - # aad length min=8 max=12 - "aad": "0001020304050607", - "aad_random_size": "", - "input": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", - "output_cipher": "1372fd85770963878bcbec1e5ab51ecd0b3c85a2000db4e9acd3d95cdd38fd565c1abac3884e8e167332357956a4c21f", - "output_hash": "00A2EBC33A8A1C8C" - }, + "aesni_ch_AES_CBC_SHA1_HMAC_01": { "vdev": "cryptodev_aesni_mb_pmd,socket_id=1,max_nb_sessions=128", diff --git a/tests/TestSuite_unit_tests_cryptodev.py b/tests/TestSuite_unit_tests_cryptodev.py new file mode 100644 index 0000000..f37eb35 --- /dev/null +++ b/tests/TestSuite_unit_tests_cryptodev.py @@ -0,0 +1,172 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (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 utils +from test_case import TestCase + + +class UnitTestsCryptodev(TestCase): + + def set_up_all(self): + + 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) + self.ports_socket = self.dut.get_numa_id(self.dut_ports[0]) + + self.logger.info("core config = " + self.core_config) + self.logger.info("number of ports = " + str(self.number_of_ports)) + self.logger.info("dut ports = " + str(self.dut_ports)) + self.logger.info("ports_socket = " + str(self.ports_socket)) + + self.core_mask = utils.create_mask(self.dut.get_core_list( + self.core_config, + socket=self.ports_socket)) + self.port_mask = utils.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[0]) + + self.tx_interface = self.tester.get_interface(self.tx_port) + self.rx_interface = self.tester.get_interface(self.rx_port) + + self.logger.info("core mask = " + self.core_mask) + self.logger.info("port mask = " + self.port_mask) + self.logger.info("tx interface = " + self.tx_interface) + self.logger.info("rx interface = " + self.rx_interface) + + # Rebuild the dpdk with cryptodev pmds CONFIG_RTE_LIBRTE_PMD_ZUC=n + self.dut.send_expect("export AESNI_MULTI_BUFFER_LIB_PATH=/root/ipsec_043/code/", "#") + self.dut.send_expect("export LIBSSO_SNOW3G_PATH=/root/libsso_snow3g/snow3g/", "#") + self.dut.send_expect("export LIBSSO_ZUC_PATH=/root/libsso_zuc.1.0.1.1-8/zuc", "#") + self.dut.send_expect("export LIBSSO_KASUMI_PATH=/root/LibSSO_0_3_1/isg_cid-wireless_libs/ciphers/kasumi/", "#") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_QAT=n$/CONFIG_RTE_LIBRTE_PMD_QAT=y/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_AESNI_GCM=n$/CONFIG_RTE_LIBRTE_PMD_AESNI_GCM=y/' config/common_base", "# ") + 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.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_OPENSSL=n$/CONFIG_RTE_LIBRTE_PMD_OPENSSL=y/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n$/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=y/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_ZUC=n$/CONFIG_RTE_LIBRTE_PMD_ZUC=y/' config/common_base", "# ") + self.dut.skip_setup = False + self.dut.build_install_dpdk(self.dut.target) + + out = self.dut.build_dpdk_apps("./app/test/") + self.verify('make: Leaving directory' in out, "Compilation failed") + + + # Bind QAT VF devices + out = self.dut.send_expect("lspci -d:443|awk '{print $1}'", "# ", 10) + self.dut.send_expect('echo "8086 0443" > /sys/bus/pci/drivers/igb_uio/new_id', "# ", 10) + for line in out.replace("\r", "\n").replace("\n\n", "\n").split("\n"): + cmd = "echo 0000:{} > /sys/bus/pci/devices/0000\:{}/driver/unbind".format(line, line.replace(":", "\:")) + self.dut.send_expect(cmd, "# ", 10) + cmd = "echo 0000:{} > /sys/bus/pci/drivers/igb_uio/bind".format(line) + self.dut.send_expect(cmd, "# ", 10) + + def set_up(self): + pass + + def tear_down(self): + pass + + def tear_down_all(self): + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_QAT=y$/CONFIG_RTE_LIBRTE_PMD_QAT=n/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_AESNI_GCM=y$/CONFIG_RTE_LIBRTE_PMD_AESNI_GCM=n/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y$/CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=n/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_SNOW3G=y$/CONFIG_RTE_LIBRTE_PMD_SNOW3G=n/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_KASUMI=y$/CONFIG_RTE_LIBRTE_PMD_KASUMI=n/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_OPENSSL=y$/CONFIG_RTE_LIBRTE_PMD_OPENSSL=n/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=y$/CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n/' config/common_base", "# ") + self.dut.send_expect("sed -i 's/CONFIG_RTE_LIBRTE_PMD_ZUC=y$/CONFIG_RTE_LIBRTE_PMD_ZUC=n/' config/common_base", "# ") + + def test_cryptodev_qat_autotest(self): + self.__run_unit_test("cryptodev_qat_autotest") + + def test_cryptodev_qat_perftest(self): + self.__run_unit_test("cryptodev_qat_perftest") + + def test_cryptodev_aesni_mb_perftest(self): + self.__run_unit_test("cryptodev_aesni_mb_perftest") + + def test_cryptodev_sw_snow3g_perftest(self): + self.__run_unit_test("cryptodev_sw_snow3g_perftest") + + def test_cryptodev_qat_snow3g_perftest(self): + self.__run_unit_test("cryptodev_qat_snow3g_perftest") + + def test_cryptodev_aesni_gcm_perftest(self): + self.__run_unit_test("cryptodev_aesni_gcm_perftest") + + def test_cryptodev_openssl_perftest(self): + self.__run_unit_test("cryptodev_openssl_perftest") + + def test_cryptodev_qat_continual_perftest(self): + self.__run_unit_test("cryptodev_qat_continual_perftest") + + def test_cryptodev_aesni_mb_autotest(self): + self.__run_unit_test("cryptodev_aesni_mb_autotest") + + def test_cryptodev_openssl_autotest(self): + self.__run_unit_test("cryptodev_openssl_autotest") + + def test_cryptodev_aesni_gcm_autotest(self): + self.__run_unit_test("cryptodev_aesni_gcm_autotest") + + def test_cryptodev_null_autotest(self): + self.__run_unit_test("cryptodev_null_autotest") + + def test_cryptodev_sw_snow3g_autotest(self): + self.__run_unit_test("cryptodev_sw_snow3g_autotest") + + def test_cryptodev_sw_kasumi_autotest(self): + self.__run_unit_test("cryptodev_sw_kasumi_autotest") + + def test_cryptodev_sw_zuc_autotest(self): + self.__run_unit_test("cryptodev_sw_zuc_autotest") + + def __run_unit_test(self, testsuite, timeout=120): + print "STEP_TEST: " + testsuite + self.dut.send_expect("dmesg -C", "# ", 30) + self.dut.send_expect("./app/test/test -n 1 -c 0xf", "R.*T.*E.*>.*>", 30) + out = "" + try: + out = self.dut.send_expect(testsuite, "RTE>>", timeout) + self.dut.send_expect("quit", "# ") + except: + print "run cryptodev_qat_autotest process coredump" + out = self.dut.alt_session.send_expect("dmesg", "# ", 30) + self.dut.alt_session.send_expect("killall test", "# ", 30) + print out + self.verify("Test OK" in out, "Test failed") + -- 1.9.3