Skip to content

Commit

Permalink
disallow updates after squeezes
Browse files Browse the repository at this point in the history
  • Loading branch information
initsecret committed Dec 21, 2024
1 parent 680136d commit 769f0b2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions openssl/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,18 @@ impl Hasher {
if self.state == Finalized {
self.init()?;
}
if self.state == Squeeze {
// [`EVP_DigestUpdate`], depending on the implementation, may allow Updates after Squeezes.
// But, [FIPS 202], as shown in Figure 7, has a distinguished absorbing phase followed by a squeezing phase.
// Indeed, the [`sha3.c`] implmentation disallows Updates after Squeezes.
// For consistency, we always return an error when Update is called after Squeeze.
//
// [`EVP_DigestUpdate`]: https://github.com/openssl/openssl/blob/b3bb214720f20f3b126ae4b9c330e9a48b835415/crypto/evp/digest.c#L385-L393
// [FIPS 202]: https://dx.doi.org/10.6028/NIST.FIPS.202
// [`sha3.c`]: https://github.com/openssl/openssl/blob/b3bb214720f20f3b126ae4b9c330e9a48b835415/crypto/sha/sha3.c#L52-L63
let errors = ErrorStack::get();
return Err(errors);
}
unsafe {
cvt(ffi::EVP_DigestUpdate(
self.ctx,
Expand Down

0 comments on commit 769f0b2

Please # to comment.