We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 49583c1 commit 381bc66Copy full SHA for 381bc66
1 file changed
httpsig/src/crypto/symmetric.rs
@@ -53,13 +53,14 @@ impl super::SigningKey for SharedKey {
53
impl super::VerifyingKey for SharedKey {
54
/// Verify the mac
55
fn verify(&self, data: &[u8], expected_mac: &[u8]) -> HttpSigResult<()> {
56
- use super::SigningKey;
57
- debug!("Verify HmacSha256");
58
- let calcurated_mac = self.sign(data)?;
59
- if calcurated_mac == expected_mac {
60
- Ok(())
61
- } else {
62
- Err(HttpSigError::InvalidSignature("Invalid MAC".to_string()))
+ match self {
+ SharedKey::HmacSha256(key) => {
+ debug!("Verify HmacSha256");
+ let mut mac = HmacSha256::new_from_slice(key).unwrap();
+ mac.update(data);
+ mac.verify_slice(expected_mac)
+ .map_err(|_| HttpSigError::InvalidSignature("Invalid MAC".to_string()))
63
+ }
64
}
65
66
0 commit comments