crypto: qce - Restore/save ahash state with custom struct in export/import
authorThara Gopinath <thara.gopinath@linaro.org>
Thu, 11 Feb 2021 20:01:18 +0000 (15:01 -0500)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 7 Mar 2021 04:13:15 +0000 (15:13 +1100)
commita01dc5c1f755899aa23e7e2cfdb146913b18a48c
tree90f913391d7a00f7b5f4c347e7024d0405c020ac
parent2eee428d8212265af09d349b74746be03513382e
crypto: qce - Restore/save ahash state with custom struct in export/import

Export and import interfaces save and restore partial transformation
states. The partial states were being stored and restored in struct
sha1_state for sha1/hmac(sha1) transformations and sha256_state for
sha256/hmac(sha256) transformations.This led to a bunch of corner cases
where improper state was being stored and restored. A few of the corner
cases that turned up during testing are:

- wrong byte_count restored if export/import is called twice without h/w
transaction in between
- wrong buflen restored back if the pending buffer
length is exactly the block size.
- wrong state restored if buffer length is 0.

To fix these issues, save and restore the partial transformation state
using the newly introduced qce_sha_saved_state struct. This ensures that
all the pieces required to properly restart the transformation is captured
and restored back

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qce/sha.c