From: Pablo de Lara Date: Mon, 27 Mar 2017 11:26:05 +0000 (+0100) Subject: app/crypto-perf: add extra option checks X-Git-Tag: spdx-start~3727 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=fc4600fb252031b7bea8aa4b984539c8c1338f8d;p=dpdk.git app/crypto-perf: add extra option checks When using the verify test, test name is necessary to be passed when digest is needed. Also, when using an block cipher algorithm (CBC, ECB), the buffer size has to be aligned to the block size. Signed-off-by: Pablo de Lara Acked-by: Sergio Gonzalez Monroy --- diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c index e458f6dac5..d172671fb5 100644 --- a/app/test-crypto-perf/cperf_options_parsing.c +++ b/app/test-crypto-perf/cperf_options_parsing.c @@ -38,6 +38,9 @@ #include "cperf_options.h" +#define AES_BLOCK_SIZE 16 +#define DES_BLOCK_SIZE 8 + struct name_id_map { const char *name; uint32_t id; @@ -717,6 +720,8 @@ cperf_options_parse(struct cperf_options *options, int argc, char **argv) int cperf_options_check(struct cperf_options *options) { + uint32_t buffer_size, buffer_size_idx = 0; + if (options->segments_nb > options->min_buffer_size) { RTE_LOG(ERR, USER1, "Segments number greater than buffer size.\n"); @@ -730,6 +735,14 @@ cperf_options_check(struct cperf_options *options) return -EINVAL; } + if (options->test == CPERF_TEST_TYPE_VERIFY && + options->op_type != CPERF_CIPHER_ONLY && + options->test_name == NULL) { + RTE_LOG(ERR, USER1, "Define test name to get the correct digest" + " from the test vectors.\n"); + return -EINVAL; + } + if (options->test_name != NULL && options->test_file == NULL) { RTE_LOG(ERR, USER1, "Define path to the file with test" " vectors.\n"); @@ -807,6 +820,45 @@ cperf_options_check(struct cperf_options *options) } } + if (options->cipher_algo == RTE_CRYPTO_CIPHER_AES_CBC || + options->cipher_algo == RTE_CRYPTO_CIPHER_AES_ECB) { + if (options->inc_buffer_size != 0) + buffer_size = options->min_buffer_size; + else + buffer_size = options->buffer_size_list[0]; + + while (buffer_size <= options->max_buffer_size) { + if ((buffer_size % AES_BLOCK_SIZE) != 0) { + RTE_LOG(ERR, USER1, "Some of the buffer sizes are " + "not suitable for the algorithm selected\n"); + return -EINVAL; + } + + if (options->inc_buffer_size != 0) + buffer_size += options->inc_buffer_size; + else { + if (++buffer_size_idx == options->buffer_size_count) + break; + buffer_size = options->buffer_size_list[buffer_size_idx]; + } + + } + } + + if (options->cipher_algo == RTE_CRYPTO_CIPHER_DES_CBC || + options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_CBC || + options->cipher_algo == RTE_CRYPTO_CIPHER_3DES_ECB) { + for (buffer_size = options->min_buffer_size; + buffer_size < options->max_buffer_size; + buffer_size += options->inc_buffer_size) { + if ((buffer_size % DES_BLOCK_SIZE) != 0) { + RTE_LOG(ERR, USER1, "Some of the buffer sizes are " + "not suitable for the algorithm selected\n"); + return -EINVAL; + } + } + } + return 0; }