@@ -280,9 +280,8 @@ impl Hasher {
280
280
281
281
/// Feeds data into the hasher.
282
282
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 ( ) ?;
286
285
}
287
286
unsafe {
288
287
cvt ( ffi:: EVP_DigestUpdate (
@@ -312,9 +311,8 @@ impl Hasher {
312
311
313
312
/// Returns the hash of the data written and resets the non-XOF hasher.
314
313
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 ( ) ?;
318
316
}
319
317
unsafe {
320
318
#[ cfg( not( boringssl) ) ]
@@ -339,9 +337,8 @@ impl Hasher {
339
337
/// The hash will be as long as the buf.
340
338
#[ cfg( ossl111) ]
341
339
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 ( ) ?;
345
342
}
346
343
unsafe {
347
344
cvt ( ffi:: EVP_DigestFinalXOF (
@@ -604,7 +601,6 @@ mod tests {
604
601
#[ test]
605
602
fn test_squeeze_then_finalize ( ) {
606
603
let digest = MessageDigest :: shake_128 ( ) ;
607
- let data = Vec :: from_hex ( MD5_TESTS [ 6 ] . 0 ) . unwrap ( ) ;
608
604
let mut h = Hasher :: new ( digest) . unwrap ( ) ;
609
605
let mut buf = vec ! [ 0 ; digest. size( ) ] ;
610
606
h. squeeze_xof ( & mut buf) . unwrap ( ) ;
0 commit comments