test mbuf attach
[dpdk.git] / app / test / test_cryptodev_hash_test_vectors.h
index dfc84db..d11d7ce 100644 (file)
@@ -1,38 +1,14 @@
-/*
- *   BSD LICENSE
- *
- *   Copyright(c) 2016 Intel Corporation. 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.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2017 Intel Corporation
  */
 
 #ifndef TEST_CRYPTODEV_HASH_TEST_VECTORS_H_
 #define TEST_CRYPTODEV_HASH_TEST_VECTORS_H_
 
+#ifdef RTE_LIBRTE_PMD_AESNI_MB
+#include <intel-ipsec-mb.h>
+#endif
+
 static const uint8_t plaintext_hash[] = {
        "What a lousy earth! He wondered how many people "
        "were destitute that same night even in his own "
@@ -97,7 +73,8 @@ hmac_md5_test_vector = {
                        0x50, 0xE8, 0xDE, 0xC5, 0xC1, 0x76, 0xAC, 0xAE,
                        0x15, 0x4A, 0xF1, 0x7F, 0x7E, 0x04, 0x42, 0x9B
                },
-               .len = 16
+               .len = 16,
+               .truncated_len = 12
        }
 };
 
@@ -114,7 +91,8 @@ sha1_test_vector = {
                        0x35, 0x62, 0xFB, 0xFA, 0x93, 0xFD, 0x7D, 0x70,
                        0xA6, 0x7D, 0x45, 0xCA
                },
-               .len = 20
+               .len = 20,
+               .truncated_len = 20
        }
 };
 
@@ -139,7 +117,8 @@ hmac_sha1_test_vector = {
                        0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
                        0x3F, 0x91, 0x64, 0x59
                },
-               .len = 20
+               .len = 20,
+               .truncated_len = 12
        }
 };
 
@@ -157,7 +136,8 @@ sha224_test_vector = {
                        0x39, 0x26, 0xDF, 0xB5, 0x78, 0x62, 0xB2, 0x6E,
                        0x5E, 0x8F, 0x25, 0x84
                },
-               .len = 28
+               .len = 28,
+               .truncated_len = 28
        }
 };
 
@@ -184,7 +164,8 @@ hmac_sha224_test_vector = {
                        0xF1, 0x8A, 0x63, 0xBB, 0x5D, 0x1D, 0xE3, 0x9F,
                        0x92, 0xF6, 0xAA, 0x19
                },
-               .len = 28
+               .len = 28,
+               .truncated_len = 14
        }
 };
 
@@ -202,7 +183,8 @@ sha256_test_vector = {
                        0x1F, 0xC7, 0x84, 0xEE, 0x76, 0xA6, 0x39, 0x15,
                        0x76, 0x2F, 0x87, 0xF9, 0x01, 0x06, 0xF3, 0xB7
                },
-               .len = 32
+               .len = 32,
+               .truncated_len = 32
        }
 };
 
@@ -229,7 +211,8 @@ hmac_sha256_test_vector = {
                        0x06, 0x4D, 0x64, 0x09, 0x0A, 0xCC, 0x02, 0x77,
                        0x71, 0x83, 0x48, 0x71, 0x07, 0x02, 0x25, 0x17
                },
-               .len = 32
+               .len = 32,
+               .truncated_len = 16
        }
 };
 
@@ -249,7 +232,8 @@ sha384_test_vector = {
                        0xAD, 0x41, 0xAB, 0x15, 0xB0, 0x03, 0x15, 0xEC,
                        0x9E, 0x3D, 0xED, 0xCB, 0x80, 0x7B, 0xF4, 0xB6
                },
-               .len = 48
+               .len = 48,
+               .truncated_len = 48
        }
 };
 
@@ -280,7 +264,8 @@ hmac_sha384_test_vector = {
                        0x10, 0x90, 0x0A, 0xE3, 0xF0, 0x59, 0xDD, 0xC0,
                        0x6F, 0xE6, 0x8C, 0x84, 0xD5, 0x03, 0xF8, 0x9E
                },
-               .len = 48
+               .len = 48,
+               .truncated_len = 24
        }
 };
 
@@ -302,7 +287,8 @@ sha512_test_vector = {
                        0x64, 0x4E, 0x15, 0x68, 0x12, 0x67, 0x26, 0x0F,
                        0x2C, 0x3C, 0x83, 0x25, 0x27, 0x86, 0xF0, 0xDB
                },
-               .len = 64
+               .len = 64,
+               .truncated_len = 64
        }
 };
 
@@ -337,7 +323,81 @@ hmac_sha512_test_vector = {
                        0x97, 0x37, 0x0F, 0xBE, 0xC2, 0x45, 0xA0, 0x87,
                        0xAF, 0x24, 0x27, 0x0C, 0x78, 0xBA, 0xBE, 0x20
                },
