Commit 5efa7186 authored by Herbert Xu's avatar Herbert Xu

crypto: marvell/cesa - 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 3ce2d597
...@@ -1104,47 +1104,27 @@ struct ahash_alg mv_sha256_alg = { ...@@ -1104,47 +1104,27 @@ struct ahash_alg mv_sha256_alg = {
} }
}; };
struct mv_cesa_ahash_result {
struct completion completion;
int error;
};
static void mv_cesa_hmac_ahash_complete(struct crypto_async_request *req,
int error)
{
struct mv_cesa_ahash_result *result = req->data;
if (error == -EINPROGRESS)
return;
result->error = error;
complete(&result->completion);
}
static int mv_cesa_ahmac_iv_state_init(struct ahash_request *req, u8 *pad, static int mv_cesa_ahmac_iv_state_init(struct ahash_request *req, u8 *pad,
void *state, unsigned int blocksize) void *state, unsigned int blocksize)
{ {
struct mv_cesa_ahash_result result; DECLARE_CRYPTO_WAIT(result);
struct scatterlist sg; struct scatterlist sg;
int ret; int ret;
ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
mv_cesa_hmac_ahash_complete, &result); crypto_req_done, &result);
sg_init_one(&sg, pad, blocksize); sg_init_one(&sg, pad, blocksize);
ahash_request_set_crypt(req, &sg, pad, blocksize); ahash_request_set_crypt(req, &sg, pad, blocksize);
init_completion(&result.completion);
ret = crypto_ahash_init(req); ret = crypto_ahash_init(req);
if (ret) if (ret)
return ret; return ret;
ret = crypto_ahash_update(req); ret = crypto_ahash_update(req);
if (ret && ret != -EINPROGRESS) ret = crypto_wait_req(ret, &result);
return ret;
wait_for_completion_interruptible(&result.completion); if (ret)
if (result.error) return ret;
return result.error;
ret = crypto_ahash_export(req, state); ret = crypto_ahash_export(req, state);
if (ret) if (ret)
...@@ -1158,7 +1138,7 @@ static int mv_cesa_ahmac_pad_init(struct ahash_request *req, ...@@ -1158,7 +1138,7 @@ static int mv_cesa_ahmac_pad_init(struct ahash_request *req,
u8 *ipad, u8 *opad, u8 *ipad, u8 *opad,
unsigned int blocksize) unsigned int blocksize)
{ {
struct mv_cesa_ahash_result result; DECLARE_CRYPTO_WAIT(result);
struct scatterlist sg; struct scatterlist sg;
int ret; int ret;
int i; int i;
...@@ -1172,17 +1152,12 @@ static int mv_cesa_ahmac_pad_init(struct ahash_request *req, ...@@ -1172,17 +1152,12 @@ static int mv_cesa_ahmac_pad_init(struct ahash_request *req,
return -ENOMEM; return -ENOMEM;
ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
mv_cesa_hmac_ahash_complete, crypto_req_done, &result);
&result);
sg_init_one(&sg, keydup, keylen); sg_init_one(&sg, keydup, keylen);
ahash_request_set_crypt(req, &sg, ipad, keylen); ahash_request_set_crypt(req, &sg, ipad, keylen);
init_completion(&result.completion);
ret = crypto_ahash_digest(req); ret = crypto_ahash_digest(req);
if (ret == -EINPROGRESS) { ret = crypto_wait_req(ret, &result);
wait_for_completion_interruptible(&result.completion);
ret = result.error;
}
/* Set the memory region to 0 to avoid any leak. */ /* Set the memory region to 0 to avoid any leak. */
kfree_sensitive(keydup); kfree_sensitive(keydup);
......
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