Skip to content

Commit a513abc

Browse files
durchjplatte
andauthored
Bump dependencies, bump versions of all three crates (#113)
* Bump dependencies (#112) * aws-region 0.22.0 * aws-creds 0.24.0 * s3 0.24.0 Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
1 parent 1541abf commit a513abc

File tree

7 files changed

+46
-45
lines changed

7 files changed

+46
-45
lines changed

aws-creds/Cargo.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aws-creds"
3-
version = "0.23.4"
3+
version = "0.24.0"
44
authors = ["Drazen Urch"]
55
description = "Tiny Rust library for working with Amazon IAM credential,s, supports `s3` crate"
66
repository = "https://github.com/durch/rust-s3"
@@ -16,11 +16,10 @@ path = "src/lib.rs"
1616

1717
[dependencies]
1818
simpl = "0.1.0"
19-
dirs = "2.0.2"
20-
rust-ini = "0.15.2"
21-
reqwest = {version = "0.10", features = ["json", "blocking"]}
19+
dirs = "3"
20+
rust-ini = "0.15"
21+
attohttpc = {version = "0.15", features = ["json"]}
2222
url = "2"
2323
serde-xml-rs = "0.4"
2424
serde = "1"
2525
serde_derive = "1"
26-

aws-creds/src/credentials.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl Credentials {
136136
],
137137
)
138138
.unwrap();
139-
let response = reqwest::blocking::get(url.as_str())?;
139+
let response = attohttpc::get(url.as_str()).send()?;
140140
let serde_response =
141141
serde_xml::from_str::<AssumeRoleWithWebIdentityResponse>(&response.text()?).unwrap();
142142
// assert!(serde_xml::from_str::<AssumeRoleWithWebIdentityResponse>(&response.text()?).unwrap());
@@ -268,20 +268,23 @@ impl Credentials {
268268
let resp: HashMap<String, String> =
269269
match env::var("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI") {
270270
Ok(credentials_path) => Some(
271-
reqwest::blocking::get(&format!("http://169.254.170.2{}", credentials_path))?
271+
attohttpc::get(&format!("http://169.254.170.2{}", credentials_path))
272+
.send()?
272273
.json()?,
273274
),
274275
Err(_) => {
275276
let resp: HashMap<String, String> =
276-
reqwest::blocking::get("http://169.254.169.254/latest/meta-data/iam/info")?
277+
attohttpc::get("http://169.254.169.254/latest/meta-data/iam/info")
278+
.send()?
277279
.json()?;
278280
if let Some(arn) = resp.get("InstanceProfileArn") {
279281
if let Some(role) = arn.split('/').last() {
280282
Some(
281-
reqwest::blocking::get(&format!(
283+
attohttpc::get(&format!(
282284
"http://169.254.169.254/latest/meta-data/iam/security-credentials/{}",
283285
role
284-
))?
286+
))
287+
.send()?
285288
.json()?,
286289
)
287290
} else {

aws-creds/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extern crate serde_derive;
66

77
simpl::err!(AwsCredsError, {
88
Utf8@std::str::Utf8Error;
9-
Reqwest@reqwest::Error;
9+
Reqwest@attohttpc::Error;
1010
Env@std::env::VarError;
1111
Ini@ini::ini::Error;
1212
Io@std::io::Error;

aws-region/Cargo.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aws-region"
3-
version = "0.21.0"
3+
version = "0.22.0"
44
authors = ["Drazen Urch"]
55
description = "Tiny Rust library for working with Amazon AWS regions, supports `s3` crate"
66
repository = "https://github.com/durch/rust-s3"
@@ -15,5 +15,4 @@ name = "awsregion"
1515
path = "src/lib.rs"
1616

1717
[dependencies]
18-
simpl = "0.1.0-alpha"
19-
18+
simpl = "0.1.0"

s3/Cargo.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust-s3"
3-
version = "0.23.0"
3+
version = "0.24.0"
44
authors = ["Drazen Urch"]
55
description = "Tiny Rust library for working with Amazon S3 and compatible object storage APIs"
66
repository = "https://github.com/durch/rust-s3"
@@ -22,20 +22,20 @@ path = "bin/simple_crud.rs"
2222
base64 = "0.12"
2323
chrono = "0.4"
2424
hex = "0.4"
25-
hmac = "0.7"
25+
hmac = "0.9"
2626
reqwest = {version = "0.10", features = ["json", "stream"]}
2727
serde_derive = "1"
2828
serde = "1"
29-
serde-xml-rs = "0.4.0"
30-
sha2 = "0.8"
29+
serde-xml-rs = "0.4"
30+
sha2 = "0.9"
3131
md5 = "0.7"
3232
url = "2"
3333
futures = "0.3"
3434
tokio = {version="0.2", features=["macros", "io-util", "stream"]}
3535
rand = "0.7"
3636
simpl = "0.1.0"
37-
aws-region = "0.21"
38-
aws-creds = "0.23"
37+
aws-region = "0.22"
38+
aws-creds = "0.24"
3939
log = "0.4"
4040
percent-encoding = "2"
4141
async-std = "1"
@@ -50,4 +50,4 @@ native-tls = ["reqwest/native-tls"]
5050
rustls-tls = ["reqwest/rustls-tls"]
5151

5252
[dev-dependencies]
53-
tokio = {version="0.2", features=["fs"]}
53+
tokio = {version="0.2", features=["fs"]}

s3/src/request.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::io::Write;
77
use super::bucket::Bucket;
88
use super::command::Command;
99
use chrono::{DateTime, Utc};
10-
use hmac::Mac;
10+
use hmac::{Mac, NewMac};
1111
use reqwest::header::{self, HeaderMap, HeaderName, HeaderValue};
1212
use reqwest::{Client, Response};
1313
use sha2::{Digest, Sha256};
@@ -157,18 +157,18 @@ impl<'a> Request<'a> {
157157
match &self.command {
158158
Command::PutObject { content, .. } => {
159159
let mut sha = Sha256::default();
160-
sha.input(content);
161-
hex::encode(sha.result().as_slice())
160+
sha.update(content);
161+
hex::encode(sha.finalize().as_slice())
162162
}
163163
Command::PutObjectTagging { tags } => {
164164
let mut sha = Sha256::default();
165-
sha.input(tags.as_bytes());
166-
hex::encode(sha.result().as_slice())
165+
sha.update(tags.as_bytes());
166+
hex::encode(sha.finalize().as_slice())
167167
}
168168
Command::CompleteMultipartUpload { data, .. } => {
169169
let mut sha = Sha256::default();
170-
sha.input(data.to_string().as_bytes());
171-
hex::encode(sha.result().as_slice())
170+
sha.update(data.to_string().as_bytes());
171+
hex::encode(sha.finalize().as_slice())
172172
}
173173
_ => EMPTY_PAYLOAD_SHA.into(),
174174
}
@@ -238,8 +238,8 @@ impl<'a> Request<'a> {
238238
let canonical_request = self.presigned_canonical_request(&headers)?;
239239
let string_to_sign = self.string_to_sign(&canonical_request);
240240
let mut hmac = signing::HmacSha256::new_varkey(&self.signing_key()?)?;
241-
hmac.input(string_to_sign.as_bytes());
242-
let signature = hex::encode(hmac.result().code());
241+
hmac.update(string_to_sign.as_bytes());
242+
let signature = hex::encode(hmac.finalize().into_bytes());
243243
// let signed_header = signing::signed_header_string(&headers);
244244
Ok(signature)
245245
}
@@ -248,8 +248,8 @@ impl<'a> Request<'a> {
248248
let canonical_request = self.canonical_request(headers);
249249
let string_to_sign = self.string_to_sign(&canonical_request);
250250
let mut hmac = signing::HmacSha256::new_varkey(&self.signing_key()?)?;
251-
hmac.input(string_to_sign.as_bytes());
252-
let signature = hex::encode(hmac.result().code());
251+
hmac.update(string_to_sign.as_bytes());
252+
let signature = hex::encode(hmac.finalize().into_bytes());
253253
let signed_header = signing::signed_header_string(headers);
254254
Ok(signing::authorization_header(
255255
&self.bucket.access_key().unwrap(),

s3/src/signing.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::str;
66

77
use chrono::{DateTime, Utc};
8-
use hmac::{Hmac, Mac};
8+
use hmac::{Hmac, Mac, NewMac};
99
use reqwest::header::HeaderMap;
1010
use sha2::{Digest, Sha256};
1111
use url::Url;
@@ -113,12 +113,12 @@ pub fn scope_string(datetime: &DateTime<Utc>, region: &Region) -> String {
113113
/// applied to sign requests.
114114
pub fn string_to_sign(datetime: &DateTime<Utc>, region: &Region, canonical_req: &str) -> String {
115115
let mut hasher = Sha256::default();
116-
hasher.input(canonical_req.as_bytes());
116+
hasher.update(canonical_req.as_bytes());
117117
let string_to = format!(
118118
"AWS4-HMAC-SHA256\n{timestamp}\n{scope}\n{hash}",
119119
timestamp = datetime.format(LONG_DATETIME),
120120
scope = scope_string(datetime, region),
121-
hash = hex::encode(hasher.result().as_slice())
121+
hash = hex::encode(hasher.finalize().as_slice())
122122
);
123123
string_to
124124
}
@@ -133,14 +133,14 @@ pub fn signing_key(
133133
) -> Result<Vec<u8>> {
134134
let secret = format!("AWS4{}", secret_key);
135135
let mut date_hmac = HmacSha256::new_varkey(secret.as_bytes())?;
136-
date_hmac.input(datetime.format(SHORT_DATE).to_string().as_bytes());
137-
let mut region_hmac = HmacSha256::new_varkey(&date_hmac.result().code())?;
138-
region_hmac.input(region.to_string().as_bytes());
139-
let mut service_hmac = HmacSha256::new_varkey(&region_hmac.result().code())?;
140-
service_hmac.input(service.as_bytes());
141-
let mut signing_hmac = HmacSha256::new_varkey(&service_hmac.result().code())?;
142-
signing_hmac.input(b"aws4_request");
143-
Ok(signing_hmac.result().code().to_vec())
136+
date_hmac.update(datetime.format(SHORT_DATE).to_string().as_bytes());
137+
let mut region_hmac = HmacSha256::new_varkey(&date_hmac.finalize().into_bytes())?;
138+
region_hmac.update(region.to_string().as_bytes());
139+
let mut service_hmac = HmacSha256::new_varkey(&region_hmac.finalize().into_bytes())?;
140+
service_hmac.update(service.as_bytes());
141+
let mut signing_hmac = HmacSha256::new_varkey(&service_hmac.finalize().into_bytes())?;
142+
signing_hmac.update(b"aws4_request");
143+
Ok(signing_hmac.finalize().into_bytes().to_vec())
144144
}
145145

146146
/// Generate the AWS authorization header.
@@ -303,8 +303,8 @@ mod tests {
303303
let secret = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY";
304304
let signing_key = signing_key(&datetime, secret, &"us-east-1".parse().unwrap(), "s3");
305305
let mut hmac = Hmac::<Sha256>::new_varkey(&signing_key.unwrap()).unwrap();
306-
hmac.input(string_to_sign.as_bytes());
307-
assert_eq!(expected, hex::encode(hmac.result().code()));
306+
hmac.update(string_to_sign.as_bytes());
307+
assert_eq!(expected, hex::encode(hmac.finalize().into_bytes()));
308308
}
309309

310310
#[test]

0 commit comments

Comments
 (0)