Skip to content

Commit cc6e1fb

Browse files
authored
Bump hmac, sha-1 and sha2 (#1117)
The crypto crates are interdependent so bump them in one go. It looks like `new_varkey()` was renamed to `new_from_slice()`, at least that is what I gather from the changed example in the documentation of the hmac crate between version 0.11 and 0.10. See https://docs.rs/hmac/0.11.0/hmac/index.html The changelog doesn't mention anything of the sort. Also I'm not sure if the S3 version even works anymore, since I think AWS requires the v4 authentication scheme now and not the older v2 version used in simples3. It would probably make sense to use the new aws-sdk or one of its subcrates. Signed-off-by: Jonathan Schwender <[email protected]>
1 parent 0363867 commit cc6e1fb

File tree

4 files changed

+19
-48
lines changed

4 files changed

+19
-48
lines changed

Cargo.lock

Lines changed: 12 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ filetime = "0.2"
4040
flate2 = { version = "1.0", optional = true, default-features = false, features = ["rust_backend"] }
4141
futures = "0.3"
4242
futures-locks = "0.6"
43-
hmac = { version = "0.10", optional = true }
43+
hmac = { version = "0.12.0", optional = true }
4444
http = "0.2"
4545
hyper = { version = "0.14", optional = true, features = ["server"] }
4646
hyperx = { version = "1.0", optional = true }
@@ -63,8 +63,8 @@ regex = "1"
6363
reqwest = { version = "0.11", features = ["json", "blocking"], optional = true }
6464
retry = "1"
6565
ring = { version = "0.16", optional = true, features = ["std"] }
66-
sha-1 = { version = "0.9", optional = true }
67-
sha2 = { version = "0.9", optional = true }
66+
sha-1 = { version = "0.10.0", optional = true }
67+
sha2 = { version = "0.10.1", optional = true }
6868
serde = "1.0"
6969
serde_derive = "1.0"
7070
serde_json = "1.0"

src/azure/blobstore.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// limitations under the License.
1515

1616
use crate::azure::credentials::*;
17-
use hmac::{Hmac, Mac, NewMac};
17+
use hmac::{Hmac, Mac};
1818
use hyperx::header;
1919
use md5::{Digest, Md5};
2020
use reqwest::Url;
@@ -29,7 +29,7 @@ use crate::util::HeadersExt;
2929
const BLOB_API_VERSION: &str = "2017-04-17";
3030

3131
fn hmac(data: &[u8], secret: &[u8]) -> Vec<u8> {
32-
let mut hmac = Hmac::<Sha256>::new_varkey(secret).expect("HMAC can take key of any size");
32+
let mut hmac = Hmac::<Sha256>::new_from_slice(secret).expect("HMAC can take key of any size");
3333
hmac.update(data);
3434
hmac.finalize().into_bytes().as_slice().to_vec()
3535
}

src/simples3/s3.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::ascii::AsciiExt;
66
use std::fmt;
77

88
use crate::simples3::credential::*;
9-
use hmac::{Hmac, Mac, NewMac};
9+
use hmac::{Hmac, Mac};
1010
use hyper::header::HeaderValue;
1111
use hyper::Method;
1212
use hyperx::header;
@@ -38,7 +38,7 @@ fn base_url(endpoint: &str, ssl: Ssl) -> String {
3838
}
3939

4040
fn hmac(key: &[u8], data: &[u8]) -> Vec<u8> {
41-
let mut hmac = Hmac::<Sha1>::new_varkey(key).expect("HMAC can take key of any size");
41+
let mut hmac = Hmac::<Sha1>::new_from_slice(key).expect("HMAC can take key of any size");
4242
hmac.update(data);
4343
hmac.finalize().into_bytes().as_slice().to_vec()
4444
}

0 commit comments

Comments
 (0)