From: Slawomir Mrozowicz Date: Thu, 9 Feb 2017 13:57:29 +0000 (+0100) Subject: app/crypto-perf: fix crash for wireless algorithms X-Git-Tag: spdx-start~4503 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=0620ebfa233f9818b6f627c75f49d8474f36b6b6;p=dpdk.git app/crypto-perf: fix crash for wireless algorithms This commit fixes segmentation fault that happens when using KASUMI, SNOW3G or ZUC authentication algorithms, as they need authentication keys and was not being set. It also set value of authentication key to cipher key when using GMAC algorithm. Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application") Signed-off-by: Slawomir Mrozowicz Acked-by: Pablo de Lara --- diff --git a/app/test-crypto-perf/cperf_test_vectors.c b/app/test-crypto-perf/cperf_test_vectors.c index e47a58191e..6307f253e7 100644 --- a/app/test-crypto-perf/cperf_test_vectors.c +++ b/app/test-crypto-perf/cperf_test_vectors.c @@ -433,22 +433,39 @@ cperf_test_vector_get_dummy(struct cperf_options *options) options->op_type == CPERF_CIPHER_THEN_AUTH || options->op_type == CPERF_AUTH_THEN_CIPHER || options->op_type == CPERF_AEAD) { + uint8_t aad_alloc = 0; + t_vec->auth_key.length = options->auth_key_sz; - if (options->auth_algo == RTE_CRYPTO_AUTH_NULL) { + + switch (options->auth_algo) { + case RTE_CRYPTO_AUTH_NULL: t_vec->auth_key.data = NULL; - t_vec->aad.data = NULL; - } else if (options->auth_algo == RTE_CRYPTO_AUTH_AES_GCM || - options->auth_algo == - RTE_CRYPTO_AUTH_AES_GMAC || - options->auth_algo == - RTE_CRYPTO_AUTH_SNOW3G_UIA2 || - options->auth_algo == - RTE_CRYPTO_AUTH_KASUMI_F9 || - options->auth_algo == - RTE_CRYPTO_AUTH_ZUC_EIA3) { + aad_alloc = 0; + break; + case RTE_CRYPTO_AUTH_AES_GCM: t_vec->auth_key.data = NULL; - t_vec->aad.data = rte_malloc(NULL, options->auth_aad_sz, - 16); + aad_alloc = 1; + break; + case RTE_CRYPTO_AUTH_SNOW3G_UIA2: + case RTE_CRYPTO_AUTH_KASUMI_F9: + case RTE_CRYPTO_AUTH_ZUC_EIA3: + t_vec->auth_key.data = auth_key; + aad_alloc = 1; + break; + case RTE_CRYPTO_AUTH_AES_GMAC: + /* auth key should be the same as cipher key */ + t_vec->auth_key.data = cipher_key; + aad_alloc = 1; + break; + default: + t_vec->auth_key.data = auth_key; + aad_alloc = 0; + break; + } + + if (aad_alloc) { + t_vec->aad.data = rte_malloc(NULL, + options->auth_aad_sz, 16); if (t_vec->aad.data == NULL) { if (options->op_type != CPERF_AUTH_ONLY) rte_free(t_vec->iv.data); @@ -457,7 +474,6 @@ cperf_test_vector_get_dummy(struct cperf_options *options) } memcpy(t_vec->aad.data, aad, options->auth_aad_sz); } else { - t_vec->auth_key.data = auth_key; t_vec->aad.data = NULL; }