From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 35C44379B for ; Fri, 11 Mar 2016 01:00:40 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 10 Mar 2016 16:00:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,317,1455004800"; d="scan'208";a="63916686" Received: from sie-lab-212-116.ir.intel.com ([10.237.212.116]) by fmsmga004.fm.intel.com with ESMTP; 10 Mar 2016 16:00:38 -0800 From: Pablo de Lara To: dev@dpdk.org Date: Fri, 11 Mar 2016 00:02:49 +0000 Message-Id: <1457654571-17432-5-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457654571-17432-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1457654571-17432-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH 4/6] l2fwd_crypto: add AAD parsing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Mar 2016 00:00:40 -0000 So far, L2fwd crypto app could parse cipher, auth keys and IV, but not AAD (additional authentication data). Signed-off-by: Pablo de Lara --- examples/l2fwd-crypto/main.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index bc37746..d7e3499 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -144,6 +144,9 @@ struct l2fwd_crypto_options { struct rte_crypto_sym_xform auth_xform; uint8_t akey_param; + + struct l2fwd_key aad; + unsigned aad_param; }; /** l2fwd crypto lcore params */ @@ -154,6 +157,7 @@ struct l2fwd_crypto_params { unsigned digest_length; unsigned block_size; struct l2fwd_key iv; + struct l2fwd_key aad; struct rte_cryptodev_sym_session *session; }; @@ -404,6 +408,12 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m, op->sym->cipher.iv.phys_addr = cparams->iv.phys_addr; op->sym->cipher.iv.length = cparams->iv.length; + if (cparams->aad.length) { + op->sym->auth.aad.data = cparams->aad.data; + op->sym->auth.aad.phys_addr = cparams->aad.phys_addr; + op->sym->auth.aad.length = cparams->aad.length; + } + op->sym->cipher.data.offset = ipdata_offset; op->sym->cipher.data.length = data_len; @@ -556,6 +566,15 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options) generate_random_key(options->iv.data, port_cparams[i].iv.length); + port_cparams[i].aad.length = + options->auth_xform.auth.add_auth_data_length; + port_cparams[i].aad.phys_addr = options->aad.phys_addr; + port_cparams[i].aad.data = options->aad.data; + if (!options->aad_param) + generate_random_key(options->aad.data, + port_cparams[i].aad.length); + + port_cparams[i].session = initialize_crypto_session(options, port_cparams[i].dev_id); @@ -695,6 +714,7 @@ l2fwd_crypto_usage(const char *prgname) " --auth_algo ALGO\n" " --auth_op GENERATE / VERIFY\n" " --auth_key KEY\n" + " --aad AAD\n" " --sessionless\n", prgname); @@ -871,6 +891,11 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options, return parse_key(options->auth_xform.auth.key.data, optarg); } + else if (strcmp(lgopts[option_index].name, "aad") == 0) { + options->aad_param = 1; + return parse_key(options->aad.data, optarg); + } + else if (strcmp(lgopts[option_index].name, "sessionless") == 0) { options->sessionless = 1; return 0; @@ -981,6 +1006,7 @@ l2fwd_crypto_default_options(struct l2fwd_crypto_options *options) options->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; options->auth_xform.next = NULL; options->akey_param = 0; + options->aad_param = 0; options->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC; options->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY; @@ -1039,6 +1065,7 @@ l2fwd_crypto_parse_args(struct l2fwd_crypto_options *options, { "auth_key", required_argument, 0, 0 }, { "iv", required_argument, 0, 0 }, + { "aad", required_argument, 0, 0 }, { "sessionless", no_argument, 0, 0 }, @@ -1354,6 +1381,11 @@ reserve_key_memory(struct l2fwd_crypto_options *options) if (options->iv.data == NULL) rte_exit(EXIT_FAILURE, "Failed to allocate memory for IV"); options->iv.phys_addr = rte_malloc_virt2phy(options->iv.data); + + options->aad.data = rte_malloc("aad", MAX_KEY_SIZE, 0); + if (options->aad.data == NULL) + rte_exit(EXIT_FAILURE, "Failed to allocate memory for AAD"); + options->aad.phys_addr = rte_malloc_virt2phy(options->aad.data); } int -- 2.5.0