From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0078.outbound.protection.outlook.com [104.47.34.78]) by dpdk.org (Postfix) with ESMTP id 00C12293B for ; Tue, 5 Sep 2017 08:00:03 +0200 (CEST) Received: from BN3PR03CA0061.namprd03.prod.outlook.com (2a01:111:e400:7a4d::21) by SN2PR03MB2269.namprd03.prod.outlook.com (2603:10b6:804:d::14) 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:02 +0000 Received: from BN1BFFO11FD026.protection.gbl (2a01:111:f400:7c10::1:182) by BN3PR03CA0061.outlook.office365.com (2a01:111:e400:7a4d::21) 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 06:00:02 +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 BN1BFFO11FD026.mail.protection.outlook.com (10.58.144.89) 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 06:00:01 +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 v855xuXw014431; Mon, 4 Sep 2017 22:59:59 -0700 From: Akhil Goyal To: , CC: , , Akhil Goyal Date: Tue, 5 Sep 2017 11:27:49 +0530 Message-ID: <20170905055749.23126-2-akhil.goyal@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170905055749.23126-1-akhil.goyal@nxp.com> References: <20170829065849.11424-2-akhil.goyal@nxp.com> <20170905055749.23126-1-akhil.goyal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131490648021423987; (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)(39860400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(53936002)(189998001)(50986999)(50466002)(48376002)(54906002)(33646002)(36756003)(498600001)(47776003)(76176999)(5660300001)(68736007)(106466001)(6666003)(2950100002)(105606002)(77096006)(86362001)(305945005)(2906002)(8656003)(626005)(5003940100001)(50226002)(85426001)(4326008)(8676002)(8936002)(104016004)(356003)(1076002)(97736004)(15650500001)(81166006)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2269; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD026; 1:SKehI0JyzBDEFawKyE8DbfggHJljTnLnDoTW6+IRo721m6iDnos1qGwDrVeXeyKTraBQ+8r/t3EN+UTWc5dTzcO0qU/mmOrltGDuknZcTwYld8RezwXizVhRbsSx87T+ MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0ccc45bd-1326-4e20-5773-08d4f4235911 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:SN2PR03MB2269; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2269; 3:0yLlO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dDHAq6+QYo/TPlmdQyKAJD0B//sjMQflNdn64/RaL0AN/2USz1A+jqRzXEhz/PbC4Xd0udYqGVQBymEIOLYJlhngF5LuQsH+Wa3L57VmTXkil4Le7pQIbFGVH7Vpvx7rTZh7d4cYNf3yX+OMafj45O9iVLUEIPgQ2TCcrTaxSRMQtPBdua9nK5MiBFj7tQV3tnd86cupC1lNL2zTCdWbmlP1q28nbDKZ/qWL3/eLMOdsLri7hBp/i8vDE0CwvUrMnD+/igDkFf50Yfg3I/VHFy+Mw== X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(5005006)(8121501046)(3002001)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(6055026)(6096035)(20161123563025)(20161123565025)(20161123556025)(20161123561025)(20161123559100)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN2PR03MB2269; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN2PR03MB2269; X-Forefront-PRVS: 0421BF7135 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN2PR03MB2269; 23:njMugRXsXbReQhM4c/nY63aL2fNtMe90CedmcPqmz?= =?us-ascii?Q?6HdqSyXkxFOfywQifAGq2yFwO8ylbQh8J/PsEtHdh6cC7SuuxCYzpH1iXRWn?= =?us-ascii?Q?2m7stYJmIMdMUraa3HEEH4cRW9RrzmtgyNb1zmWp66unoTQR6W0qBIdLy47R?= =?us-ascii?Q?EJWwVDVulAcw9R/j+8e7qyft3VSMOtwQ9uRx8mMX2kqq9lxBM7pYYic3uSDB?= =?us-ascii?Q?YSIZyweMK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XRKF+YuKpv?= =?us-ascii?Q?zbU6JAQvaE=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2269; 6:i5e8NYJyaF2gVzYYM2jsHmUCGUnbObK4SYUGdg+IQq8BZwLyscPVgohQlAfMS9FsAYV+mgmJVXoQbz34sEG6+AzmhHBTZ9aAc17DjpwQO6CytHxL7bYYMK+F1XQhKVWkVg174GdPWySW3jUP+p+IoN0pcSRUj2woAI6sAXeeOnTJFj9AFNAhl7CGMFqoRH+4I9693yLPHsKdpgLxhK8yLi1nR2+Gv14ggK/tJeXipfPuvQ9ttFeUSBX7lOuaHFv0NmprIY+fa5qCudGIaclmzpeFfJ3TZ/POSBs10fZ1JBp3xxp0631LgmUQHDQO1iliKaiXVEA1Tayn3Y1xi3IyJQ==; 5:vt7OsBekeZNwYz98B22LaKDOif6q3QXE5Ji059QNyC+6GafcyM6zMBKRX8ejeMfmsMNNCXLA1qrTTXLN2VnhubpB3XN3RwbZJu5zjtAt74PR8wrETCVM7hczM9+3WzvsiaSdKN9EqQhOTjkHt5jzzw==; 24:LhtnZzWeIj+Ht4tSh798B13wwYOUrjP9Ta69dqSkPJhaZtsv4HL1SPTTYIwl6G2b6JwHUmtkQaVfjas06sLlQaL2Jao0XkrAdtsFFm2hhrM=; 7:NVr/ASF01jDVw+m9/Eh4clyaq0C5pld2NP7R7uPtq7VCU9+4P3E68XzYR+G9C7jntuvT9grmwbI5qhyXgyU9ILEmqTYAgFs4MzDF+g54JBm7AzeDey6j43rvBIPdj4MXdXc8PISxqm4xfet1bgZCNJXJcPOT7vyp95spI6D0sO6kjzFZiAuVOEslPnAL0i7RKRvYRrc3qqxm7rM4jWObm2T0LQe9x+XiO0UYIJHig8c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2017 06:00:01.9707 (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: SN2PR03MB2269 Subject: [dpdk-dev] [PATCH v3 2/2] crypto/openssl: key and algo updated during session init 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:04 -0000 key and algo are added in the openssl ctx during session initialization instead of adding it for each packet. This would give performance improvement. Signed-off-by: Akhil Goyal Reviewed-by: Pablo de Lara changes in v3: updated patch title --- drivers/crypto/openssl/rte_openssl_pmd.c | 58 ++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index 889d632..b11a7fb 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -308,6 +308,22 @@ openssl_set_session_cipher_parameters(struct openssl_session *sess, get_cipher_key(xform->cipher.key.data, sess->cipher.key.length, sess->cipher.key.data); + if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) { + if (EVP_EncryptInit_ex(sess->cipher.ctx, + sess->cipher.evp_algo, + NULL, xform->cipher.key.data, + NULL) != 1) { + return -EINVAL; + } + } else if (sess->cipher.direction == + RTE_CRYPTO_CIPHER_OP_DECRYPT) { + if (EVP_DecryptInit_ex(sess->cipher.ctx, + sess->cipher.evp_algo, + NULL, xform->cipher.key.data, + NULL) != 1) { + return -EINVAL; + } + } break; @@ -334,6 +350,23 @@ openssl_set_session_cipher_parameters(struct openssl_session *sess, get_cipher_key(xform->cipher.key.data, sess->cipher.key.length, sess->cipher.key.data); + if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) { + if (EVP_EncryptInit_ex(sess->cipher.ctx, + sess->cipher.evp_algo, + NULL, xform->cipher.key.data, + NULL) != 1) { + return -EINVAL; + } + } else if (sess->cipher.direction == + RTE_CRYPTO_CIPHER_OP_DECRYPT) { + if (EVP_DecryptInit_ex(sess->cipher.ctx, + sess->cipher.evp_algo, + NULL, xform->cipher.key.data, + NULL) != 1) { + return -EINVAL; + } + } + break; default: sess->cipher.algo = RTE_CRYPTO_CIPHER_NULL; @@ -698,12 +731,11 @@ process_openssl_decryption_update(struct rte_mbuf *mbuf_src, int offset, /** Process standard openssl cipher encryption */ static int process_openssl_cipher_encrypt(struct rte_mbuf *mbuf_src, uint8_t *dst, - int offset, uint8_t *iv, uint8_t *key, int srclen, - EVP_CIPHER_CTX *ctx, const EVP_CIPHER *algo) + int offset, uint8_t *iv, int srclen, EVP_CIPHER_CTX *ctx) { int totlen; - if (EVP_EncryptInit_ex(ctx, algo, NULL, key, iv) <= 0) + if (EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv) <= 0) goto process_cipher_encrypt_err; EVP_CIPHER_CTX_set_padding(ctx, 0); @@ -748,12 +780,11 @@ process_openssl_cipher_bpi_encrypt(uint8_t *src, uint8_t *dst, /** Process standard openssl cipher decryption */ static int process_openssl_cipher_decrypt(struct rte_mbuf *mbuf_src, uint8_t *dst, - int offset, uint8_t *iv, uint8_t *key, int srclen, - EVP_CIPHER_CTX *ctx, const EVP_CIPHER *algo) + int offset, uint8_t *iv, int srclen, EVP_CIPHER_CTX *ctx) { int totlen; - if (EVP_DecryptInit_ex(ctx, algo, NULL, key, iv) <= 0) + if (EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv) <= 0) goto process_cipher_decrypt_err; EVP_CIPHER_CTX_set_padding(ctx, 0); @@ -1126,15 +1157,11 @@ process_openssl_cipher_op if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) status = process_openssl_cipher_encrypt(mbuf_src, dst, op->sym->cipher.data.offset, iv, - sess->cipher.key.data, srclen, - sess->cipher.ctx, - sess->cipher.evp_algo); + srclen, sess->cipher.ctx); else status = process_openssl_cipher_decrypt(mbuf_src, dst, op->sym->cipher.data.offset, iv, - sess->cipher.key.data, srclen, - sess->cipher.ctx, - sess->cipher.evp_algo); + srclen, sess->cipher.ctx); else status = process_openssl_cipher_des3ctr(mbuf_src, dst, op->sym->cipher.data.offset, iv, @@ -1178,8 +1205,7 @@ process_openssl_docsis_bpi_op(struct rte_crypto_op *op, /* Encrypt with the block aligned stream with CBC mode */ status = process_openssl_cipher_encrypt(mbuf_src, dst, op->sym->cipher.data.offset, iv, - sess->cipher.key.data, srclen, - sess->cipher.ctx, sess->cipher.evp_algo); + srclen, sess->cipher.ctx); if (last_block_len) { /* Point at last block */ dst += srclen; @@ -1229,9 +1255,7 @@ process_openssl_docsis_bpi_op(struct rte_crypto_op *op, /* Decrypt with CBC mode */ status |= process_openssl_cipher_decrypt(mbuf_src, dst, op->sym->cipher.data.offset, iv, - sess->cipher.key.data, srclen, - sess->cipher.ctx, - sess->cipher.evp_algo); + srclen, sess->cipher.ctx); } } -- 2.9.3