aboutsummaryrefslogtreecommitdiff
path: root/src/api/signature/payload.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-02-29 12:43:25 +0100
committerAlex Auvolat <alex@adnab.me>2024-02-29 13:07:18 +0100
commit6d33e721c41bdb0fe7da6404e6d6d32509eed6be (patch)
treeb8e6a49c3e13607a0f235e6cc262ba94e7671662 /src/api/signature/payload.rs
parenteaac4924ef5c18eb40eabfbf246f5ae9c894889a (diff)
downloadgarage-6d33e721c41bdb0fe7da6404e6d6d32509eed6be.tar.gz
garage-6d33e721c41bdb0fe7da6404e6d6d32509eed6be.zip
[fix-auth-ct-eq] use consant time comparison for awsv4 signature verificationfix-auth-ct-eq
Diffstat (limited to 'src/api/signature/payload.rs')
-rw-r--r--src/api/signature/payload.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/api/signature/payload.rs b/src/api/signature/payload.rs
index 949da601..a9e7d34d 100644
--- a/src/api/signature/payload.rs
+++ b/src/api/signature/payload.rs
@@ -375,9 +375,10 @@ pub async fn verify_v4(
)
.ok_or_internal_error("Unable to build signing HMAC")?;
hmac.update(payload);
- let our_signature = hex::encode(hmac.finalize().into_bytes());
- if auth.signature != our_signature {
- return Err(Error::forbidden("Invalid signature".to_string()));
+ let signature =
+ hex::decode(&auth.signature).map_err(|_| Error::forbidden("Invalid signature"))?;
+ if hmac.verify_slice(&signature).is_err() {
+ return Err(Error::forbidden("Invalid signature"));
}
Ok(key)