From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0071.outbound.protection.outlook.com [104.47.36.71]) by dpdk.org (Postfix) with ESMTP id 242AB374F for ; Tue, 5 Sep 2017 08:00:02 +0200 (CEST) Received: from MWHPR03CA0036.namprd03.prod.outlook.com (10.174.173.153) by CY4PR03MB3317.namprd03.prod.outlook.com (10.171.246.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Tue, 5 Sep 2017 06:00:00 +0000 Received: from BY2FFO11FD048.protection.gbl (2a01:111:f400:7c0c::153) by MWHPR03CA0036.outlook.office365.com (2603:10b6:301:3b::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10 via Frontend Transport; Tue, 5 Sep 2017 05:59:59 +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 BY2FFO11FD048.mail.protection.outlook.com (10.1.15.176) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1385.11 via Frontend Transport; Tue, 5 Sep 2017 05:59:59 +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 v855xuXv014431; Mon, 4 Sep 2017 22:59:57 -0700 From: Akhil Goyal To: , CC: , , Akhil Goyal Date: Tue, 5 Sep 2017 11:27:48 +0530 Message-ID: <20170905055749.23126-1-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170829065849.11424-2-akhil.goyal@nxp.com> References: <20170829065849.11424-2-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131490647998570420; (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)(2906002)(5003940100001)(626005)(189998001)(33646002)(86362001)(76176999)(4326008)(5660300001)(50986999)(105606002)(106466001)(8936002)(81156014)(8656003)(36756003)(6666003)(2950100002)(1076002)(50226002)(81166006)(8676002)(356003)(305945005)(48376002)(50466002)(68736007)(104016004)(77096006)(54906002)(498600001)(85426001)(47776003)(97736004)(53936002)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB3317; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD048; 1:F6pdNCMsD03bBaOALaXFskkt1Qe+UCUt46Qvu1T837MaQJrL9pbAlo4BU46VnYOugNnypUADA1QrVPO0+IsrJSIwlAzH/wa+rwZ/hAduLGDPDLUwDCStt6GhaVOyn6lV MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc0cfdf7-2d02-47f6-3e55-08d4f42357b2 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CY4PR03MB3317; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB3317; 3:eddxMmVges5lGcvkDA2PAYKQNPe0Iw7dsoHQj/5sCybywQ/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FTnWHW0bKhTm4eQXD9k2rLs+krjpi+CAfbGzMflnpMHUmlZbUXc2BOi3OOXYfbePnVHB9pPApvBTwcpl0ADuILbTps1h4v+tEOLYvzYgKb5nOIg0zR7Rm1FcwXuxK108iVlQ8wxeqgpApmmzkcmcfAGvxtkWvCNL8pePVzY9cf+j0t/UJsxBTJijROfzI0wfPN3PEqp4qe7Nmxp6FjiOokioH64nEXfU6j+4mQKxmKdMvqKCsmyY+IbFdrH6kf5sl8= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(788757137089)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6096035)(20161123561025)(20161123563025)(20161123565025)(20161123556025)(20161123559100)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR03MB3317; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR03MB3317; X-Forefront-PRVS: 0421BF7135 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR03MB3317; 23:I0Dub08LuYHXY0WgKtrB6wqEP6CMj8j+r5YEWjJl3?= =?us-ascii?Q?Pmgsakn7BdyW4sDjXeUFEj3zACn98d96031lNMzuU7/yI/BBA5aXstubFmsa?= =?us-ascii?Q?In1IpE8RV3hWLs6HzShAmu05vGIfk0RsImW0ojp7jhnFZx1vnL7mk0kPWPSK?= =?us-ascii?Q?byEyRNYN7eAnox6UToPiwduqsjolV2n0pICP2vXhzcq56UxMyuRO5w5N/iDL?= =?us-ascii?Q?N4/yAyRuEnsc/ukgx99wGezT6GgXnw5c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?dywXWHrCjM=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB3317; 6:dM/n1mnC7r5QqhzdoqKVLAs0ytFb1DaIr1QrqKHD9XyUgm9ryp0gjiRdeIQiHLDrdy97YmGa6LVPyo6chu8XUxy/Gr+qaW3dv6CeO9ZWYU3giuZ5QvB0AanEDKOIOBoIOiK+44nW0fK3NuympSxBbPxef8Pr348Mtkwfxyd6GR33tHXKQRkx/ACCLeb8AV/Yb600+7kBi/pppdqxSTmkNcBb7nI6VKPv7JWY+BZP6GMaIsS9rxdskB9ojgoyCl6qxWqeXrPsro+QVXr/1f2g59WSdTz+5g5eoBnuNlxqH0UzVIFtWBhy9XKHEpXnRIwCG93JWnsbV9Q8mUtK9fvD+g==; 5:0Gop9RNQziW1EmDYPri8AvOXAIG71FvgL3/DUi5VERCQK1Vl/n0QwDXrD9543FcP2h4nbKCzRDna2fCR9WUtWaNqA6IBzKvHrvAYWZRwMwfFLhbJjqeHDjAgFTIM72K2CpKLoEK2hhdHiDhEQD3njQ==; 24:IpfGOEJIUrLyiCTKNMuAbFJy2CRo3oPfPwlhqzgN0wQS+FMPMXY61CgmwnpBJXDenNMzhog5IfAGIlD7NTA/WvO7WNaredyOpub1TDY8yhE=; 7:k0wuJh46aDoFK4po7dQ+H+kKeMoO79W2Dev4pFwbePvwgIXgiAw2j201Zx2kRVrewXrWR2pK0Y/0TrSvLfjeXA27Q59cNR7mOxcCqcrUEWuDuYZbR+VfJJ52EBru0K9FjnVcD1Xxr3qdk2ES+0qbVW5pqW8ze3Zj79ISq7pcoTjGwH88qkZXwB3oJ8UYuJFaLCqP3wX5IsbtgWoy7C26mkhebPE47ko84ChytNExZ6Q= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2017 05:59:59.6542 (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: CY4PR03MB3317 Subject: [dpdk-dev] [PATCH v3 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, 05 Sep 2017 06:00:02 -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 Reviewed-by: Pablo de Lara --- 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