test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] tests l2fwd_crypto: add md5 hmac algorithm check
@ 2016-09-18  3:22 Marvin Liu
  2016-09-18  6:00 ` Chen, Zhaoyan
  0 siblings, 1 reply; 3+ messages in thread
From: Marvin Liu @ 2016-09-18  3:22 UTC (permalink / raw)
  To: dts; +Cc: Marvin Liu

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@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_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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dts] [PATCH] tests l2fwd_crypto: add md5 hmac algorithm check
  2016-09-18  3:22 [dts] [PATCH] tests l2fwd_crypto: add md5 hmac algorithm check Marvin Liu
@ 2016-09-18  6:00 ` Chen, Zhaoyan
  2016-09-18  6:59   ` Liu, Yong
  0 siblings, 1 reply; 3+ messages in thread
From: Chen, Zhaoyan @ 2016-09-18  6:00 UTC (permalink / raw)
  To: dts

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Marvin Liu
> Sent: Sunday, September 18, 2016 11:22 AM
> To: dts@dpdk.org
> Cc: Liu, Yong <yong.liu@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@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@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dts] [PATCH] tests l2fwd_crypto: add md5 hmac algorithm check
  2016-09-18  6:00 ` Chen, Zhaoyan
@ 2016-09-18  6:59   ` Liu, Yong
  0 siblings, 0 replies; 3+ messages in thread
From: Liu, Yong @ 2016-09-18  6:59 UTC (permalink / raw)
  To: Chen, Zhaoyan, dts

Thanks, applied into master branch.

On 09/18/2016 02:00 PM, Chen, Zhaoyan wrote:
>> -----Original Message-----
>> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Marvin Liu
>> Sent: Sunday, September 18, 2016 11:22 AM
>> To: dts@dpdk.org
>> Cc: Liu, Yong <yong.liu@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@intel.com>
> Acked-by: Zhaoyan Chen <zhaoyan.chen@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-18  6:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-18  3:22 [dts] [PATCH] tests l2fwd_crypto: add md5 hmac algorithm check Marvin Liu
2016-09-18  6:00 ` Chen, Zhaoyan
2016-09-18  6:59   ` Liu, Yong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).