diff --git a/transports/noise/CHANGELOG.md b/transports/noise/CHANGELOG.md index ea4ae6ca..e966d6ee 100644 --- a/transports/noise/CHANGELOG.md +++ b/transports/noise/CHANGELOG.md @@ -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]. diff --git a/transports/noise/src/io/handshake.rs b/transports/noise/src/io/handshake.rs index e57288d5..cdcea045 100644 --- a/transports/noise/src/io/handshake.rs +++ b/transports/noise/src/io/handshake.rs @@ -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 { /// The known or received public identity key of the remote, if any. id_remote_pubkey: Option, /// Legacy configuration parameters. + #[allow(deprecated)] legacy: LegacyConfig, } @@ -86,6 +88,7 @@ impl State { /// 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()); diff --git a/transports/noise/src/lib.rs b/transports/noise/src/lib.rs index 52f13cca..9e8a9ea2 100644 --- a/transports/noise/src/lib.rs +++ b/transports/noise/src/lib.rs @@ -79,6 +79,7 @@ use zeroize::Zeroize; pub struct NoiseConfig { dh_keys: AuthenticKeypair, params: ProtocolParams, + #[allow(deprecated)] legacy: LegacyConfig, remote: R, _marker: std::marker::PhantomData

, @@ -105,6 +106,11 @@ impl NoiseConfig { } /// 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 diff --git a/transports/noise/src/protocol/x25519.rs b/transports/noise/src/protocol/x25519.rs index 182d9905..c0902136 100644 --- a/transports/noise/src/protocol/x25519.rs +++ b/transports/noise/src/protocol/x25519.rs @@ -59,7 +59,7 @@ static PARAMS_XX: Lazy = 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]);