Repository: cloudflare/boringtun (language: rust)

Issue:
Crate no longer compiles
First off, I am no expert in Rust, so I may make some mistakes in this report.

We're building BoringTun in a container and recently it has failed to compile with errors like the following:

```text
#12 154.5    Compiling boringtun v0.5.2
#12 154.5 error[E0433]: failed to resolve: could not find `StaticSecret` in `x25519_dalek`                                                                                                                                                                                                                                                                                                                                              #12 154.5    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/boringtun-0.5.2/src/device/api.rs:226:62
#12 154.5     |
#12 154.5 226 | ...                   device.set_key(x25519_dalek::StaticSecret::from(key_bytes.0))
#12 154.5     |                                                    ^^^^^^^^^^^^
#12 154.5     |                                                    |
#12 154.5     |                                                    could not find `StaticSecret` in `x25519_dalek`
#12 154.5     |                                                    help: a struct with a similar name exists: `SharedSecret`
#12 154.5
#12 154.6 error[E0412]: cannot find type `StaticSecret` in crate `x25519_dalek`
#12 154.6    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/boringtun-0.5.2/src/device/mod.rs:118:37
#12 154.6     |
#12 154.6 118 |     key_pair: Option<(x25519_dalek::StaticSecret, x25519_dalek::PublicKey)>,
#12 154.6     |                                     ^^^^^^^^^^^^ help: a struct with a similar name exists: `SharedSecret`
#12 154.6     |
#12 154.6    ::: /root/.cargo/registry/src/github.com-1ecc6299db9ec823/x25519-dalek-2.0.0-rc.2/src/x25519.rs:282:1
#12 154.6     |
```

I believe this is the dependency that is causing the problem:

```text
#12 151.4    Compiling x25519-dalek v2.0.0-rc.2
```

The version listed above was released on April 1, which correlates with our failure to build the container:

https://crates.io/crates/x25519-dalek/2.0.0-rc.2

This PR on that project makes the static secrets an optional setting, so presumably BoringTun needs to opt in to this new setting:

https://github.com/dalek-cryptography/x25519-dalek/pull/122

I suspect the new setting needs to be added here. Not knowing much about Rust/Cargo, it would appear to my untrained eye that the version is pinned to `2.0.0-pre.1`, so I'm not sure why `2.0.0-rc.2` is being used, but I'm sure that will make sense to you.

https://github.com/cloudflare/boringtun/blob/be08af94a76135df209bbbb93492a6bc1e1f769f/boringtun/Cargo.toml#L30

Here is the relevant snippet from our Dockerfile that should help you reproduce the build failure:

```Dockerfile
FROM debian:latest AS builder

RUN apt-get update && \
    apt-get -y install ca-certificates curl build-essential && \
    curl https://sh.rustup.rs -sSf | sh -s -- -y && \
    ~/.cargo/bin/cargo install boringtun-cli
```
I do note that the setting was introduced since using these types can be harmful, but I assume you're using them in the correct manner.


Discussion / hints:
Hello, this works:

```bash
cargo install --locked boringtun-cli
```

I'm not an expert in Rust too, so I'm not sure this is the best solution. I just found it in [AUR](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=boringtun).
This is breaking downstream projects where passing `--locked` isn't straightforward, e.g. https://github.com/mitmproxy/mitmproxy/discussions/6045. It would be super nice to get a patch release for this. A very quick way would be to simplify specify the dependency with `version = "=2.0.0-pre.1"`.
cc @jeff-hiner
Should be solved in upstream. Please reopen if you're still seeing issues. Thanks for the pinpoint assessment, it really helped the fix!
Any chance you could give an idea on when it might reach `crates.io`?
We can put out a new patch release over the next few days.
@Noah-Kennedy would it be possible to get the patch release out, since it's been two weeks?
@Noah-Kennedy 

can you make releases using the name v0.5.x without adding the name boringtun. I have this problem in version v0.5.2 I'm using openwrt
For anyone using boringtun as a dependency, I've been able to forcibly use the [fixed revision](https://github.com/cloudflare/boringtun/commit/878385f171d60effac4ad1a9d4dee41e777528b8) using the following in `Cargo.toml`:
```
boringtun = { git = "https://github.com/cloudflare/boringtun.git", rev = "878385f1" }
```

