The data of the out-of-place header is never checked. Therefore,
the faulty PMD, which overwrites this data, will not be able to
verify that with tests. New checks to support that were added to
the GCM OOP functions.

Fixes: 51e202f0596f ("test/crypto: rename GCM test code")
Cc: sta...@dpdk.org

Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusz...@intel.com>
---
 app/test/test_cryptodev.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 441ecc6ad5..6ef43a784d 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -13769,8 +13769,9 @@ test_authenticated_encryption_oop(const struct 
aead_test_data *tdata)
        struct crypto_testsuite_params *ts_params = &testsuite_params;
        struct crypto_unittest_params *ut_params = &unittest_params;
 
+       uint32_t i;
        int retval;
-       uint8_t *ciphertext, *auth_tag;
+       uint8_t *ciphertext, *auth_tag, *buffer_oop;
        uint16_t plaintext_pad_len;
        struct rte_cryptodev_info dev_info;
 
@@ -13846,6 +13847,18 @@ test_authenticated_encryption_oop(const struct 
aead_test_data *tdata)
                        ut_params->op->sym->cipher.data.offset);
        auth_tag = ciphertext + plaintext_pad_len;
 
+       /* Check if the data within the offset range is not overwritten in the 
OOP */
+       buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
+       for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
+               if (buffer_oop[i]) {
+                       RTE_LOG(ERR, USER1,
+                               "Incorrect value of the output buffer 
header\n");
+                       debug_hexdump(stdout, "Incorrect value:", buffer_oop,
+                               ut_params->op->sym->cipher.data.offset);
+                       return TEST_FAILED;
+               }
+       }
+
        debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
        debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
 
@@ -13878,8 +13891,9 @@ test_authenticated_decryption_oop(const struct 
aead_test_data *tdata)
        struct crypto_testsuite_params *ts_params = &testsuite_params;
        struct crypto_unittest_params *ut_params = &unittest_params;
 
+       uint32_t i;
        int retval;
-       uint8_t *plaintext;
+       uint8_t *plaintext, *buffer_oop;
        struct rte_cryptodev_info dev_info;
 
        rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
@@ -13957,6 +13971,17 @@ test_authenticated_decryption_oop(const struct 
aead_test_data *tdata)
 
        debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
 
+       /* Check if the data within the offset range is not overwritten in the 
OOP */
+       buffer_oop = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
+       for (i = 0; i < ut_params->op->sym->cipher.data.offset; i++) {
+               if (buffer_oop[i]) {
+                       RTE_LOG(ERR, USER1,
+                               "Incorrect value of the output buffer 
header\n");
+                       debug_hexdump(stdout, "Incorrect value:", buffer_oop,
+                               ut_params->op->sym->cipher.data.offset);
+                       return TEST_FAILED;
+               }
+       }
        /* Validate obuf */
        TEST_ASSERT_BUFFERS_ARE_EQUAL(
                        plaintext,
-- 
2.43.0

Reply via email to