From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 37DBAA0542; Tue, 5 Jul 2022 15:16:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C61F34021D; Tue, 5 Jul 2022 15:16:38 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id D7849400D7 for ; Tue, 5 Jul 2022 15:16:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657026997; x=1688562997; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=cHeOs+Y0E1d1cojheBFCDcDdbKibjcP8ffLFuGJYOqY=; b=e4ozTCRyY46eIGJNU1Z6hYOOD1x9TTKrGhlU9v+ns0McWoLBOccC9iAi 8kkNXRTTjKZRNm/cILWw1tuY4UrhTv8rBH6Zc7zfXmUXJg35REGleGQhy qfFMA9qpXdQ8oIDlGRAOATGtjBCsIwAz8TOS8wQc1YouqX4CK7cRmtYFF 9e9Ss3U8+LPoZqM+b7Dt7FTvPxmG/jXccTGqsESmk/ZZp6lBn0ptuvJA4 mcrXBXOa370F5ruTxPuTuUpgOkeSL4Tzt8wAlMSAN27Gr62DhdrSJfnHw n7fXOmf+kwzXpSzlMWE6mzk5XugAWX7lDI6JJWFU7Ov9bX+eJ6TZ6VinA Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10398"; a="369672799" X-IronPort-AV: E=Sophos;i="5.92,245,1650956400"; d="scan'208";a="369672799" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2022 06:16:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,245,1650956400"; d="scan'208";a="682517503" Received: from silpixa00400465.ir.intel.com ([10.55.128.22]) by FMSMGA003.fm.intel.com with ESMTP; 05 Jul 2022 06:16:34 -0700 From: Kai Ji To: dev@dpdk.org Cc: gakhil@marvell.com, thomas@monjalon.net, Kai Ji Subject: [dpdk-dev v2] crypto/openssl: EVP_PKEY routine update in rsa op Date: Tue, 5 Jul 2022 21:16:25 +0800 Message-Id: <20220705131625.40665-1-kai.ji@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220630103848.36515-1-kai.ji@intel.com> References: <20220630103848.36515-1-kai.ji@intel.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org EVP_PKEY function need to be called twice for rsa sign and verify operations in 3.0 EVP API, original openssl 1.x routines are untouched. The OPENSSL_API_COMPAT also removed as this branch code will be executed when Openssl 3.0 lib is detected on the host. Fixes: d7bd42f6db19 ("crypto/openssl: update RSA routine with 3.0 EVP API") Signed-off-by: Kai Ji --- drivers/crypto/openssl/rte_openssl_pmd.c | 32 ++++++++++++++------ drivers/crypto/openssl/rte_openssl_pmd_ops.c | 2 -- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index 84bca86894..e01dacc98d 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -1788,7 +1788,7 @@ process_openssl_dsa_sign_op_evp(struct rte_crypto_op *cop, if (key_ctx == NULL || EVP_PKEY_fromdata_init(key_ctx) <= 0 || EVP_PKEY_fromdata(key_ctx, &pkey, - EVP_PKEY_PUBLIC_KEY, params) <= 0) + EVP_PKEY_KEYPAIR, params) <= 0) goto err_dsa_sign; dsa_ctx = EVP_PKEY_CTX_new(pkey, NULL); @@ -2478,6 +2478,14 @@ process_openssl_rsa_op_evp(struct rte_crypto_op *cop, if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0) goto err_rsa; + if (EVP_PKEY_sign(rsa_ctx, NULL, &outlen, + op->rsa.message.data, + op->rsa.message.length) <= 0) + goto err_rsa; + + if (outlen <= 0) + goto err_rsa; + if (EVP_PKEY_sign(rsa_ctx, op->rsa.sign.data, &outlen, op->rsa.message.data, op->rsa.message.length) <= 0) @@ -2486,19 +2494,23 @@ process_openssl_rsa_op_evp(struct rte_crypto_op *cop, break; case RTE_CRYPTO_ASYM_OP_VERIFY: - tmp = rte_malloc(NULL, op->rsa.sign.length, 0); - if (tmp == NULL) { - OPENSSL_LOG(ERR, "Memory allocation failed"); + if (EVP_PKEY_verify_recover_init(rsa_ctx) <= 0) goto err_rsa; - } - if (EVP_PKEY_verify_recover_init(rsa_ctx) <= 0) { - rte_free(tmp); + if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0) goto err_rsa; - } - if (EVP_PKEY_CTX_set_rsa_padding(rsa_ctx, pad) <= 0) { - rte_free(tmp); + if (EVP_PKEY_verify_recover(rsa_ctx, NULL, &outlen, + op->rsa.sign.data, + op->rsa.sign.length) <= 0) + goto err_rsa; + + if ((outlen <= 0) || (outlen != op->rsa.sign.length)) + goto err_rsa; + + tmp = OPENSSL_malloc(outlen); + if (tmp == NULL) { + OPENSSL_LOG(ERR, "Memory allocation failed"); goto err_rsa; } diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c index 8d1f8e834a..3e24ef94f7 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -2,8 +2,6 @@ * Copyright(c) 2016-2017 Intel Corporation */ -#define OPENSSL_API_COMPAT 0x10100000L - #include #include -- 2.17.1