This should fix compiles, but git dependencies are not allowed when publishing to crates.io.
Another option is to `git clone` the repo, 
then run `git revert 878385f171d60effac4ad1a9d4dee41e777528b8`, 
then do `cargo build --bin boringtun-cli`
I ran into this problem today, it's still not fixed on crates.io. I need the library, i'd rather not do tricks with the cli or specify a git rev in my cargo.toml if i can help it.

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index 16b4ecf7..fe90c25c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -76,7 +76,7 @@ dependencies = [
 
 [[package]]
 name = "boringtun"
-version = "0.5.2"
+version = "0.6.0"
 dependencies = [
  "aead",
  "base64",
@@ -105,7 +105,7 @@ dependencies = [
 
 [[package]]
 name = "boringtun-cli"
-version = "0.5.2"
+version = "0.6.0"
 dependencies = [
  "boringtun",
  "clap 3.2.8",
@@ -260,9 +260,9 @@ dependencies = [
 
 [[package]]
 name = "cpufeatures"
-version = "0.2.2"
+version = "0.2.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b"
+checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1"
 dependencies = [
  "libc",
 ]
@@ -383,18 +383,31 @@ dependencies = [
 
 [[package]]
 name = "curve25519-dalek"
-version = "4.0.0-rc.2"
+version = "4.0.0-rc.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03d928d978dbec61a1167414f5ec534f24bea0d7a0d24dd9b6233d3d8223e585"
+checksum = "436ace70fc06e06f7f689d2624dc4e2f0ea666efb5aa704215f7249ae6e047a7"
 dependencies = [
  "cfg-if",
+ "cpufeatures",
+ "curve25519-dalek-derive",
  "fiat-crypto",
- "packed_simd_2",
  "platforms",
+ "rustc_version",
  "subtle",
  "zeroize",
 ]
 
+[[package]]
+name = "curve25519-dalek-derive"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.23",
+]
+
 [[package]]
 name = "daemonize"
 version = "0.4.1"
@@ -597,12 +610,6 @@ version = "0.2.132"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
 
-[[package]]
-name = "libm"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
-
 [[package]]
 name = "lock_api"
 version = "0.4.7"
@@ -707,16 +714,6 @@ version = "6.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
 
-[[package]]
-name = "packed_simd_2"
-version = "0.3.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282"
-dependencies = [
- "cfg-if",
- "libm",
-]
-
 [[package]]
 name = "parking_lot"
 version = "0.12.1"
@@ -793,18 +790,18 @@ dependencies = [
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.40"
+version = "1.0.63"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
+checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb"
 dependencies = [
  "unicode-ident",
 ]
 
 [[package]]
 name = "quote"
-version = "1.0.20"
+version = "1.0.29"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
+checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105"
 dependencies = [
  "proc-macro2",
 ]
@@ -950,7 +947,7 @@ checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.98",
 ]
 
 [[package]]
@@ -1018,6 +1015,17 @@ dependencies = [
  "unicode-ident",
 ]
 
+[[package]]
+name = "syn"
+version = "2.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
 [[package]]
 name = "synstructure"
 version = "0.12.6"
@@ -1026,7 +1034,7 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.98",
  "unicode-xid",
 ]
 
@@ -1071,7 +1079,7 @@ checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.98",
 ]
 
 [[package]]
@@ -1135,7 +1143,7 @@ checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.98",
 ]
 
 [[package]]
@@ -1269,7 +1277,7 @@ dependencies = [
  "log",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.98",
  "wasm-bindgen-shared",
 ]
 
@@ -1291,7 +1299,7 @@ checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.98",
  "wasm-bindgen-backend",
  "wasm-bindgen-shared",
 ]
@@ -1388,9 +1396,9 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
 
 [[package]]
 name = "x25519-dalek"
-version = "2.0.0-rc.2"
+version = "2.0.0-rc.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fabd6e16dd08033932fc3265ad4510cc2eab24656058a6dcb107ffe274abcc95"
+checksum = "ec7fae07da688e17059d5886712c933bb0520f15eff2e09cfa18e30968f4e63a"
 dependencies = [
  "curve25519-dalek",
  "rand_core",
@@ -1415,6 +1423,6 @@ checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.98",
  "synstructure",
 ]
diff --git a/boringtun-cli/Cargo.toml b/boringtun-cli/Cargo.toml
index 26450d6f..18c7917e 100644
--- a/boringtun-cli/Cargo.toml
+++ b/boringtun-cli/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "boringtun-cli"
 description = "an implementation of the WireGuard® protocol designed for portability and speed"
-version = "0.5.2"
+version = "0.6.0"
 authors = ["Noah Kennedy <nkennedy@cloudflare.com>", "Andy Grover <agrover@cloudflare.com>", "Jeff Hiner <jhiner@cloudflare.com>"]
 license = "BSD-3-Clause"
 repository = "https://github.com/cloudflare/boringtun"
@@ -16,6 +16,6 @@ tracing-subscriber = "0.3.9"
 tracing-appender = "0.2.1"
 
 [dependencies.boringtun]
-version = "0.5.2"
+version = "0.6.0"
 path = "../boringtun"
-features = ["device"]
\ No newline at end of file
+features = ["device"]
diff --git a/boringtun/Cargo.toml b/boringtun/Cargo.toml
index 829a83ad..c9d9eec6 100644
--- a/boringtun/Cargo.toml
+++ b/boringtun/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "boringtun"
 description = "an implementation of the WireGuard® protocol designed for portability and speed"
-version = "0.5.2"
+version = "0.6.0"
 authors = [
     "Noah Kennedy <nkennedy@cloudflare.com>",
     "Andy Grover <agrover@cloudflare.com>",
@@ -31,7 +31,7 @@ tracing-subscriber = { version = "0.3", features = ["fmt"], optional = true }
 ip_network = "0.4.1"
 ip_network_table = "0.2.0"
 ring = "0.16"
-x25519-dalek = { version = "=2.0.0-rc.2", features = [
+x25519-dalek = { version = "=2.0.0-rc.3", features = [
     "reusable_secrets",
     "static_secrets",
 ] }


Test patch: