Commit 4d03c504 authored by Phil Sutter's avatar Phil Sutter Committed by Herbert Xu

crypto: mv_cesa - fix for hash finalisation with data

Since mv_hash_final_fallback() uses ctx->state, read out the digest
state register before calling it.
Signed-off-by: default avatarPhil Sutter <phil.sutter@viprinet.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 5741d2ee
...@@ -423,6 +423,15 @@ static int mv_hash_final_fallback(struct ahash_request *req) ...@@ -423,6 +423,15 @@ static int mv_hash_final_fallback(struct ahash_request *req)
return rc; return rc;
} }
static void mv_save_digest_state(struct mv_req_hash_ctx *ctx)
{
ctx->state[0] = readl(cpg->reg + DIGEST_INITIAL_VAL_A);
ctx->state[1] = readl(cpg->reg + DIGEST_INITIAL_VAL_B);
ctx->state[2] = readl(cpg->reg + DIGEST_INITIAL_VAL_C);
ctx->state[3] = readl(cpg->reg + DIGEST_INITIAL_VAL_D);
ctx->state[4] = readl(cpg->reg + DIGEST_INITIAL_VAL_E);
}
static void mv_hash_algo_completion(void) static void mv_hash_algo_completion(void)
{ {
struct ahash_request *req = ahash_request_cast(cpg->cur_req); struct ahash_request *req = ahash_request_cast(cpg->cur_req);
...@@ -437,14 +446,12 @@ static void mv_hash_algo_completion(void) ...@@ -437,14 +446,12 @@ static void mv_hash_algo_completion(void)
memcpy(req->result, cpg->sram + SRAM_DIGEST_BUF, memcpy(req->result, cpg->sram + SRAM_DIGEST_BUF,
crypto_ahash_digestsize(crypto_ahash_reqtfm crypto_ahash_digestsize(crypto_ahash_reqtfm
(req))); (req)));
} else } else {
mv_save_digest_state(ctx);
mv_hash_final_fallback(req); mv_hash_final_fallback(req);
}
} else { } else {
ctx->state[0] = readl(cpg->reg + DIGEST_INITIAL_VAL_A); mv_save_digest_state(ctx);
ctx->state[1] = readl(cpg->reg + DIGEST_INITIAL_VAL_B);
ctx->state[2] = readl(cpg->reg + DIGEST_INITIAL_VAL_C);
ctx->state[3] = readl(cpg->reg + DIGEST_INITIAL_VAL_D);
ctx->state[4] = readl(cpg->reg + DIGEST_INITIAL_VAL_E);
} }
} }
......
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