From patchwork Tue Sep 5 12:38:47 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: 111675 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp2783938qge; Tue, 5 Sep 2017 05:41:24 -0700 (PDT) X-Google-Smtp-Source: ADKCNb50hd+v73qWypoYSULG4/dj7odqF4WZVXssT+DntZAB7d3VF2jJTnnj4piwm/SNWol501gG X-Received: by 10.101.66.205 with SMTP id l13mr3844146pgp.278.1504615284101; Tue, 05 Sep 2017 05:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504615284; cv=none; d=google.com; s=arc-20160816; b=miYikhN9x+jziqCm7tsrk70e/JOgVg8w9mLr7YWwu20MJGtUF3f0WmrGR+Cn6LMRth qvg9IiEzEdiU2MkXJmF3DA4WXfunuli6X4a/JfsaV6yCRdDCz+UEtPJpYjOxNU0NJ9x0 iQ7rgrUuvspzv39dcVYSbIlGmtzYsbtc9gqH4MzFswEvvhQMfAIWGnr9dRGaR7Pqi2K4 nbbQcf4W9zbmwlleyNNZVudMuRkRex2uD+UweaxzgsoSy9pNJ1luYotkp+3SIZpfrj3+ LjbusLjrSQV/F6LXX3vHvRJzIanqEgyjIashyBjmvTxqBB1JnzUep8PNWiep3/MSecyA t7jw== 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=Q0Qjooj63EkzIYcrFqm6X58jYMDXF9BL6op9E+mBwwYAXyiPC/ucbs77B8mw7dJNb1 oP8BacHygiH7loe2XZh4H4fc/0TJHGNAFoAL4GHta37nJ/tjGUXXi3qYOMaZxvMX68i1 jmWMNUrvjH528w4hdciqw8DbJ4FAKVkpBuinck9y96rbpeC/Yx+XtaDszd1gWiVMMDCG nvgCc+kTZ8yK7bH+E0bVJV6Y97JPlFqnAbM2i1IcgEpk07srGkMn/OGC9AGfTxlcbPQx c3cIEefHWIHiDSdqaZw7nUitwzvYbfQ/wneFK2L6tzc+supxl6lP+WzxifksS2JK8Jbe 0r7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 h6si322621plk.127.2017.09.05.05.41.23; Tue, 05 Sep 2017 05:41:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751456AbdIEMlT (ORCPT + 1 other); Tue, 5 Sep 2017 08:41:19 -0400 Received: from foss.arm.com ([217.140.101.70]:39330 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751386AbdIEMlQ (ORCPT ); Tue, 5 Sep 2017 08:41:16 -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 C9BDA165C; Tue, 5 Sep 2017 05:41:15 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 64AED3F3E1; Tue, 5 Sep 2017 05:41:06 -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 , Steffen Klassert , Alexey Kuznetsov , Hideaki YOSHIFUJI , 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, netdev@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 v8 08/20] crypto: move pub key to generic async completion Date: Tue, 5 Sep 2017 15:38:47 +0300 Message-Id: <1504615144-29770-9-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504615144-29770-1-git-send-email-gilad@benyossef.com> References: <1504615144-29770-1-git-send-email-gilad@benyossef.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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;