Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1706458
| From | Gilad Ben-Yossef <gilad@benyossef.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v4 07/19] crypto: move pub key to generic async completion |
| Date | 2017-08-08 14:10 +0200 |
| Message-ID | <ucbuH-8cT-53@gated-at.bofh.it> (permalink) |
| References | <ucbuF-8cT-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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 <gilad@benyossef.com>
---
crypto/asymmetric_keys/public_key.c | 28 ++++------------------------
1 file changed, 4 insertions(+), 24 deletions(-)
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;
--
2.1.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v4 00/19] simplify crypto wait for async op Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:10 +0200 [PATCH v4 18/19] crypto: mediatek: move to generic async completion Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:10 +0200 [PATCH v4 01/19] crypto: change transient busy return code to -EAGAIN Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:10 +0200 [PATCH v4 17/19] crypto: qce: move to generic async completion Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:10 +0200 [PATCH v4 12/19] dm: move dm-verity to generic async completion Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:10 +0200 [PATCH v4 08/19] crypto: move drbg to generic async completion Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:10 +0200 [PATCH v4 07/19] crypto: move pub key to generic async completion Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:10 +0200 [PATCH v4 16/19] crypto: talitos: move to generic async completion Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:10 +0200 [PATCH v4 05/19] crypto: introduce crypto wait for async op Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:10 +0200 [PATCH v4 19/19] crypto: adapt api sample to use async. op wait Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:10 +0200 [PATCH v4 14/19] ima: move to generic async completion Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:10 +0200 [PATCH v4 03/19] crypto: remove redundant backlog checks on EBUSY Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-08 14:20 +0200
csiph-web