From patchwork Tue Aug 8 12:03:38 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: 109620 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp3983615obb; Tue, 8 Aug 2017 05:05:49 -0700 (PDT) X-Received: by 10.101.88.8 with SMTP id g8mr3847826pgr.302.1502193949100; Tue, 08 Aug 2017 05:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502193949; cv=none; d=google.com; s=arc-20160816; b=VupJJQCDFVGb+l0J1EXhvl3NF7ZnulW8kJU4fm3YT2NaNEDbEfXzxpSR1twtYba71P iG1R7qgRLg1/r22sXlErFa4C2R2oBoINEeo7wvOjH1M4PDn77KSSEREqYz+FiBxwLert FDxahCHxhKIyqv3i3+0PMaZFYYiJxO0PxIMSbDRZnQh4FsW5RcBjKhPY+OMfB+uoRVsp ritaPbC6cER9nZrgKhHugoB8Gj2plkbU/oCRgGisvobsNJUxHGyAvHuWE8Qbb1+PH0Wy sJZAD+hCxva4xhBcxyyT8Lun/5FtIizkZYnKyY0VJYCti+EYZg7SuboAXMx2TYgHLhdE WGHw== 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=miSlrQhTNiOwh16C9lEBXce9khHpOSlDwPTQ443Sf0ZPiHzSR3K+E8h5zv0uXbGzR7 dZOkqzJ9ad805G+ncTR2JBsiWtnfpDSqBsJi2uf3bcvaL8qM8C3HN1hl+gn9wmc9e7zF +zVo4Htgxm//dWeDuQ/e1zJvSAtMbjcD6cy0bVSV87aI/inKjNPyYcHhBj3LprI8LsrL G4GdjDujMLzy8bqiXnMQjZFg6BLQ+kCiNkGzoRb/pNtlB8yKp/lQSe/w1reeLIScMUt/ atuFIBdF+xn7KhLl7hI+UHEpsHTRvNuU13NDIRwzzc9vXX7mxQp6GXYUY3ygZ+hwdN3U oP6g== 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 o129si779393pfo.503.2017.08.08.05.05.48; Tue, 08 Aug 2017 05:05:49 -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 S1752632AbdHHMFq (ORCPT + 25 others); Tue, 8 Aug 2017 08:05:46 -0400 Received: from foss.arm.com ([217.140.101.70]:33552 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752082AbdHHMFm (ORCPT ); Tue, 8 Aug 2017 08:05:42 -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 C4EDF1715; Tue, 8 Aug 2017 05:05:41 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.154]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D2EB13F577; Tue, 8 Aug 2017 05:05:33 -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 v4 07/19] crypto: move pub key to generic async completion Date: Tue, 8 Aug 2017 15:03:38 +0300 Message-Id: <1502193834-11289-8-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1502193834-11289-1-git-send-email-gilad@benyossef.com> References: <1502193834-11289-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;