diff options
author | Antoine Tenart <antoine.tenart@bootlin.com> | 2018-03-19 09:21:19 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-03-31 01:32:47 +0800 |
commit | 4505bb02ec87f24e4704716ef5a55b233805157d (patch) | |
tree | c65059413a6df07eb4198cf78f9630309a081034 | |
parent | 15f64ee0aecdd7a65bd8a6067511e14abf159590 (diff) | |
download | linux-4505bb02ec87f24e4704716ef5a55b233805157d.tar.gz linux-4505bb02ec87f24e4704716ef5a55b233805157d.tar.bz2 linux-4505bb02ec87f24e4704716ef5a55b233805157d.zip |
crypto: inside-secure - the context ipad/opad should use the state sz
This patches uses the state size of the algorithms instead of their
digest size to copy the ipad and opad in the context. This doesn't fix
anything as the state and digest size are the same for many algorithms,
and for all the hmac currently supported by this driver. However
hmac(sha224) use the sha224 hash function which has a different digest
and state size. This commit prepares the addition of such algorithms.
Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/inside-secure/safexcel_hash.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c index d3ba935d0266..31df97eec89a 100644 --- a/drivers/crypto/inside-secure/safexcel_hash.c +++ b/drivers/crypto/inside-secure/safexcel_hash.c @@ -120,11 +120,11 @@ static void safexcel_context_control(struct safexcel_ahash_ctx *ctx, ctx->base.ctxr->data[i] = cpu_to_le32(req->processed / blocksize); } } else if (req->digest == CONTEXT_CONTROL_DIGEST_HMAC) { - cdesc->control_data.control0 |= CONTEXT_CONTROL_SIZE(10); + cdesc->control_data.control0 |= CONTEXT_CONTROL_SIZE(2 * req->state_sz / sizeof(u32)); - memcpy(ctx->base.ctxr->data, ctx->ipad, digestsize); - memcpy(ctx->base.ctxr->data + digestsize / sizeof(u32), - ctx->opad, digestsize); + memcpy(ctx->base.ctxr->data, ctx->ipad, req->state_sz); + memcpy(ctx->base.ctxr->data + req->state_sz / sizeof(u32), + ctx->opad, req->state_sz); } } |