Update Dependencies (#931)

* update secio dependencies: ed25519-dalek, sha2, hmac
* Update websocket dependencies
* Update multiaddr dependencies
This commit is contained in:
Benjamin Kampmann
2019-02-08 08:56:31 +01:00
committed by GitHub
parent 63db253566
commit bf5ed98895
7 changed files with 29 additions and 29 deletions

View File

@@ -69,13 +69,15 @@ impl Hmac {
/// Signs the data.
// TODO: better return type?
pub fn sign(&mut self, crypted_data: &[u8]) -> Vec<u8> {
pub fn sign(&self, crypted_data: &[u8]) -> Vec<u8> {
match *self {
Hmac::Sha256(ref mut hmac) => {
Hmac::Sha256(ref hmac) => {
let mut hmac = hmac.clone();
hmac.input(crypted_data);
hmac.result().code().to_vec()
},
Hmac::Sha512(ref mut hmac) => {
Hmac::Sha512(ref hmac) => {
let mut hmac = hmac.clone();
hmac.input(crypted_data);
hmac.result().code().to_vec()
},
@@ -84,13 +86,15 @@ impl Hmac {
/// Verifies that the data matches the expected hash.
// TODO: better error?
pub fn verify(&mut self, crypted_data: &[u8], expected_hash: &[u8]) -> Result<(), ()> {
pub fn verify(&self, crypted_data: &[u8], expected_hash: &[u8]) -> Result<(), ()> {
match *self {
Hmac::Sha256(ref mut hmac) => {
Hmac::Sha256(ref hmac) => {
let mut hmac = hmac.clone();
hmac.input(crypted_data);
hmac.verify(expected_hash).map_err(|_| ())
},
Hmac::Sha512(ref mut hmac) => {
Hmac::Sha512(ref hmac) => {
let mut hmac = hmac.clone();
hmac.input(crypted_data);
hmac.verify(expected_hash).map_err(|_| ())
},

View File

@@ -40,7 +40,7 @@ use ring::signature::{RSA_PKCS1_2048_8192_SHA256, RSA_PKCS1_SHA256, verify as ri
use ring::rand::SystemRandom;
#[cfg(feature = "secp256k1")]
use secp256k1;
use sha2::{Digest as ShaDigestTrait, Sha256, Sha512};
use sha2::{Digest as ShaDigestTrait, Sha256};
use std::cmp::{self, Ordering};
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
use crate::structs_proto::{Exchange, Propose};
@@ -385,7 +385,7 @@ where
signature
},
SecioKeyPairInner::Ed25519 { ref key_pair } => {
let signature = key_pair.sign::<Sha512>(&data_to_sign);
let signature = key_pair.sign(&data_to_sign);
signature.to_bytes().to_vec()
},
#[cfg(feature = "secp256k1")]
@@ -468,7 +468,7 @@ where
let pubkey = Ed25519PublicKey::from_bytes(remote_public_key);
if let (Ok(signature), Ok(pubkey)) = (signature, pubkey) {
match pubkey.verify::<Sha512>(&data_to_verify, &signature) {
match pubkey.verify(&data_to_verify, &signature) {
Ok(()) => (),
Err(_) => {
debug!("failed to verify the remote's signature");
@@ -591,8 +591,11 @@ fn stretch_key(hmac: Hmac, result: &mut [u8]) {
}
}
fn stretch_key_inner<D: ::hmac::digest::Digest + Clone>(hmac: ::hmac::Hmac<D>, result: &mut [u8])
where ::hmac::Hmac<D>: Clone {
fn stretch_key_inner<D>(hmac: ::hmac::Hmac<D>, result: &mut [u8])
where D: ::hmac::digest::Input + ::hmac::digest::BlockInput +
::hmac::digest::FixedOutput + ::hmac::digest::Reset + Default + Clone,
::hmac::Hmac<D>: Clone + ::hmac::crypto_mac::Mac
{
use ::hmac::Mac;
const SEED: &[u8] = b"key expansion";

View File

@@ -238,7 +238,7 @@ impl SecioKeyPair {
/// Generates a new Ed25519 key pair and uses it.
pub fn ed25519_generated() -> Result<SecioKeyPair, Box<Error + Send + Sync>> {
let mut csprng = rand::thread_rng();
let keypair: Ed25519KeyPair = Ed25519KeyPair::generate::<sha2::Sha512, _>(&mut csprng);
let keypair: Ed25519KeyPair = Ed25519KeyPair::generate::<_>(&mut csprng);
Ok(SecioKeyPair {
inner: SecioKeyPairInner::Ed25519 {
key_pair: Arc::new(keypair),
@@ -252,7 +252,7 @@ impl SecioKeyPair {
pub fn ed25519_raw_key(key: impl AsRef<[u8]>) -> Result<SecioKeyPair, Box<Error + Send + Sync>> {
let secret = ed25519_dalek::SecretKey::from_bytes(key.as_ref())
.map_err(|err| err.to_string())?;
let public = ed25519_dalek::PublicKey::from_secret::<sha2::Sha512>(&secret);
let public = ed25519_dalek::PublicKey::from(&secret);
Ok(SecioKeyPair {
inner: SecioKeyPairInner::Ed25519 {