mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 01:21:58 +00:00
crypto: shash - Export async functions
This patch exports the async functions so that they can be reused by cryptd when it switches over to using shash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
6941c3a0aa
commit
7eddf95ec5
2 changed files with 27 additions and 22 deletions
|
@ -202,9 +202,8 @@ static int shash_async_init(struct ahash_request *req)
|
||||||
return crypto_shash_init(desc);
|
return crypto_shash_init(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int shash_async_update(struct ahash_request *req)
|
int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc)
|
||||||
{
|
{
|
||||||
struct shash_desc *desc = ahash_request_ctx(req);
|
|
||||||
struct crypto_hash_walk walk;
|
struct crypto_hash_walk walk;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
|
|
||||||
|
@ -214,13 +213,19 @@ static int shash_async_update(struct ahash_request *req)
|
||||||
|
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(shash_ahash_update);
|
||||||
|
|
||||||
|
static int shash_async_update(struct ahash_request *req)
|
||||||
|
{
|
||||||
|
return shash_ahash_update(req, ahash_request_ctx(req));
|
||||||
|
}
|
||||||
|
|
||||||
static int shash_async_final(struct ahash_request *req)
|
static int shash_async_final(struct ahash_request *req)
|
||||||
{
|
{
|
||||||
return crypto_shash_final(ahash_request_ctx(req), req->result);
|
return crypto_shash_final(ahash_request_ctx(req), req->result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int shash_async_digest(struct ahash_request *req)
|
int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc)
|
||||||
{
|
{
|
||||||
struct scatterlist *sg = req->src;
|
struct scatterlist *sg = req->src;
|
||||||
unsigned int offset = sg->offset;
|
unsigned int offset = sg->offset;
|
||||||
|
@ -228,35 +233,32 @@ static int shash_async_digest(struct ahash_request *req)
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) {
|
if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) {
|
||||||
struct crypto_shash **ctx =
|
|
||||||
crypto_ahash_ctx(crypto_ahash_reqtfm(req));
|
|
||||||
struct shash_desc *desc = ahash_request_ctx(req);
|
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
desc->tfm = *ctx;
|
|
||||||
desc->flags = req->base.flags;
|
|
||||||
|
|
||||||
data = crypto_kmap(sg_page(sg), 0);
|
data = crypto_kmap(sg_page(sg), 0);
|
||||||
err = crypto_shash_digest(desc, data + offset, nbytes,
|
err = crypto_shash_digest(desc, data + offset, nbytes,
|
||||||
req->result);
|
req->result);
|
||||||
crypto_kunmap(data, 0);
|
crypto_kunmap(data, 0);
|
||||||
crypto_yield(desc->flags);
|
crypto_yield(desc->flags);
|
||||||
goto out;
|
} else
|
||||||
}
|
err = crypto_shash_init(desc) ?:
|
||||||
|
shash_ahash_update(req, desc) ?:
|
||||||
|
crypto_shash_final(desc, req->result);
|
||||||
|
|
||||||
err = shash_async_init(req);
|
|
||||||
if (err)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
err = shash_async_update(req);
|
|
||||||
if (err)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
err = shash_async_final(req);
|
|
||||||
|
|
||||||
out:
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(shash_ahash_digest);
|
||||||
|
|
||||||
|
static int shash_async_digest(struct ahash_request *req)
|
||||||
|
{
|
||||||
|
struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
|
||||||
|
struct shash_desc *desc = ahash_request_ctx(req);
|
||||||
|
|
||||||
|
desc->tfm = *ctx;
|
||||||
|
desc->flags = req->base.flags;
|
||||||
|
|
||||||
|
return shash_ahash_digest(req, desc);
|
||||||
|
}
|
||||||
|
|
||||||
static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm)
|
static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm)
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,6 +63,9 @@ int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
|
||||||
|
|
||||||
struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
|
struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
|
||||||
|
|
||||||
|
int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc);
|
||||||
|
int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc);
|
||||||
|
|
||||||
static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
|
static inline void *crypto_ahash_ctx(struct crypto_ahash *tfm)
|
||||||
{
|
{
|
||||||
return crypto_tfm_ctx(&tfm->base);
|
return crypto_tfm_ctx(&tfm->base);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue