From patchwork Sun Oct 15 09:19:53 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: 115867 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2529182qgn; Sun, 15 Oct 2017 02:23:16 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDM81qhdBIgBp2JJyvFdeCBgHjLTWvhlPmRYdJrDpHobKMvVzWi07fOpDc8XyLpKmI73UZx X-Received: by 10.98.217.2 with SMTP id s2mr5804154pfg.298.1508059395965; Sun, 15 Oct 2017 02:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508059395; cv=none; d=google.com; s=arc-20160816; b=E9XrrM6eAteNaYeCVMh2NRTdsuT3XDLi4WLNr+OQ4leKLfvWzUqNta2mBwrqh0J0zl 8E8zJlb+nZ27o4PA2/Z5XsBrQ9n8ZRNFp18+lHqspgXu5GrhiMdjdLfAfdO9MzWlUgrT wSFs2QbG0Aw7XUm6B/lwnrv2ke3gT4rcFuRVAHzaWcILTSk5rs1lF2gD4i7irEPIn4/C R+sKq5cCfFoL0Yrcgpcv798tLRtVfmwqybMSqRvQmBcMWAftBHuUax5Zdn3NOKCQ/S+g N9/wm5bLM9FV0EF3l44Ph7mElfYUF4qHo+g6XG72zk+/z2oQcYHFXb0DF/wtYyds99FN x5Yw== 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=2lU1kmLxlJRc7BuVtgQp+iIw4AduitxM2TXwLw8qR4g=; b=j8rSSVwsC12NTo7d4LPTReUggdyvkVw95REyMwTQX38sCMMlEK5CA4Ymepov4+DlEI qfvNnOX008gEjL7Db9jXzMZd0ckUofZVd2f3S137aQupvmqO9+OMDtGxYlU9uxJSgfET ErpbtIm2lbBHTFTSyK1AxVeG2V7mQDHACt38SZTSVhwa++Jw3bUlzUP2wIY2KvFjD11k 27wyKabtVvJIdGDA/kDp/JB8iUw/F9dThRnppMHDoRJ+f6tNN3Fsk3DEl6oJdWVFLS5a LLLbQkjpXeZjQutXVL6EUjdHplZxgWZ7S+nrWJMhEToZ+I9F/jF/U+lAt0BMvUCC+ztE WzXg== 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 m7si3032236plt.61.2017.10.15.02.23.15; Sun, 15 Oct 2017 02:23:15 -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 S1752483AbdJOJXO (ORCPT + 27 others); Sun, 15 Oct 2017 05:23:14 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47594 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752394AbdJOJXJ (ORCPT ); Sun, 15 Oct 2017 05:23:09 -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 9BF7E16A0; Sun, 15 Oct 2017 02:23:08 -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 C1AAA3F3E1; Sun, 15 Oct 2017 02:22:59 -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, Steve French , "Theodore Y. Ts'o" , Jaegeuk Kim , Steffen Klassert , Alexey Kuznetsov , Hideaki YOSHIFUJI , Mimi Zohar , Dmitry Kasatkin , James Morris , "Serge E. Hallyn" Cc: Ofir Drang , 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-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fscrypt@vger.kernel.org, netdev@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-security-module@vger.kernel.org Subject: [PATCH v9 08/20] crypto: move pub key to generic async completion Date: Sun, 15 Oct 2017 10:19:53 +0100 Message-Id: <1508059209-25529-9-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508059209-25529-1-git-send-email-gilad@benyossef.com> References: <1508059209-25529-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.7.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;