You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rust-cookie/0001-port-to-crypto-mac-0.1...

23 lines
1.1 KiB

diff --git a/src/secure/signed.rs b/src/secure/signed.rs
index 2390f17..954866e 100644
--- a/src/secure/signed.rs
+++ b/src/secure/signed.rs
@@ -33,7 +33,7 @@ impl<'a> SignedJar<'a> {
/// Signs the cookie's value providing integrity and authenticity.
fn sign_cookie(&self, cookie: &mut Cookie) {
// Compute HMAC-SHA256 of the cookie's value.
- let mut mac = Hmac::<Sha256>::new_varkey(&self.key).expect("good key");
+ let mut mac = Hmac::<Sha256>::new_from_slice(&self.key).expect("good key");
mac.update(cookie.value().as_bytes());
// Cookie's new value is [MAC | original-value].
@@ -55,7 +55,7 @@ impl<'a> SignedJar<'a> {
let digest = base64::decode(digest_str).map_err(|_| "bad base64 digest")?;
// Perform the verification.
- let mut mac = Hmac::<Sha256>::new_varkey(&self.key).expect("good key");
+ let mut mac = Hmac::<Sha256>::new_from_slice(&self.key).expect("good key");
mac.update(value.as_bytes());
mac.verify(&digest)
.map(|_| value.to_string())