From patchwork Mon Aug 14 15:21:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 110034 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4478198qge; Mon, 14 Aug 2017 08:23:28 -0700 (PDT) X-Received: by 10.98.13.70 with SMTP id v67mr26018917pfi.182.1502724208293; Mon, 14 Aug 2017 08:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502724208; cv=none; d=google.com; s=arc-20160816; b=uT6Cx3H4G8yozyF+tqxMXqGgWRVPi5W/HpflA8YSEH1kjN/O0sYwfQwebSgy+IKM6j KyW1DIdq8PU4i73b3yTvlmGWuKNbS9+YcMLb+z8qHEAIm7iRetiJMbDAg5KIAdFbOLHP 6nHPoOw8gGbFDkDSeMj1u4yky9jz31KPa4rllWNQIZrHG4+2i6YzimufB475oTfnd/jj F4EHoi5D6rURl7C+TBouzTwIfSWeuUU5cMYokx1Qw8aRJIoUuB4fxyFbEEf3ZarKP7JR ALaK2W0aQ9V+u45h5YsEbbCgcR+vlquHALeGSN4/2Xwh9X8ql8BFRpXPIqvW69eeRb4t Jl4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uVGCKHc2uD3hicn0yfC02peYpdFzwFicU6prIu8exhI=; b=tHPRb+y5aV5KyvBsS0R2/ZvEaH+gnBvRfsd6HXFeb1R0pi4auIc1+ojVwTXy/MJ//3 IY6Gw4nEpMS8nKggPObwpOAhUalf6/YXO+4TwiV6bGKTluzIAW7sKk9XkqRxYPgHCJJO qhRJkqHtHzeJQg9ojM+xj1Jh26iUm4k11HUbtjn7dMqQqD280YwMmMbJwNw++bp+N2ua 5bf0Gs+H2eKAnVyYosqwAbyjCXY4E54t6DOTTEoWFJRJaYMyF3lpTkHuPpfWO0r5Oz1U KLPD0e00AxkLs5rV3WCycDAj4uX02+gb6z0Y2Ogqb81X8arIy/WRi8uU+X6uhxiFgQCj 3ivA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q6si4157016pgf.309.2017.08.14.08.23.27; Mon, 14 Aug 2017 08:23:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753261AbdHNPXY (ORCPT + 25 others); Mon, 14 Aug 2017 11:23:24 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:39864 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752021AbdHNPXT (ORCPT ); Mon, 14 Aug 2017 11:23:19 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ECB351713; Mon, 14 Aug 2017 08:23:18 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.148]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 10DDA3F483; Mon, 14 Aug 2017 08:23:10 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells , Tom Lendacky , Gary Hook , Boris Brezillon , Arnaud Ebalard , Matthias Brugger , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-raid@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v5 07/19] crypto: move pub key to generic async completion Date: Mon, 14 Aug 2017 18:21:17 +0300 Message-Id: <1502724094-23305-8-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1502724094-23305-1-git-send-email-gilad@benyossef.com> References: <1502724094-23305-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org public_key_verify_signature() is starting an async crypto op and waiting for it to complete. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef --- crypto/asymmetric_keys/public_key.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) -- 2.1.4 diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c index 3cd6e12..d916235 100644 --- a/crypto/asymmetric_keys/public_key.c +++ b/crypto/asymmetric_keys/public_key.c @@ -57,29 +57,13 @@ static void public_key_destroy(void *payload0, void *payload3) public_key_signature_free(payload3); } -struct public_key_completion { - struct completion completion; - int err; -}; - -static void public_key_verify_done(struct crypto_async_request *req, int err) -{ - struct public_key_completion *compl = req->data; - - if (err == -EINPROGRESS) - return; - - compl->err = err; - complete(&compl->completion); -} - /* * Verify a signature using a public key. */ int public_key_verify_signature(const struct public_key *pkey, const struct public_key_signature *sig) { - struct public_key_completion compl; + struct crypto_wait cwait; struct crypto_akcipher *tfm; struct akcipher_request *req; struct scatterlist sig_sg, digest_sg; @@ -131,20 +115,16 @@ int public_key_verify_signature(const struct public_key *pkey, sg_init_one(&digest_sg, output, outlen); akcipher_request_set_crypt(req, &sig_sg, &digest_sg, sig->s_size, outlen); - init_completion(&compl.completion); + crypto_init_wait(&cwait); akcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - public_key_verify_done, &compl); + crypto_req_done, &cwait); /* Perform the verification calculation. This doesn't actually do the * verification, but rather calculates the hash expected by the * signature and returns that to us. */ - ret = crypto_akcipher_verify(req); - if ((ret == -EINPROGRESS) || (ret == -EBUSY)) { - wait_for_completion(&compl.completion); - ret = compl.err; - } + ret = crypto_wait_req(crypto_akcipher_verify(req), &cwait); if (ret < 0) goto out_free_output;