From patchwork Mon Dec 18 15:00:19 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: 122234 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2946580qgn; Mon, 18 Dec 2017 07:05:34 -0800 (PST) X-Google-Smtp-Source: ACJfBovL3DnVJR/YnjIBph8nbX0NQyyFRK6Pl9+0l6dAHFE1HeQEAu+sSSqHPbPydb+2ypaDGO39 X-Received: by 10.37.79.66 with SMTP id d63mr37118ybb.384.1513609534691; Mon, 18 Dec 2017 07:05:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513609534; cv=none; d=google.com; s=arc-20160816; b=gCiIylvtRe+hU96P8xbf01UV7oou8DAIThAuVosTkostcIPvGBhmnZhMJ/E7Dn5keo FgpR/XcC23OOu65OyYj9ha4BEKhL3f3AwrvlQD+357U1Zftm4CSck0fynhrRTJ8PB26W DmcLHcLdSqTEagPo38pIce1T0jQr4TvFCwXvj8m5aCh4IeTWN4bVDi928kEe/lrRemr+ hkGhRCKvCOI5j/czJY+RPfGUrZrs82/yFluLOr16IZJoeIwm0ShKxDyUAdPiRNmbBtVm vMGS7TFS3cK7mwtSr6VKI+MEKOHnq7gWh0IKmeX64c/Hspn+NAY8bCYV5Kjs48NGH1WQ CAjg== 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=EclxsdDR3jYNqZlL/nk/ZO/7PvfHgPKeMJgoSsxtV3k=; b=o5EJoSnZzBeG84wLoOLG7SmHwuFQVbEgJADhhjFpjo6F1TqJUDxlb6yq9eQ5fRkE7F kLLbs2l76+v8914q2+H118tWtU1OTdSEZuHwsgXZ/EerhucdYi0OKGmkqyjTqiUDvvUA jEVd/V7R7hvsbtnUFODaKfY8tvnTrlRa+B5ZtgU0jYDJXsGF6oCQRBtFvKAP1pq/8TVz j6IIxoM5n9wT/nhnnYKd7dW6zEqTIsNI14+m7EopH+gCuRuxz20M8FCSESDUe4SOEiek Zhgq2vtZxHwp6jfwNsayQEfxB3Hqch/P4/Mlwmml2ZdlNFJqMtTaB3DFawqe8MCe7Ejl 21rw== 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 v1si678870ybl.600.2017.12.18.07.05.34; Mon, 18 Dec 2017 07:05:34 -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 D5DA46151B; Mon, 18 Dec 2017 15:05:33 +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 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 EE8766087E; Mon, 18 Dec 2017 15:01:32 +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 AE0F960960; Mon, 18 Dec 2017 15:01:24 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id 486796087E for ; Mon, 18 Dec 2017 15:00:31 +0000 (UTC) Received: from mxback9j.mail.yandex.net (mxback9j.mail.yandex.net [IPv6:2a02:6b8:0:1619::112]) by forward106o.mail.yandex.net (Yandex) with ESMTP id BDFCB7814FC for ; Mon, 18 Dec 2017 18:00:29 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback9j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Ewl9Rnz1P4-0TdeQMRn; Mon, 18 Dec 2017 18:00:29 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id wGOKnC8159-0TuKxnoK; Mon, 18 Dec 2017 18:00:29 +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: Mon, 18 Dec 2017 18:00:19 +0300 Message-Id: <1513609222-7581-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513609222-7581-1-git-send-email-odpbot@yandex.ru> References: <1513609222-7581-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 342 Subject: [lng-odp] [PATCH v7 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: a4f9f27409a74cc7c659d7f9970dde3d61fb9c57 **/ 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 Mon Dec 18 15:00:20 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: 122237 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2951157qgn; Mon, 18 Dec 2017 07:08:55 -0800 (PST) X-Google-Smtp-Source: ACJfBouLCf5ODDWntlX0PDvRbZqJ/BkvrgjBURLzQ5bVjwACRlU4UcksyDwkP4u7vnpOH5l5nO0p X-Received: by 10.55.43.134 with SMTP id r6mr53658qkr.266.1513609735335; Mon, 18 Dec 2017 07:08:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513609735; cv=none; d=google.com; s=arc-20160816; b=ptXhjR5rVBYUoiuP38CYOq0syT4vWiB0Egkmhl69+PvgMUK4eGu4aAweVrDjKAYz8j JL2R0Pb5ARPcebNWsiV2t9G1BR0ZA5zbzbzfWZKLVnxKVg81YJ5z4SNeZxC86sboBvdK 1M5Okh9zk6V+rU/hpw7chpn6fGZEAT7ncEfBKrNFUXR+dtOqDjueCIm/vitMSXtyUrTW f3CC9HpJywrnIigNrPNvf2GRz6Jw6oXmgY/iCNR4Y6Iibm15fpZ4dzPzYoNbyTnks1F3 asT1NgVWQy3ZVKN40aprW1pyE2aSvF1a2GQve/Tm4kpMiTS9ueGwQSvdSOYk2/+XC2e3 903A== 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=tGx7QIkrvVIuFhSWNhMvloNMBEkQYgC5SKqcABW23WU=; b=e5aBGPSi7Gbm+PA1u1J3JoiNYDONXsUS0zv06o4V5GJzJkAwiRBBgoLRXXL+8GGvrF 6ujhL6466Md5y/eMa+QUBMWRcbIELYdaMl4Q9e6q04q7C4fPmsyKeaMw/Q0CHR5k0VLi yq516o84SlQBlmiAwsLDFpuJhoC/x+Vn79M1KuHhwkzwyc/PWcWJ8aMtkSIQovREyzmw cI8QU+6MoDPLXCEqap1Vk/le0VsdQzJmAXSSogwDE9E/4Bo0pPfEtjX4nVnkxrgcF4+q ijw+1ufZNY97id2j23Rn26E1KWorHAFGJW1ll3vp1tsPK9p3RNjLSTFDHQeDNdnC9qnU WccA== 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 v124si948392qki.405.2017.12.18.07.08.55; Mon, 18 Dec 2017 07:08:55 -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 0709C6151C; Mon, 18 Dec 2017 15:08:55 +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 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 28CE661506; Mon, 18 Dec 2017 15:01:48 +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 37EAA60956; Mon, 18 Dec 2017 15:01:33 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id F192860814 for ; Mon, 18 Dec 2017 15:00:31 +0000 (UTC) Received: from mxback6o.mail.yandex.net (mxback6o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::20]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 9DFA12D828A7 for ; Mon, 18 Dec 2017 18:00:30 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback6o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id GjvnPvMmsr-0UJuF3Zx; Mon, 18 Dec 2017 18:00:30 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id wGOKnC8159-0TuKXHZ1; Mon, 18 Dec 2017 18:00:29 +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: Mon, 18 Dec 2017 18:00:20 +0300 Message-Id: <1513609222-7581-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513609222-7581-1-git-send-email-odpbot@yandex.ru> References: <1513609222-7581-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 342 Subject: [lng-odp] [PATCH v7 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: a4f9f27409a74cc7c659d7f9970dde3d61fb9c57 **/ 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 Mon Dec 18 15:00:21 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: 122236 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2950156qgn; Mon, 18 Dec 2017 07:08:12 -0800 (PST) X-Google-Smtp-Source: ACJfBot5r7CU5Uf4rReyzBQyi9sXHIdV7xFneL9JMBFzkje0Kb++1BGw+n984IdiuDzCTvb8tDlg X-Received: by 10.55.127.193 with SMTP id a184mr26088qkd.119.1513609692000; Mon, 18 Dec 2017 07:08:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513609691; cv=none; d=google.com; s=arc-20160816; b=SvQFAcPUCD7OYUtXzWF7K9lXwwoieAx1UlOv5hfInRzXunDdC+Cjqip8ZgN34jWLAO 29D0YK6SKrZ+6p0t3r8xtveGFI0p3yEsJ9CgbP0FUL9oam15uQ21Tqkfv84YcYsIfmTz Im/9fhyvx+NGAFd1UGVa3eL1xtJNqMofI3auM/2ivn8sxS0+bivXU4uq9hB0wY7H22t4 /0N6+HlExAXvbxLFT2ziMMDqu5Rkk8L8IOf39TLbxaAFc3/RlDTfgmvLPbzKzHKGHcYI qfSFimE5fdpC4fwLXDiamDfiIXpaufzapY/9OjnRNjX1PlpFV9fjT0FZgmpSdGtGUren w9Ww== 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=RNOZioGQptsn1Mouue3hAyWvTMwiKtthRp/Wrg/qdLo=; b=VrBzDXXPhhYaGwdhzoLm36hMahshUawRFBJkXHvswdUU8gb91YogoG5d6Bc9mclvdu l2XiRNJ+e29Bj3WbLwyZlTrDv41D0j2V/+DLoip/3qmIw+IMJ1kGNg8U+1yZzmjite2e W/p/+8otbiRDmfYBSIlC8e8IlSvJV0xUxwHGOldhNNgcdhHkXTdcuGAmaeOydglrbl3c 6YoloW8lF5GgJ3WD0vFXT24oa7QO4sQV1mVaOFlC3uMql+Hq/lxNdJ6S/5aPXs3whFSj Z7TfHKgz6HQeyo24SPpveuLYg7IpdkqAxyekVuIDmBpYMmQ+PSI9KDxKeJLLD9e6SFVm sHeQ== 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 z5si1514053qkb.109.2017.12.18.07.08.11; Mon, 18 Dec 2017 07:08:11 -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 9FD136151E; Mon, 18 Dec 2017 15:08:11 +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 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 B93F0609A2; Mon, 18 Dec 2017 15:01:45 +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 D1F656085F; Mon, 18 Dec 2017 15:01:29 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id 8DBD6608A7 for ; Mon, 18 Dec 2017 15:00:32 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 1E1445A02D11 for ; Mon, 18 Dec 2017 18:00:31 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id YCoJRtjBtl-0VDaCObk; Mon, 18 Dec 2017 18:00:31 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id wGOKnC8159-0UuiYQtu; Mon, 18 Dec 2017 18:00:30 +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: Mon, 18 Dec 2017 18:00:21 +0300 Message-Id: <1513609222-7581-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513609222-7581-1-git-send-email-odpbot@yandex.ru> References: <1513609222-7581-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 342 Subject: [lng-odp] [PATCH v7 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: a4f9f27409a74cc7c659d7f9970dde3d61fb9c57 **/ .../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 Mon Dec 18 15:00:22 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: 122235 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2948506qgn; Mon, 18 Dec 2017 07:06:57 -0800 (PST) X-Google-Smtp-Source: ACJfBovaAMAuER6kfBtV8R4tItNG8WGSq3971NL+JuUpK7Cdf0OJ7riCDn24/JCx7Zv6uXi3WwmV X-Received: by 10.37.218.214 with SMTP id n205mr46614ybf.234.1513609617318; Mon, 18 Dec 2017 07:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513609617; cv=none; d=google.com; s=arc-20160816; b=gAQI0JFTC5FhHiPXv9ZZLHmMY83lx7+xmDR042GFPrLBuzOVvOEpHJHem2yOT0mE9x tXKIUrm/pp9NILCkbpf3s8hkuWuaa8FxcIIT9NmgJdg6YImBkqyt89pS4/atqFKQXtsQ 4SV6L1qyxdtpUvlWrsZEvOrMSiWkRZ/71lEwPfaggyD8jA7kujSzW+BkyEj3qop0scPO pr84gQTTBRvv9XX9fsjbDQa67d34e67E+Lg1L+uurISbvN7849OJTmo8VmskjJTKOIi5 RS1295IcRk+DKTYMBPonrgxMbK4sEggF9cuXr3sT3/JzYO3z4QRvyaj/uMeyFvYyH8mp /PJA== 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=LbHmvL3jdj4CRPXwBB2yb933gp2vb9Bn1WF738LW4VA=; b=eDg3JObSYNXLqxWwCOcqUTo0jrUjHnJ04zXT0n1fePMXdLFf8G8XaMZq0mpmDDUe1X 1YY5Fyo5youaBQGYTDH3c+jTRPdw36Cyw5q6HxfCukKDRF3gc4eOsc/eIkaVBm8FO3EK g86r9JjxENUWhFOlS6LjPIAsB1Ec8XPOggoRDOi+uokggL8pVfDg955A1x9hDa3ywSnQ GJ1P+R0QYInVMptRoN0BWdNT94oFocFYyOEO549IhPILFk96kbOoI2zY7R26auCLefek s5GPEtOCO4PNhTOkaE9pOUa4Sp149t4V2prdnU1A5LnpKsqQ1m7bf+pxrweDY8YpGghH wX7Q== 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 o1si2432688ybe.450.2017.12.18.07.06.57; Mon, 18 Dec 2017 07:06:57 -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 052C661511; Mon, 18 Dec 2017 15:06:57 +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 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 8AB3060961; Mon, 18 Dec 2017 15:01:42 +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 5A01B6084A; Mon, 18 Dec 2017 15:01:27 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 39ED4608BB for ; Mon, 18 Dec 2017 15:00:33 +0000 (UTC) Received: from mxback14j.mail.yandex.net (mxback14j.mail.yandex.net [IPv6:2a02:6b8:0:1619::90]) by forward103j.mail.yandex.net (Yandex) with ESMTP id D5ABD34C33D2 for ; Mon, 18 Dec 2017 18:00:31 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback14j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id mZ3N4xL8jp-0V3qQTIj; Mon, 18 Dec 2017 18:00:31 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id wGOKnC8159-0VuK2dCj; Mon, 18 Dec 2017 18:00:31 +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: Mon, 18 Dec 2017 18:00:22 +0300 Message-Id: <1513609222-7581-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513609222-7581-1-git-send-email-odpbot@yandex.ru> References: <1513609222-7581-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 342 Subject: [lng-odp] [PATCH v7 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: a4f9f27409a74cc7c659d7f9970dde3d61fb9c57 **/ platform/linux-generic/include/odp_internal.h | 2 + platform/linux-generic/odp_crypto.c | 202 +++++++++++++++++--------- platform/linux-generic/odp_init.c | 13 ++ 3 files changed, 148 insertions(+), 69 deletions(-) diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index fc69cd0c5..94aa16ccd 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..f3ec135a8 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -85,6 +85,9 @@ typedef odp_crypto_alg_err_t (*crypto_func_t)(odp_crypto_op_param_t *param, odp_crypto_generic_session_t *session); +typedef uint32_t crypto_valid; +#define CV_SIZE sizeof(crypto_valid) + /** * Per crypto session data structure */ @@ -112,8 +115,22 @@ struct odp_crypto_generic_session_t { const EVP_MD *evp_md; crypto_func_t func; } auth; + + /* These bitfields are cleared at odp_crypto_session_destroy() + * together with the rest of data */ + crypto_valid cipher_valid[(ODP_THREAD_COUNT_MAX + CV_SIZE - 1) / + CV_SIZE]; + crypto_valid hmac_valid[(ODP_THREAD_COUNT_MAX + CV_SIZE - 1) / + CV_SIZE]; + unsigned idx; }; +#define IS_VALID(session, type, id) \ + (session->type ## _valid[id / CV_SIZE] & (1 << (id % CV_SIZE))) + +#define SET_VALID(session, type, id) \ + session->type ## _valid[id / CV_SIZE] |= (1 << (id % CV_SIZE)) + typedef struct odp_crypto_global_s odp_crypto_global_t; struct odp_crypto_global_s { @@ -125,6 +142,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 +173,8 @@ odp_crypto_generic_session_t *alloc_session(void) } odp_spinlock_unlock(&global->lock); + session->idx = (session - global->sessions) / sizeof(*session); + return session; } @@ -165,24 +194,52 @@ 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); + } else { + /* Reinitialize HMAC calculation without resetting the key */ + HMAC_Init_ex(ctx, + NULL, + session->auth.key_length, + NULL, + NULL); + } + /* Hash it */ while (len > 0) { uint32_t seglen = 0; /* GCC */ void *mapaddr = odp_packet_offset(pkt, offset, &seglen, NULL); @@ -196,34 +253,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 +415,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 +427,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 +445,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 +457,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 +502,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 +518,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 +540,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 +548,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 +564,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 +586,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 +1089,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..e5de95025 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");