diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/security/signed.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/security/signed.rs b/src/security/signed.rs index 2954954..080bed2 100644 --- a/src/security/signed.rs +++ b/src/security/signed.rs @@ -1,4 +1,4 @@ -use hmac::{Hmac, Mac, NewMac}; +use hmac::{Hmac, Mac}; use sha2::Sha256; const SIGNED_KEY_LEN: usize = 32; @@ -42,7 +42,7 @@ impl Key { /// Signs the value providing integrity and authenticity. pub fn sign(&self, value: &str) -> String { // Compute HMAC-SHA256 of the cookie's value. - let mut mac = Hmac::<Sha256>::new_varkey(&self.0).expect("good key"); + let mut mac = Hmac::<Sha256>::new_from_slice(&self.0).expect("good key"); mac.update(value.as_bytes()); // Cookie's new value is [MAC | original-value]. @@ -63,9 +63,9 @@ impl Key { let digest = base64::decode(digest_str).map_err(|_| "bad base64 digest")?; // Perform the verification. - let mut mac = Hmac::<Sha256>::new_varkey(&self.0).expect("good key"); + let mut mac = Hmac::<Sha256>::new_from_slice(&self.0).expect("good key"); mac.update(value.as_bytes()); - mac.verify(&digest) + mac.verify_slice(&digest) .map(|_| value.to_string()) .map_err(|_| "value did not verify".to_string()) } |