From patchwork Thu Aug 24 14:18:54 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: 110920 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp8561520ybm; Thu, 24 Aug 2017 07:21:00 -0700 (PDT) X-Received: by 10.84.231.197 with SMTP id g5mr5187817pln.346.1503584460278; Thu, 24 Aug 2017 07:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503584460; cv=none; d=google.com; s=arc-20160816; b=vJd/kiSw6MLiAUYGVOI6h5nHZ7Q1o8CSfX3Ek9Ry97DBm+HKJPq3AGQdcwZ+ysw/BB eSpDbFxwnPTwerW8eYUC6tWsqC1l5hEYND6YoWMUwDJkr7hsSV52klhmE/tW4GLeWwQ2 1fwF63ySPrXmzNKPoxjFXa7kgkWxJKVr5i5MgGXhMFJNvMA+kQnA4BU00KoTo9zrG3lG x61XXtJp7+gFNoFqEVmUxFAaYpkwQ70lN+CGIIS/1wc6AMY6lIDS6UJXZeY0ij+0Snx2 S2h5saD5OEQZjZ8ufnLdFVw40aVirRv9fPW64xB2p+MWFTxqGelDlrXjPdmQIFcI0HBJ /VXw== 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=PWsC9Z/COHaWozt4UO6/HzgN+I3S7jPULUARlI97STXID4U5YlwJDBeyYSBrh5FMVn zjVSRglpZeCOZfxmZYK+eqLZhB6kyqlHR9goe0O7z/ggMHiJX5LTko0H75wVet5i0RkE bo1GBk3tdp2pLpes7b4wFGCB4RRL0HX47VM6FDqBYYu39+40IjB293QOGedUUkJki/XB Wj2NYsH/FV/YKWg7+Dxb/D3Bp0gRR/dfyfznmbhhr7kpymY2e++S569edqeY62WQf+h9 Mra+hwj1uqStZA/wY7UYmOOVBQ9ytDa5oJF6bT/hvm33nlOO2+0Sz8jUKngkNkn7NirB Q+gA== 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 h188si2887382pfb.183.2017.08.24.07.21.00; Thu, 24 Aug 2017 07:21:00 -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 S1753493AbdHXOU5 (ORCPT + 26 others); Thu, 24 Aug 2017 10:20:57 -0400 Received: from foss.arm.com ([217.140.101.70]:41912 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751352AbdHXOUy (ORCPT ); Thu, 24 Aug 2017 10:20:54 -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 E3CF319E8; Thu, 24 Aug 2017 07:20:53 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.132]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EA1813F540; Thu, 24 Aug 2017 07:20:45 -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 v7 07/19] crypto: move pub key to generic async completion Date: Thu, 24 Aug 2017 17:18:54 +0300 Message-Id: <1503584350-7831-8-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1503584350-7831-1-git-send-email-gilad@benyossef.com> References: <1503584350-7831-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;