crypto: sahara - fix ahash selftest failure
authorOvidiu Panait <ovidiu.panait@windriver.com>
Fri, 1 Dec 2023 17:06:21 +0000 (19:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:16 +0000 (15:35 -0800)
commitab82cb379a5ac5e5151ca6cadf624dfa57f6d5d4
treeb89ad77762aad70318ea0ddca7564969ee36d318
parent489bfd8f8a64107c0bd38a4724fa16c7eda9426a
crypto: sahara - fix ahash selftest failure

[ Upstream commit afffcf3db98b9495114b79d5381f8cc3f69476fb ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/sahara.c