mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-28 01:01:34 +00:00
Update dependency versions (#1265)
* Update versions of many dependencies * Bump version of rand * Updates for changed APIs in rand, ring, and webpki * Replace references to `snow::Session` `Session` no longer exists in `snow` but the replacement is two structs `HandshakeState` and `TransportState` Something will have to be done to harmonize `NoiseOutput.session` * Add precise type for UnparsedPublicKey * Update data structures/functions to match new snow's API * Delete diff.diff Remove accidentally committed diff file * Remove commented lines in identity/rsa.rs * Bump libsecp256k1 to 0.3.1
This commit is contained in:
committed by
Pierre Krieger
parent
11c2e5fbc5
commit
d683828f37
@ -15,9 +15,9 @@ lazy_static = "1.2"
|
||||
libp2p-core = { version = "0.12.0", path = "../../core" }
|
||||
log = "0.4"
|
||||
protobuf = "2.3"
|
||||
rand = "0.6.5"
|
||||
ring = { version = "0.14", features = ["use_heap"], default-features = false }
|
||||
snow = { version = "0.5.2", features = ["ring-resolver"], default-features = false }
|
||||
rand = "^0.7"
|
||||
ring = { version = "^0.16", features = ["alloc"], default-features = false }
|
||||
snow = { version = "0.6.1", features = ["ring-resolver"], default-features = false }
|
||||
tokio-io = "0.1"
|
||||
x25519-dalek = "0.5"
|
||||
zeroize = "0.9"
|
||||
|
@ -19,7 +19,7 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use libp2p_core::identity;
|
||||
use snow::SnowError;
|
||||
use snow::error::Error as SnowError;
|
||||
use std::{error::Error, fmt, io};
|
||||
|
||||
/// libp2p_noise error type.
|
||||
|
@ -25,6 +25,7 @@ pub mod handshake;
|
||||
use futures::Poll;
|
||||
use log::{debug, trace};
|
||||
use snow;
|
||||
use snow::error::{StateProblem, Error as SnowError};
|
||||
use std::{fmt, io};
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
|
||||
@ -55,12 +56,48 @@ impl Buffer {
|
||||
}
|
||||
}
|
||||
|
||||
/// A passthrough enum for the two kinds of state machines in `snow`
|
||||
pub(crate) enum SnowState {
|
||||
Transport(snow::TransportState),
|
||||
Handshake(snow::HandshakeState)
|
||||
}
|
||||
|
||||
impl SnowState {
|
||||
pub fn read_message(&mut self, message: &[u8], payload: &mut [u8]) -> Result<usize, SnowError> {
|
||||
match self {
|
||||
SnowState::Handshake(session) => session.read_message(message, payload),
|
||||
SnowState::Transport(session) => session.read_message(message, payload),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_message(&mut self, message: &[u8], payload: &mut [u8]) -> Result<usize, SnowError> {
|
||||
match self {
|
||||
SnowState::Handshake(session) => session.write_message(message, payload),
|
||||
SnowState::Transport(session) => session.write_message(message, payload),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_remote_static(&self) -> Option<&[u8]> {
|
||||
match self {
|
||||
SnowState::Handshake(session) => session.get_remote_static(),
|
||||
SnowState::Transport(session) => session.get_remote_static(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_transport_mode(self) -> Result<snow::TransportState, SnowError> {
|
||||
match self {
|
||||
SnowState::Handshake(session) => session.into_transport_mode(),
|
||||
SnowState::Transport(_) => Err(SnowError::State(StateProblem::HandshakeAlreadyFinished)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A noise session to a remote.
|
||||
///
|
||||
/// `T` is the type of the underlying I/O resource.
|
||||
pub struct NoiseOutput<T> {
|
||||
io: T,
|
||||
session: snow::Session,
|
||||
session: SnowState,
|
||||
buffer: Buffer,
|
||||
read_state: ReadState,
|
||||
write_state: WriteState
|
||||
@ -76,9 +113,10 @@ impl<T> fmt::Debug for NoiseOutput<T> {
|
||||
}
|
||||
|
||||
impl<T> NoiseOutput<T> {
|
||||
fn new(io: T, session: snow::Session) -> Self {
|
||||
fn new(io: T, session: SnowState) -> Self {
|
||||
NoiseOutput {
|
||||
io, session,
|
||||
io,
|
||||
session,
|
||||
buffer: Buffer { inner: Box::new([0; TOTAL_BUFFER_LEN]) },
|
||||
read_state: ReadState::Init,
|
||||
write_state: WriteState::Init
|
||||
|
@ -24,6 +24,7 @@ mod payload;
|
||||
|
||||
use crate::error::NoiseError;
|
||||
use crate::protocol::{Protocol, PublicKey, KeypairIdentity};
|
||||
use crate::io::SnowState;
|
||||
use libp2p_core::identity;
|
||||
use futures::{future, Async, Future, future::FutureResult, Poll};
|
||||
use std::{mem, io};
|
||||
@ -128,7 +129,7 @@ where
|
||||
/// ```
|
||||
pub fn rt1_initiator(
|
||||
io: T,
|
||||
session: Result<snow::Session, NoiseError>,
|
||||
session: Result<snow::HandshakeState, NoiseError>,
|
||||
identity: KeypairIdentity,
|
||||
identity_x: IdentityExchange
|
||||
) -> Handshake<T, C> {
|
||||
@ -157,7 +158,7 @@ where
|
||||
/// ```
|
||||
pub fn rt1_responder(
|
||||
io: T,
|
||||
session: Result<snow::Session, NoiseError>,
|
||||
session: Result<snow::HandshakeState, NoiseError>,
|
||||
identity: KeypairIdentity,
|
||||
identity_x: IdentityExchange,
|
||||
) -> Handshake<T, C> {
|
||||
@ -188,7 +189,7 @@ where
|
||||
/// ```
|
||||
pub fn rt15_initiator(
|
||||
io: T,
|
||||
session: Result<snow::Session, NoiseError>,
|
||||
session: Result<snow::HandshakeState, NoiseError>,
|
||||
identity: KeypairIdentity,
|
||||
identity_x: IdentityExchange
|
||||
) -> Handshake<T, C> {
|
||||
@ -220,7 +221,7 @@ where
|
||||
/// ```
|
||||
pub fn rt15_responder(
|
||||
io: T,
|
||||
session: Result<snow::Session, NoiseError>,
|
||||
session: Result<snow::HandshakeState, NoiseError>,
|
||||
identity: KeypairIdentity,
|
||||
identity_x: IdentityExchange
|
||||
) -> Handshake<T, C> {
|
||||
@ -289,7 +290,7 @@ impl<T> State<T> {
|
||||
/// Noise handshake pattern.
|
||||
fn new(
|
||||
io: T,
|
||||
session: Result<snow::Session, NoiseError>,
|
||||
session: Result<snow::HandshakeState, NoiseError>,
|
||||
identity: KeypairIdentity,
|
||||
identity_x: IdentityExchange
|
||||
) -> FutureResult<Self, NoiseError> {
|
||||
@ -302,7 +303,7 @@ impl<T> State<T> {
|
||||
future::result(session.map(|s|
|
||||
State {
|
||||
identity,
|
||||
io: NoiseOutput::new(io, s),
|
||||
io: NoiseOutput::new(io, SnowState::Handshake(s)),
|
||||
dh_remote_pubkey_sig: None,
|
||||
id_remote_pubkey,
|
||||
send_identity
|
||||
@ -340,7 +341,7 @@ impl<T> State<T>
|
||||
}
|
||||
}
|
||||
};
|
||||
future::ok((remote, NoiseOutput { session: s, .. self.io }))
|
||||
future::ok((remote, NoiseOutput { session: SnowState::Transport(s), .. self.io }))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ pub mod x25519;
|
||||
|
||||
use crate::NoiseError;
|
||||
use libp2p_core::identity;
|
||||
use rand::FromEntropy;
|
||||
use rand::SeedableRng;
|
||||
use zeroize::Zeroize;
|
||||
|
||||
/// The parameters of a Noise protocol, consisting of a choice
|
||||
|
@ -27,7 +27,7 @@ sha2 = "0.8.0"
|
||||
hmac = "0.7.0"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
ring = { version = "0.14", features = ["use_heap"], default-features = false }
|
||||
ring = { version = "^0.16", features = ["alloc"], default-features = false }
|
||||
untrusted = { version = "0.6" }
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
|
@ -64,8 +64,8 @@ pub fn generate_agreement(algorithm: KeyAgreement) -> impl Future<Item = (Agreem
|
||||
pub fn agree(algorithm: KeyAgreement, my_private_key: AgreementPrivateKey, other_public_key: &[u8], _out_size: usize)
|
||||
-> impl Future<Item = Vec<u8>, Error = SecioError>
|
||||
{
|
||||
ring_agreement::agree_ephemeral(my_private_key, algorithm.into(),
|
||||
UntrustedInput::from(other_public_key),
|
||||
ring_agreement::agree_ephemeral(my_private_key,
|
||||
&ring_agreement::UnparsedPublicKey::new(algorithm.into(), other_public_key),
|
||||
SecioError::SecretGenerationFailed,
|
||||
|key_material| Ok(key_material.to_vec()))
|
||||
.into_future()
|
||||
|
Reference in New Issue
Block a user