Merge pull request #7 from ruma/update-deps
Update ring to 0.16.1, untrusted to 0.7.0
This commit is contained in:
commit
cebb40eca0
@ -14,6 +14,6 @@ version = "0.5.0"
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.10.1"
|
||||
ring = "0.14.6"
|
||||
ring = "0.16.1"
|
||||
serde_json = "1.0.40"
|
||||
untrusted = "0.6.2"
|
||||
untrusted = "0.7.0"
|
||||
|
14
src/keys.rs
14
src/keys.rs
@ -6,7 +6,6 @@ use std::{
|
||||
};
|
||||
|
||||
use ring::signature::Ed25519KeyPair as RingEd25519KeyPair;
|
||||
use untrusted::Input;
|
||||
|
||||
use crate::{signatures::Signature, Algorithm, Error};
|
||||
|
||||
@ -49,10 +48,7 @@ impl Ed25519KeyPair {
|
||||
/// Returns an error if the public and private keys provided are invalid for the implementing
|
||||
/// algorithm.
|
||||
pub fn new(public_key: &[u8], private_key: &[u8], version: String) -> Result<Self, Error> {
|
||||
if let Err(error) = RingEd25519KeyPair::from_seed_and_public_key(
|
||||
Input::from(private_key),
|
||||
Input::from(public_key),
|
||||
) {
|
||||
if let Err(error) = RingEd25519KeyPair::from_seed_and_public_key(private_key, public_key) {
|
||||
return Err(Error::new(error.to_string()));
|
||||
}
|
||||
|
||||
@ -67,11 +63,9 @@ impl Ed25519KeyPair {
|
||||
impl KeyPair for Ed25519KeyPair {
|
||||
fn sign(&self, message: &[u8]) -> Signature {
|
||||
// Okay to unwrap because we verified the input in `new`.
|
||||
let ring_key_pair = RingEd25519KeyPair::from_seed_and_public_key(
|
||||
Input::from(&self.private_key),
|
||||
Input::from(&self.public_key),
|
||||
)
|
||||
.unwrap();
|
||||
let ring_key_pair =
|
||||
RingEd25519KeyPair::from_seed_and_public_key(&self.private_key, &self.public_key)
|
||||
.unwrap();
|
||||
|
||||
Signature {
|
||||
algorithm: Algorithm::Ed25519,
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Verification of digital signatures.
|
||||
|
||||
use ring::signature::{verify, ED25519};
|
||||
use ring::signature::{VerificationAlgorithm, ED25519};
|
||||
use untrusted::Input;
|
||||
|
||||
use crate::Error;
|
||||
@ -33,13 +33,13 @@ impl Verifier for Ed25519Verifier {
|
||||
signature: &[u8],
|
||||
message: &[u8],
|
||||
) -> Result<(), Error> {
|
||||
verify(
|
||||
&ED25519,
|
||||
Input::from(public_key),
|
||||
Input::from(message),
|
||||
Input::from(signature),
|
||||
)
|
||||
.map_err(|_| Error::new("signature verification failed"))
|
||||
ED25519
|
||||
.verify(
|
||||
Input::from(public_key),
|
||||
Input::from(message),
|
||||
Input::from(signature),
|
||||
)
|
||||
.map_err(|_| Error::new("signature verification failed"))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user