提交 434b4212 编写于 作者: R Russell King 提交者: Herbert Xu

crypto: caam - avoid needlessly saving and restoring caam_hash_ctx

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 caam_hash_ctx structure on export, and
restoring it on import is a waste of resources.  So, remove this code.
Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 6ea30f0a
...@@ -1554,24 +1554,20 @@ static int ahash_final(struct ahash_request *req) ...@@ -1554,24 +1554,20 @@ static int ahash_final(struct ahash_request *req)
static int ahash_export(struct ahash_request *req, void *out) static int ahash_export(struct ahash_request *req, void *out)
{ {
struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
struct caam_hash_state *state = ahash_request_ctx(req); struct caam_hash_state *state = ahash_request_ctx(req);
memcpy(out, ctx, sizeof(struct caam_hash_ctx)); memcpy(out, state, sizeof(struct caam_hash_state));
memcpy(out + sizeof(struct caam_hash_ctx), state,
sizeof(struct caam_hash_state));
return 0; return 0;
} }
static int ahash_import(struct ahash_request *req, const void *in) static int ahash_import(struct ahash_request *req, const void *in)
{ {
struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
struct caam_hash_state *state = ahash_request_ctx(req); struct caam_hash_state *state = ahash_request_ctx(req);
memcpy(ctx, in, sizeof(struct caam_hash_ctx)); memcpy(state, in, sizeof(struct caam_hash_state));
memcpy(state, in + sizeof(struct caam_hash_ctx),
sizeof(struct caam_hash_state));
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册