From patchwork Thu Dec 14 10:00:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 121890 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6594452qgn; Thu, 14 Dec 2017 02:01:24 -0800 (PST) X-Google-Smtp-Source: ACJfBoscNw8PrsUsL65tSBzBd/A/CIQh6O5M2Kkc5/MeFlVcsMmnPzRUDuvLIV1K/J8qvpzsjgIj X-Received: by 10.55.40.76 with SMTP id o73mr15210656qkh.301.1513245683868; Thu, 14 Dec 2017 02:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513245683; cv=none; d=google.com; s=arc-20160816; b=V+iPyb3uivR0hWsxkf+RrvwVOGCbYqVJQK0AZG/k5Wm9SC1OkSpG7CxNp3CsXWES8z V96BpUPRMwJ5vpm2uYTL/pwbtRDjgVI/DWQD1Am+jpyUrNyKP+HX1t1+SFGo+GwtFrEU cBNZUOgR+D2+TVuWZRv0Lsi1oOeSqNflC5s1BprLRAroskYRaTD7lyhnqKf7B1LkJ1Gx WQK1jOLgPNH7RAeP++Fp0FEgdkwVjhqVy5SIVUdoi446lvDSwQTSMsvYvKedGje3LHCg x4wOysn688mi6vgX/DzGkSeYBOoAoN/1K9I0HH8Q5nd05eQ78EjAmBSLcy8JEwCjrASH u/yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=uo3GQJ8xd487wQunHdYQWJZOBSgDiBufHf0I0Rfo8Lo=; b=0qY8j5iQlxELCofWnwBPsNS5/hg/lUNtA5RPXH6edLBVqXvBa9QoO6CgrqgXZPQhqW pSAQ9WbjI5znLw1W/5gwMAogMid1O/LtvTYqeLTXKF82jwr8bJaXz2HICGjjIs60W6tz HDsAyyYfWUL8+6DyitNYgg+6U57NloSXz4bxJnOpS3AXbU5+rZ9s1g/253fYnkkmdNz/ M7ziNive0JdoMuDxSLebR2w5Y/yfQPMU2Ulo+EYcB2MYKdin4CXNojTwZ4SyYyhNdDlY mGCzrtQjhnGj6kLnVgemUSvAUahWkaOWLplecLBnTw1/GT+EWYmtMauiQx33j64Vvvi3 v0NA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id m1si3970862qkc.328.2017.12.14.02.01.23; Thu, 14 Dec 2017 02:01:23 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 7B44B60955; Thu, 14 Dec 2017 10:01:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id A1CF460918; Thu, 14 Dec 2017 10:00:27 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 5D4F860918; Thu, 14 Dec 2017 10:00:20 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id DF7A16087C for ; Thu, 14 Dec 2017 10:00:17 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward103j.mail.yandex.net (Yandex) with ESMTP id D88B134C5C89 for ; Thu, 14 Dec 2017 13:00:16 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id u8SS6RYI5a-0G88MswT; Thu, 14 Dec 2017 13:00:16 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZXeXutjQDE-0GSqXM5G; Thu, 14 Dec 2017 13:00:16 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 14 Dec 2017 13:00:12 +0300 Message-Id: <1513245615-4755-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513245615-4755-1-git-send-email-odpbot@yandex.ru> References: <1513245615-4755-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 342 Subject: [lng-odp] [PATCH v3 1/4] performance: add AES tests to crypto performance tests X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 342 (lumag:openssl-ctx) ** https://github.com/Linaro/odp/pull/342 ** Patch: https://github.com/Linaro/odp/pull/342.patch ** Base sha: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: b50f165406b6897013b69e014bf29f7b75c3ca45 **/ test/performance/odp_crypto.c | 71 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/test/performance/odp_crypto.c b/test/performance/odp_crypto.c index a65e4449e..423be0956 100644 --- a/test/performance/odp_crypto.c +++ b/test/performance/odp_crypto.c @@ -30,7 +30,7 @@ */ #define POOL_NUM_PKT 64 -static uint8_t test_iv[8] = "01234567"; +static uint8_t test_iv[16] = "0123456789abcdef"; static uint8_t test_key16[16] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, @@ -38,6 +38,12 @@ static uint8_t test_key16[16] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x10, }; +static uint8_t test_key20[20] = { 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0a, + 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, +}; + static uint8_t test_key24[24] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, @@ -226,6 +232,69 @@ static crypto_alg_config_t algs_config[] = { .auth_digest_len = 12, }, }, + { + .name = "aes-cbc-null", + .session = { + .cipher_alg = ODP_CIPHER_ALG_AES_CBC, + .cipher_key = { + .data = test_key16, + .length = sizeof(test_key16) + }, + .iv = { + .data = test_iv, + .length = 16, + }, + .auth_alg = ODP_AUTH_ALG_NULL + }, + }, + { + .name = "aes-cbc-hmac-sha1-96", + .session = { + .cipher_alg = ODP_CIPHER_ALG_AES_CBC, + .cipher_key = { + .data = test_key16, + .length = sizeof(test_key16) + }, + .iv = { + .data = test_iv, + .length = 16, + }, + .auth_alg = ODP_AUTH_ALG_SHA1_HMAC, + .auth_key = { + .data = test_key20, + .length = sizeof(test_key20) + }, + .auth_digest_len = 12, + }, + }, + { + .name = "null-hmac-sha1-96", + .session = { + .cipher_alg = ODP_CIPHER_ALG_NULL, + .auth_alg = ODP_AUTH_ALG_SHA1_HMAC, + .auth_key = { + .data = test_key20, + .length = sizeof(test_key20) + }, + .auth_digest_len = 12, + }, + }, + { + .name = "aes-gcm", + .session = { + .cipher_alg = ODP_CIPHER_ALG_AES_GCM, + .cipher_key = { + .data = test_key16, + .length = sizeof(test_key16) + }, + .iv = { + .data = test_iv, + .length = 12, + }, + .auth_alg = ODP_AUTH_ALG_AES_GCM, + .auth_digest_len = 16, + }, + }, }; /** From patchwork Thu Dec 14 10:00:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 121893 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6597759qgn; Thu, 14 Dec 2017 02:04:16 -0800 (PST) X-Google-Smtp-Source: ACJfBot6+hWPMEkThh5zJkaibz6SN4F4RXCD18UbMg5lGCys6rg8bNVMU6VrnLBn7tfVh+KJnxcs X-Received: by 10.237.59.202 with SMTP id s10mr15300206qte.294.1513245856139; Thu, 14 Dec 2017 02:04:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513245856; cv=none; d=google.com; s=arc-20160816; b=Ic0+X69g0cJMwy4m9Izgid2wqQ5402sKFpstInyH9Aith9K3u8YjkGEVFYli6Yj6ge YdNX18y4Hk7rML9Uziq8g4JPgaEnMKDQEryxhySUacwIbn3OyF3AP8K+eQuZMOLbKuU2 fqLDHGnk/apaX0W+EDuCqpzNyUtX3MH5EplhhvoEoSGEb6hEtJT64Ltp73d8W/Iv5Rr4 kmRJZgXJA/FmpwVI64MJfq9oQp3N1jPLRoRsLnxPrZt4Zr7wVizMYR6ds7QYVx2Qkw93 83Cbg+RPklHmDdkDGG77nfA8047mlzawSYBGfbmU3qHVFBnHfX1FwSPnVvDQkQKAl/In /Glw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=ZlaA3UCwqyn2h7tj/Q3C5dmSx4nhVq5yhUaSEqk8u+M=; b=mu2OS5VerLsOlmEM2f9JoRtlyE+45BjIZlXuDiT7bZYjqtdR8Wn1rv5VCSB8sO3uuJ h1HpTeQKM213BY82XdWsIcJgTM1t9D/kt+La1TScs3RiyC2SGizDRZO3yAcWSwULIj40 cvDZcRnrH9LTT6iVSQsppdf/f/Pe8qN1OJmfbR2qZtxGVHI5f7RdLJ4OSJUcDoBAicFC BcRsBSkQcwwOFb/YSudsZX1nakj6BT+GNpMxTiSIMCRtX8ydcql0lIIhPgetjOvRqW1T kagKaS2kLDEQqrx2edEZHiy4BzfyIgTzb2SgmKmnEdVBH+Wfl0DRoX1V4OWsgsI+bpRA OWTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id v8si4049264qka.435.2017.12.14.02.04.14; Thu, 14 Dec 2017 02:04:16 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id D1CB360922; Thu, 14 Dec 2017 10:04:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id D462C60943; Thu, 14 Dec 2017 10:00:36 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id CE9836065D; Thu, 14 Dec 2017 10:00:24 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 89AD56065D for ; Thu, 14 Dec 2017 10:00:18 +0000 (UTC) Received: from mxback3g.mail.yandex.net (mxback3g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:164]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 4329F510271E for ; Thu, 14 Dec 2017 13:00:17 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback3g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 0SM9yzrZ14-0Hb8KhdY; Thu, 14 Dec 2017 13:00:17 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZXeXutjQDE-0GSSx95G; Thu, 14 Dec 2017 13:00:16 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 14 Dec 2017 13:00:13 +0300 Message-Id: <1513245615-4755-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513245615-4755-1-git-send-email-odpbot@yandex.ru> References: <1513245615-4755-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 342 Subject: [lng-odp] [PATCH v3 2/4] performance: destroy out queue on exit X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 342 (lumag:openssl-ctx) ** https://github.com/Linaro/odp/pull/342 ** Patch: https://github.com/Linaro/odp/pull/342.patch ** Base sha: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: b50f165406b6897013b69e014bf29f7b75c3ca45 **/ test/performance/odp_crypto.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/performance/odp_crypto.c b/test/performance/odp_crypto.c index 423be0956..b2625b3ca 100644 --- a/test/performance/odp_crypto.c +++ b/test/performance/odp_crypto.c @@ -904,6 +904,11 @@ int main(int argc, char *argv[]) } } + if (out_queue != ODP_QUEUE_INVALID && odp_queue_destroy(out_queue)) { + app_err("Error: queue destroy\n"); + exit(EXIT_FAILURE); + } + if (odp_pool_destroy(pool)) { app_err("Error: pool destroy\n"); exit(EXIT_FAILURE); From patchwork Thu Dec 14 10:00:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 121891 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6595533qgn; Thu, 14 Dec 2017 02:02:15 -0800 (PST) X-Google-Smtp-Source: ACJfBosG7Kd92odutg+Xgt0kWS46iC6VZ3ySYIZgjv20FU2U2qzZvlH6fVv3Ue/3vFmaq6i0o4Lo X-Received: by 10.200.51.249 with SMTP id d54mr15527299qtb.168.1513245735372; Thu, 14 Dec 2017 02:02:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513245735; cv=none; d=google.com; s=arc-20160816; b=ryA5VrQq1p7YGyXbLyYd6hzzTwiW1BvIoy749r5o4AF88CQHRNidKpDl9dQ9G8vL2E hYRuQLy1MaEMKwqUD18WLWeXvh1p5ZdbiAI59w8eQbmbGCBI48D5iWLEd4n8hXt8+Ig/ TFuPprll16PToP0cUL/YwTFPDsZKYDsIgtBiM+en3JLyNG+BdLqO3AZW63uC8CpBQRMd D+rxr/yAD328BPMr4EjYImbl2HD85IY2cf5oBPQaJvCVKLmuFaJgeNsLaSWQGqPf3gig n2W44+1OCto6T5NJiofJ/QfJRxAyj40/5Eyq2GNHh46p0IWyl5gC30lMVBP6qRrIynCe 91Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=qKTfi7bZVyIPIl8TvNfXrbwsSv3MqxrSy3YS94yaAAI=; b=gRSaQqvXX2CqQ+7WxDhTvF93IKmyGg5nDodHl59ly6HItQnjMSFeYxTmULSJ3DYsPl PYKx87yv0C+XRJZWdWTKoGUnm6YtDgGduoopEVB8AAXvnVmqMOexizfgCL1o6gaz4Yjk IbEmpMkJBsXXuLWYEjMECP1fScCxH7S5uy8TozJC3xrWISSbm2bt1+XTiTwNr4Llr/BG 4lb6hAsLqdqBO7QZkPoOh6gpWmhIZlLKk75QTfDfqj/D0cPWe5rADaN5w13cO6uW2Nwb SXMnObEAtQg7JceF5tR6pt1kQ/+hxd0PPMDp+nt3otJqV8Kvfid84KyUoSMlulZNDkys WGRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id g28si3977286qtf.276.2017.12.14.02.02.15; Thu, 14 Dec 2017 02:02:15 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 023756091D; Thu, 14 Dec 2017 10:02:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id EC14760865; Thu, 14 Dec 2017 10:00:30 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 05A5260916; Thu, 14 Dec 2017 10:00:22 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 2CED860830 for ; Thu, 14 Dec 2017 10:00:19 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward102p.mail.yandex.net (Yandex) with ESMTP id ACA484303301 for ; Thu, 14 Dec 2017 13:00:17 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id wCYL2T23H0-0HmOlDrl; Thu, 14 Dec 2017 13:00:17 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZXeXutjQDE-0HSqoUnI; Thu, 14 Dec 2017 13:00:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 14 Dec 2017 13:00:14 +0300 Message-Id: <1513245615-4755-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513245615-4755-1-git-send-email-odpbot@yandex.ru> References: <1513245615-4755-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 342 Subject: [lng-odp] [PATCH v3 3/4] linux-gen: crypto: move session type to odp_crypto module X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov There is no point in having odp_crypto_generic_session_t definition in global include file. Move it to odp_crypto module. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 342 (lumag:openssl-ctx) ** https://github.com/Linaro/odp/pull/342 ** Patch: https://github.com/Linaro/odp/pull/342.patch ** Base sha: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: b50f165406b6897013b69e014bf29f7b75c3ca45 **/ .../linux-generic/include/odp_crypto_internal.h | 50 ---------------------- platform/linux-generic/odp_crypto.c | 41 +++++++++++++++++- 2 files changed, 40 insertions(+), 51 deletions(-) diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h index c3b70b231..bdbbf7379 100644 --- a/platform/linux-generic/include/odp_crypto_internal.h +++ b/platform/linux-generic/include/odp_crypto_internal.h @@ -11,50 +11,8 @@ extern "C" { #endif -#include - -#define MAX_IV_LEN 64 #define OP_RESULT_MAGIC 0x91919191 -/** Forward declaration of session structure */ -typedef struct odp_crypto_generic_session odp_crypto_generic_session_t; - -/** - * Algorithm handler function prototype - */ -typedef -odp_crypto_alg_err_t (*crypto_func_t)(odp_crypto_op_param_t *param, - odp_crypto_generic_session_t *session); - -/** - * Per crypto session data structure - */ -struct odp_crypto_generic_session { - struct odp_crypto_generic_session *next; - - /* Session creation parameters */ - odp_crypto_session_param_t p; - - odp_bool_t do_cipher_first; - - struct { - /* Copy of session IV data */ - uint8_t iv_data[MAX_IV_LEN]; - uint8_t key_data[EVP_MAX_KEY_LENGTH]; - - const EVP_CIPHER *evp_cipher; - crypto_func_t func; - } cipher; - - struct { - uint8_t key[EVP_MAX_KEY_LENGTH]; - uint32_t key_length; - uint32_t bytes; - const EVP_MD *evp_md; - crypto_func_t func; - } auth; -}; - /** * Per packet operation result */ @@ -63,14 +21,6 @@ typedef struct odp_crypto_generic_op_result { odp_crypto_op_result_t result; } odp_crypto_generic_op_result_t; -/** - * Per session creation operation result - */ -typedef struct odp_crypto_generic_session_result { - odp_crypto_ses_create_err_t rc; - odp_crypto_session_t session; -} odp_crypto_generic_session_result_t; - #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 4c708931a..9b5d94034 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -75,6 +75,45 @@ static const odp_crypto_auth_capability_t auth_capa_sha512_hmac[] = { static const odp_crypto_auth_capability_t auth_capa_aes_gcm[] = { {.digest_len = 16, .key_len = 0, .aad_len = {.min = 8, .max = 12, .inc = 4} } }; +/** Forward declaration of session structure */ +typedef struct odp_crypto_generic_session_t odp_crypto_generic_session_t; + +/** + * Algorithm handler function prototype + */ +typedef +odp_crypto_alg_err_t (*crypto_func_t)(odp_crypto_op_param_t *param, + odp_crypto_generic_session_t *session); + +/** + * Per crypto session data structure + */ +struct odp_crypto_generic_session_t { + odp_crypto_generic_session_t *next; + + /* Session creation parameters */ + odp_crypto_session_param_t p; + + odp_bool_t do_cipher_first; + + struct { + /* Copy of session IV data */ + uint8_t iv_data[EVP_MAX_IV_LENGTH]; + uint8_t key_data[EVP_MAX_KEY_LENGTH]; + + const EVP_CIPHER *evp_cipher; + crypto_func_t func; + } cipher; + + struct { + uint8_t key[EVP_MAX_KEY_LENGTH]; + uint32_t key_length; + uint32_t bytes; + const EVP_MD *evp_md; + crypto_func_t func; + } auth; +}; + typedef struct odp_crypto_global_s odp_crypto_global_t; struct odp_crypto_global_s { @@ -705,7 +744,7 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, /* Copy parameters */ session->p = *param; - if (session->p.iv.length > MAX_IV_LEN) { + if (session->p.iv.length > EVP_MAX_IV_LENGTH) { ODP_DBG("Maximum IV length exceeded\n"); free_session(session); return -1; From patchwork Thu Dec 14 10:00:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 121896 Delivered-To: patch@linaro.org Received: by 10.80.152.193 with SMTP id j59csp6501868edb; Thu, 14 Dec 2017 02:05:56 -0800 (PST) X-Google-Smtp-Source: ACJfBos7vgIkxNM7BWKslDOAWVrHwo6GA0oSrLO/CKgglKGtBXh0rZkhYbac9DEeVsTilg0GMwXr X-Received: by 10.200.42.14 with SMTP id k14mr15174187qtk.20.1513245956702; Thu, 14 Dec 2017 02:05:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513245956; cv=none; d=google.com; s=arc-20160816; b=hgUl3AVX8XQOOMcOL0jROr1YMJERd7nSBryZZdE48HFR2wtHFfYAtSomxM7lBB+W18 QZEB/xlVdMnUP0m/JbypqxyvD0DbtKn18bL3gsG0v/9TeSdGf3UE8xnUUncovjdxbLIi HJIKIYLyjLjL9BslVeP+ruNUft4dBrE2zZ7l31Db/9L26zQSTC5ClP+K0tD5TdnXvodC D4D/7Lfx4KT5rKXrO5SqFp7AValLi0CI9K16ZPGMLwqEYfzkb6b89Uvdbv7u2Hp0xSQh 6hv1EdkOKdVDtv7xozs4ywZp8TpnCqLsc/HsVh+eJNwIZIEunC5xgZhrf6H2dUDeiDrO rw+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=7gU0b4O2um4TtB9E4Z/tTeufJG7uAig7qolTNaYrW/w=; b=WUsYDRQjxScHbL9QcS05MmOE2yJD2JDEL0tBxTw9m+EB8DeFBCnCNpnqO4Jp96AZqC RSgTXLFgskPP5qtEZkWv/t5M4sL2gdi7yohpio1+NGcQqkCiGLfDgdceowXb7LzF7Oot ndC2j4dfT09EhFz7CWsnVCtcxVzrrysAbtWxFu7gy5AYULCNmskdgC51xmSBPOChkjpC 0G7t3UFnVzb+m35XeECSI963av1Ws0MqR3s7fqyDaXfBJPRmD0fayXGxZnsm7joqVAyP 8TdiiVGiZoLI1OkGsQVtjBZUHfKFTcFXP3Tehe1DgJZ1Mp+jZbNiWcakOT/vN8dMYhuB 7acA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id r13si4079448qtb.84.2017.12.14.02.05.56; Thu, 14 Dec 2017 02:05:56 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 4F4366092E; Thu, 14 Dec 2017 10:05:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 90CCE6095B; Thu, 14 Dec 2017 10:00:50 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 539DE6091E; Thu, 14 Dec 2017 10:00:30 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id D575E60865 for ; Thu, 14 Dec 2017 10:00:24 +0000 (UTC) Received: from mxback7o.mail.yandex.net (mxback7o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::21]) by forward106o.mail.yandex.net (Yandex) with ESMTP id 9E4B47828C9 for ; Thu, 14 Dec 2017 13:00:18 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback7o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 2Mit3TWPcF-0INOC4Pf; Thu, 14 Dec 2017 13:00:18 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZXeXutjQDE-0HSCKui5; Thu, 14 Dec 2017 13:00:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 14 Dec 2017 13:00:15 +0300 Message-Id: <1513245615-4755-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513245615-4755-1-git-send-email-odpbot@yandex.ru> References: <1513245615-4755-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 342 Subject: [lng-odp] [PATCH v3 4/4] linux-gen: crypto: significant speedup of all operations X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Per idea of Janne Peltonen, do not allocate/free crypto contexts for each operation, providing significant speed increase. Each thread on startup allocates hmac+cipher contexts pair for each crypto session. Then they are initialized on demand, when session is first executed using this thread. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 342 (lumag:openssl-ctx) ** https://github.com/Linaro/odp/pull/342 ** Patch: https://github.com/Linaro/odp/pull/342.patch ** Base sha: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: b50f165406b6897013b69e014bf29f7b75c3ca45 **/ platform/linux-generic/include/odp_internal.h | 2 + platform/linux-generic/odp_crypto.c | 189 ++++++++++++++++---------- platform/linux-generic/odp_init.c | 13 ++ 3 files changed, 135 insertions(+), 69 deletions(-) diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index fc69cd0c5..72fe1acfa 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -108,6 +108,8 @@ int odp_queue_term_global(void); int odp_crypto_init_global(void); int odp_crypto_term_global(void); +int odp_crypto_init_local(void); +int odp_crypto_term_local(void); int odp_timer_init_global(void); int odp_timer_term_global(void); diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 9b5d94034..581aaec28 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -112,8 +112,18 @@ struct odp_crypto_generic_session_t { const EVP_MD *evp_md; crypto_func_t func; } auth; + + uint32_t cipher_valid[(ODP_THREAD_COUNT_MAX + 32 - 1) / 32]; + uint32_t hmac_valid[(ODP_THREAD_COUNT_MAX + 32 - 1) / 32]; + unsigned idx; }; +#define IS_VALID(session, type, id) \ + (session->type ## _valid[id / 32] & (1 << (id % 32))) + +#define SET_VALID(session, type, id) \ + session->type ## _valid[id / 32] |= (1 << (id % 32)) + typedef struct odp_crypto_global_s odp_crypto_global_t; struct odp_crypto_global_s { @@ -125,6 +135,16 @@ struct odp_crypto_global_s { static odp_crypto_global_t *global; +typedef struct crypto_local_t { + struct { + HMAC_CTX *hmac; + EVP_CIPHER_CTX *cipher; + } ctx[MAX_SESSIONS]; + int id; +} crypto_local_t; + +static __thread crypto_local_t local; + static odp_crypto_generic_op_result_t *get_op_result_from_event(odp_event_t ev) { @@ -146,6 +166,9 @@ odp_crypto_generic_session_t *alloc_session(void) } odp_spinlock_unlock(&global->lock); + + session->idx = (session - global->sessions) / sizeof(*session); + return session; } @@ -165,24 +188,45 @@ null_crypto_routine(odp_crypto_op_param_t *param ODP_UNUSED, return ODP_CRYPTO_ALG_ERR_NONE; } +/* Mimic new OpenSSL 1.1.y API */ +#if OPENSSL_VERSION_NUMBER < 0x10100000L +static HMAC_CTX *HMAC_CTX_new(void) +{ + HMAC_CTX *ctx = malloc(sizeof(*ctx)); + + HMAC_CTX_init(ctx); + return ctx; +} + +static void HMAC_CTX_free(HMAC_CTX *ctx) +{ + HMAC_CTX_cleanup(ctx); + free(ctx); +} +#endif + static -void packet_hmac_calculate(HMAC_CTX *ctx, - odp_crypto_op_param_t *param, - odp_crypto_generic_session_t *session, - uint8_t *hash) +void packet_hmac(odp_crypto_op_param_t *param, + odp_crypto_generic_session_t *session, + uint8_t *hash) { + HMAC_CTX *ctx = local.ctx[session->idx].hmac; odp_packet_t pkt = param->out_pkt; uint32_t offset = param->auth_range.offset; uint32_t len = param->auth_range.length; ODP_ASSERT(offset + len <= odp_packet_len(pkt)); - HMAC_Init_ex(ctx, - session->auth.key, - session->auth.key_length, - session->auth.evp_md, - NULL); + if (!IS_VALID(session, hmac, local.id)) { + SET_VALID(session, hmac, local.id); + HMAC_Init_ex(ctx, + session->auth.key, + session->auth.key_length, + session->auth.evp_md, + NULL); + } + /* Hash it */ while (len > 0) { uint32_t seglen = 0; /* GCC */ void *mapaddr = odp_packet_offset(pkt, offset, &seglen, NULL); @@ -196,34 +240,6 @@ void packet_hmac_calculate(HMAC_CTX *ctx, HMAC_Final(ctx, hash, NULL); } -#if OPENSSL_VERSION_NUMBER < 0x10100000L -static -void packet_hmac(odp_crypto_op_param_t *param, - odp_crypto_generic_session_t *session, - uint8_t *hash) -{ - HMAC_CTX ctx; - - /* Hash it */ - HMAC_CTX_init(&ctx); - packet_hmac_calculate(&ctx, param, session, hash); - HMAC_CTX_cleanup(&ctx); -} -#else -static -void packet_hmac(odp_crypto_op_param_t *param, - odp_crypto_generic_session_t *session, - uint8_t *hash) -{ - HMAC_CTX *ctx; - - /* Hash it */ - ctx = HMAC_CTX_new(); - packet_hmac_calculate(ctx, param, session, hash); - HMAC_CTX_free(ctx); -} -#endif - static odp_crypto_alg_err_t auth_gen(odp_crypto_op_param_t *param, odp_crypto_generic_session_t *session) @@ -386,7 +402,7 @@ static odp_crypto_alg_err_t cipher_encrypt(odp_crypto_op_param_t *param, odp_crypto_generic_session_t *session) { - EVP_CIPHER_CTX *ctx; + EVP_CIPHER_CTX *ctx = local.ctx[session->idx].cipher; void *iv_ptr; int ret; @@ -398,16 +414,16 @@ odp_crypto_alg_err_t cipher_encrypt(odp_crypto_op_param_t *param, return ODP_CRYPTO_ALG_ERR_IV_INVALID; /* Encrypt it */ - ctx = EVP_CIPHER_CTX_new(); - EVP_EncryptInit_ex(ctx, session->cipher.evp_cipher, NULL, - session->cipher.key_data, NULL); + if (!IS_VALID(session, cipher, local.id)) { + SET_VALID(session, cipher, local.id); + EVP_EncryptInit_ex(ctx, session->cipher.evp_cipher, NULL, + session->cipher.key_data, NULL); + EVP_CIPHER_CTX_set_padding(ctx, 0); + } EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); - EVP_CIPHER_CTX_set_padding(ctx, 0); ret = internal_encrypt(ctx, param); - EVP_CIPHER_CTX_free(ctx); - return ret <= 0 ? ODP_CRYPTO_ALG_ERR_DATA_SIZE : ODP_CRYPTO_ALG_ERR_NONE; } @@ -416,7 +432,7 @@ static odp_crypto_alg_err_t cipher_decrypt(odp_crypto_op_param_t *param, odp_crypto_generic_session_t *session) { - EVP_CIPHER_CTX *ctx; + EVP_CIPHER_CTX *ctx = local.ctx[session->idx].cipher; void *iv_ptr; int ret; @@ -428,16 +444,16 @@ odp_crypto_alg_err_t cipher_decrypt(odp_crypto_op_param_t *param, return ODP_CRYPTO_ALG_ERR_IV_INVALID; /* Decrypt it */ - ctx = EVP_CIPHER_CTX_new(); - EVP_DecryptInit_ex(ctx, session->cipher.evp_cipher, NULL, - session->cipher.key_data, NULL); + if (!IS_VALID(session, cipher, local.id)) { + SET_VALID(session, cipher, local.id); + EVP_DecryptInit_ex(ctx, session->cipher.evp_cipher, NULL, + session->cipher.key_data, NULL); + EVP_CIPHER_CTX_set_padding(ctx, 0); + } EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); - EVP_CIPHER_CTX_set_padding(ctx, 0); ret = internal_decrypt(ctx, param); - EVP_CIPHER_CTX_free(ctx); - return ret <= 0 ? ODP_CRYPTO_ALG_ERR_DATA_SIZE : ODP_CRYPTO_ALG_ERR_NONE; } @@ -473,7 +489,7 @@ static odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, odp_crypto_generic_session_t *session) { - EVP_CIPHER_CTX *ctx; + EVP_CIPHER_CTX *ctx = local.ctx[session->idx].cipher; const uint8_t *aad_head = param->aad.ptr; uint32_t aad_len = param->aad.length; void *iv_ptr; @@ -489,13 +505,15 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, return ODP_CRYPTO_ALG_ERR_IV_INVALID; /* Encrypt it */ - ctx = EVP_CIPHER_CTX_new(); - EVP_EncryptInit_ex(ctx, session->cipher.evp_cipher, NULL, - session->cipher.key_data, NULL); - EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, - session->p.iv.length, NULL); + if (!IS_VALID(session, cipher, local.id)) { + SET_VALID(session, cipher, local.id); + EVP_EncryptInit_ex(ctx, session->cipher.evp_cipher, NULL, + session->cipher.key_data, NULL); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, + session->p.iv.length, NULL); + EVP_CIPHER_CTX_set_padding(ctx, 0); + } EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); - EVP_CIPHER_CTX_set_padding(ctx, 0); /* Authenticate header data (if any) without encrypting them */ if (aad_len > 0) @@ -509,8 +527,6 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, odp_packet_copy_from_mem(param->out_pkt, param->hash_result_offset, session->p.auth_digest_len, block); - EVP_CIPHER_CTX_free(ctx); - return ret <= 0 ? ODP_CRYPTO_ALG_ERR_DATA_SIZE : ODP_CRYPTO_ALG_ERR_NONE; } @@ -519,7 +535,7 @@ static odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, odp_crypto_generic_session_t *session) { - EVP_CIPHER_CTX *ctx; + EVP_CIPHER_CTX *ctx = local.ctx[session->idx].cipher; const uint8_t *aad_head = param->aad.ptr; uint32_t aad_len = param->aad.length; int dummy_len = 0; @@ -535,13 +551,15 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, return ODP_CRYPTO_ALG_ERR_IV_INVALID; /* Decrypt it */ - ctx = EVP_CIPHER_CTX_new(); - EVP_DecryptInit_ex(ctx, session->cipher.evp_cipher, NULL, - session->cipher.key_data, NULL); - EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, - session->p.iv.length, NULL); + if (!IS_VALID(session, cipher, local.id)) { + SET_VALID(session, cipher, local.id); + EVP_DecryptInit_ex(ctx, session->cipher.evp_cipher, NULL, + session->cipher.key_data, NULL); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, + session->p.iv.length, NULL); + EVP_CIPHER_CTX_set_padding(ctx, 0); + } EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); - EVP_CIPHER_CTX_set_padding(ctx, 0); odp_packet_copy_to_mem(param->out_pkt, param->hash_result_offset, session->p.auth_digest_len, block); @@ -555,8 +573,6 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, ret = internal_decrypt(ctx, param); - EVP_CIPHER_CTX_free(ctx); - return ret <= 0 ? ODP_CRYPTO_ALG_ERR_ICV_CHECK : ODP_CRYPTO_ALG_ERR_NONE; } @@ -1060,6 +1076,41 @@ int odp_crypto_term_global(void) return rc; } +int odp_crypto_init_local(void) +{ + unsigned i; + + memset(&local, 0, sizeof(local)); + + for (i = 0; i < MAX_SESSIONS; i++) { + local.ctx[i].hmac = HMAC_CTX_new(); + local.ctx[i].cipher = EVP_CIPHER_CTX_new(); + + if (local.ctx[i].hmac == NULL || local.ctx[i].cipher == NULL) { + odp_crypto_term_local(); + return -1; + } + } + + local.id = odp_thread_id(); + + return 0; +} + +int odp_crypto_term_local(void) +{ + unsigned i; + + for (i = 0; i < MAX_SESSIONS; i++) { + if (local.ctx[i].hmac != NULL) + HMAC_CTX_free(local.ctx[i].hmac); + if (local.ctx[i].cipher != NULL) + EVP_CIPHER_CTX_free(local.ctx[i].cipher); + } + + return 0; +} + odp_random_kind_t odp_random_max_kind(void) { return ODP_RANDOM_CRYPTO; diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index fe03709b7..809769187 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -300,6 +300,12 @@ int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type) } stage = PKTIO_INIT; + if (odp_crypto_init_local()) { + ODP_ERR("ODP crypto local init failed.\n"); + goto init_fail; + } + stage = CRYPTO_INIT; + if (odp_pool_init_local()) { ODP_ERR("ODP pool local init failed.\n"); goto init_fail; @@ -352,6 +358,13 @@ int _odp_term_local(enum init_stage stage) } /* Fall through */ + case CRYPTO_INIT: + if (odp_crypto_term_local()) { + ODP_ERR("ODP crypto local term failed.\n"); + rc = -1; + } + /* Fall through */ + case POOL_INIT: if (odp_pool_term_local()) { ODP_ERR("ODP buffer pool local term failed.\n");