From patchwork Thu Sep 21 13:11:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "De Lara Guarch, Pablo" X-Patchwork-Id: 29075 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 90ADB1B1A8; Thu, 21 Sep 2017 23:11:51 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 172AE1B1A3 for ; Thu, 21 Sep 2017 23:11:47 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2017 14:11:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,426,1500966000"; d="scan'208";a="902703274" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by FMSMGA003.fm.intel.com with ESMTP; 21 Sep 2017 14:11:46 -0700 From: Pablo de Lara To: declan.doherty@intel.com, fiona.trahe@intel.com, deepak.k.jain@intel.com, john.griffin@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Thu, 21 Sep 2017 14:11:16 +0100 Message-Id: <20170921131123.16513-4-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170921131123.16513-1-pablo.de.lara.guarch@intel.com> References: <20170818080728.43248-1-pablo.de.lara.guarch@intel.com> <20170921131123.16513-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v2 3/9] app/crypto-perf: add AES-CCM support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" According to the API, AES-CCM has special requirements when setting IV and AAD fields. The L2fwd-crypto app is updated to set the nonce (IV) and AAD in the right positions in these two fields (1 byte after start of IV field and 18 bytes after start of AAD). Signed-off-by: Pablo de Lara --- app/test-crypto-perf/cperf_ops.c | 21 +++++++++++++++-- app/test-crypto-perf/cperf_test_latency.c | 34 +++++++++++++++++++++++---- app/test-crypto-perf/cperf_test_throughput.c | 34 +++++++++++++++++++++++---- app/test-crypto-perf/cperf_test_verify.c | 35 ++++++++++++++++++++++++---- 4 files changed, 107 insertions(+), 17 deletions(-) diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c index 88fb972..df579f8 100644 --- a/app/test-crypto-perf/cperf_ops.c +++ b/app/test-crypto-perf/cperf_ops.c @@ -318,7 +318,15 @@ cperf_set_ops_aead(struct rte_crypto_op **ops, /* AEAD parameters */ sym_op->aead.data.length = options->test_buffer_size; - sym_op->aead.data.offset = + /* + * If doing AES-CCM, first 18 bytes has to be reserved, + * and actual AAD should start from byte 18 + */ + if (options->aead_algo == RTE_CRYPTO_AEAD_AES_CCM) + sym_op->aead.data.offset = + RTE_ALIGN_CEIL(options->aead_aad_sz + 18, 16); + else + sym_op->aead.data.offset = RTE_ALIGN_CEIL(options->aead_aad_sz, 16); sym_op->aead.aad.data = rte_pktmbuf_mtod(bufs_in[i], uint8_t *); @@ -358,8 +366,17 @@ cperf_set_ops_aead(struct rte_crypto_op **ops, uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ops[i], uint8_t *, iv_offset); - memcpy(iv_ptr, test_vector->aead_iv.data, + /* + * If doing AES-CCM, nonce is copied one byte + * after the start of IV field + */ + if (options->aead_algo == RTE_CRYPTO_AEAD_AES_CCM) + memcpy(iv_ptr + 1, test_vector->aead_iv.data, test_vector->aead_iv.length); + else + memcpy(iv_ptr, test_vector->aead_iv.data, + test_vector->aead_iv.length); + } } diff --git a/app/test-crypto-perf/cperf_test_latency.c b/app/test-crypto-perf/cperf_test_latency.c index 58b21ab..0e21092 100644 --- a/app/test-crypto-perf/cperf_test_latency.c +++ b/app/test-crypto-perf/cperf_test_latency.c @@ -175,13 +175,29 @@ cperf_mbuf_create(struct rte_mempool *mempool, } if (options->op_type == CPERF_AEAD) { - uint8_t *aead = (uint8_t *)rte_pktmbuf_prepend(mbuf, - RTE_ALIGN_CEIL(options->aead_aad_sz, 16)); + /* + * If doing AES-CCM, first 18 bytes has to be reserved, + * and actual AAD should start from byte 18 + */ + if (options->aead_algo == RTE_CRYPTO_AEAD_AES_CCM) { + uint8_t *aad = (uint8_t *)rte_pktmbuf_prepend(mbuf, + RTE_ALIGN_CEIL(options->aead_aad_sz + 18, 16)); + + if (aad == NULL) + goto error; + + memcpy(aad + 18, test_vector->aad.data, + test_vector->aad.length); + } else { + uint8_t *aad = (uint8_t *)rte_pktmbuf_prepend(mbuf, + RTE_ALIGN_CEIL(options->aead_aad_sz, 16)); - if (aead == NULL) - goto error; + if (aad == NULL) + goto error; - memcpy(aead, test_vector->aad.data, test_vector->aad.length); + memcpy(aad, test_vector->aad.data, + test_vector->aad.length); + } } return mbuf; @@ -293,6 +309,14 @@ cperf_latency_test_constructor(struct rte_mempool *sess_mp, test_vector->cipher_iv.length + test_vector->auth_iv.length + test_vector->aead_iv.length; + /* + * If doing AES-CCM, 16 bytes need to be reserved, + * regardless the IV length + */ + if (options->op_type == CPERF_AEAD && + options->aead_algo == RTE_CRYPTO_AEAD_AES_CCM) + priv_size = 16; + ctx->crypto_op_pool = rte_crypto_op_pool_create(pool_name, RTE_CRYPTO_OP_TYPE_SYMMETRIC, options->pool_sz, 512, priv_size, rte_socket_id()); diff --git a/app/test-crypto-perf/cperf_test_throughput.c b/app/test-crypto-perf/cperf_test_throughput.c index 3bb1cb0..6f34708 100644 --- a/app/test-crypto-perf/cperf_test_throughput.c +++ b/app/test-crypto-perf/cperf_test_throughput.c @@ -159,13 +159,29 @@ cperf_mbuf_create(struct rte_mempool *mempool, } if (options->op_type == CPERF_AEAD) { - uint8_t *aead = (uint8_t *)rte_pktmbuf_prepend(mbuf, - RTE_ALIGN_CEIL(options->aead_aad_sz, 16)); + /* + * If doing AES-CCM, first 18 bytes has to be reserved, + * and actual AAD should start from byte 18 + */ + if (options->aead_algo == RTE_CRYPTO_AEAD_AES_CCM) { + uint8_t *aad = (uint8_t *)rte_pktmbuf_prepend(mbuf, + RTE_ALIGN_CEIL(options->aead_aad_sz + 18, 16)); + + if (aad == NULL) + goto error; + + memcpy(aad + 18, test_vector->aad.data, + test_vector->aad.length); + } else { + uint8_t *aad = (uint8_t *)rte_pktmbuf_prepend(mbuf, + RTE_ALIGN_CEIL(options->aead_aad_sz, 16)); - if (aead == NULL) - goto error; + if (aad == NULL) + goto error; - memcpy(aead, test_vector->aad.data, test_vector->aad.length); + memcpy(aad, test_vector->aad.data, + test_vector->aad.length); + } } return mbuf; @@ -273,6 +289,14 @@ cperf_throughput_test_constructor(struct rte_mempool *sess_mp, uint16_t priv_size = test_vector->cipher_iv.length + test_vector->auth_iv.length + test_vector->aead_iv.length; + /* + * If doing AES-CCM, 16 bytes need to be reserved, + * regardless the IV length + */ + if (options->op_type == CPERF_AEAD && + options->aead_algo == RTE_CRYPTO_AEAD_AES_CCM) + priv_size = 16; + ctx->crypto_op_pool = rte_crypto_op_pool_create(pool_name, RTE_CRYPTO_OP_TYPE_SYMMETRIC, options->pool_sz, 512, priv_size, rte_socket_id()); diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c index a314646..32818fe 100644 --- a/app/test-crypto-perf/cperf_test_verify.c +++ b/app/test-crypto-perf/cperf_test_verify.c @@ -163,13 +163,29 @@ cperf_mbuf_create(struct rte_mempool *mempool, } if (options->op_type == CPERF_AEAD) { - uint8_t *aead = (uint8_t *)rte_pktmbuf_prepend(mbuf, - RTE_ALIGN_CEIL(options->aead_aad_sz, 16)); + /* + * If doing AES-CCM, first 18 bytes has to be reserved, + * and actual AAD should start from byte 18 + */ + if (options->aead_algo == RTE_CRYPTO_AEAD_AES_CCM) { + uint8_t *aad = (uint8_t *)rte_pktmbuf_prepend(mbuf, + RTE_ALIGN_CEIL(options->aead_aad_sz + 18, 16)); - if (aead == NULL) - goto error; + if (aad == NULL) + goto error; + + memcpy(aad + 18, test_vector->aad.data, + test_vector->aad.length); + } else { + uint8_t *aad = (uint8_t *)rte_pktmbuf_prepend(mbuf, + RTE_ALIGN_CEIL(options->aead_aad_sz, 16)); - memcpy(aead, test_vector->aad.data, test_vector->aad.length); + if (aad == NULL) + goto error; + + memcpy(aad, test_vector->aad.data, + test_vector->aad.length); + } } return mbuf; @@ -276,6 +292,15 @@ cperf_verify_test_constructor(struct rte_mempool *sess_mp, uint16_t priv_size = test_vector->cipher_iv.length + test_vector->auth_iv.length + test_vector->aead_iv.length; + + /* + * If doing AES-CCM, 16 bytes need to be reserved, + * regardless the IV length + */ + if (options->op_type == CPERF_AEAD && + options->aead_algo == RTE_CRYPTO_AEAD_AES_CCM) + priv_size = 16; + ctx->crypto_op_pool = rte_crypto_op_pool_create(pool_name, RTE_CRYPTO_OP_TYPE_SYMMETRIC, options->pool_sz, 512, priv_size, rte_socket_id());