Skip to content

Commit

Permalink
Upgrade ring. (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
khuey authored Oct 16, 2023
1 parent 61b8c1e commit b7599eb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ rust-version = "1.67.0"
[dependencies]
serde_json = "1.0"
serde = {version = "1.0", features = ["derive"] }
ring = { version = "0.16.5", features = ["std"] }
ring = { version = "0.17.3", features = ["std"] }
base64 = "0.21.0"
# For PEM decoding
pem = {version = "2", optional = true}
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ pub fn sign(
key: &[u8],
message: &[u8],
) -> Result<String> {
let signing_key = signature::EcdsaKeyPair::from_pkcs8(alg, key)?;
let rng = rand::SystemRandom::new();
let signing_key = signature::EcdsaKeyPair::from_pkcs8(alg, key, &rng)?;
let out = signing_key.sign(&rng, message)?;
Ok(b64_encode(out))
}
4 changes: 2 additions & 2 deletions src/crypto/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ pub(crate) fn sign(
message: &[u8],
) -> Result<String> {
let key_pair = signature::RsaKeyPair::from_der(key)
.map_err(|e| ErrorKind::InvalidRsaKey(e.description_()))?;
.map_err(|e| ErrorKind::InvalidRsaKey(e.to_string()))?;

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

Expand Down
2 changes: 1 addition & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub enum ErrorKind {
/// When the secret given is not a valid ECDSA key
InvalidEcdsaKey,
/// When the secret given is not a valid RSA key
InvalidRsaKey(&'static str),
InvalidRsaKey(String),
/// We could not sign with the given key
RsaFailedSigning,
/// When the algorithm from string doesn't match the one passed to `from_str`
Expand Down

0 comments on commit b7599eb

Please sign in to comment.