[dts] [PATCH] tests l2fwd_crypto: add md5 hmac algorithm check

Chen, Zhaoyan zhaoyan.chen at intel.com
Sun Sep 18 08:00:29 CEST 2016


> -----Original Message-----
> From: dts [mailto:dts-bounces at dpdk.org] On Behalf Of Marvin Liu
> Sent: Sunday, September 18, 2016 11:22 AM
> To: dts at dpdk.org
> Cc: Liu, Yong <yong.liu at intel.com>
> Subject: [dts] [PATCH] tests l2fwd_crypto: add md5 hmac algorithm check
> 
> 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 <yong.liu at intel.com>
> 
> 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_SN
> OW3G=y/' config/common_base", "# ")
>          self.dut.send_expect("sed -i
> 's/CONFIG_RTE_LIBRTE_PMD_KASUMI=n$/CONFIG_RTE_LIBRTE_PMD_KAS
> UMI=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":
> "111111111111111111111111111111111111111111111111111111111111111111
> 11111111111111111111111111111100000000000000000000000000000000",
> +        "output_cipher": "",
> +        "output_hash": None
> +    },
> +
>      "qat_h_SHA1_HMAC_01": {
>          "vdev": "",
>          "chain": "HASH_ONLY",
> --
> 1.9.3

Acked-by: Zhaoyan Chen <zhaoyan.chen at intel.com>


More information about the dts mailing list