test/crypto: add AES-GCM J0 case
authorArek Kusztal <arkadiuszx.kusztal@intel.com>
Fri, 13 Mar 2020 18:07:51 +0000 (19:07 +0100)
committerAkhil Goyal <akhil.goyal@oss.nxp.com>
Sun, 5 Apr 2020 16:26:04 +0000 (18:26 +0200)
This patch adds crypto J0 test case to AES-GCM

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
app/test/test_cryptodev.c
app/test/test_cryptodev.h
app/test/test_cryptodev_aead_test_vectors.h

index 7b1ef5c..927c3b7 100644 (file)
@@ -6885,9 +6885,15 @@ create_aead_operation(enum rte_crypto_aead_operation op,
                uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
                                uint8_t *, IV_OFFSET);
 
-               rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
-               debug_hexdump(stdout, "iv:", iv_ptr,
-                       tdata->iv.len);
+               if (tdata->iv.len == 0) {
+                       rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
+                       debug_hexdump(stdout, "iv:", iv_ptr,
+                               AES_GCM_J0_LENGTH);
+               } else {
+                       rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
+                       debug_hexdump(stdout, "iv:", iv_ptr,
+                               tdata->iv.len);
+               }
        }
 
        /* Append plaintext/ciphertext */
@@ -7712,6 +7718,12 @@ test_AES_GCM_authenticated_encryption_test_case_8(void)
        return test_authenticated_encryption(&gcm_test_case_8);
 }
 
+static int
+test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
+{
+       return test_authenticated_encryption(&gcm_J0_test_case_1);
+}
+
 static int
 test_AES_GCM_auth_encryption_test_case_192_1(void)
 {
@@ -8045,6 +8057,12 @@ test_AES_GCM_authenticated_decryption_test_case_8(void)
        return test_authenticated_decryption(&gcm_test_case_8);
 }
 
+static int
+test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
+{
+       return test_authenticated_decryption(&gcm_J0_test_case_1);
+}
+
 static int
 test_AES_GCM_auth_decryption_test_case_192_1(void)
 {
@@ -11755,6 +11773,8 @@ static struct unit_test_suite cryptodev_testsuite  = {
                        test_AES_GCM_authenticated_encryption_test_case_7),
                TEST_CASE_ST(ut_setup, ut_teardown,
                        test_AES_GCM_authenticated_encryption_test_case_8),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_AES_GCM_J0_authenticated_encryption_test_case_1),
 
                /** AES GCM Authenticated Decryption */
                TEST_CASE_ST(ut_setup, ut_teardown,
@@ -11773,6 +11793,8 @@ static struct unit_test_suite cryptodev_testsuite  = {
                        test_AES_GCM_authenticated_decryption_test_case_7),
                TEST_CASE_ST(ut_setup, ut_teardown,
                        test_AES_GCM_authenticated_decryption_test_case_8),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                       test_AES_GCM_J0_authenticated_decryption_test_case_1),
 
                /** AES GCM Authenticated Encryption 192 bits key */
                TEST_CASE_ST(ut_setup, ut_teardown,
index def304e..41542e0 100644 (file)
@@ -44,6 +44,7 @@
 #define TRUNCATED_DIGEST_BYTE_LENGTH_SHA512            (32)
 
 #define MAXIMUM_IV_LENGTH                              (16)
+#define AES_GCM_J0_LENGTH                              (16)
 
 #define IV_OFFSET                      (sizeof(struct rte_crypto_op) + \
                sizeof(struct rte_crypto_sym_op) + DEFAULT_NUM_XFORMS * \
index a4a3a25..e62fdb2 100644 (file)
@@ -982,6 +982,57 @@ static const struct aead_test_data gcm_test_case_8 = {
        }
 };
 
+static const struct aead_test_data gcm_J0_test_case_1 = {
+       .algo = RTE_CRYPTO_AEAD_AES_GCM,
+       .key = {
+               .data = {
+                       0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+                       0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08 },
+               .len = 16
+       },
+       .iv = {
+               .data = {
+                       0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
+                       0xde, 0xca, 0xf8, 0x88, 0x00, 0x00, 0x00, 0x01 },
+               .len = 0
+       },
+       .aad = {
+               .data = gcm_aad_zero_text,
+               .len = 0
+       },
+       .plaintext = {
+               .data = {
+                       0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
+                       0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
+                       0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
+                       0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
+                       0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+                       0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
+                       0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
+                       0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55 },
+               .len = 64
+       },
+       .ciphertext = {
+               .data = {
+                       0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
+                       0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
+                       0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
+                       0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
+                       0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
+                       0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
+                       0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
+                       0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85
+               },
+               .len = 64
+       },
+       .auth_tag = {
+               .data = {
+                       0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6,
+                       0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4 },
+               .len = 16
+       }
+};
+
 /** AES-GCM-192 Test Vectors */
 static const struct aead_test_data gcm_test_case_192_1 = {
        .algo = RTE_CRYPTO_AEAD_AES_GCM,