mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-09 17:46:52 +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`.
|
||||
|
||||
- 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
|
||||
|
||||
- Remove `prost::Error` from public API. See [PR 3058].
|
||||
|
@ -27,6 +27,7 @@ mod payload_proto {
|
||||
|
||||
use crate::io::{framed::NoiseFramed, NoiseOutput};
|
||||
use crate::protocol::{KeypairIdentity, Protocol, PublicKey};
|
||||
#[allow(deprecated)]
|
||||
use crate::LegacyConfig;
|
||||
use crate::NoiseError;
|
||||
use bytes::Bytes;
|
||||
@ -77,6 +78,7 @@ pub struct State<T> {
|
||||
/// The known or received public identity key of the remote, if any.
|
||||
id_remote_pubkey: Option<identity::PublicKey>,
|
||||
/// Legacy configuration parameters.
|
||||
#[allow(deprecated)]
|
||||
legacy: LegacyConfig,
|
||||
}
|
||||
|
||||
@ -86,6 +88,7 @@ impl<T> State<T> {
|
||||
/// will be sent and received on the given I/O resource and using the
|
||||
/// provided session for cryptographic operations according to the chosen
|
||||
/// Noise handshake pattern.
|
||||
#[allow(deprecated)]
|
||||
pub fn new(
|
||||
io: T,
|
||||
session: snow::HandshakeState,
|
||||
@ -177,6 +180,7 @@ where
|
||||
|
||||
let mut pb_result = payload_proto::NoiseHandshakePayload::decode(&msg[..]);
|
||||
|
||||
#[allow(deprecated)]
|
||||
if pb_result.is_err() && state.legacy.recv_legacy_handshake {
|
||||
// NOTE: This is support for legacy handshake payloads. As long as
|
||||
// the frame length is less than 256 bytes, which is the case for
|
||||
@ -238,6 +242,7 @@ where
|
||||
pb.identity_sig = sig.clone()
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
let mut msg = if state.legacy.send_legacy_handshake {
|
||||
let mut msg = Vec::with_capacity(2 + pb.encoded_len());
|
||||
msg.extend_from_slice(&(pb.encoded_len() as u16).to_be_bytes());
|
||||
@ -264,6 +269,7 @@ where
|
||||
pb.identity_sig = sig.clone()
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
let mut msg = if state.legacy.send_legacy_handshake {
|
||||
let mut msg = Vec::with_capacity(2 + pb.encoded_len());
|
||||
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 = ()> {
|
||||
dh_keys: AuthenticKeypair<C>,
|
||||
params: ProtocolParams,
|
||||
#[allow(deprecated)]
|
||||
legacy: LegacyConfig,
|
||||
remote: R,
|
||||
_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.
|
||||
#[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 {
|
||||
self.legacy = cfg;
|
||||
self
|
||||
@ -150,7 +156,10 @@ where
|
||||
NoiseConfig {
|
||||
dh_keys,
|
||||
params: C::params_ix(),
|
||||
legacy: LegacyConfig::default(),
|
||||
legacy: {
|
||||
#[allow(deprecated)]
|
||||
LegacyConfig::default()
|
||||
},
|
||||
remote: (),
|
||||
_marker: std::marker::PhantomData,
|
||||
prologue: Vec::default(),
|
||||
@ -167,7 +176,10 @@ where
|
||||
NoiseConfig {
|
||||
dh_keys,
|
||||
params: C::params_xx(),
|
||||
legacy: LegacyConfig::default(),
|
||||
legacy: {
|
||||
#[allow(deprecated)]
|
||||
LegacyConfig::default()
|
||||
},
|
||||
remote: (),
|
||||
_marker: std::marker::PhantomData,
|
||||
prologue: Vec::default(),
|
||||
@ -187,7 +199,10 @@ where
|
||||
NoiseConfig {
|
||||
dh_keys,
|
||||
params: C::params_ik(),
|
||||
legacy: LegacyConfig::default(),
|
||||
legacy: {
|
||||
#[allow(deprecated)]
|
||||
LegacyConfig::default()
|
||||
},
|
||||
remote: (),
|
||||
_marker: std::marker::PhantomData,
|
||||
prologue: Vec::default(),
|
||||
@ -211,7 +226,10 @@ where
|
||||
NoiseConfig {
|
||||
dh_keys,
|
||||
params: C::params_ik(),
|
||||
legacy: LegacyConfig::default(),
|
||||
legacy: {
|
||||
#[allow(deprecated)]
|
||||
LegacyConfig::default()
|
||||
},
|
||||
remote: (remote_dh, remote_id),
|
||||
_marker: std::marker::PhantomData,
|
||||
prologue: Vec::default(),
|
||||
@ -573,6 +591,10 @@ where
|
||||
|
||||
/// Legacy configuration options.
|
||||
#[derive(Clone, Copy, Default)]
|
||||
#[deprecated(
|
||||
since = "0.42.0",
|
||||
note = "`LegacyConfig` will be removed without replacement."
|
||||
)]
|
||||
pub struct LegacyConfig {
|
||||
/// Whether to continue sending legacy handshake payloads,
|
||||
/// i.e. length-prefixed protobuf payloads inside a length-prefixed
|
||||
|
@ -59,7 +59,7 @@ static PARAMS_XX: Lazy<ProtocolParams> = Lazy::new(|| {
|
||||
/// A X25519 key.
|
||||
#[derive(Clone)]
|
||||
#[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."
|
||||
)]
|
||||
pub struct X25519([u8; 32]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user