test/crypto: skip plain text compare for null cipher
authorAnoob Joseph <anoobj@marvell.com>
Wed, 10 Nov 2021 13:04:08 +0000 (18:34 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Tue, 16 Nov 2021 06:38:07 +0000 (07:38 +0100)
NULL cipher is used for validating auth only cases. With NULL cipher,
validating plain text should not be done as the PMD is only expected
to update auth data.

Fixes: e847fc512817 ("test/crypto: add encrypted digest case for AES-CTR-CMAC")
Cc: stable@dpdk.org
Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Acked-by: Ciara Power <ciara.power@intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
app/test/test_cryptodev.c

index 5245759..1b68d7c 100644 (file)
@@ -7484,27 +7484,30 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
                                tdata->digest_enc.len);
        }
 
-       /* Validate obuf */
-       if (verify) {
-               TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
-                               plaintext,
-                               tdata->plaintext.data,
-                               tdata->plaintext.len_bits >> 3,
-                               "Plaintext data not as expected");
-       } else {
-               TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
-                               ciphertext,
-                               tdata->ciphertext.data,
-                               tdata->validDataLen.len_bits,
-                               "Ciphertext data not as expected");
-
+       if (!verify) {
                TEST_ASSERT_BUFFERS_ARE_EQUAL(
                                ut_params->digest,
                                tdata->digest_enc.data,
-                               DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
+                               tdata->digest_enc.len,
                                "Generated auth tag not as expected");
        }
 
+       if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
+               if (verify) {
+                       TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
+                                       plaintext,
+                                       tdata->plaintext.data,
+                                       tdata->plaintext.len_bits >> 3,
+                                       "Plaintext data not as expected");
+               } else {
+                       TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
+                                       ciphertext,
+                                       tdata->ciphertext.data,
+                                       tdata->validDataLen.len_bits,
+                                       "Ciphertext data not as expected");
+               }
+       }
+
        TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
                        "crypto op processing failed");
 
@@ -7701,19 +7704,7 @@ test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
                                tdata->digest_enc.data, tdata->digest_enc.len);
        }
 
-       /* Validate obuf */
-       if (verify) {
-               TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
-                               plaintext,
-                               tdata->plaintext.data,
-                               tdata->plaintext.len_bits >> 3,
-                               "Plaintext data not as expected");
-       } else {
-               TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
-                               ciphertext,
-                               tdata->ciphertext.data,
-                               tdata->validDataLen.len_bits,
-                               "Ciphertext data not as expected");
+       if (!verify) {
                TEST_ASSERT_BUFFERS_ARE_EQUAL(
                                digest,
                                tdata->digest_enc.data,
@@ -7721,6 +7712,22 @@ test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
                                "Generated auth tag not as expected");
        }
 
+       if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
+               if (verify) {
+                       TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
+                                       plaintext,
+                                       tdata->plaintext.data,
+                                       tdata->plaintext.len_bits >> 3,
+                                       "Plaintext data not as expected");
+               } else {
+                       TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
+                                       ciphertext,
+                                       tdata->ciphertext.data,
+                                       tdata->validDataLen.len_bits,
+                                       "Ciphertext data not as expected");
+               }
+       }
+
        TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
                        "crypto op processing failed");