-               .len = 64
+               .len = 64,
+               .truncated_len = 32
+       }
+};
+
+static const struct blockcipher_test_data
+cmac_test_vector = {
+       .auth_algo = RTE_CRYPTO_AUTH_AES_CMAC,
+       .ciphertext = {
+               .data = plaintext_hash,
+               .len = 512
+       },
+       .auth_key = {
+               .data = {
+                       0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
+                       0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
+               },
+               .len = 16
+       },
+       .digest = {
+               .data = {
+                       0x4C, 0x77, 0x87, 0xA0, 0x78, 0x8E, 0xEA, 0x96,
+                       0xC1, 0xEB, 0x1E, 0x4E, 0x95, 0x8F, 0xED, 0x27
+               },
+               .len = 16,
+               .truncated_len = 16
+       }
+};
+
+static const struct blockcipher_test_data
+null_auth_test_vector = {
+       .auth_algo = RTE_CRYPTO_AUTH_NULL,
+       .ciphertext = {         /* arbitrary data - shouldn't be used */
+               .data = plaintext_hash,
+               .len = 512
+       },
+       .auth_key = {           /* arbitrary data - shouldn't be used */
+               .data = {
+                       0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
+                       0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
+               },
+               .len = 16
+       },
+       .digest = {
+               .data = {
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                       0x00, 0x00, 0x00, 0x00
+               },
+               .len = 20,
+               .truncated_len = 12
+       }
+};
+
+static const struct blockcipher_test_data
+cmac_test_vector_12 = {
+       .auth_algo = RTE_CRYPTO_AUTH_AES_CMAC,
+       .ciphertext = {
+               .data = plaintext_hash,
+               .len = 512
+       },
+       .auth_key = {
+               .data = {
+                       0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
+                       0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
+               },
+               .len = 16
+       },
+       .digest = {
+               .data = {
+                       0x4C, 0x77, 0x87, 0xA0, 0x78, 0x8E, 0xEA, 0x96,
+                       0xC1, 0xEB, 0x1E, 0x4E, 0x95, 0x8F, 0xED, 0x27
+               },
+               .len = 12,
+               .truncated_len = 12
        }
 };
 
@@ -346,146 +406,177 @@ static const struct blockcipher_test_case hash_test_cases[] = {
                .test_descr = "MD5 Digest",
                .test_data = &md5_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "MD5 Digest Verify",
                .test_data = &md5_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "HMAC-MD5 Digest",
                .test_data = &hmac_md5_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "HMAC-MD5 Digest Verify",
                .test_data = &hmac_md5_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "SHA1 Digest",
                .test_data = &sha1_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "SHA1 Digest Verify",
                .test_data = &sha1_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "HMAC-SHA1 Digest",
                .test_data = &hmac_sha1_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
+       },
+       {
+               .test_descr = "HMAC-SHA1 Digest Scatter Gather",
+               .test_data = &hmac_sha1_test_vector,
+               .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+               .feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
        },
        {
                .test_descr = "HMAC-SHA1 Digest Verify",
                .test_data = &hmac_sha1_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
+       },
+       {
+               .test_descr = "HMAC-SHA1 Digest Verify Scatter Gather",
+               .test_data = &hmac_sha1_test_vector,
+               .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+               .feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
        },
        {
                .test_descr = "SHA224 Digest",
                .test_data = &sha224_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "SHA224 Digest Verify",
                .test_data = &sha224_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "HMAC-SHA224 Digest",
                .test_data = &hmac_sha224_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "HMAC-SHA224 Digest Verify",
                .test_data = &hmac_sha224_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "SHA256 Digest",
                .test_data = &sha256_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "SHA256 Digest Verify",
                .test_data = &sha256_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "HMAC-SHA256 Digest",
                .test_data = &hmac_sha256_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "HMAC-SHA256 Digest Verify",
                .test_data = &hmac_sha256_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "SHA384 Digest",
                .test_data = &sha384_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "SHA384 Digest Verify",
                .test_data = &sha384_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "HMAC-SHA384 Digest",
                .test_data = &hmac_sha384_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "HMAC-SHA384 Digest Verify",
                .test_data = &hmac_sha384_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "SHA512 Digest",
                .test_data = &sha512_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "SHA512 Digest Verify",
                .test_data = &sha512_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "HMAC-SHA512 Digest",
                .test_data = &hmac_sha512_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
        {
                .test_descr = "HMAC-SHA512 Digest Verify",
                .test_data = &hmac_sha512_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
-               .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO
        },
+       {
+               .test_descr = "CMAC Digest 12B",
+               .test_data = &cmac_test_vector_12,
+               .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+       },
+       {
+               .test_descr = "CMAC Digest Verify 12B",
+               .test_data = &cmac_test_vector_12,
+               .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+       },
+       {
+               .test_descr = "CMAC Digest 16B",
+               .test_data = &cmac_test_vector,
+               .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+       },
+       {
+               .test_descr = "CMAC Digest Verify 16B",
+               .test_data = &cmac_test_vector,
+               .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+       },
+       {
+               .test_descr = "NULL algo - auth generate",
+               .test_data = &null_auth_test_vector,
+               .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+       },
+       {
+               .test_descr = "NULL algo - auth verify",
+               .test_data = &null_auth_test_vector,
+               .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+       },
+       {
+               .test_descr = "NULL algo - auth generate - OOP",
+               .test_data = &null_auth_test_vector,
+               .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+               .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+       },
+       {
+               .test_descr = "NULL algo - auth verify - OOP",
+               .test_data = &null_auth_test_vector,
+               .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+               .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+       },
+
 };
 
 #endif /* TEST_CRYPTODEV_HASH_TEST_VECTORS_H_ */