Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
crypto: sahara - avoid needlessly saving and restoring sahara_ctx
Browse files Browse the repository at this point in the history
Based on commit 434b421 ("crypto: caam - avoid needlessly saving and
restoring caam_hash_ctx") from Russell King.

When exporting and importing the hash state, we will only export and
import into hashes which share the same struct crypto_ahash pointer.
(See hash_accept->af_alg_accept->hash_accept_parent.)

This means that saving the sahara_ctx structure on export, and
restoring it on import is a waste of resources.  So, remove this code.

Signed-off-by: Fabio Estevam <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
Fabio Estevam authored and herbertx committed Feb 6, 2016
1 parent 6e56201 commit bceab44
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions drivers/crypto/sahara.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,26 +1162,18 @@ static int sahara_sha_digest(struct ahash_request *req)

static int sahara_sha_export(struct ahash_request *req, void *out)
{
struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
struct sahara_ctx *ctx = crypto_ahash_ctx(ahash);
struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);

memcpy(out, ctx, sizeof(struct sahara_ctx));
memcpy(out + sizeof(struct sahara_sha_reqctx), rctx,
sizeof(struct sahara_sha_reqctx));
memcpy(out, rctx, sizeof(struct sahara_sha_reqctx));

return 0;
}

static int sahara_sha_import(struct ahash_request *req, const void *in)
{
struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
struct sahara_ctx *ctx = crypto_ahash_ctx(ahash);
struct sahara_sha_reqctx *rctx = ahash_request_ctx(req);

memcpy(ctx, in, sizeof(struct sahara_ctx));
memcpy(rctx, in + sizeof(struct sahara_sha_reqctx),
sizeof(struct sahara_sha_reqctx));
memcpy(rctx, in, sizeof(struct sahara_sha_reqctx));

return 0;
}
Expand Down

0 comments on commit bceab44

Please sign in to comment.