Skip to content

Commit e35ec91

Browse files
committed
minimize diffs
1 parent 4ad9249 commit e35ec91

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

openssl/src/hash.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,8 @@ impl Hasher {
280280

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

313312
/// Returns the hash of the data written and resets the non-XOF hasher.
314313
pub fn finish(&mut self) -> Result<DigestBytes, ErrorStack> {
315-
match self.state {
316-
Finalized => self.init()?,
317-
_ => {}
314+
if self.state == Finalized {
315+
self.init()?;
318316
}
319317
unsafe {
320318
#[cfg(not(boringssl))]
@@ -339,9 +337,8 @@ impl Hasher {
339337
/// The hash will be as long as the buf.
340338
#[cfg(ossl111)]
341339
pub fn finish_xof(&mut self, buf: &mut [u8]) -> Result<(), ErrorStack> {
342-
match self.state {
343-
Finalized => self.init()?,
344-
_ => {}
340+
if self.state == Finalized {
341+
self.init()?;
345342
}
346343
unsafe {
347344
cvt(ffi::EVP_DigestFinalXOF(
@@ -604,7 +601,6 @@ mod tests {
604601
#[test]
605602
fn test_squeeze_then_finalize() {
606603
let digest = MessageDigest::shake_128();
607-
let data = Vec::from_hex(MD5_TESTS[6].0).unwrap();
608604
let mut h = Hasher::new(digest).unwrap();
609605
let mut buf = vec![0; digest.size()];
610606
h.squeeze_xof(&mut buf).unwrap();

0 commit comments

Comments
 (0)