Skip to content

Commit b7599eb

Browse files
authored
Upgrade ring. (#333)
1 parent 61b8c1e commit b7599eb

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rust-version = "1.67.0"
1515
[dependencies]
1616
serde_json = "1.0"
1717
serde = {version = "1.0", features = ["derive"] }
18-
ring = { version = "0.16.5", features = ["std"] }
18+
ring = { version = "0.17.3", features = ["std"] }
1919
base64 = "0.21.0"
2020
# For PEM decoding
2121
pem = {version = "2", optional = true}

src/crypto/ecdsa.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ pub fn sign(
3131
key: &[u8],
3232
message: &[u8],
3333
) -> Result<String> {
34-
let signing_key = signature::EcdsaKeyPair::from_pkcs8(alg, key)?;
3534
let rng = rand::SystemRandom::new();
35+
let signing_key = signature::EcdsaKeyPair::from_pkcs8(alg, key, &rng)?;
3636
let out = signing_key.sign(&rng, message)?;
3737
Ok(b64_encode(out))
3838
}

src/crypto/rsa.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ pub(crate) fn sign(
3939
message: &[u8],
4040
) -> Result<String> {
4141
let key_pair = signature::RsaKeyPair::from_der(key)
42-
.map_err(|e| ErrorKind::InvalidRsaKey(e.description_()))?;
42+
.map_err(|e| ErrorKind::InvalidRsaKey(e.to_string()))?;
4343

44-
let mut signature = vec![0; key_pair.public_modulus_len()];
44+
let mut signature = vec![0; key_pair.public().modulus_len()];
4545
let rng = rand::SystemRandom::new();
4646
key_pair.sign(alg, &rng, message, &mut signature).map_err(|_| ErrorKind::RsaFailedSigning)?;
4747

src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub enum ErrorKind {
4242
/// When the secret given is not a valid ECDSA key
4343
InvalidEcdsaKey,
4444
/// When the secret given is not a valid RSA key
45-
InvalidRsaKey(&'static str),
45+
InvalidRsaKey(String),
4646
/// We could not sign with the given key
4747
RsaFailedSigning,
4848
/// When the algorithm from string doesn't match the one passed to `from_str`

0 commit comments

Comments
 (0)