Skip to content

Commit

Permalink
fix(s3s/sig_v4): fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Nugine committed Oct 25, 2024
1 parent 8961184 commit d7e8efc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion crates/s3s/src/ops/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ impl SignatureContext<'_> {
let secret_key = auth.get_secret_key(&access_key).await?;

let string_to_sign = info.policy;
let signature = sig_v4::calculate_signature(string_to_sign, &secret_key, &amz_date, credential.aws_region, credential.aws_service);
let signature =
sig_v4::calculate_signature(string_to_sign, &secret_key, &amz_date, credential.aws_region, credential.aws_service);

let expected_signature = info.x_amz_signature;
if signature != expected_signature {
Expand Down
16 changes: 14 additions & 2 deletions crates/s3s/src/sig_v4/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,13 @@ pub fn create_chunk_string_to_sign(

/// calculate signature
#[must_use]
pub fn calculate_signature(string_to_sign: &str, secret_key: &SecretKey, amz_date: &AmzDate, region: &str, service: &str) -> String {
pub fn calculate_signature(
string_to_sign: &str,
secret_key: &SecretKey,
amz_date: &AmzDate,
region: &str,
service: &str,
) -> String {
let mut secret = {
let secret_key = secret_key.expose();
let mut buf = <SmallVec<[u8; 128]>>::with_capacity(secret_key.len().saturating_add(4));
Expand Down Expand Up @@ -787,7 +793,13 @@ mod tests {
)
);

let signature = calculate_signature(&string_to_sign, &secret_access_key, &info.amz_date, info.credential.aws_region, info.credential.aws_service);
let signature = calculate_signature(
&string_to_sign,
&secret_access_key,
&info.amz_date,
info.credential.aws_region,
info.credential.aws_service,
);
assert_eq!(signature, "aeeed9bbccd4d02ee5c0109b86d86835f995330da4c265957d157751f604d404");
assert_eq!(signature, info.signature);
}
Expand Down

0 comments on commit d7e8efc

Please sign in to comment.