Skip to content

Commit

Permalink
minimize diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
initsecret committed Sep 2, 2024
1 parent 4ad9249 commit e35ec91
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions openssl/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,8 @@ impl Hasher {

/// Feeds data into the hasher.
pub fn update(&mut self, data: &[u8]) -> Result<(), ErrorStack> {
match self.state {
Finalized => self.init()?,
_ => {}
if self.state == Finalized {
self.init()?;
}
unsafe {
cvt(ffi::EVP_DigestUpdate(
Expand Down Expand Up @@ -312,9 +311,8 @@ impl Hasher {

/// Returns the hash of the data written and resets the non-XOF hasher.
pub fn finish(&mut self) -> Result<DigestBytes, ErrorStack> {
match self.state {
Finalized => self.init()?,
_ => {}
if self.state == Finalized {
self.init()?;
}
unsafe {
#[cfg(not(boringssl))]
Expand All @@ -339,9 +337,8 @@ impl Hasher {
/// The hash will be as long as the buf.
#[cfg(ossl111)]
pub fn finish_xof(&mut self, buf: &mut [u8]) -> Result<(), ErrorStack> {
match self.state {
Finalized => self.init()?,
_ => {}
if self.state == Finalized {
self.init()?;
}
unsafe {
cvt(ffi::EVP_DigestFinalXOF(
Expand Down Expand Up @@ -604,7 +601,6 @@ mod tests {
#[test]
fn test_squeeze_then_finalize() {
let digest = MessageDigest::shake_128();
let data = Vec::from_hex(MD5_TESTS[6].0).unwrap();
let mut h = Hasher::new(digest).unwrap();
let mut buf = vec![0; digest.size()];
h.squeeze_xof(&mut buf).unwrap();
Expand Down

0 comments on commit e35ec91

Please sign in to comment.