diff options
| author | Gleb Kozyrev <[email protected]> | 2015-01-29 17:50:10 +0200 |
|---|---|---|
| committer | Gleb Kozyrev <[email protected]> | 2015-01-29 17:50:10 +0200 |
| commit | 4bd7ed8a39354416094ad6fb939c49d26300981f (patch) | |
| tree | cbe679204d9d3f8a12e535437928b6f63a5d0cb5 /src | |
| parent | Merge pull request #141 from gkoz/borrow_mut (diff) | |
| download | rust-openssl-4bd7ed8a39354416094ad6fb939c49d26300981f.tar.xz rust-openssl-4bd7ed8a39354416094ad6fb939c49d26300981f.zip | |
Avoid duplicate calls to *_Final when dropping Hasher and HMAC
An assertion triggered in finalize() would lead to drop() erroneously redoing the finalization. Set the state to Finalized unconditionally to prevent this.
Diffstat (limited to 'src')
| -rw-r--r-- | src/crypto/hash.rs | 2 | ||||
| -rw-r--r-- | src/crypto/hmac.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/crypto/hash.rs b/src/crypto/hash.rs index a9a3d8b9..f81532c9 100644 --- a/src/crypto/hash.rs +++ b/src/crypto/hash.rs @@ -153,10 +153,10 @@ impl Hasher { unsafe { let mut len = 0; let r = ffi::EVP_DigestFinal_ex(self.ctx, res.as_mut_ptr(), &mut len); + self.state = Finalized; assert_eq!(len as usize, md_len); assert_eq!(r, 1); } - self.state = Finalized; res } diff --git a/src/crypto/hmac.rs b/src/crypto/hmac.rs index 1b9653c1..65808e58 100644 --- a/src/crypto/hmac.rs +++ b/src/crypto/hmac.rs @@ -136,10 +136,10 @@ impl HMAC { unsafe { let mut len = 0; let r = ffi::HMAC_Final(&mut self.ctx, res.as_mut_ptr(), &mut len); + self.state = Finalized; assert_eq!(len as usize, md_len); assert_eq!(r, 1); } - self.state = Finalized; res } |