Skip to content

Commit

Permalink
Merge pull request #11 from PassFort/jc/bump-reqwest-version
Browse files Browse the repository at this point in the history
Bump reqwest version to 0.11
  • Loading branch information
Jack Cargill authored Aug 19, 2021
2 parents 4cd243e + dc19c32 commit d93ec08
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ chrono = "0.4.11"
http = "0.2.1"
sha2 = "0.8.1"
base64 = "0.12.0"
reqwest = {version = "0.10.4", features = ["blocking"], optional = true}
reqwest = {version = "0.11", features = ["blocking"], optional = true}
rouille = {version = "3.0.0", optional = true}
subtle = "2.2.2"
ring = { version = "0.16.12", features = ["std"], optional = true }
Expand Down
3 changes: 1 addition & 2 deletions src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ macro_rules! hmac_signature {
/// Create a new instance of the signature scheme using the
/// provided key.
pub fn new(key: &[u8]) -> Self {
Self(Hmac::new_varkey(key)
.expect("Hmac construction should be infallible"))
Self(Hmac::new_varkey(key).expect("Hmac construction should be infallible"))
}
}

Expand Down
12 changes: 9 additions & 3 deletions src/algorithm/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ macro_rules! rsa_signature {
/// Create a new instance of the signature scheme using the
/// provided private key.
pub fn new_der(private_key: &[u8]) -> Result<Self, Box<dyn std::error::Error>> {
Ok(Self(PKey::from_rsa(Rsa::private_key_from_der(private_key)?)?))
Ok(Self(PKey::from_rsa(Rsa::private_key_from_der(
private_key,
)?)?))
}
/// Create a new instance of the signature scheme using the
/// provided private key.
pub fn new_pem(private_key: &[u8]) -> Result<Self, Box<dyn std::error::Error>> {
Ok(Self(PKey::from_rsa(Rsa::private_key_from_pem(private_key)?)?))
Ok(Self(PKey::from_rsa(Rsa::private_key_from_pem(
private_key,
)?)?))
}
}

Expand All @@ -67,7 +71,9 @@ macro_rules! rsa_signature {
fn http_sign(&self, bytes_to_sign: &[u8]) -> String {
let mut signer = Signer::new(MessageDigest::$hash_alg(), &self.0).unwrap();
signer.set_rsa_padding(Padding::PKCS1).unwrap();
let tag = signer.sign_oneshot_to_vec(bytes_to_sign).expect("Signing to be infallible");
let tag = signer
.sign_oneshot_to_vec(bytes_to_sign)
.expect("Signing to be infallible");
base64::encode(&tag)
}
}
Expand Down
15 changes: 12 additions & 3 deletions src/algorithm/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ macro_rules! rsa_signature {
impl HttpSignatureSign for $sign_name {
fn http_sign(&self, bytes_to_sign: &[u8]) -> String {
let mut tag = vec![0; self.0.public_modulus_len()];
self.0.sign(&signature::$sign_alg, &rand::SystemRandom::new(), bytes_to_sign, &mut tag)
self.0
.sign(
&signature::$sign_alg,
&rand::SystemRandom::new(),
bytes_to_sign,
&mut tag,
)
.expect("Signing should be infallible");
base64::encode(&tag)
}
Expand All @@ -63,8 +69,11 @@ macro_rules! rsa_signature {
};
signature::VerificationAlgorithm::verify(
&signature::$verify_alg,
self.0.as_slice().into(), bytes_to_verify.into(), tag.as_slice().into()
).is_ok()
self.0.as_slice().into(),
bytes_to_verify.into(),
tag.as_slice().into(),
)
.is_ok()
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/canonicalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<T: RequestLike> CanonicalizeExt for T {
let (headers, missing_headers): (Vec<_>, Vec<_>) = config
.headers
.as_deref()
.unwrap_or_else(|| DEFAULT_HEADERS)
.unwrap_or(DEFAULT_HEADERS)
.iter()
.cloned()
.partition_map(|header| {
Expand Down
2 changes: 1 addition & 1 deletion src/mock_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl MockRequest {

if let Some(body) = &self.body {
writeln!(writer)?;
writer.write_all(&body)?;
writer.write_all(body)?;
}

Ok(())
Expand Down

0 comments on commit d93ec08

Please sign in to comment.