aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-12-23 15:55:41 +0100
committerMartin Fischer <martin@push-f.com>2021-12-23 23:05:10 +0100
commit4061b03b3be49ae4fab026a92c463f837173831b (patch)
treeff061dff7f93408139f362fbac0356fb3d5d6664 /src
parent460150079f7bbf868c42d0c3c10119a15e9d6b84 (diff)
upgrade hmac and sha2
Diffstat (limited to 'src')
-rw-r--r--src/security/signed.rs8
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())
}