crypto: sahara - fix ahash selftest failure
authorOvidiu Panait <ovidiu.panait@windriver.com>
Fri, 1 Dec 2023 17:06:21 +0000 (19:06 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 8 Dec 2023 03:59:45 +0000 (11:59 +0800)
update() calls should not modify the result buffer, so add an additional
check for "rctx->last" to make sure that only the final hash value is
copied into the buffer.

Fixes the following selftest failure:
alg: ahash: sahara-sha256 update() used result buffer on test vector 3,
cfg="init+update+final aligned buffer"

Fixes: 5a2bb93f5992 ("crypto: sahara - add support for SHA1/256")
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/sahara.c

index 888e5e5157bb52ec6a3860487a6ca1c27cae5a80..863171b44cdaba8e007deab1093f4cf7b08c64e6 100644 (file)
@@ -1047,7 +1047,7 @@ static int sahara_sha_process(struct ahash_request *req)
 
        memcpy(rctx->context, dev->context_base, rctx->context_size);
 
-       if (req->result)
+       if (req->result && rctx->last)
                memcpy(req->result, rctx->context, rctx->digest_size);
 
        return 0;