]> git.droids-corp.org - dpdk.git/commitdiff
app/crypto-perf: allow auth generate followed by encryption
authorTejasree Kondoj <ktejasree@marvell.com>
Tue, 10 May 2022 12:40:45 +0000 (18:10 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Wed, 1 Jun 2022 14:26:36 +0000 (16:26 +0200)
Allowing auth generation followed by encryption mode.
--optype auth-then-cipher can take cipher-op as encrypt
and auth-op as generate now.

Signed-off-by: Tejasree Kondoj <ktejasree@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
app/test-crypto-perf/cperf_ops.c
app/test-crypto-perf/cperf_options_parsing.c

index cbefce8d6ca50e9aac75fa6259fb5fea6d8c44f3..93d2744c68a2bbc1370387ec67827efbbbdbfe93 100644 (file)
@@ -458,6 +458,10 @@ cperf_set_ops_cipher_auth(struct rte_crypto_op **ops,
                } else
                        sym_op->cipher.data.length = options->test_buffer_size;
 
+               if ((options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE) &&
+                               (options->op_type == CPERF_AUTH_THEN_CIPHER))
+                       sym_op->cipher.data.length += options->digest_sz;
+
                if (options->cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
                                options->cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
                                options->cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3)
index 09c98121c83e8303092dbdc79861bcd6c179d85a..566255bf2d4a7f90506d8f181e6d84a09d70dd23 100644 (file)
@@ -1130,6 +1130,20 @@ check_docsis_buffer_length(struct cperf_options *options)
 }
 #endif
 
+static bool
+is_valid_chained_op(struct cperf_options *options)
+{
+       if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT &&
+                       options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE)
+               return true;
+
+       if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT &&
+                       options->auth_op == RTE_CRYPTO_AUTH_OP_VERIFY)
+               return true;
+
+       return false;
+}
+
 int
 cperf_options_check(struct cperf_options *options)
 {
@@ -1236,6 +1250,14 @@ cperf_options_check(struct cperf_options *options)
                return -EINVAL;
        }
 
+       if (options->op_type == CPERF_CIPHER_THEN_AUTH ||
+                       options->op_type == CPERF_AUTH_THEN_CIPHER) {
+               if (!is_valid_chained_op(options)) {
+                       RTE_LOG(ERR, USER1, "Invalid chained operation.\n");
+                       return -EINVAL;
+               }
+       }
+
        if (options->op_type == CPERF_CIPHER_THEN_AUTH) {
                if (options->cipher_op != RTE_CRYPTO_CIPHER_OP_ENCRYPT &&
                                options->auth_op !=
@@ -1244,14 +1266,6 @@ cperf_options_check(struct cperf_options *options)
                                        " options: encrypt and generate.\n");
                        return -EINVAL;
                }
-       } else if (options->op_type == CPERF_AUTH_THEN_CIPHER) {
-               if (options->cipher_op != RTE_CRYPTO_CIPHER_OP_DECRYPT &&
-                               options->auth_op !=
-                               RTE_CRYPTO_AUTH_OP_VERIFY) {
-                       RTE_LOG(ERR, USER1, "Option auth then cipher must use"
-                                       " options: decrypt and verify.\n");
-                       return -EINVAL;
-               }
        }
 
        if (options->op_type == CPERF_CIPHER_ONLY ||