mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-11 10:27:15 +00:00
feat(noise): deprecate LegacyConfig
without replacement (#3265)
As the name implies, `LegacyConfig` allows users to interact with older versions of the noise protocol. These are not interoperable and we've been supporting them for a long time now. Hopefully, users have migrated away from it since. To not directly break them, we officially deprecate now without a replacement.
This commit is contained in:
parent
87dc7b6e51
commit
cafa37ea21
@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
- Update to `libp2p-core` `v0.39.0`.
|
- Update to `libp2p-core` `v0.39.0`.
|
||||||
|
|
||||||
|
- Deprecate non-compliant noise implementation. We intend to remove it in a future release without replacement. See [PR 3227].
|
||||||
|
|
||||||
|
- Deprecate `LegacyConfig` without replacement. See [PR 3265].
|
||||||
|
|
||||||
|
[PR 3227]: https://github.com/libp2p/rust-libp2p/pull/3227
|
||||||
|
[PR 3265]: https://github.com/libp2p/rust-libp2p/pull/3265
|
||||||
|
|
||||||
# 0.41.0
|
# 0.41.0
|
||||||
|
|
||||||
- Remove `prost::Error` from public API. See [PR 3058].
|
- Remove `prost::Error` from public API. See [PR 3058].
|
||||||
|
@ -27,6 +27,7 @@ mod payload_proto {
|
|||||||
|
|
||||||
use crate::io::{framed::NoiseFramed, NoiseOutput};
|
use crate::io::{framed::NoiseFramed, NoiseOutput};
|
||||||
use crate::protocol::{KeypairIdentity, Protocol, PublicKey};
|
use crate::protocol::{KeypairIdentity, Protocol, PublicKey};
|
||||||
|
#[allow(deprecated)]
|
||||||
use crate::LegacyConfig;
|
use crate::LegacyConfig;
|
||||||
use crate::NoiseError;
|
use crate::NoiseError;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
@ -77,6 +78,7 @@ pub struct State<T> {
|
|||||||
/// The known or received public identity key of the remote, if any.
|
/// The known or received public identity key of the remote, if any.
|
||||||
id_remote_pubkey: Option<identity::PublicKey>,
|
id_remote_pubkey: Option<identity::PublicKey>,
|
||||||
/// Legacy configuration parameters.
|
/// Legacy configuration parameters.
|
||||||
|
#[allow(deprecated)]
|
||||||
legacy: LegacyConfig,
|
legacy: LegacyConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +88,7 @@ impl<T> State<T> {
|
|||||||
/// will be sent and received on the given I/O resource and using the
|
/// will be sent and received on the given I/O resource and using the
|
||||||
/// provided session for cryptographic operations according to the chosen
|
/// provided session for cryptographic operations according to the chosen
|
||||||
/// Noise handshake pattern.
|
/// Noise handshake pattern.
|
||||||
|
#[allow(deprecated)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
io: T,
|
io: T,
|
||||||
session: snow::HandshakeState,
|
session: snow::HandshakeState,
|
||||||
@ -177,6 +180,7 @@ where
|
|||||||
|
|
||||||
let mut pb_result = payload_proto::NoiseHandshakePayload::decode(&msg[..]);
|
let mut pb_result = payload_proto::NoiseHandshakePayload::decode(&msg[..]);
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
if pb_result.is_err() && state.legacy.recv_legacy_handshake {
|
if pb_result.is_err() && state.legacy.recv_legacy_handshake {
|
||||||
// NOTE: This is support for legacy handshake payloads. As long as
|
// NOTE: This is support for legacy handshake payloads. As long as
|
||||||
// the frame length is less than 256 bytes, which is the case for
|
// the frame length is less than 256 bytes, which is the case for
|
||||||
@ -238,6 +242,7 @@ where
|
|||||||
pb.identity_sig = sig.clone()
|
pb.identity_sig = sig.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
let mut msg = if state.legacy.send_legacy_handshake {
|
let mut msg = if state.legacy.send_legacy_handshake {
|
||||||
let mut msg = Vec::with_capacity(2 + pb.encoded_len());
|
let mut msg = Vec::with_capacity(2 + pb.encoded_len());
|
||||||
msg.extend_from_slice(&(pb.encoded_len() as u16).to_be_bytes());
|
msg.extend_from_slice(&(pb.encoded_len() as u16).to_be_bytes());
|
||||||
@ -264,6 +269,7 @@ where
|
|||||||
pb.identity_sig = sig.clone()
|
pb.identity_sig = sig.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
let mut msg = if state.legacy.send_legacy_handshake {
|
let mut msg = if state.legacy.send_legacy_handshake {
|
||||||
let mut msg = Vec::with_capacity(2 + pb.encoded_len());
|
let mut msg = Vec::with_capacity(2 + pb.encoded_len());
|
||||||
msg.extend_from_slice(&(pb.encoded_len() as u16).to_be_bytes());
|
msg.extend_from_slice(&(pb.encoded_len() as u16).to_be_bytes());
|
||||||
|
@ -79,6 +79,7 @@ use zeroize::Zeroize;
|
|||||||
pub struct NoiseConfig<P, C: Zeroize, R = ()> {
|
pub struct NoiseConfig<P, C: Zeroize, R = ()> {
|
||||||
dh_keys: AuthenticKeypair<C>,
|
dh_keys: AuthenticKeypair<C>,
|
||||||
params: ProtocolParams,
|
params: ProtocolParams,
|
||||||
|
#[allow(deprecated)]
|
||||||
legacy: LegacyConfig,
|
legacy: LegacyConfig,
|
||||||
remote: R,
|
remote: R,
|
||||||
_marker: std::marker::PhantomData<P>,
|
_marker: std::marker::PhantomData<P>,
|
||||||
@ -105,6 +106,11 @@ impl<H, C: Zeroize, R> NoiseConfig<H, C, R> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the legacy configuration options to use, if any.
|
/// Sets the legacy configuration options to use, if any.
|
||||||
|
#[deprecated(
|
||||||
|
since = "0.42.0",
|
||||||
|
note = "`LegacyConfig` will be removed without replacement."
|
||||||
|
)]
|
||||||
|
#[allow(deprecated)]
|
||||||
pub fn set_legacy_config(&mut self, cfg: LegacyConfig) -> &mut Self {
|
pub fn set_legacy_config(&mut self, cfg: LegacyConfig) -> &mut Self {
|
||||||
self.legacy = cfg;
|
self.legacy = cfg;
|
||||||
self
|
self
|
||||||
@ -150,7 +156,10 @@ where
|
|||||||
NoiseConfig {
|
NoiseConfig {
|
||||||
dh_keys,
|
dh_keys,
|
||||||
params: C::params_ix(),
|
params: C::params_ix(),
|
||||||
legacy: LegacyConfig::default(),
|
legacy: {
|
||||||
|
#[allow(deprecated)]
|
||||||
|
LegacyConfig::default()
|
||||||
|
},
|
||||||
remote: (),
|
remote: (),
|
||||||
_marker: std::marker::PhantomData,
|
_marker: std::marker::PhantomData,
|
||||||
prologue: Vec::default(),
|
prologue: Vec::default(),
|
||||||
@ -167,7 +176,10 @@ where
|
|||||||
NoiseConfig {
|
NoiseConfig {
|
||||||
dh_keys,
|
dh_keys,
|
||||||
params: C::params_xx(),
|
params: C::params_xx(),
|
||||||
legacy: LegacyConfig::default(),
|
legacy: {
|
||||||
|
#[allow(deprecated)]
|
||||||
|
LegacyConfig::default()
|
||||||
|
},
|
||||||
remote: (),
|
remote: (),
|
||||||
_marker: std::marker::PhantomData,
|
_marker: std::marker::PhantomData,
|
||||||
prologue: Vec::default(),
|
prologue: Vec::default(),
|
||||||
@ -187,7 +199,10 @@ where
|
|||||||
NoiseConfig {
|
NoiseConfig {
|
||||||
dh_keys,
|
dh_keys,
|
||||||
params: C::params_ik(),
|
params: C::params_ik(),
|
||||||
legacy: LegacyConfig::default(),
|
legacy: {
|
||||||
|
#[allow(deprecated)]
|
||||||
|
LegacyConfig::default()
|
||||||
|
},
|
||||||
remote: (),
|
remote: (),
|
||||||
_marker: std::marker::PhantomData,
|
_marker: std::marker::PhantomData,
|
||||||
prologue: Vec::default(),
|
prologue: Vec::default(),
|
||||||
@ -211,7 +226,10 @@ where
|
|||||||
NoiseConfig {
|
NoiseConfig {
|
||||||
dh_keys,
|
dh_keys,
|
||||||
params: C::params_ik(),
|
params: C::params_ik(),
|
||||||
legacy: LegacyConfig::default(),
|
legacy: {
|
||||||
|
#[allow(deprecated)]
|
||||||
|
LegacyConfig::default()
|
||||||
|
},
|
||||||
remote: (remote_dh, remote_id),
|
remote: (remote_dh, remote_id),
|
||||||
_marker: std::marker::PhantomData,
|
_marker: std::marker::PhantomData,
|
||||||
prologue: Vec::default(),
|
prologue: Vec::default(),
|
||||||
@ -573,6 +591,10 @@ where
|
|||||||
|
|
||||||
/// Legacy configuration options.
|
/// Legacy configuration options.
|
||||||
#[derive(Clone, Copy, Default)]
|
#[derive(Clone, Copy, Default)]
|
||||||
|
#[deprecated(
|
||||||
|
since = "0.42.0",
|
||||||
|
note = "`LegacyConfig` will be removed without replacement."
|
||||||
|
)]
|
||||||
pub struct LegacyConfig {
|
pub struct LegacyConfig {
|
||||||
/// Whether to continue sending legacy handshake payloads,
|
/// Whether to continue sending legacy handshake payloads,
|
||||||
/// i.e. length-prefixed protobuf payloads inside a length-prefixed
|
/// i.e. length-prefixed protobuf payloads inside a length-prefixed
|
||||||
|
@ -59,7 +59,7 @@ static PARAMS_XX: Lazy<ProtocolParams> = Lazy::new(|| {
|
|||||||
/// A X25519 key.
|
/// A X25519 key.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
#[deprecated(
|
#[deprecated(
|
||||||
since = "0.41.1",
|
since = "0.42.0",
|
||||||
note = "Will be removed because it is not compliant with the official libp2p specification. Use `X25519Spec` instead."
|
note = "Will be removed because it is not compliant with the official libp2p specification. Use `X25519Spec` instead."
|
||||||
)]
|
)]
|
||||||
pub struct X25519([u8; 32]);
|
pub struct X25519([u8; 32]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user