Commit 5419f2b2 authored by Herbert Xu's avatar Herbert Xu

KEYS: DH: Use crypto_wait_req

This patch replaces the custom crypto completion function with
crypto_req_done.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 8d338c76
...@@ -64,22 +64,6 @@ static void dh_free_data(struct dh *dh) ...@@ -64,22 +64,6 @@ static void dh_free_data(struct dh *dh)
kfree_sensitive(dh->g); kfree_sensitive(dh->g);
} }
struct dh_completion {
struct completion completion;
int err;
};
static void dh_crypto_done(struct crypto_async_request *req, int err)
{
struct dh_completion *compl = req->data;
if (err == -EINPROGRESS)
return;
compl->err = err;
complete(&compl->completion);
}
static int kdf_alloc(struct crypto_shash **hash, char *hashname) static int kdf_alloc(struct crypto_shash **hash, char *hashname)
{ {
struct crypto_shash *tfm; struct crypto_shash *tfm;
...@@ -146,7 +130,7 @@ long __keyctl_dh_compute(struct keyctl_dh_params __user *params, ...@@ -146,7 +130,7 @@ long __keyctl_dh_compute(struct keyctl_dh_params __user *params,
struct keyctl_dh_params pcopy; struct keyctl_dh_params pcopy;
struct dh dh_inputs; struct dh dh_inputs;
struct scatterlist outsg; struct scatterlist outsg;
struct dh_completion compl; DECLARE_CRYPTO_WAIT(compl);
struct crypto_kpp *tfm; struct crypto_kpp *tfm;
struct kpp_request *req; struct kpp_request *req;
uint8_t *secret; uint8_t *secret;
...@@ -266,22 +250,18 @@ long __keyctl_dh_compute(struct keyctl_dh_params __user *params, ...@@ -266,22 +250,18 @@ long __keyctl_dh_compute(struct keyctl_dh_params __user *params,
kpp_request_set_input(req, NULL, 0); kpp_request_set_input(req, NULL, 0);
kpp_request_set_output(req, &outsg, outlen); kpp_request_set_output(req, &outsg, outlen);
init_completion(&compl.completion);
kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG |
CRYPTO_TFM_REQ_MAY_SLEEP, CRYPTO_TFM_REQ_MAY_SLEEP,
dh_crypto_done, &compl); crypto_req_done, &compl);
/* /*
* For DH, generate_public_key and generate_shared_secret are * For DH, generate_public_key and generate_shared_secret are
* the same calculation * the same calculation
*/ */
ret = crypto_kpp_generate_public_key(req); ret = crypto_kpp_generate_public_key(req);
if (ret == -EINPROGRESS) { ret = crypto_wait_req(ret, &compl);
wait_for_completion(&compl.completion); if (ret)
ret = compl.err; goto out6;
if (ret)
goto out6;
}
if (kdfcopy) { if (kdfcopy) {
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment