• Thara Gopinath's avatar
    crypto: qce - Restore/save ahash state with custom struct in export/import · a01dc5c1
    Thara Gopinath authored
    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: default avatarThara Gopinath <thara.gopinath@linaro.org>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    a01dc5c1
sha.c 13.5 KB