From patchwork Sun Jul 2 14:41:58 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: 106856 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp8294725obb; Sun, 2 Jul 2017 07:46:36 -0700 (PDT) X-Received: by 10.84.215.208 with SMTP id g16mr1457150plj.191.1499006796293; Sun, 02 Jul 2017 07:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499006796; cv=none; d=google.com; s=arc-20160816; b=Rxcdvua29SL1NlXURndvxAuI6Oq/v7twcbln9ub9UWD4RiAfYePJ2PoE6fq3013oPB gECNSHcIjVgN9eTBVEENoTO/UuPYtrU76o8nHOMSbLKkeH26eNATOlmMz/k8boEgAZuJ BO9MCxL469Kck6P9Umnpr1p5fRLnXaNQ0/Qe/9HDMQUMto4dsNwd27txf4iib2i2rlE3 EGFWsL18Leo+54lUIwPV2aZ2UCYCWJTfcE84zXKCITgzWYjl0O6Xye2BF8ROcgYs7t/0 DUaVAHyuE6mFwF601Lb0xGOyeEFro21nokcDvI4GELsNG3tNoHU37LDrAbSIh9vv/hk8 XPhg== 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=mBIA/+71fn4aktCad5U20n0CBbsp9uSZ0R2Oo8dtavw=; b=eJrkK5n1QW52vGdPy+dFtiAE/i7paDzho68WrqhMCVRyIgCZ0zMAVzvIPRpsGXOPg4 oLkdmcCx2MqRMXXQFO6MRn15J/8r7J5bBidi76Qr3/PjbJHH3aXTksgO0sNVgjoGS+mT 6KMDCGRBFuhMHTIBBRS7jCRsRo/fkE25CUzhOSF9ReMxLf4c2eYPb/eow5of7CXpAaX8 grPaRAFdydhGXmvidaR7OQL8zLYS0v1nrQIfIri6K+upXHc2x/WHD64Iteb3B0CJmrcw bm8j9304jrG5f2ZUbgT8Dvkpje/vJTLN30Q29EFTQZUucLmAqZPqnD66zSkxJeE/fWWw 9+RQ== 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 y69si10330627pfb.190.2017.07.02.07.46.35; Sun, 02 Jul 2017 07:46:36 -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 S1752671AbdGBOqN (ORCPT + 25 others); Sun, 2 Jul 2017 10:46:13 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54244 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752052AbdGBOqG (ORCPT ); Sun, 2 Jul 2017 10:46:06 -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 C625F344; Sun, 2 Jul 2017 07:46:00 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E7B793F578; Sun, 2 Jul 2017 07:45:52 -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 v3 16/28] crypto: move pub key to generic async completion Date: Sun, 2 Jul 2017 17:41:58 +0300 Message-Id: <1499006535-19760-17-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1499006535-19760-1-git-send-email-gilad@benyossef.com> References: <1499006535-19760-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 3fad1fd..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 == -EIOCBQUEUED)) { - wait_for_completion(&compl.completion); - ret = compl.err; - } + ret = crypto_wait_req(crypto_akcipher_verify(req), &cwait); if (ret < 0) goto out_free_output;