From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0043.outbound.protection.outlook.com [104.47.33.43]) by dpdk.org (Postfix) with ESMTP id 1C4F211D4 for ; Tue, 29 Aug 2017 09:00:56 +0200 (CEST) Received: from BN3PR03CA0090.namprd03.prod.outlook.com (10.167.1.178) by BLUPR03MB549.namprd03.prod.outlook.com (10.141.76.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.13.10; Tue, 29 Aug 2017 07:00:54 +0000 Received: from BN1AFFO11FD039.protection.gbl (2a01:111:f400:7c10::171) by BN3PR03CA0090.outlook.office365.com (2a01:111:e400:7a4d::50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1362.18 via Frontend Transport; Tue, 29 Aug 2017 07:00:54 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD039.mail.protection.outlook.com (10.58.52.243) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1341.15 via Frontend Transport; Tue, 29 Aug 2017 07:00:53 +0000 Received: from netperf2.ap.freescale.net ([10.232.133.164]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v7T70o0O001223; Tue, 29 Aug 2017 00:00:51 -0700 From: Akhil Goyal To: , CC: , , Akhil Goyal Date: Tue, 29 Aug 2017 12:28:48 +0530 Message-ID: <20170829065849.11424-1-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170728110738.28922-3-akhil.goyal@nxp.com> References: <20170728110738.28922-3-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131484636539618839; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39380400002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(1076002)(5003940100001)(54906002)(305945005)(86362001)(77096006)(6666003)(356003)(189998001)(2950100002)(626005)(33646002)(47776003)(68736007)(105606002)(498600001)(4326008)(106466001)(85426001)(5660300001)(48376002)(76176999)(50986999)(8936002)(50466002)(97736004)(8656003)(2906002)(50226002)(53936002)(104016004)(81166006)(8676002)(81156014)(36756003)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB549; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD039; 1:HoPBlMNJrbJG9GVbE1i/y8od82G/snpqFWJjP8DYmu0niWh5qodgo1x1oCSMPC2RFEmQHHqLxnUCRrcXgbRvUjtOOpHq7NkwAwMCZx5rldF7B+qqq5GHUmz+L01cxOr1 MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0cc6de5b-0a37-464c-24b6-08d4eeabb0d2 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BLUPR03MB549; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB549; 3:EVwu9DHaKUU2P/OFOcB1JcQo4QkRnsmzTW51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tfu9EACRUDBsAtwZYcHpRtsLXusPpQUaP8eN6jWR7Ggrpp25laVvlCeutnQgIoQ/gnwFDt5FI1OTZ/6kBB8YvFf5SiFJr87P5EZMDxRCk/S6Tk5FDmk/hyyc/w+7pb9YeY22wUGJiYZ9+EjkdRVW8gJEZ6F7raQBytSnygpez0zTHF8MKMml+bUAgAb7aLb4a2wlwduOIHjT2ArcmzV4Pnb1Wpan8DEeZpDCCZQX7c7Mcu4yda6HPtspgHgMKeA== X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(788757137089); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(13016025)(13018025)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6096035)(20161123561025)(20161123563025)(20161123556025)(20161123565025)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123559100)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BLUPR03MB549; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BLUPR03MB549; X-Forefront-PRVS: 0414DF926F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR03MB549; 23:vZ7wERDwAY83A29EfWfCzgtDV3nM7QJlVL7bwfei4X?= =?us-ascii?Q?QjCnQIPMmwExrPG8MjeusOt4YR8oOSmsjyAqeY9D20OS5CxEXNPCP+I6yNgw?= =?us-ascii?Q?hzLqr76ie8j8Go99naYhkSMU4yWoaYhLhTkR95tHJY4gDApQZLg8XvwlTeYV?= =?us-ascii?Q?X/2EL48Qt7QYwYSzqJllI/r2mydxn1Z0GxL7Y59nlIqhsv5LNGOmU144/3HH?= =?us-ascii?Q?K8j6nptBmrxz5+QBrLuo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zljo=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB549; 6:/8FxZimbvH4zmF/D1nqMht+E+uWupccLxirLH2BafT3T+FjD+CmGW9fw35jE7ILr9xaInrspjaEffycfJCjSuIGbG/PkCSxZqr6FvrxBRn+wNbijbMo6vy59ovF4PlAj3BOZyERs2uNHiFVawxvl8cLmcq+dSkOs1qCoDPaB2Z0cvN4NFeilMYdz1j2krSiq/+t1ETOJYBPZEFKc3T+cOFOxQ7a93DH7/n8ZvH7UkMHgm98YGR2HJN/rb/vOHwH0GXHDQ5RV12dy1dBVogIKjhwAgPNu8HPFMzI4F9/hjHE2bdooRol6jdLQbcaGiljSBS4lJyvOHyetSVTjdhsPXw==; 5:J3lWPh/SCy4Rjbi5j+Tm3OXyrJaEGIKRXiW15ZQ6Bl4BJsipvsGDtcoV5OYAJ4zVYmMwblXS4cVMpg7jTvJ3bWm3EHVgowjMGGBTYJQwlaiG4bfBBEkieJJF6HF6gzGak6rnjy/czEQSZEwiaYeTbw==; 24:WceUAOvdY/3pHU6qD8IiAAExAhsURI3AKG/MsjzbDtaw4qZe97OdkUE+UqO2m0Hr51AAXV7sjCcHCW/LBn0KeNQNoTAzWFzue4R4t3PQxV4=; 7:89j68DkaVYpBwLF+XWuJogNE6vp93n1+Cb/Q7PV28uy3Hku/6MwKUUzteAfmG9st0VsnW1fu9jtp+gn4CYY++Ho0hLsRnhwr8h7e/fD4qoGdy4BrSthdzGj/xv8AcnaIUf6dM2DlQP8u+7t5W3grnBTi/T71AQ3g9bj4iWnyCduuhACANAfKVu2II85o47awRtZH2Ano1QeqxcHD4biYXmzUw2qN6SR9q8n4Tg9si/s= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2017 07:00:53.7746 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB549 Subject: [dpdk-dev] [PATCH v2 1/2] crypto/openssl: replace evp APIs with HMAC APIs 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: , X-List-Received-Date: Tue, 29 Aug 2017 07:00:57 -0000 in case of HMAC the openssl APIs HMAC_XXX give better performance for all HMAC cases as compared with EVP_XXX Signed-off-by: Akhil Goyal --- changes in v2: patch split in two patches as per Pablo's recommendations drivers/crypto/openssl/rte_openssl_pmd.c | 37 +++++++++++++----------- drivers/crypto/openssl/rte_openssl_pmd_private.h | 3 +- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index 0bd5f98..889d632 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -39,6 +39,7 @@ #include #include +#include #include #include "rte_openssl_pmd_private.h" @@ -403,12 +404,16 @@ openssl_set_session_auth_parameters(struct openssl_session *sess, case RTE_CRYPTO_AUTH_SHA384_HMAC: case RTE_CRYPTO_AUTH_SHA512_HMAC: sess->auth.mode = OPENSSL_AUTH_AS_HMAC; - sess->auth.hmac.ctx = EVP_MD_CTX_create(); + HMAC_CTX_init(&sess->auth.hmac.ctx); if (get_auth_algo(xform->auth.algo, &sess->auth.hmac.evp_algo) != 0) return -EINVAL; - sess->auth.hmac.pkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, - xform->auth.key.data, xform->auth.key.length); + + if (HMAC_Init_ex(&sess->auth.hmac.ctx, + xform->auth.key.data, + xform->auth.key.length, + sess->auth.hmac.evp_algo, NULL) != 1) + return -EINVAL; break; default: @@ -547,7 +552,7 @@ openssl_reset_session(struct openssl_session *sess) break; case OPENSSL_AUTH_AS_HMAC: EVP_PKEY_free(sess->auth.hmac.pkey); - EVP_MD_CTX_destroy(sess->auth.hmac.ctx); + HMAC_CTX_cleanup(&sess->auth.hmac.ctx); break; default: break; @@ -971,10 +976,9 @@ process_openssl_auth(struct rte_mbuf *mbuf_src, uint8_t *dst, int offset, /** Process standard openssl auth algorithms with hmac */ static int process_openssl_auth_hmac(struct rte_mbuf *mbuf_src, uint8_t *dst, int offset, - __rte_unused uint8_t *iv, EVP_PKEY *pkey, - int srclen, EVP_MD_CTX *ctx, const EVP_MD *algo) + int srclen, HMAC_CTX *ctx) { - size_t dstlen; + unsigned int dstlen; struct rte_mbuf *m; int l, n = srclen; uint8_t *src; @@ -986,19 +990,16 @@ process_openssl_auth_hmac(struct rte_mbuf *mbuf_src, uint8_t *dst, int offset, if (m == 0) goto process_auth_err; - if (EVP_DigestSignInit(ctx, NULL, algo, NULL, pkey) <= 0) - goto process_auth_err; - src = rte_pktmbuf_mtod_offset(m, uint8_t *, offset); l = rte_pktmbuf_data_len(m) - offset; if (srclen <= l) { - if (EVP_DigestSignUpdate(ctx, (char *)src, srclen) <= 0) + if (HMAC_Update(ctx, (unsigned char *)src, srclen) != 1) goto process_auth_err; goto process_auth_final; } - if (EVP_DigestSignUpdate(ctx, (char *)src, l) <= 0) + if (HMAC_Update(ctx, (unsigned char *)src, l) != 1) goto process_auth_err; n -= l; @@ -1006,13 +1007,16 @@ process_openssl_auth_hmac(struct rte_mbuf *mbuf_src, uint8_t *dst, int offset, for (m = m->next; (m != NULL) && (n > 0); m = m->next) { src = rte_pktmbuf_mtod(m, uint8_t *); l = rte_pktmbuf_data_len(m) < n ? rte_pktmbuf_data_len(m) : n; - if (EVP_DigestSignUpdate(ctx, (char *)src, l) <= 0) + if (HMAC_Update(ctx, (unsigned char *)src, l) != 1) goto process_auth_err; n -= l; } process_auth_final: - if (EVP_DigestSignFinal(ctx, dst, &dstlen) <= 0) + if (HMAC_Final(ctx, dst, &dstlen) != 1) + goto process_auth_err; + + if (unlikely(HMAC_Init_ex(ctx, NULL, 0, NULL, NULL) != 1)) goto process_auth_err; return 0; @@ -1265,9 +1269,8 @@ process_openssl_auth_op break; case OPENSSL_AUTH_AS_HMAC: status = process_openssl_auth_hmac(mbuf_src, dst, - op->sym->auth.data.offset, NULL, - sess->auth.hmac.pkey, srclen, - sess->auth.hmac.ctx, sess->auth.hmac.evp_algo); + op->sym->auth.data.offset, srclen, + &sess->auth.hmac.ctx); break; default: status = -1; diff --git a/drivers/crypto/openssl/rte_openssl_pmd_private.h b/drivers/crypto/openssl/rte_openssl_pmd_private.h index b7f7475..e36741e 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_private.h +++ b/drivers/crypto/openssl/rte_openssl_pmd_private.h @@ -34,6 +34,7 @@ #define _OPENSSL_PMD_PRIVATE_H_ #include +#include #include #define CRYPTODEV_NAME_OPENSSL_PMD crypto_openssl @@ -164,7 +165,7 @@ struct openssl_session { /**< pointer to EVP key */ const EVP_MD *evp_algo; /**< pointer to EVP algorithm function */ - EVP_MD_CTX *ctx; + HMAC_CTX ctx; /**< pointer to EVP context structure */ } hmac; }; -- 2.9.3