crypto: omap-sham - fix closing of hash with separate finalize call
authorTero Kristo <t-kristo@ti.com>
Wed, 24 May 2017 07:35:33 +0000 (10:35 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Apr 2018 17:48:26 +0000 (19:48 +0200)
commit1fb08363c85da3c3c3c0acb53d7809ca2c72bede
tree3a301f3be32af19b7870564312ed6b07232f4a14
parentc0fe1e29a59f436c10b9ed05df52ab650a9f3727
crypto: omap-sham - fix closing of hash with separate finalize call

[ Upstream commit 898d86a565925f09de3d0b30cf3b47ec2e409680 ]

Currently there is an interesting corner case failure with omap-sham
driver, if the finalize call is done separately with no data, but
all previous data has already been processed. In this case, it is not
possible to close the hash with the hardware without providing any data,
so we get incorrect results. Fix this by adjusting the size of data
sent to the hardware crypto engine in case the non-final data size falls
on the block size boundary, by reducing the amount of data sent by one
full block. This makes it sure that we always have some data available
for the finalize call and we can close the hash properly.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Reported-by: Aparna Balasubramanian <aparnab@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/crypto/omap-sham.c