Merge pull request #7 from ruma/update-deps

Update ring to 0.16.1, untrusted to 0.7.0
This commit is contained in:
Jimmy Cuadra 2019-07-24 10:15:42 -07:00 committed by GitHub
commit cebb40eca0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 20 deletions

View File

@ -14,6 +14,6 @@ version = "0.5.0"
[dependencies] [dependencies]
base64 = "0.10.1" base64 = "0.10.1"
ring = "0.14.6" ring = "0.16.1"
serde_json = "1.0.40" serde_json = "1.0.40"
untrusted = "0.6.2" untrusted = "0.7.0"

View File

@ -6,7 +6,6 @@ use std::{
}; };
use ring::signature::Ed25519KeyPair as RingEd25519KeyPair; use ring::signature::Ed25519KeyPair as RingEd25519KeyPair;
use untrusted::Input;
use crate::{signatures::Signature, Algorithm, Error}; 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 /// Returns an error if the public and private keys provided are invalid for the implementing
/// algorithm. /// algorithm.
pub fn new(public_key: &[u8], private_key: &[u8], version: String) -> Result<Self, Error> { pub fn new(public_key: &[u8], private_key: &[u8], version: String) -> Result<Self, Error> {
if let Err(error) = RingEd25519KeyPair::from_seed_and_public_key( if let Err(error) = RingEd25519KeyPair::from_seed_and_public_key(private_key, public_key) {
Input::from(private_key),
Input::from(public_key),
) {
return Err(Error::new(error.to_string())); return Err(Error::new(error.to_string()));
} }
@ -67,11 +63,9 @@ impl Ed25519KeyPair {
impl KeyPair for Ed25519KeyPair { impl KeyPair for Ed25519KeyPair {
fn sign(&self, message: &[u8]) -> Signature { fn sign(&self, message: &[u8]) -> Signature {
// Okay to unwrap because we verified the input in `new`. // Okay to unwrap because we verified the input in `new`.
let ring_key_pair = RingEd25519KeyPair::from_seed_and_public_key( let ring_key_pair =
Input::from(&self.private_key), RingEd25519KeyPair::from_seed_and_public_key(&self.private_key, &self.public_key)
Input::from(&self.public_key), .unwrap();
)
.unwrap();
Signature { Signature {
algorithm: Algorithm::Ed25519, algorithm: Algorithm::Ed25519,

View File

@ -1,6 +1,6 @@
//! Verification of digital signatures. //! Verification of digital signatures.
use ring::signature::{verify, ED25519}; use ring::signature::{VerificationAlgorithm, ED25519};
use untrusted::Input; use untrusted::Input;
use crate::Error; use crate::Error;
@ -33,13 +33,13 @@ impl Verifier for Ed25519Verifier {
signature: &[u8], signature: &[u8],
message: &[u8], message: &[u8],
) -> Result<(), Error> { ) -> Result<(), Error> {
verify( ED25519
&ED25519, .verify(
Input::from(public_key), Input::from(public_key),
Input::from(message), Input::from(message),
Input::from(signature), Input::from(signature),
) )
.map_err(|_| Error::new("signature verification failed")) .map_err(|_| Error::new("signature verification failed"))
} }
} }