Skip to content

Commit

Permalink
Support spec-compliant reading of noise handshake payloads.
Browse files Browse the repository at this point in the history
See libp2p#1631.

This the first of a three-step process to addressing the issue.
In this step, support for reading noise handshake payloads
without an additional length prefix is added, falling back
to attempting a decoding with length prefix on failure.
Length prefixes are still sent in this step. Hence
interoperability with other libp2p implementations is not
yet achieved after with step.

To achieve a better separation of handshake and transport
I/O, the `NoiseFramed` type has been extracted from
`NoiseOutput`. `NoiseFramed` is a `Sink` and `Stream`
of length-delimited Noise protocol messages. This type
is used in the handshake phase. Once a handshake
completes the underlying Noise session transitions to
transport mode and the `NoiseFramed` is wrapped in
the `NoiseOutput` which provides a regular `AsyncRead`
/ `AsyncWrite` I/O resource on top of the framed
encoding. No new buffers are introduced, they are
just split between `NoiseFramed` and `NoiseOutput`.

The second step involves removing the sending of the
length prefix in a subsequent release.

The third step involves removing the support for reading
length-prefixed protobuf payloads.
  • Loading branch information
Roman S. Borschel committed Jul 9, 2020
1 parent 68587ee commit d14229a
Show file tree
Hide file tree
Showing 7 changed files with 592 additions and 446 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
- [`parity-multiaddr` CHANGELOG](misc/multiaddr/CHANGELOG.md)
- [`libp2p-core-derive` CHANGELOG](misc/core-derive/CHANGELOG.md)

# Version 0.22.0 (????-??-??)

**NOTE**: For a smooth upgrade path from `0.21` to `> 0.22`
on an existing deployment using `libp2p-noise`, this version
must not be skipped!

- Bump `libp2p-noise` dependency to `0.21`.

# Version 0.21.1 (2020-07-02)

- Bump `libp2p-websockets` lower bound.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ libp2p-gossipsub = { version = "0.20.0", path = "./protocols/gossipsub", optiona
libp2p-identify = { version = "0.20.0", path = "protocols/identify", optional = true }
libp2p-kad = { version = "0.21.0", path = "protocols/kad", optional = true }
libp2p-mplex = { version = "0.20.0", path = "muxers/mplex", optional = true }
libp2p-noise = { version = "0.20.0", path = "protocols/noise", optional = true }
libp2p-noise = { version = "0.21.0", path = "protocols/noise", optional = true }
libp2p-ping = { version = "0.20.0", path = "protocols/ping", optional = true }
libp2p-plaintext = { version = "0.20.0", path = "protocols/plaintext", optional = true }
libp2p-pnet = { version = "0.19.1", path = "protocols/pnet", optional = true }
Expand Down
11 changes: 11 additions & 0 deletions protocols/noise/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 0.21.0 [????-??-??]

**NOTE**: For a smooth upgrade path from `0.20` to `> 0.21`
on an existing deployment, this version must not be skipped!

- Add support for reading handshake protobuf frames without
length prefixes in preparation for no longer sending them.
See [issue 1631](https://github.com/libp2p/rust-libp2p/issues/1631).

- Update the `snow` dependency to the latest patch version.

# 0.20.0 [2020-07-01]

- Updated dependencies.
Expand Down
6 changes: 3 additions & 3 deletions protocols/noise/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "libp2p-noise"
description = "Cryptographic handshake protocol using the noise framework."
version = "0.20.0"
version = "0.21.0"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand All @@ -21,10 +21,10 @@ x25519-dalek = "0.6.0"
zeroize = "1"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
snow = { version = "0.7.0", features = ["ring-resolver"], default-features = false }
snow = { version = "0.7.1", features = ["ring-resolver"], default-features = false }

[target.'cfg(target_arch = "wasm32")'.dependencies]
snow = { version = "0.7.0", features = ["default-resolver"], default-features = false }
snow = { version = "0.7.1", features = ["default-resolver"], default-features = false }

[dev-dependencies]
env_logger = "0.7.1"
Expand Down
Loading

0 comments on commit d14229a

Please sign in to comment.