mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-22 22:31:33 +00:00
Update Dependencies (#931)
* update secio dependencies: ed25519-dalek, sha2, hmac * Update websocket dependencies * Update multiaddr dependencies
This commit is contained in:
committed by
GitHub
parent
63db253566
commit
bf5ed98895
@ -11,7 +11,7 @@ version = "0.1.0"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
arrayref = "0.3"
|
arrayref = "0.3"
|
||||||
bs58 = "0.2.0"
|
bs58 = "0.2.0"
|
||||||
byteorder = "0.4"
|
byteorder = "1.3.1"
|
||||||
data-encoding = "2.1"
|
data-encoding = "2.1"
|
||||||
multihash = { package = "parity-multihash", version = "0.1.0", path = "../multihash" }
|
multihash = { package = "parity-multihash", version = "0.1.0", path = "../multihash" }
|
||||||
serde = "1.0.70"
|
serde = "1.0.70"
|
||||||
@ -21,6 +21,6 @@ unsigned-varint = "0.2"
|
|||||||
bincode = "1"
|
bincode = "1"
|
||||||
bs58 = "0.2.0"
|
bs58 = "0.2.0"
|
||||||
data-encoding = "2"
|
data-encoding = "2"
|
||||||
quickcheck = "0.7"
|
quickcheck = "0.8.1"
|
||||||
rand = "0.6"
|
rand = "0.6.5"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use std::{net, fmt, error, io, num, str, string};
|
use std::{net, fmt, error, io, num, str, string};
|
||||||
use bs58;
|
use bs58;
|
||||||
use multihash;
|
use multihash;
|
||||||
use byteorder;
|
|
||||||
use unsigned_varint::decode;
|
use unsigned_varint::decode;
|
||||||
|
|
||||||
pub type Result<T> = ::std::result::Result<T, Error>;
|
pub type Result<T> = ::std::result::Result<T, Error>;
|
||||||
@ -70,12 +69,6 @@ impl From<net::AddrParseError> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<byteorder::Error> for Error {
|
|
||||||
fn from(err: byteorder::Error) -> Error {
|
|
||||||
Error::ParsingError(err.into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<num::ParseIntError> for Error {
|
impl From<num::ParseIntError> for Error {
|
||||||
fn from(err: num::ParseIntError) -> Error {
|
fn from(err: num::ParseIntError) -> Error {
|
||||||
Error::ParsingError(err.into())
|
Error::ParsingError(err.into())
|
||||||
|
@ -14,9 +14,9 @@ asn1_der = "0.6.1"
|
|||||||
bytes = "0.4"
|
bytes = "0.4"
|
||||||
futures = "0.1"
|
futures = "0.1"
|
||||||
libp2p-core = { version = "0.3.0", path = "../../core" }
|
libp2p-core = { version = "0.3.0", path = "../../core" }
|
||||||
log = "0.4.1"
|
log = "0.4.6"
|
||||||
protobuf = "2.3"
|
protobuf = "2.3"
|
||||||
rand = "0.6"
|
rand = "0.6.5"
|
||||||
secp256k1 = { version = "0.12", features = ["rand"], optional = true }
|
secp256k1 = { version = "0.12", features = ["rand"], optional = true }
|
||||||
aes-ctr = "0.3"
|
aes-ctr = "0.3"
|
||||||
aesni = { version = "0.6", features = ["nocheck"], optional = true }
|
aesni = { version = "0.6", features = ["nocheck"], optional = true }
|
||||||
@ -25,9 +25,9 @@ ctr = "0.3"
|
|||||||
lazy_static = "1.2.0"
|
lazy_static = "1.2.0"
|
||||||
rw-stream-sink = { version = "0.1.0", path = "../../misc/rw-stream-sink" }
|
rw-stream-sink = { version = "0.1.0", path = "../../misc/rw-stream-sink" }
|
||||||
tokio-io = "0.1.0"
|
tokio-io = "0.1.0"
|
||||||
sha2 = "0.7.1"
|
sha2 = "0.8.0"
|
||||||
ed25519-dalek = "0.8.0"
|
ed25519-dalek = "1.0.0-pre.1"
|
||||||
hmac = "0.6.3"
|
hmac = "0.7.0"
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os = "emscripten", target_os = "unknown")))'.dependencies]
|
[target.'cfg(not(any(target_os = "emscripten", target_os = "unknown")))'.dependencies]
|
||||||
ring = { version = "0.14", features = ["use_heap"], default-features = false }
|
ring = { version = "0.14", features = ["use_heap"], default-features = false }
|
||||||
|
@ -69,13 +69,15 @@ impl Hmac {
|
|||||||
|
|
||||||
/// Signs the data.
|
/// Signs the data.
|
||||||
// TODO: better return type?
|
// 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 {
|
match *self {
|
||||||
Hmac::Sha256(ref mut hmac) => {
|
Hmac::Sha256(ref hmac) => {
|
||||||
|
let mut hmac = hmac.clone();
|
||||||
hmac.input(crypted_data);
|
hmac.input(crypted_data);
|
||||||
hmac.result().code().to_vec()
|
hmac.result().code().to_vec()
|
||||||
},
|
},
|
||||||
Hmac::Sha512(ref mut hmac) => {
|
Hmac::Sha512(ref hmac) => {
|
||||||
|
let mut hmac = hmac.clone();
|
||||||
hmac.input(crypted_data);
|
hmac.input(crypted_data);
|
||||||
hmac.result().code().to_vec()
|
hmac.result().code().to_vec()
|
||||||
},
|
},
|
||||||
@ -84,13 +86,15 @@ impl Hmac {
|
|||||||
|
|
||||||
/// Verifies that the data matches the expected hash.
|
/// Verifies that the data matches the expected hash.
|
||||||
// TODO: better error?
|
// 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 {
|
match *self {
|
||||||
Hmac::Sha256(ref mut hmac) => {
|
Hmac::Sha256(ref hmac) => {
|
||||||
|
let mut hmac = hmac.clone();
|
||||||
hmac.input(crypted_data);
|
hmac.input(crypted_data);
|
||||||
hmac.verify(expected_hash).map_err(|_| ())
|
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.input(crypted_data);
|
||||||
hmac.verify(expected_hash).map_err(|_| ())
|
hmac.verify(expected_hash).map_err(|_| ())
|
||||||
},
|
},
|
||||||
|
@ -40,7 +40,7 @@ use ring::signature::{RSA_PKCS1_2048_8192_SHA256, RSA_PKCS1_SHA256, verify as ri
|
|||||||
use ring::rand::SystemRandom;
|
use ring::rand::SystemRandom;
|
||||||
#[cfg(feature = "secp256k1")]
|
#[cfg(feature = "secp256k1")]
|
||||||
use secp256k1;
|
use secp256k1;
|
||||||
use sha2::{Digest as ShaDigestTrait, Sha256, Sha512};
|
use sha2::{Digest as ShaDigestTrait, Sha256};
|
||||||
use std::cmp::{self, Ordering};
|
use std::cmp::{self, Ordering};
|
||||||
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
|
use std::io::{Error as IoError, ErrorKind as IoErrorKind};
|
||||||
use crate::structs_proto::{Exchange, Propose};
|
use crate::structs_proto::{Exchange, Propose};
|
||||||
@ -385,7 +385,7 @@ where
|
|||||||
signature
|
signature
|
||||||
},
|
},
|
||||||
SecioKeyPairInner::Ed25519 { ref key_pair } => {
|
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()
|
signature.to_bytes().to_vec()
|
||||||
},
|
},
|
||||||
#[cfg(feature = "secp256k1")]
|
#[cfg(feature = "secp256k1")]
|
||||||
@ -468,7 +468,7 @@ where
|
|||||||
let pubkey = Ed25519PublicKey::from_bytes(remote_public_key);
|
let pubkey = Ed25519PublicKey::from_bytes(remote_public_key);
|
||||||
|
|
||||||
if let (Ok(signature), Ok(pubkey)) = (signature, pubkey) {
|
if let (Ok(signature), Ok(pubkey)) = (signature, pubkey) {
|
||||||
match pubkey.verify::<Sha512>(&data_to_verify, &signature) {
|
match pubkey.verify(&data_to_verify, &signature) {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
debug!("failed to verify the remote's signature");
|
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])
|
fn stretch_key_inner<D>(hmac: ::hmac::Hmac<D>, result: &mut [u8])
|
||||||
where ::hmac::Hmac<D>: Clone {
|
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;
|
use ::hmac::Mac;
|
||||||
const SEED: &[u8] = b"key expansion";
|
const SEED: &[u8] = b"key expansion";
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ impl SecioKeyPair {
|
|||||||
/// Generates a new Ed25519 key pair and uses it.
|
/// Generates a new Ed25519 key pair and uses it.
|
||||||
pub fn ed25519_generated() -> Result<SecioKeyPair, Box<Error + Send + Sync>> {
|
pub fn ed25519_generated() -> Result<SecioKeyPair, Box<Error + Send + Sync>> {
|
||||||
let mut csprng = rand::thread_rng();
|
let mut csprng = rand::thread_rng();
|
||||||
let keypair: Ed25519KeyPair = Ed25519KeyPair::generate::<sha2::Sha512, _>(&mut csprng);
|
let keypair: Ed25519KeyPair = Ed25519KeyPair::generate::<_>(&mut csprng);
|
||||||
Ok(SecioKeyPair {
|
Ok(SecioKeyPair {
|
||||||
inner: SecioKeyPairInner::Ed25519 {
|
inner: SecioKeyPairInner::Ed25519 {
|
||||||
key_pair: Arc::new(keypair),
|
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>> {
|
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())
|
let secret = ed25519_dalek::SecretKey::from_bytes(key.as_ref())
|
||||||
.map_err(|err| err.to_string())?;
|
.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 {
|
Ok(SecioKeyPair {
|
||||||
inner: SecioKeyPairInner::Ed25519 {
|
inner: SecioKeyPairInner::Ed25519 {
|
||||||
|
@ -17,7 +17,7 @@ rw-stream-sink = { version = "0.1.0", path = "../../misc/rw-stream-sink" }
|
|||||||
tokio-io = "0.1"
|
tokio-io = "0.1"
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os = "emscripten", target_os = "unknown")))'.dependencies]
|
[target.'cfg(not(any(target_os = "emscripten", target_os = "unknown")))'.dependencies]
|
||||||
websocket = { version = "0.21.0", default-features = false, features = ["async", "async-ssl"] }
|
websocket = { version = "0.22.2", default-features = false, features = ["async", "async-ssl"] }
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "emscripten", target_os = "unknown"))'.dependencies]
|
[target.'cfg(any(target_os = "emscripten", target_os = "unknown"))'.dependencies]
|
||||||
stdweb = { version = "0.4", default-features = false }
|
stdweb = { version = "0.4", default-features = false }
|
||||||
|
Reference in New Issue
Block a user