Skip to content

Commit bcf8048

Browse files
committed
Use RustCrypto's md5 crate to match sha2 provenance
Since we use RustCrypto's SHA-2 implementation, we might as well use RustCrypto's MD5 implementation, despite its somewhat more awkward name ("md-5" vs. "md5").
1 parent b94d7be commit bcf8048

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- Update to `rustc_version` 0.3
1010
- Replace `time`-related types in `rusoto_signature` with `chrono` types, to
1111
match `rusoto_credential`
12+
- Swap the non-RustCrypto `md5` crate for the RustCrypto `md-5` crate, to match
13+
usage of RustCrypto `sha2` crate
1214

1315
## [0.46.0] - 2021-01-05
1416

rusoto/signature/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ rustc_version = "0.3"
2222
[dependencies]
2323
bytes = "1.0"
2424
chrono = { version = "0.4", default-features = false, features = ["clock"] }
25+
digest = "0.9.0"
2526
futures = "0.3"
2627
hmac = "0.10"
2728
http = "0.2"
2829
hyper = { version = "0.14", features = ["stream"] }
2930
log = "0.4.1"
30-
md5 = "0.7"
31+
md-5 = "0.9"
3132
base64 = "0.13"
3233
hex = "0.4"
3334
serde = "1"

rusoto/signature/src/signature.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ use std::time::Duration;
2020
use base64;
2121
use bytes::Bytes;
2222
use chrono::{DateTime, Utc, NaiveDate};
23+
use digest::Digest;
2324
use hex;
2425
use hmac::{Hmac, Mac, NewMac};
2526
use http::header::{HeaderMap, HeaderName, HeaderValue};
2627
use http::{Method, Request};
2728
use hyper::Body;
2829
use log::{debug, log_enabled, Level::Debug};
29-
use md5;
30+
use md5::Md5;
3031
use percent_encoding::{percent_decode, utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC};
31-
use sha2::{Digest, Sha256};
32+
use sha2::Sha256;
3233

3334
use crate::credential::AwsCredentials;
3435
use crate::region::Region;
@@ -157,7 +158,7 @@ impl SignedRequest {
157158
return;
158159
}
159160
if let Some(SignedRequestPayload::Buffer(ref payload)) = self.payload {
160-
let digest = md5::compute(payload);
161+
let digest = Md5::digest(payload);
161162
self.add_header("Content-MD5", &base64::encode(&*digest));
162163
}
163164
}

0 commit comments

Comments
 (0)