aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml4
-rw-r--r--src/security/signed.rs8
2 files changed, 6 insertions, 6 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 4455e47..1c0769f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -28,9 +28,9 @@ hyper = { version = "0.14", optional = true }
serde_json = { version = "1.0", optional = true }
base64 = { version = "0.13", optional = true }
-hmac = { version = "0.10", optional = true }
+hmac = { version = "0.12", optional = true }
rand = { version = "0.8", optional = true }
-sha2 = { version = "0.9", optional = true }
+sha2 = { version = "0.10", optional = true }
[package.metadata.docs.rs]
all-features = true
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())
}