Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05d7ada449 |
20 changed files with 54 additions and 740 deletions
|
|
@ -17,8 +17,6 @@ on:
|
||||||
- "Cargo.toml"
|
- "Cargo.toml"
|
||||||
- "Cargo.lock"
|
- "Cargo.lock"
|
||||||
- ".forgejo/workflows/ci.yml"
|
- ".forgejo/workflows/ci.yml"
|
||||||
- "fuzz/**"
|
|
||||||
- "scripts/run-fuzz.sh"
|
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- "src/**"
|
- "src/**"
|
||||||
|
|
@ -27,8 +25,6 @@ on:
|
||||||
- "Cargo.toml"
|
- "Cargo.toml"
|
||||||
- "Cargo.lock"
|
- "Cargo.lock"
|
||||||
- ".forgejo/workflows/ci.yml"
|
- ".forgejo/workflows/ci.yml"
|
||||||
- "fuzz/**"
|
|
||||||
- "scripts/run-fuzz.sh"
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
# One cargo job on the Pi at a time. Overlapping PR+main runs shared the
|
# One cargo job on the Pi at a time. Overlapping PR+main runs shared the
|
||||||
|
|
@ -43,19 +39,11 @@ env:
|
||||||
CARGO_REGISTRY_VOLUME: onionwire-cargo-registry
|
CARGO_REGISTRY_VOLUME: onionwire-cargo-registry
|
||||||
CARGO_TARGET_VOLUME: onionwire-target-ci
|
CARGO_TARGET_VOLUME: onionwire-target-ci
|
||||||
BUILD_CONTAINER: onionwire-ci-${{ github.run_id }}
|
BUILD_CONTAINER: onionwire-ci-${{ github.run_id }}
|
||||||
# The SDK job gets its own target volume: `crates/onionwire-sdk` is a
|
# The SDK job gets its own target volume: it resolves the root crate with
|
||||||
# separate cargo workspace with its own lockfile and its own crate set, so
|
# `rustls` instead of `native-tls`, so sharing a target dir would thrash both
|
||||||
# sharing a target dir with the root job would thrash both.
|
# jobs' feature-unified artifacts.
|
||||||
SDK_CARGO_TARGET_VOLUME: onionwire-target-ci-sdk
|
SDK_CARGO_TARGET_VOLUME: onionwire-target-ci-sdk
|
||||||
SDK_BUILD_CONTAINER: onionwire-ci-sdk-${{ github.run_id }}
|
SDK_BUILD_CONTAINER: onionwire-ci-sdk-${{ github.run_id }}
|
||||||
# The fuzz job builds on nightly with a release profile + debug=line-tables-only;
|
|
||||||
# it must not thrash the test/sdk target volumes and needs its own registry cache.
|
|
||||||
FUZZ_REGISTRY_VOLUME: onionwire-cargo-registry-fuzz
|
|
||||||
FUZZ_TARGET_VOLUME: onionwire-target-ci-fuzz
|
|
||||||
FUZZ_BUILD_CONTAINER: onionwire-ci-fuzz-${{ github.run_id }}
|
|
||||||
# libFuzzer writes its -fork dir into TMPDIR; point it at the target volume so
|
|
||||||
# a host tmpfs quota can't OOM-kill the builder.
|
|
||||||
FUZZ_TMP_DIR: /target/tmp
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|
@ -77,12 +65,13 @@ jobs:
|
||||||
-e CARGO_TARGET_DIR=/target \
|
-e CARGO_TARGET_DIR=/target \
|
||||||
-e CARGO_BUILD_JOBS=2 \
|
-e CARGO_BUILD_JOBS=2 \
|
||||||
-e CARGO_TERM_COLOR=never \
|
-e CARGO_TERM_COLOR=never \
|
||||||
-e TMPDIR=/target/tmp \
|
|
||||||
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
||||||
-v "$CARGO_TARGET_VOLUME":/target \
|
-v "$CARGO_TARGET_VOLUME":/target \
|
||||||
-w /src \
|
-w /src \
|
||||||
"$RUST_IMAGE" \
|
"$RUST_IMAGE" \
|
||||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
|
||||||
&& rustup component add clippy \
|
&& rustup component add clippy \
|
||||||
&& cargo test --locked \
|
&& cargo test --locked \
|
||||||
&& cargo clippy --locked --all-targets -- -D warnings'
|
&& cargo clippy --locked --all-targets -- -D warnings'
|
||||||
|
|
@ -91,19 +80,12 @@ jobs:
|
||||||
docker rm -f "$BUILD_CONTAINER" > /dev/null
|
docker rm -f "$BUILD_CONTAINER" > /dev/null
|
||||||
|
|
||||||
# `crates/onionwire-sdk` is a SEPARATE cargo workspace: its own Cargo.lock and
|
# `crates/onionwire-sdk` is a SEPARATE cargo workspace: its own Cargo.lock and
|
||||||
# a path dependency on the root crate. The `test` job above therefore never
|
# a path dependency on the root crate, resolved with `rustls` instead of
|
||||||
# compiles it, so a root-crate signature change (`Node::send` gaining the
|
# `native-tls`. The `test` job above therefore never compiles it, so a
|
||||||
# outbox result, the SQLCipher passphrase entry points) breaks the Android SDK
|
# root-crate signature change (`Node::send` gaining the outbox result, the
|
||||||
# — and the tagged release AAR, since android-release.yml only builds on
|
# SQLCipher passphrase entry points) breaks the Android SDK — and the tagged
|
||||||
# `v*.*.*` — while both the root suites and local `cargo test` stay green.
|
# release AAR, since android-release.yml only builds on `v*.*.*` — while both
|
||||||
# Build it here.
|
# the root suites and local `cargo test` stay green. Build it here.
|
||||||
#
|
|
||||||
# The root `test` job no longer installs `pkg-config`/`libssl-dev` — the root
|
|
||||||
# crate defaults to Arti's rustls backend, so TLS needs no system OpenSSL.
|
|
||||||
# The `rusqlite` `bundled-sqlcipher-vendored-openssl` feature that both jobs
|
|
||||||
# use compiles OpenSSL from source, which needs `perl` and `make` (present in
|
|
||||||
# the `rust:*-bookworm` image), not the `-dev` headers. This job keeps the
|
|
||||||
# install: the Android SDK build is unchanged by the root crate's TLS default.
|
|
||||||
sdk:
|
sdk:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
timeout-minutes: 120
|
timeout-minutes: 120
|
||||||
|
|
@ -123,7 +105,6 @@ jobs:
|
||||||
-e CARGO_TARGET_DIR=/target \
|
-e CARGO_TARGET_DIR=/target \
|
||||||
-e CARGO_BUILD_JOBS=2 \
|
-e CARGO_BUILD_JOBS=2 \
|
||||||
-e CARGO_TERM_COLOR=never \
|
-e CARGO_TERM_COLOR=never \
|
||||||
-e TMPDIR=/target/tmp \
|
|
||||||
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
-v "$CARGO_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
||||||
-v "$SDK_CARGO_TARGET_VOLUME":/target \
|
-v "$SDK_CARGO_TARGET_VOLUME":/target \
|
||||||
-w /src \
|
-w /src \
|
||||||
|
|
@ -138,82 +119,3 @@ jobs:
|
||||||
--exclude=./crates/onionwire-sdk/target . \
|
--exclude=./crates/onionwire-sdk/target . \
|
||||||
| docker start -a -i "$SDK_BUILD_CONTAINER"
|
| docker start -a -i "$SDK_BUILD_CONTAINER"
|
||||||
docker rm -f "$SDK_BUILD_CONTAINER" > /dev/null
|
docker rm -f "$SDK_BUILD_CONTAINER" > /dev/null
|
||||||
|
|
||||||
# Nightly cargo-fuzz harness. The `fuzz/` crate (PR #103) is a detached
|
|
||||||
# workspace with four libFuzzer targets over the untrusted-input parsers —
|
|
||||||
# RatchetState::from_bytes/decrypt, qr::decode, dispatch::classify, file::decode.
|
|
||||||
# Nothing in CI ever compiles this crate, so the targets bit-rot silently: this
|
|
||||||
# job catches it. It only does something useful after PR #103 merges to main.
|
|
||||||
fuzz:
|
|
||||||
runs-on: docker
|
|
||||||
timeout-minutes: 120
|
|
||||||
# The cold fuzz build (~12 min locally for the full Arti + SQLCipher +
|
|
||||||
# vendored-OpenSSL graph) can SERIALIZE other PRs with the same concurrency
|
|
||||||
# group. Give it its own group so a long fuzz build does not block the test/sdk
|
|
||||||
# jobs and the PRs that trigger them.
|
|
||||||
concurrency:
|
|
||||||
group: onionwire-ci-pi-fuzz
|
|
||||||
cancel-in-progress: false
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: https://code.forgejo.org/actions/checkout@v4
|
|
||||||
|
|
||||||
- name: nightly toolchain + cargo-fuzz
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
cd "${GITHUB_WORKSPACE}"
|
|
||||||
echo "workspace: $GITHUB_WORKSPACE"
|
|
||||||
docker volume create "$FUZZ_REGISTRY_VOLUME" > /dev/null
|
|
||||||
docker volume create "$FUZZ_TARGET_VOLUME" > /dev/null
|
|
||||||
docker rm -f "$FUZZ_BUILD_CONTAINER" > /dev/null 2>&1 || true
|
|
||||||
docker create --name "$FUZZ_BUILD_CONTAINER" -i \
|
|
||||||
-e CARGO_TARGET_DIR=/target \
|
|
||||||
-e CARGO_BUILD_JOBS=2 \
|
|
||||||
-e CARGO_TERM_COLOR=never \
|
|
||||||
-e TMPDIR=/target/tmp \
|
|
||||||
-e RUSTUP_HOME=/usr/local/rustup \
|
|
||||||
-e CARGO_HOME=/usr/local/cargo \
|
|
||||||
-v "$FUZZ_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
|
||||||
-v "$FUZZ_TARGET_VOLUME":/target \
|
|
||||||
-w /src \
|
|
||||||
"$RUST_IMAGE" \
|
|
||||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
|
||||||
&& apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
|
|
||||||
&& rustup toolchain install nightly --profile minimal \
|
|
||||||
&& rustup default nightly \
|
|
||||||
&& cargo install cargo-fuzz --locked \
|
|
||||||
&& export PATH="/usr/local/cargo/bin:$PATH" \
|
|
||||||
&& cd /src/fuzz \
|
|
||||||
&& cargo +nightly fuzz build \
|
|
||||||
&& cargo +nightly fuzz list'
|
|
||||||
tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees . \
|
|
||||||
| docker start -a -i "$FUZZ_BUILD_CONTAINER"
|
|
||||||
|
|
||||||
- name: run each fuzz target for 15s
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
cd "${GITHUB_WORKSPACE}"
|
|
||||||
docker volume create "$FUZZ_REGISTRY_VOLUME" > /dev/null
|
|
||||||
docker volume create "$FUZZ_TARGET_VOLUME" > /dev/null
|
|
||||||
docker rm -f "$FUZZ_BUILD_CONTAINER" > /dev/null 2>&1 || true
|
|
||||||
docker create --name "$FUZZ_BUILD_CONTAINER" -i \
|
|
||||||
-e CARGO_TARGET_DIR=/target \
|
|
||||||
-e CARGO_BUILD_JOBS=2 \
|
|
||||||
-e CARGO_TERM_COLOR=never \
|
|
||||||
-e TMPDIR=/target/tmp \
|
|
||||||
-e RUSTUP_HOME=/usr/local/rustup \
|
|
||||||
-e CARGO_HOME=/usr/local/cargo \
|
|
||||||
-e FUZZ_SECS=15 \
|
|
||||||
-e FUZZ_JOBS=2 \
|
|
||||||
-v "$FUZZ_REGISTRY_VOLUME":/usr/local/cargo/registry \
|
|
||||||
-v "$FUZZ_TARGET_VOLUME":/target \
|
|
||||||
-w /src \
|
|
||||||
"$RUST_IMAGE" \
|
|
||||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
|
||||||
&& export PATH="/usr/local/cargo/bin:$PATH" \
|
|
||||||
&& cd /src/fuzz \
|
|
||||||
&& bash /src/scripts/run-fuzz.sh'
|
|
||||||
tar czf - --exclude=./target --exclude=./.git --exclude=./.worktrees . \
|
|
||||||
| docker start -a -i "$FUZZ_BUILD_CONTAINER"
|
|
||||||
docker rm -f "$FUZZ_BUILD_CONTAINER" > /dev/null
|
|
||||||
|
|
|
||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -2645,7 +2645,6 @@ dependencies = [
|
||||||
"ratatui",
|
"ratatui",
|
||||||
"rpassword",
|
"rpassword",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"rustls",
|
|
||||||
"safelog",
|
"safelog",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
|
@ -3501,7 +3500,6 @@ checksum = "6725596c3f2c3a0aef021139e145d4eafe314a6623e4680ca83852b2c67ab2ba"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"ring",
|
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"rustls-webpki",
|
"rustls-webpki",
|
||||||
"subtle",
|
"subtle",
|
||||||
|
|
|
||||||
22
Cargo.toml
22
Cargo.toml
|
|
@ -8,16 +8,16 @@ license = "MIT"
|
||||||
publish = false
|
publish = false
|
||||||
repository = "https://github.com/sirius0xdev/onionwire"
|
repository = "https://github.com/sirius0xdev/onionwire"
|
||||||
|
|
||||||
# TLS backend: `rustls` by default, `native-tls` (OpenSSL) opt-in.
|
# The Linux TUI build is unchanged: `default` keeps Arti's native-tls
|
||||||
|
# (OpenSSL) backend exactly as before, and ratatui remains a normal
|
||||||
|
# dependency so `src/tui.rs` is untouched.
|
||||||
#
|
#
|
||||||
# Arti marks these two backends non-additive, so exactly one may be selected per
|
# Android has no OpenSSL in the NDK, so the SDK crate depends on this crate
|
||||||
# build graph — hence exposing them as crate features. rustls is the default
|
# with `default-features = false, features = ["rustls"]`. Arti marks these two
|
||||||
# because Android has no OpenSSL in the NDK and the Linux TUI/release build does
|
# backends non-additive, so exactly one may be selected per build graph — hence
|
||||||
# not need a system OpenSSL for TLS either. (OpenSSL is still *compiled* into
|
# exposing them as crate features.
|
||||||
# every build by rusqlite's `bundled-sqlcipher-vendored-openssl`, vendored and
|
|
||||||
# static: that is the SQLCipher layer, not Arti's TLS.)
|
|
||||||
[features]
|
[features]
|
||||||
default = ["rustls"]
|
default = ["native-tls"]
|
||||||
native-tls = ["arti-client/native-tls"]
|
native-tls = ["arti-client/native-tls"]
|
||||||
rustls = ["arti-client/rustls"]
|
rustls = ["arti-client/rustls"]
|
||||||
|
|
||||||
|
|
@ -37,12 +37,6 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-util", "ti
|
||||||
tor-cell = "0.46"
|
tor-cell = "0.46"
|
||||||
tor-hsservice = "0.46"
|
tor-hsservice = "0.46"
|
||||||
tor-rtcompat = { version = "0.46", features = ["tokio"] }
|
tor-rtcompat = { version = "0.46", features = ["tokio"] }
|
||||||
# Direct dependency only to select rustls's crypto provider: Arti pulls rustls in
|
|
||||||
# through `tor-rtcompat` with `default-features = false`, and rustls 0.23
|
|
||||||
# resolves its provider from its OWN `ring`/`aws-lc-rs` features, so without this
|
|
||||||
# line the rustls backend compiles with no provider at all and the first TLS
|
|
||||||
# config fails. Same reasoning (and pin) as `crates/onionwire-sdk/Cargo.toml`.
|
|
||||||
rustls = { version = "0.23", default-features = false, features = ["ring"] }
|
|
||||||
ratatui = { version = "0.30.2", default-features = false, features = ["crossterm"] }
|
ratatui = { version = "0.30.2", default-features = false, features = ["crossterm"] }
|
||||||
x25519-dalek = { version = "2", features = ["static_secrets"] }
|
x25519-dalek = { version = "2", features = ["static_secrets"] }
|
||||||
snow = "0.10"
|
snow = "0.10"
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,8 @@ cargo install --path . --locked --force
|
||||||
# lands in ~/.cargo/bin/onionwire
|
# lands in ~/.cargo/bin/onionwire
|
||||||
```
|
```
|
||||||
|
|
||||||
Build needs a C toolchain plus `perl` and `make`: SQLCipher is compiled from
|
Build needs `pkg-config` and OpenSSL 3 headers (`libssl-dev` / `openssl-devel`) —
|
||||||
vendored OpenSSL sources (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`).
|
the released binaries link `libssl.so.3` dynamically.
|
||||||
No system OpenSSL headers or `pkg-config` are required — Arti's TLS backend is
|
|
||||||
`rustls`, and the binaries carry no dynamic `libssl` dependency.
|
|
||||||
|
|
||||||
### Two instances on one machine
|
### Two instances on one machine
|
||||||
|
|
||||||
|
|
@ -136,7 +134,6 @@ Focus starts on the composer so typing works immediately. `Tab` cycles panes; `j
|
||||||
| `F4` | Rotate **onion** (locator only) |
|
| `F4` | Rotate **onion** (locator only) |
|
||||||
| `F5` | Selected friend's profile (`/who`) |
|
| `F5` | Selected friend's profile (`/who`) |
|
||||||
| `F6` | Wallet screen (receive QR, balance, transfers) |
|
| `F6` | Wallet screen (receive QR, balance, transfers) |
|
||||||
| `F8` | Rotate **prekey** (hard cut: every friend re-pastes the invite) |
|
|
||||||
| Enter | Send chat to the selected friend, or run a `/command` |
|
| Enter | Send chat to the selected friend, or run a `/command` |
|
||||||
| `Esc` | Close overlay / back to Main / clear composer |
|
| `Esc` | Close overlay / back to Main / clear composer |
|
||||||
| `Ctrl-Q` | Quit: type `CLEAR`+Enter to wipe history, `QUIT`+Enter to leave it, Esc to stay |
|
| `Ctrl-Q` | Quit: type `CLEAR`+Enter to wipe history, `QUIT`+Enter to leave it, Esc to stay |
|
||||||
|
|
@ -406,7 +403,7 @@ FORGEJO_TOKEN=<pat> scripts/build-release-local.sh v0.2.1
|
||||||
|
|
||||||
Workflows (Forgejo Actions, `.forgejo/workflows/`):
|
Workflows (Forgejo Actions, `.forgejo/workflows/`):
|
||||||
|
|
||||||
- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — two jobs on the Pi runner (`docker` label), serialized by `onionwire-ci-pi`. `test`: `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` at the repo root. `sdk`: the same for `crates/onionwire-sdk` (separate cargo workspace — own `Cargo.lock`, root crate by path, so a root signature change cannot silently break the Android SDK). Both run on `main` and PRs when `src/`, `crates/`, `tests/`, `Cargo.toml`, `Cargo.lock`, or this workflow change (ignored Tor-live tests are not run). `workflow_dispatch` always runs the suite.
|
- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — two jobs on the Pi runner (`docker` label), serialized by `onionwire-ci-pi`. `test`: `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` at the repo root. `sdk`: the same for `crates/onionwire-sdk` (separate cargo workspace — own `Cargo.lock`, root crate by path, `rustls` instead of `native-tls` — so a root signature change cannot silently break the Android SDK). Both run on `main` and PRs when `src/`, `crates/`, `tests/`, `Cargo.toml`, `Cargo.lock`, or this workflow change (ignored Tor-live tests are not run). `workflow_dispatch` always runs the suite.
|
||||||
- [`.forgejo/workflows/android-ci.yml`](.forgejo/workflows/android-ci.yml) — the android side of CI, on the `docker-amd64` runner: builds `:sdk:assembleRelease` + `:app:assembleRelease` with the same script the release uses (`scripts/build-android-local.sh`, Rust for `aarch64-linux-android` via cargo-ndk + UniFFI bindings) and verifies the packaged `libonionwire_sdk.so`, checksums and APK badging. Debug keystore, no publish, no tag. Runs on `main` and PRs when `android/`, `src/`, `crates/`, `Cargo.toml`, `Cargo.lock` or `scripts/build-android-local.sh` change. Same concurrency group **and** the same runner volumes as `android-release.yml`, so a PR build never fights a release build over the SDK/NDK, cargo and Gradle caches.
|
- [`.forgejo/workflows/android-ci.yml`](.forgejo/workflows/android-ci.yml) — the android side of CI, on the `docker-amd64` runner: builds `:sdk:assembleRelease` + `:app:assembleRelease` with the same script the release uses (`scripts/build-android-local.sh`, Rust for `aarch64-linux-android` via cargo-ndk + UniFFI bindings) and verifies the packaged `libonionwire_sdk.so`, checksums and APK badging. Debug keystore, no publish, no tag. Runs on `main` and PRs when `android/`, `src/`, `crates/`, `Cargo.toml`, `Cargo.lock` or `scripts/build-android-local.sh` change. Same concurrency group **and** the same runner volumes as `android-release.yml`, so a PR build never fights a release build over the SDK/NDK, cargo and Gradle caches.
|
||||||
- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — manual, batched release (`workflow_dispatch` only: `dry_run`, `bump`, `version`, `tag`): next tag, aarch64 (`docker`) + x86_64 (`docker-amd64`), one release, fail-closed tag delete on failure. Dispatch [`android-release.yml`](.forgejo/workflows/android-release.yml) with that tag to add the APK + AAR (no automatic trigger fires on this Forgejo; it is `workflow_dispatch` only). Concurrency group `onionwire-ci-pi` (same as `ci.yml`, `cancel-in-progress: false`) so cargo jobs do not overlap on the Pi. Amd64 dind is serialized by runner `capacity=1`.
|
- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — manual, batched release (`workflow_dispatch` only: `dry_run`, `bump`, `version`, `tag`): next tag, aarch64 (`docker`) + x86_64 (`docker-amd64`), one release, fail-closed tag delete on failure. Dispatch [`android-release.yml`](.forgejo/workflows/android-release.yml) with that tag to add the APK + AAR (no automatic trigger fires on this Forgejo; it is `workflow_dispatch` only). Concurrency group `onionwire-ci-pi` (same as `ci.yml`, `cancel-in-progress: false`) so cargo jobs do not overlap on the Pi. Amd64 dind is serialized by runner `capacity=1`.
|
||||||
- [`.forgejo/workflows/android-release.yml`](.forgejo/workflows/android-release.yml) — amd64-only Android build (dispatch-only on this Forgejo; wakes from an explicit `tag=` input, not a tag push).
|
- [`.forgejo/workflows/android-release.yml`](.forgejo/workflows/android-release.yml) — amd64-only Android build (dispatch-only on this Forgejo; wakes from an explicit `tag=` input, not a tag push).
|
||||||
|
|
|
||||||
|
|
@ -130,13 +130,8 @@ fun parseDelivery(direction: String, delivery: String?): Delivery? {
|
||||||
/**
|
/**
|
||||||
* Chat-level delivery summary derived from the rendered rows.
|
* Chat-level delivery summary derived from the rendered rows.
|
||||||
*
|
*
|
||||||
* The *counting* rule mirrors `src/tui.rs::OutboxSummary`: `Queued` + `Sending`
|
* Mirrors `src/tui.rs::OutboxSummary`: `Queued` + `Sending` are "still coming",
|
||||||
* are "still coming", `Failed` is terminal and keeps a fail-closed statement on
|
* `Failed` is terminal and keeps a fail-closed statement on screen.
|
||||||
* screen. The TUI's footer wording for an outstanding row also carries the
|
|
||||||
* reachability statement and retry clock (`peer unreachable, queued (n/8, retry
|
|
||||||
* 45s)`); on Android that per-row detail already lives in the row's own
|
|
||||||
* `queued (try n/8, retry …)` marker (`OutboxDetail.kt`), so the summary stays
|
|
||||||
* the short count form instead of repeating it.
|
|
||||||
*/
|
*/
|
||||||
data class OutboxSummary(
|
data class OutboxSummary(
|
||||||
val queued: Int = 0,
|
val queued: Int = 0,
|
||||||
|
|
|
||||||
1
crates/onionwire-sdk/Cargo.lock
generated
1
crates/onionwire-sdk/Cargo.lock
generated
|
|
@ -2776,7 +2776,6 @@ dependencies = [
|
||||||
"ratatui",
|
"ratatui",
|
||||||
"rpassword",
|
"rpassword",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"rustls",
|
|
||||||
"safelog",
|
"safelog",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,11 @@ description = "OnionWire Android/Kotlin SDK: in-process Arti onion transport, No
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
# Standalone workspace on purpose: the SDK carries its own lockfile and its own
|
# Standalone workspace on purpose.
|
||||||
# crate set (Android: `static-sqlite`, rustls TLS), so it path-depends on the
|
# Arti's TLS backends (`native-tls` vs `rustls`) are non-additive: exactly one
|
||||||
|
# may be enabled per feature resolution. The Linux TUI crate keeps native-tls,
|
||||||
|
# Android has no OpenSSL in the NDK and needs rustls. Two separate workspaces
|
||||||
|
# keep the two resolutions from colliding — this crate path-depends on the
|
||||||
# root package without joining its feature graph.
|
# root package without joining its feature graph.
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ output.
|
||||||
## Why this crate has its own Cargo workspace
|
## Why this crate has its own Cargo workspace
|
||||||
|
|
||||||
Arti's TLS backends are **non-additive**: exactly one of `native-tls` and
|
Arti's TLS backends are **non-additive**: exactly one of `native-tls` and
|
||||||
`rustls` may be enabled in a given feature resolution. The root crate defaults
|
`rustls` may be enabled in a given feature resolution. The Linux TUI keeps
|
||||||
to `rustls` (Linux TUI and releases), so this crate does not differ from the
|
`native-tls` (OpenSSL, as it always has). Android has no OpenSSL in the NDK, so
|
||||||
root on TLS; it does add `static-sqlite`, because Android has no system
|
this crate selects `rustls` plus `static-sqlite` (no system `libsqlite3` on
|
||||||
`libsqlite3`. Two separate workspaces keep the two resolutions from colliding.
|
Android). Two separate workspaces keep the two resolutions from colliding.
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,9 @@ part of a Tor upgrade.
|
||||||
Two crate features re-expose Arti's TLS backends, which Arti marks
|
Two crate features re-expose Arti's TLS backends, which Arti marks
|
||||||
**non-additive** — exactly one may be selected per build graph:
|
**non-additive** — exactly one may be selected per build graph:
|
||||||
|
|
||||||
* `rustls` (**default**) → every build: the Linux TUI, the released binaries and
|
* `native-tls` (default) → Linux TUI build, via OpenSSL.
|
||||||
the Android SDK. No system OpenSSL is needed for TLS; the root `Cargo.toml`
|
* `rustls` → the Android SDK crate (`crates/onionwire-sdk`), because the NDK has
|
||||||
pins rustls's `ring` feature so the crypto provider resolves from crate
|
no OpenSSL.
|
||||||
features (without it the rustls backend compiles with no provider).
|
|
||||||
* `native-tls` → opt-in only, via OpenSSL.
|
|
||||||
|
|
||||||
Published Arti releases move all four crates together in lockstep. Bump them as
|
Published Arti releases move all four crates together in lockstep. Bump them as
|
||||||
**one set**. A mixed set (e.g. `arti-client` 0.47 with `tor-hsservice` 0.46) is
|
**one set**. A mixed set (e.g. `arti-client` 0.47 with `tor-hsservice` 0.46) is
|
||||||
|
|
@ -120,9 +118,8 @@ issue the watcher files.
|
||||||
7. Confirm the fail-closed path by hand if the publish wait changed at all:
|
7. Confirm the fail-closed path by hand if the publish wait changed at all:
|
||||||
with the write timeout still 360s, a peer whose onion is down must fail the
|
with the write timeout still 360s, a peer whose onion is down must fail the
|
||||||
send. There is no outbox in v1 — the message must not be silently queued.
|
send. There is no outbox in v1 — the message must not be silently queued.
|
||||||
8. Rebuild the Android target. The root crate defaults to `rustls` now, so this
|
8. Rebuild the Android target — Arti's TLS backends are non-additive, and this
|
||||||
is less about exercising a non-default feature than about proving the default
|
is the build that exercises the `rustls` feature:
|
||||||
still cross-compiles where OpenSSL does not exist:
|
|
||||||
```
|
```
|
||||||
scripts/build-android-local.sh
|
scripts/build-android-local.sh
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,7 @@ Each install holds:
|
||||||
- **Identity** — ed25519 keypair. The 32-byte public key **is** the person.
|
- **Identity** — ed25519 keypair. The 32-byte public key **is** the person.
|
||||||
Roster primary key. Displayed as 64 lowercase hex chars (the fingerprint).
|
Roster primary key. Displayed as 64 lowercase hex chars (the fingerprint).
|
||||||
- **Prekey** — x25519 keypair. This is the Noise IK *static*. It is long-lived
|
- **Prekey** — x25519 keypair. This is the Noise IK *static*. It is long-lived
|
||||||
in v1 — rotate it with `F8`, which hard-cuts every stored session. Rotating
|
in v1. Rotating the onion (`F4`) does **not** rotate it.
|
||||||
the onion (`F4`) does **not** rotate it.
|
|
||||||
- **Onion** — Tor v3 address. Locator only. Disposable.
|
- **Onion** — Tor v3 address. Locator only. Disposable.
|
||||||
|
|
||||||
A friend is `{identity_pk, current_onion, current_prekey_pk}`. Pasting the same
|
A friend is `{identity_pk, current_onion, current_prekey_pk}`. Pasting the same
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ A signed `loc` frame (`onion`, `ts`, `sig`) rewrites a friend’s locator **only
|
||||||
|
|
||||||
`F4` changes the locator only. The identity key is unchanged. Anyone who already has your pubkey can still prove they are talking to you, and a later invite paste with the same `k` updates their row. To become a new person, `/wipe-all` (new identity key). There is no in-band unfriend/revoke in v1.
|
`F4` changes the locator only. The identity key is unchanged. Anyone who already has your pubkey can still prove they are talking to you, and a later invite paste with the same `k` updates their row. To become a new person, `/wipe-all` (new identity key). There is no in-band unfriend/revoke in v1.
|
||||||
|
|
||||||
## Rotating the prekey is a hard cut, and it is wider than F4
|
|
||||||
|
|
||||||
`F8` rotates the long-lived signed prekey. The identity key and the onion are unchanged, but the prekey is our Noise static **and** the seed of the bootstrap ratchet epoch, so once it moves nothing is reachable any more: a friend's dial uses the prekey they pinned from your invite, and their stored epoch is derived from the old one. There is no push path for a prekey — it only travels inside a signed invite — so every friend, online or offline, has to F3-paste the new invite before chat works in either direction again. F8 therefore also drops the local ratchet state for every friend, exactly as a peer's own prekey change does. Rotating the prekey shrinks the forward-secrecy window of the long-lived static; it is not a revocation (the old invite holder still learns nothing new, but they also cannot talk to you).
|
|
||||||
|
|
||||||
## Your store is encrypted
|
## Your store is encrypted
|
||||||
|
|
||||||
The sqlite store is SQLCipher (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`).
|
The sqlite store is SQLCipher (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`).
|
||||||
|
|
@ -70,16 +66,6 @@ A chat send to an unreachable onion is written to an `outbox` row next to its `m
|
||||||
|
|
||||||
The queue is bounded in scope: chat only. File transfer and `rcp` frames are one-shot, so a failed payment claim does not sit in the store being retried forever.
|
The queue is bounded in scope: chat only. File transfer and `rcp` frames are one-shot, so a failed payment claim does not sit in the store being retried forever.
|
||||||
|
|
||||||
## Reachability: there is no sealed mailbox, and no mutual-online indicator
|
|
||||||
|
|
||||||
**No sealed mailbox.** OnionWire does not implement a server-side message store, a sealed mailbox, or any store-and-forward drop. There is no address a peer can write a message to when you are offline, and nothing that holds a message on your behalf after your device is gone. A mailbox of that kind needs a persistent process that accepts and later replays ciphertext for an absent recipient — exactly the hosted store-and-forward server this threat model rules out (“Tor relays are not a chat server”, “Out of v1”). A sealed box whose key never leaves the user's device is still a server holding the traffic pattern and the ciphertext, and it is still a third party that can be compelled, logged, or silently serve a stale box. That is the design decision, and it is not planned as a follow-up.
|
|
||||||
|
|
||||||
**The chat outbox is local-device retry only.** A message to an unreachable peer is written to the local `outbox` row and re-dialed from this device. It dies with the device: no relay, no friend, no other install ever holds it. Nothing in the outbox is a delivery guarantee.
|
|
||||||
|
|
||||||
**No mutual-online indicator.** OnionWire has no presence, no "peer is online" dot, and no shared online state. Every send is a one-shot Noise IK session to the peer's onion and is closed after one application frame; the peer's availability is only learned from whether *this* dial succeeded. A roster row we have not reached is marked `stale` (from the last connect attempt, `last_connect_ok`) and the footer states the consequence instead of implying presence: `peer unreachable, queued (n/8, retry …)` while an outbox row is outstanding. "They are offline right now" and "they have never been online since my last attempt" are indistinguishable to OnionWire, and the UI does not pretend otherwise.
|
|
||||||
|
|
||||||
**What this costs, stated plainly.** Two devices that are never online at the same time cannot talk, and there is no queue that changes that — the sender's own device is the only queue. Anyone who needs offline delivery must run their own always-on OnionWire install (their own identity, their own onion) to hold the messages, which is a hosted server *they* own and operate, not a service OnionWire provides.
|
|
||||||
|
|
||||||
## Chat is ratcheted on top of the one-shot Noise session
|
## Chat is ratcheted on top of the one-shot Noise session
|
||||||
|
|
||||||
The Noise IK session is still the transport: handshake, **one** application
|
The Noise IK session is still the transport: handshake, **one** application
|
||||||
|
|
@ -132,9 +118,7 @@ device.
|
||||||
- *No one-time prekeys.* The bootstrap epoch uses the long-lived signed prekey
|
- *No one-time prekeys.* The bootstrap epoch uses the long-lived signed prekey
|
||||||
only, so there is no per-session prekey consumption. A peer prekey change
|
only, so there is no per-session prekey consumption. A peer prekey change
|
||||||
drops the state locally and the next chat frame re-bootstraps; there is no
|
drops the state locally and the next chat frame re-bootstraps; there is no
|
||||||
in-band reset and no key confirmation. The same is true of your **own**
|
in-band reset and no key confirmation.
|
||||||
prekey: `F8` rotates it, drops every stored state, and each friend has to
|
|
||||||
re-paste your invite, because a new prekey is never pushed.
|
|
||||||
- *A compromised endpoint is out of scope.* The ratchet state lives in the same
|
- *A compromised endpoint is out of scope.* The ratchet state lives in the same
|
||||||
SQLCipher file as the chat log, under the same passphrase. Anyone who opens
|
SQLCipher file as the chat log, under the same passphrase. Anyone who opens
|
||||||
the store holds the roots, both chain keys, the skipped keys and the plaintext
|
the store holds the roots, both chain keys, the skipped keys and the plaintext
|
||||||
|
|
@ -250,8 +234,7 @@ the peer already knows the plaintext they sent.
|
||||||
|
|
||||||
## Out of v1
|
## Out of v1
|
||||||
|
|
||||||
Prosody, XMPP, s2s, MAM, carbons, a **sealed mailbox**, a **server-side**
|
Prosody, XMPP, s2s, MAM, carbons, a **server-side** outbox / store-and-forward
|
||||||
outbox / store-and-forward relay, multi-device, DHT / name server, A/V. The
|
relay, multi-device, DHT / name server, A/V. The local retry queue of the
|
||||||
local retry queue of the previous section is not an outbox in the XMPP sense: it
|
previous section is not an outbox in the XMPP sense: it never leaves the device.
|
||||||
never leaves the device, and it is not a mailbox either — see “Reachability”.
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
# Ratchet wire format — frozen at v1
|
|
||||||
|
|
||||||
Status: **frozen**. A change to the persisted ratchet state layout, or to the
|
|
||||||
`rat ` frame layout, is a wire-format break and needs a migration path (see
|
|
||||||
"Changing the format" below). The guard tests that enforce this live in
|
|
||||||
`tests/ratchet.rs`:
|
|
||||||
|
|
||||||
- `ratchet_state_blob_is_frozen_at_version_v1`
|
|
||||||
- `ratchet_state_foreign_version_is_rejected_not_misread`
|
|
||||||
|
|
||||||
Both are written to fail visibly on a version bump or a field insertion:
|
|
||||||
they assert the literal byte `0x01` and the literal 210-byte prefix length,
|
|
||||||
not the `STATE_VERSION` constant, so a bump cannot quietly follow them.
|
|
||||||
|
|
||||||
## Persisted state (`ratchet_sessions.state`)
|
|
||||||
|
|
||||||
Written by `RatchetState::to_bytes`, read by `RatchetState::from_bytes`
|
|
||||||
(`src/ratchet.rs`). The store treats the blob as opaque
|
|
||||||
(`Store::load_ratchet` / `Store::save_ratchet`, `src/store.rs`; the row is
|
|
||||||
`ratchet_sessions(state BLOB NOT NULL)` keyed by `friend_id`). There is no
|
|
||||||
public `decode_state` function in the crate: the persisted blob is decoded by
|
|
||||||
`RatchetState::from_bytes`, reached from `ratchet_for` in `src/node.rs`, and
|
|
||||||
the resulting version error is reported as `Error::UnsupportedStateVersion`.
|
|
||||||
|
|
||||||
Layout — version `0x01`:
|
|
||||||
|
|
||||||
```
|
|
||||||
0 version byte 0x01 (STATE_VERSION)
|
|
||||||
1..33 root_key
|
|
||||||
33..65 local ratchet secret
|
|
||||||
65..97 local ratchet public
|
|
||||||
97..129 remote ratchet public
|
|
||||||
129..161 sending chain key
|
|
||||||
161..165 send_n u32 BE
|
|
||||||
165..197 receiving chain key
|
|
||||||
197..201 recv_n u32 BE
|
|
||||||
201..205 prev_send_len u32 BE
|
|
||||||
205 established (0 or 1)
|
|
||||||
206..210 skipped-key count u32 BE
|
|
||||||
210.. per skipped key, in insertion order: dh_pub[32] || n u32 BE || key[32]
|
|
||||||
```
|
|
||||||
|
|
||||||
The fixed prefix is **210 bytes** (pinned as `STATE_PREFIX_LEN` in the test);
|
|
||||||
the skipped-key tail is `68` bytes per key, capped at `MAX_SKIPPED_KEYS`
|
|
||||||
(2000). The blob contains secret key material — the caller owns wiping it.
|
|
||||||
|
|
||||||
`from_bytes` is fail-closed on every malformed input it can see: a foreign
|
|
||||||
version byte returns `Error::UnsupportedStateVersion(byte)` *before* any field
|
|
||||||
is read, so a blob from another version is never decoded under the v1 layout;
|
|
||||||
empty, truncated, trailing-byte, bad-`established`-flag, bad skipped-count and
|
|
||||||
secret-does-not-match-its-public-key inputs return `Error::BadState(&str)`.
|
|
||||||
None of them panic or partially apply.
|
|
||||||
|
|
||||||
## Frames (`rat ` chat frames)
|
|
||||||
|
|
||||||
Written by `RatchetState::encrypt`, parsed by `Frame::parse`
|
|
||||||
(`src/ratchet.rs`). Framing constants: `FRAME_PREFIX = b"rat "`,
|
|
||||||
`FRAME_VERSION = 0x01`, `HEADER_LEN = 40`, `HEADER_OFFSET = 5`.
|
|
||||||
|
|
||||||
```
|
|
||||||
0..4 b"rat "
|
|
||||||
4 version byte 0x01 (FRAME_VERSION)
|
|
||||||
5..45 header: dh_pub[32] || N u32 BE || PN u32 BE
|
|
||||||
45..57 nonce[12]
|
|
||||||
57.. ciphertext || Poly1305 tag[16] (ChaCha20-Poly1305)
|
|
||||||
```
|
|
||||||
|
|
||||||
The 40-byte header is also the AEAD associated data, so any header edit fails
|
|
||||||
authentication rather than being silently ignored. `Frame::parse` checks the
|
|
||||||
prefix, then the minimum length (`HEADER_OFFSET + HEADER_LEN + 12 + 16 = 73`),
|
|
||||||
then the version byte; a sub-73-byte frame is a length error whatever its
|
|
||||||
version byte says, and a frame of 73 bytes or more with a foreign version is a
|
|
||||||
version error. Rejected frames leave the state byte-identical.
|
|
||||||
|
|
||||||
## Changing the format
|
|
||||||
|
|
||||||
There is **no migration code today**, and a version bump must not silently
|
|
||||||
re-bootstrap a session: replacing an unreadable stored session with a fresh
|
|
||||||
bootstrap produces traffic the peer cannot decrypt and loses the established
|
|
||||||
epoch. The required shape for a v2 is:
|
|
||||||
|
|
||||||
1. Bump `STATE_VERSION` and make `from_bytes` keep the v1 decoder reachable
|
|
||||||
(match on the version byte, decode old blobs with the old layout, then
|
|
||||||
re-serialize as v2).
|
|
||||||
2. Do **not** let an older build read a newer blob: it must keep rejecting
|
|
||||||
anything that is not its own version with `UnsupportedStateVersion`, never
|
|
||||||
decode it under the old layout. That is what the current code does, and it
|
|
||||||
is why only the *newer* build may convert a blob in place.
|
|
||||||
3. Surface the refusal to the user. Today the message only reaches a log:
|
|
||||||
an outbound `Node::send` fails closed with `Err(String)`
|
|
||||||
(`ratchet state: unsupported ratchet state version N`, from
|
|
||||||
`ratchet_for`), and an inbound frame is dropped with
|
|
||||||
`eprintln!("rat dropped ({e})")` in `Node::handle_incoming`'s
|
|
||||||
`Kind::Ratchet` arm. There is no dialog and no automatic recovery; a v2
|
|
||||||
must add the user-visible message rather than rely on stderr.
|
|
||||||
4. Keep the freeze tests green only by updating the pinned literals in
|
|
||||||
`tests/ratchet.rs` *and* the layout docs in this file in the same change.
|
|
||||||
|
|
||||||
An additive change with no version bump is not an option: the skipped-key tail
|
|
||||||
is read by count, so appending a field changes what the tail means for every
|
|
||||||
stored blob.
|
|
||||||
|
|
@ -18,8 +18,7 @@ chmod +x onionwire-x86_64-unknown-linux-gnu
|
||||||
./onionwire-<target> --version
|
./onionwire-<target> --version
|
||||||
```
|
```
|
||||||
|
|
||||||
Keep the asset filenames so `sha256sum -c` matches. The TLS stack is rustls and
|
Keep the asset filenames so `sha256sum -c` matches. Both binaries link OpenSSL 3
|
||||||
OpenSSL (for SQLCipher) is compiled in from vendored sources, so the binaries
|
dynamically (`libssl.so.3`), which is standard on Debian 12+/Ubuntu 24.04+.
|
||||||
have no dynamic `libssl` dependency.
|
|
||||||
|
|
||||||
Building from source is covered in the README install guide.
|
Building from source is covered in the README install guide.
|
||||||
|
|
|
||||||
79
src/node.rs
79
src/node.rs
|
|
@ -8,7 +8,6 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use futures::io::{AsyncRead, AsyncWrite};
|
use futures::io::{AsyncRead, AsyncWrite};
|
||||||
use hkdf::Hkdf;
|
use hkdf::Hkdf;
|
||||||
use rand::rngs::OsRng;
|
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
use tor_cell::relaycell::msg::Connected;
|
use tor_cell::relaycell::msg::Connected;
|
||||||
use tor_hsservice::{RunningOnionService, handle_rend_requests};
|
use tor_hsservice::{RunningOnionService, handle_rend_requests};
|
||||||
|
|
@ -881,34 +880,6 @@ impl Node {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rotate the long-lived signed prekey (F8). Hard cut, like the locator
|
|
||||||
/// rotate: the prekey is our Noise static and the bootstrap ratchet epoch is
|
|
||||||
/// derived from the prekey DH, so every stored session is dead the moment
|
|
||||||
/// this returns and every friend has to F3-paste the new invite. Nothing is
|
|
||||||
/// pushed to peers — a new prekey only travels inside a signed invite. The
|
|
||||||
/// identity key (and therefore the fingerprint) does not move; the caller
|
|
||||||
/// re-encodes the F2 invite around the returned pubkey.
|
|
||||||
pub fn rotate_prekey(&self) -> Result<[u8; 32], String> {
|
|
||||||
let mut k = self.keys()?;
|
|
||||||
let sk = StaticSecret::random_from_rng(OsRng);
|
|
||||||
let pk = X25519Public::from(&sk).to_bytes();
|
|
||||||
{
|
|
||||||
let store = self.store.lock().map_err(|e| e.to_string())?;
|
|
||||||
// `replace_identity_keys` rewrites the prekey columns too; the
|
|
||||||
// identity values passed back are the ones already stored.
|
|
||||||
store
|
|
||||||
.replace_identity_keys(&k.identity_sk, &k.identity_pk, &sk.to_bytes(), &pk)
|
|
||||||
.map_err(|e| e.to_string())?;
|
|
||||||
for f in store.list_friends().map_err(|e| e.to_string())? {
|
|
||||||
store.clear_ratchet(&f.pubkey).map_err(|e| e.to_string())?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
k.prekey_sk = sk.to_bytes();
|
|
||||||
k.prekey_pk = pk;
|
|
||||||
*self.keys.lock().map_err(|e| e.to_string())? = k;
|
|
||||||
Ok(pk)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// One-shot file to a friend. Fail closed; no outbox, no resume.
|
/// One-shot file to a friend. Fail closed; no outbox, no resume.
|
||||||
/// Chunks are paced (`file::CHUNK_PACE`) with bounded per-chunk retry so
|
/// Chunks are paced (`file::CHUNK_PACE`) with bounded per-chunk retry so
|
||||||
/// a 1 MiB transfer fits the receiver's rendezvous token bucket.
|
/// a 1 MiB transfer fits the receiver's rendezvous token bucket.
|
||||||
|
|
@ -1856,56 +1827,6 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// F8: rotate the long-lived signed prekey. The identity must not move, the
|
|
||||||
/// stored/dialed prekey must, every prekey-bound ratchet epoch must be
|
|
||||||
/// dropped, and the F2 invite must be re-encodable around the new prekey.
|
|
||||||
#[tokio::test]
|
|
||||||
async fn rotating_the_prekey_keeps_identity_and_drops_stale_ratchet_state() {
|
|
||||||
let dir = tempfile::tempdir().unwrap();
|
|
||||||
let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial));
|
|
||||||
let peer = Keys::generate();
|
|
||||||
let old_identity = node.identity_pk();
|
|
||||||
let old_prekey = node_prekey(&node);
|
|
||||||
*node.onion.lock().unwrap() = format!("{}.onion", "a".repeat(56));
|
|
||||||
{
|
|
||||||
let store = node.store.lock().unwrap();
|
|
||||||
befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion");
|
|
||||||
store
|
|
||||||
.save_ratchet(&peer.identity_pk, b"epoch-bound-to-the-old-prekey")
|
|
||||||
.expect("seed ratchet state");
|
|
||||||
}
|
|
||||||
|
|
||||||
let new_prekey = node.rotate_prekey().expect("rotate prekey");
|
|
||||||
|
|
||||||
assert_ne!(new_prekey, old_prekey, "the prekey must actually change");
|
|
||||||
assert_eq!(node_prekey(&node), new_prekey, "the live keys follow");
|
|
||||||
assert_eq!(
|
|
||||||
node.identity_pk(),
|
|
||||||
old_identity,
|
|
||||||
"identity = pubkey, it stays"
|
|
||||||
);
|
|
||||||
{
|
|
||||||
let store = node.store.lock().unwrap();
|
|
||||||
assert_eq!(
|
|
||||||
store.self_identity().unwrap().prekey_pk,
|
|
||||||
new_prekey.to_vec(),
|
|
||||||
"the self row carries the new prekey"
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
store.load_ratchet(&peer.identity_pk).unwrap().is_none(),
|
|
||||||
"the bootstrap epoch is prekey-bound, so the stored state is stale"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let payload = qr::decode(&node.qr_payload().expect("re-encode the invite"))
|
|
||||||
.expect("the re-encoded invite decodes");
|
|
||||||
assert_eq!(payload.signed_prekey, new_prekey.to_vec());
|
|
||||||
assert_eq!(
|
|
||||||
payload.pubkey,
|
|
||||||
old_identity.to_vec(),
|
|
||||||
"the new invite still names the same identity"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An outbound tip must be recorded as a *tip*. The receipt row is the
|
/// An outbound tip must be recorded as a *tip*. The receipt row is the
|
||||||
/// recipient's view of a receipt frame; for money the user just spent the
|
/// recipient's view of a receipt frame; for money the user just spent the
|
||||||
/// wallet history wants the tip they paid. `ingest_tip` already stores
|
/// wallet history wants the tip they paid. `ingest_tip` already stores
|
||||||
|
|
|
||||||
97
src/tui.rs
97
src/tui.rs
|
|
@ -204,22 +204,11 @@ pub struct OutboxSummary {
|
||||||
pub failed: usize,
|
pub failed: usize,
|
||||||
/// First terminal failure, for the fail-closed footer copy.
|
/// First terminal failure, for the fail-closed footer copy.
|
||||||
pub first_error: Option<String>,
|
pub first_error: Option<String>,
|
||||||
/// Highest attempt count across outstanding rows (0 when nothing is
|
|
||||||
/// outstanding). With `DEFAULT_MAX_ATTEMPTS` this is the `n` in `(n/8)`.
|
|
||||||
pub attempts: u32,
|
|
||||||
/// Seconds until the earliest scheduled retry, relative to the render
|
|
||||||
/// `now`. `None` while nothing is outstanding.
|
|
||||||
pub next_in_secs: Option<i64>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutboxSummary {
|
impl OutboxSummary {
|
||||||
/// Footer note, or `None` when nothing is outstanding. Any terminal failure
|
/// Footer note, or `None` when nothing is outstanding. Any terminal failure
|
||||||
/// keeps a `send failed` statement so the fail-closed copy stays visible.
|
/// keeps a `send failed` statement so the fail-closed copy stays visible.
|
||||||
///
|
|
||||||
/// An outstanding row is a reachability statement, not just a count: the
|
|
||||||
/// peer's onion did not answer *this* dial, so the note names that and the
|
|
||||||
/// retry it is waiting on (`peer unreachable, queued (n/8, retry 45s)`).
|
|
||||||
/// There is no mutual-online indicator to fall back on.
|
|
||||||
pub fn note(&self) -> Option<String> {
|
pub fn note(&self) -> Option<String> {
|
||||||
let reason = || {
|
let reason = || {
|
||||||
short_send_reason(
|
short_send_reason(
|
||||||
|
|
@ -227,19 +216,12 @@ impl OutboxSummary {
|
||||||
FAIL_REASON_BUDGET,
|
FAIL_REASON_BUDGET,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
let queued = || {
|
|
||||||
format!(
|
|
||||||
"peer unreachable, queued ({}/{DEFAULT_MAX_ATTEMPTS}, {})",
|
|
||||||
self.attempts,
|
|
||||||
retry_in_text(self.next_in_secs.unwrap_or(0))
|
|
||||||
)
|
|
||||||
};
|
|
||||||
match (self.queued, self.failed) {
|
match (self.queued, self.failed) {
|
||||||
(0, 0) => None,
|
(0, 0) => None,
|
||||||
|
(queued, 0) => Some(format!("{queued} queued")),
|
||||||
(0, 1) => Some(format!("send failed: {}", reason())),
|
(0, 1) => Some(format!("send failed: {}", reason())),
|
||||||
(0, failed) => Some(format!("send failed: {} ({failed} failed)", reason())),
|
(0, failed) => Some(format!("send failed: {} ({failed} failed)", reason())),
|
||||||
(_, 0) => Some(queued()),
|
(queued, _) => Some(format!("{queued} queued, send failed: {}", reason())),
|
||||||
(_, _) => Some(format!("{}, send failed: {}", queued(), reason())),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -262,17 +244,7 @@ pub fn chat_with_delivery(
|
||||||
summary.failed += 1;
|
summary.failed += 1;
|
||||||
summary.first_error.get_or_insert_with(|| why.clone());
|
summary.first_error.get_or_insert_with(|| why.clone());
|
||||||
}
|
}
|
||||||
_ => {
|
_ => summary.queued += 1,
|
||||||
summary.queued += 1;
|
|
||||||
// The note is the reachability statement for the selected
|
|
||||||
// friend: highest attempt count, soonest scheduled retry.
|
|
||||||
summary.attempts = summary.attempts.max(entry.attempts);
|
|
||||||
let secs = entry.next_attempt_at - now;
|
|
||||||
summary.next_in_secs = Some(match summary.next_in_secs {
|
|
||||||
Some(prev) => prev.min(secs),
|
|
||||||
None => secs,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if msgs.is_empty() {
|
if msgs.is_empty() {
|
||||||
|
|
@ -491,17 +463,6 @@ Offline friends CANNOT find you until they F3-paste your new invite.\n\
|
||||||
Type ROTATE to confirm Esc to cancel"
|
Type ROTATE to confirm Esc to cancel"
|
||||||
}
|
}
|
||||||
|
|
||||||
/// F8. Hard cut like the locator rotate: the prekey is our Noise static and the
|
|
||||||
/// ratchet bootstrap is derived from the prekey DH, so nothing short of a fresh
|
|
||||||
/// invite re-syncs a friend.
|
|
||||||
pub fn prekey_screen_text() -> &'static str {
|
|
||||||
"Rotate prekey?\n\
|
|
||||||
Your identity and onion stay the same.\n\
|
|
||||||
Every friend must F3-paste your new invite to pick up the new prekey,\n\
|
|
||||||
or you cannot reach them and they cannot reach you.\n\
|
|
||||||
Type ROTATE to confirm Esc to cancel"
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn quit_screen_text() -> &'static str {
|
pub fn quit_screen_text() -> &'static str {
|
||||||
"Quit OnionWire?\n\
|
"Quit OnionWire?\n\
|
||||||
Message history can be cleared; identity and friends stay.\n\
|
Message history can be cleared; identity and friends stay.\n\
|
||||||
|
|
@ -546,7 +507,6 @@ OnionWire keys\n\
|
||||||
F4 rotate onion locator\n\
|
F4 rotate onion locator\n\
|
||||||
F5 selected friend's profile (/who)\n\
|
F5 selected friend's profile (/who)\n\
|
||||||
F6 wallet (receive QR, create/import)\n\
|
F6 wallet (receive QR, create/import)\n\
|
||||||
F8 rotate prekey\n\
|
|
||||||
/profile edit name, bio, Monero address\n\
|
/profile edit name, bio, Monero address\n\
|
||||||
/pay <xmr> [memo] invoice to receive\n\
|
/pay <xmr> [memo] invoice to receive\n\
|
||||||
/tip <xmr> [memo] pay selected friend\n\
|
/tip <xmr> [memo] pay selected friend\n\
|
||||||
|
|
@ -1197,9 +1157,6 @@ enum Screen {
|
||||||
Rotate {
|
Rotate {
|
||||||
prompt: RotatePrompt,
|
prompt: RotatePrompt,
|
||||||
},
|
},
|
||||||
RotatePrekey {
|
|
||||||
prompt: RotatePrompt,
|
|
||||||
},
|
|
||||||
Wipe {
|
Wipe {
|
||||||
kind: WipeKind,
|
kind: WipeKind,
|
||||||
prompt: WipePrompt,
|
prompt: WipePrompt,
|
||||||
|
|
@ -1339,11 +1296,6 @@ impl App {
|
||||||
}
|
}
|
||||||
KeyCode::F(5) => self.who_open = true,
|
KeyCode::F(5) => self.who_open = true,
|
||||||
KeyCode::F(6) => self.open_wallet()?,
|
KeyCode::F(6) => self.open_wallet()?,
|
||||||
KeyCode::F(8) => {
|
|
||||||
self.screen = Screen::RotatePrekey {
|
|
||||||
prompt: RotatePrompt::new(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
KeyCode::Esc => self.composer.clear(),
|
KeyCode::Esc => self.composer.clear(),
|
||||||
KeyCode::Backspace => {
|
KeyCode::Backspace => {
|
||||||
if self.focus == Pane::Composer {
|
if self.focus == Pane::Composer {
|
||||||
|
|
@ -1463,18 +1415,6 @@ impl App {
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Screen::RotatePrekey { prompt } => match key.code {
|
|
||||||
KeyCode::Esc => self.screen = Screen::Main,
|
|
||||||
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
|
||||||
if prompt.on_char(c) == RotateDecision::Confirm {
|
|
||||||
self.confirm_rotate_prekey()?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
KeyCode::Backspace => {
|
|
||||||
prompt.on_char('\u{8}');
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
},
|
|
||||||
Screen::Wipe { kind, prompt } => {
|
Screen::Wipe { kind, prompt } => {
|
||||||
let kind = *kind;
|
let kind = *kind;
|
||||||
match key.code {
|
match key.code {
|
||||||
|
|
@ -1747,24 +1687,6 @@ impl App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// F8. Local and synchronous: nothing is pushed to peers — the new prekey
|
|
||||||
/// only travels inside a fresh signed invite — so the screen goes straight
|
|
||||||
/// to that invite (the F2 share path) for the user to hand out.
|
|
||||||
fn confirm_rotate_prekey(&mut self) -> Result<(), String> {
|
|
||||||
match self.node.rotate_prekey() {
|
|
||||||
Ok(_) => {
|
|
||||||
self.status_note =
|
|
||||||
Some("prekey rotated · friends must F3-paste your new invite".into());
|
|
||||||
self.open_share()
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
self.alert = Some(e);
|
|
||||||
self.screen = Screen::Main;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn open_share(&mut self) -> Result<(), String> {
|
fn open_share(&mut self) -> Result<(), String> {
|
||||||
let payload = self.node.qr_payload()?;
|
let payload = self.node.qr_payload()?;
|
||||||
self.screen = Screen::Share { payload };
|
self.screen = Screen::Share { payload };
|
||||||
|
|
@ -2142,7 +2064,6 @@ impl App {
|
||||||
Screen::Paste { buf, err } => draw_paste(f, buf, err.as_deref()),
|
Screen::Paste { buf, err } => draw_paste(f, buf, err.as_deref()),
|
||||||
Screen::Approve { payload } => draw_approve(f, payload),
|
Screen::Approve { payload } => draw_approve(f, payload),
|
||||||
Screen::Rotate { prompt } => draw_rotate(f, prompt.typed()),
|
Screen::Rotate { prompt } => draw_rotate(f, prompt.typed()),
|
||||||
Screen::RotatePrekey { prompt } => draw_rotate_prekey(f, prompt.typed()),
|
|
||||||
Screen::Wipe { kind, prompt } => draw_wipe(f, *kind, prompt.typed()),
|
Screen::Wipe { kind, prompt } => draw_wipe(f, *kind, prompt.typed()),
|
||||||
Screen::Profile { editor } => draw_profile(f, editor),
|
Screen::Profile { editor } => draw_profile(f, editor),
|
||||||
Screen::ConfirmKeys { kind, prompt, .. } => draw_confirm_keys(f, *kind, prompt.typed()),
|
Screen::ConfirmKeys { kind, prompt, .. } => draw_confirm_keys(f, *kind, prompt.typed()),
|
||||||
|
|
@ -2461,7 +2382,6 @@ match screen {
|
||||||
Screen::Paste { .. } => "Enter submit Esc back ? help",
|
Screen::Paste { .. } => "Enter submit Esc back ? help",
|
||||||
Screen::Approve { .. } => "y accept n reject ? help",
|
Screen::Approve { .. } => "y accept n reject ? help",
|
||||||
Screen::Rotate { .. } => "type ROTATE Esc cancel ? help",
|
Screen::Rotate { .. } => "type ROTATE Esc cancel ? help",
|
||||||
Screen::RotatePrekey { .. } => "type ROTATE Esc cancel ? help",
|
|
||||||
Screen::Wipe { kind, .. } => match kind {
|
Screen::Wipe { kind, .. } => match kind {
|
||||||
WipeKind::Messages => "type WIPE Esc cancel ? help",
|
WipeKind::Messages => "type WIPE Esc cancel ? help",
|
||||||
WipeKind::All => "type WIPEALL Esc cancel ? help",
|
WipeKind::All => "type WIPEALL Esc cancel ? help",
|
||||||
|
|
@ -2562,17 +2482,6 @@ fn draw_rotate(f: &mut Frame, typed: &str) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_rotate_prekey(f: &mut Frame, typed: &str) {
|
|
||||||
let body = format!("{}\n\n{typed}", prekey_screen_text());
|
|
||||||
f.render_widget(
|
|
||||||
Paragraph::new(body)
|
|
||||||
.style(style_text())
|
|
||||||
.wrap(Wrap { trim: false })
|
|
||||||
.block(themed_block("(o) rotate prekey")),
|
|
||||||
f.area(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_wipe(f: &mut Frame, kind: WipeKind, typed: &str) {
|
fn draw_wipe(f: &mut Frame, kind: WipeKind, typed: &str) {
|
||||||
let title = match kind {
|
let title = match kind {
|
||||||
WipeKind::Messages => "(o) wipe",
|
WipeKind::Messages => "(o) wipe",
|
||||||
|
|
|
||||||
199
tests/ratchet.rs
199
tests/ratchet.rs
|
|
@ -147,130 +147,6 @@ fn round_trip_across_two_dh_ratchet_steps() {
|
||||||
assert_eq!(a.decrypt(&m4).expect("decrypt m4"), b"m4");
|
assert_eq!(a.decrypt(&m4).expect("decrypt m4"), b"m4");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The ratchet key a frame advertises: `dh_pub[0..32]` of the header.
|
|
||||||
fn dh_pub(frame: &[u8]) -> [u8; 32] {
|
|
||||||
header_at(frame)[..32].try_into().expect("32")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Lockstep on a bidirectional burst: every frame after a peer has stepped
|
|
||||||
/// carries the key that peer is now sending with, and the receiver *adopts
|
|
||||||
/// exactly that key* before its sending chain rekeys.
|
|
||||||
///
|
|
||||||
/// `round_trip_across_two_dh_ratchet_steps` only asserts that neither sending
|
|
||||||
/// ratchet stayed put; it would still pass if the two sides stepped onto
|
|
||||||
/// unconnected epochs, and it never checks that either side adopted the key the
|
|
||||||
/// other advertised. This test reads the key out of the wire header and asserts
|
|
||||||
/// the adoption, per step, on a burst in both directions.
|
|
||||||
///
|
|
||||||
/// The bootstrap tie-break means one A→B/B→A round cannot step both sides: only
|
|
||||||
/// the lower-key peer rotates its sending chain on establishment, and the other
|
|
||||||
/// peer has still only ever seen bootstrap keys. The burst therefore drives the
|
|
||||||
/// second and third rounds, and pins the intermediate state at each one.
|
|
||||||
#[test]
|
|
||||||
fn bidirectional_burst_keeps_the_dh_ratchet_in_lockstep() {
|
|
||||||
let (mut a, mut b) = peers();
|
|
||||||
let (a0, b0) = (a.public(), b.public());
|
|
||||||
assert_eq!(a.remote_pub(), b0, "a starts keyed to b's bootstrap key");
|
|
||||||
assert_eq!(b.remote_pub(), a0, "b starts keyed to a's bootstrap key");
|
|
||||||
|
|
||||||
// Round 1 — A→B then B→A. Only a rotates here (it sorts lower).
|
|
||||||
let m1 = a.encrypt(b"a/1").expect("encrypt");
|
|
||||||
assert_eq!(
|
|
||||||
dh_pub(&m1),
|
|
||||||
a0,
|
|
||||||
"a's first frame advertises its bootstrap key"
|
|
||||||
);
|
|
||||||
assert_eq!(b.decrypt(&m1).expect("b decrypts a/1"), b"a/1");
|
|
||||||
assert_eq!(b.public(), b0, "b has no new key to adopt yet");
|
|
||||||
assert_eq!(b.remote_pub(), a0);
|
|
||||||
|
|
||||||
let m2 = b.encrypt(b"b/1").expect("encrypt");
|
|
||||||
assert_eq!(
|
|
||||||
dh_pub(&m2),
|
|
||||||
b0,
|
|
||||||
"b's first frame advertises its bootstrap key"
|
|
||||||
);
|
|
||||||
assert_eq!(a.decrypt(&m2).expect("a decrypts b/1"), b"b/1");
|
|
||||||
let a1 = a.public();
|
|
||||||
assert_ne!(a1, a0, "round 1 must rotate a's sending ratchet key");
|
|
||||||
assert_eq!(a.remote_pub(), b0, "a is keyed to the key b advertised");
|
|
||||||
|
|
||||||
// Round 2 — a's fresh key reaches b, which is the step the one-round
|
|
||||||
// exchange never takes.
|
|
||||||
let m3 = a.encrypt(b"a/2").expect("encrypt");
|
|
||||||
assert_eq!(dh_pub(&m3), a1, "a advertises the key it just ratcheted to");
|
|
||||||
assert_eq!(b.decrypt(&m3).expect("b decrypts a/2"), b"a/2");
|
|
||||||
let b1 = b.public();
|
|
||||||
assert_ne!(b1, b0, "b must DH-ratchet on a's new key");
|
|
||||||
assert_eq!(b.remote_pub(), a1, "b adopted exactly the key a advertised");
|
|
||||||
|
|
||||||
// Round 3 — the mirror image: b's fresh key reaches a.
|
|
||||||
let m4 = b.encrypt(b"b/2").expect("encrypt");
|
|
||||||
assert_eq!(dh_pub(&m4), b1, "b advertises the key it just ratcheted to");
|
|
||||||
assert_eq!(a.decrypt(&m4).expect("a decrypts b/2"), b"b/2");
|
|
||||||
let a2 = a.public();
|
|
||||||
assert_ne!(a2, a1, "a stepped onto a fresh key of its own");
|
|
||||||
assert_eq!(a.remote_pub(), b1, "a adopted exactly the key b advertised");
|
|
||||||
|
|
||||||
// The burst proper: three frames each way on the epoch both sides now hold.
|
|
||||||
let to_b: Vec<Vec<u8>> = (0..3)
|
|
||||||
.map(|i| {
|
|
||||||
a.encrypt(format!("a/burst{i}").as_bytes())
|
|
||||||
.expect("encrypt")
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
for frame in &to_b {
|
|
||||||
assert_eq!(dh_pub(frame), a2, "the burst stays on a's current key");
|
|
||||||
}
|
|
||||||
for (i, frame) in to_b.iter().enumerate() {
|
|
||||||
assert_eq!(
|
|
||||||
b.decrypt(frame).expect("burst a→b"),
|
|
||||||
format!("a/burst{i}").as_bytes()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let b2 = b.public();
|
|
||||||
assert_ne!(
|
|
||||||
b2, b1,
|
|
||||||
"b's first burst frame is a full step, not a chain read"
|
|
||||||
);
|
|
||||||
assert_eq!(b.remote_pub(), a2, "b adopted a's burst key");
|
|
||||||
assert_eq!(b.recv_index(), 3, "all three burst frames were consumed");
|
|
||||||
assert_eq!(b.skipped_len(), 0, "in-order burst skipped nothing");
|
|
||||||
|
|
||||||
let to_a: Vec<Vec<u8>> = (0..3)
|
|
||||||
.map(|i| {
|
|
||||||
b.encrypt(format!("b/burst{i}").as_bytes())
|
|
||||||
.expect("encrypt")
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
for frame in &to_a {
|
|
||||||
assert_eq!(dh_pub(frame), b2, "the burst stays on b's current key");
|
|
||||||
}
|
|
||||||
for (i, frame) in to_a.iter().enumerate() {
|
|
||||||
assert_eq!(
|
|
||||||
a.decrypt(frame).expect("burst b→a"),
|
|
||||||
format!("b/burst{i}").as_bytes()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lockstep after the burst: the peer that received last is keyed to the
|
|
||||||
// other's *current* key, and the sender's own key is the one its burst
|
|
||||||
// advertised. (b's view of a is a2 — a's step generated a3, which has not
|
|
||||||
// been sent yet; that lag is the ratchet's normal one-header asymmetry.)
|
|
||||||
assert_eq!(a.remote_pub(), b2);
|
|
||||||
assert_eq!(a.remote_pub(), b.public(), "a is keyed to b's current key");
|
|
||||||
assert_eq!(b.remote_pub(), a2, "b is keyed to a's last advertised key");
|
|
||||||
assert_ne!(a.public(), a2, "a stepped again on b's burst");
|
|
||||||
assert_ne!(a.public(), a0, "a never ratcheted across the whole burst");
|
|
||||||
assert_ne!(b.public(), b0, "b never ratcheted across the whole burst");
|
|
||||||
assert_eq!(a.skipped_len(), 0);
|
|
||||||
assert_eq!(a.recv_index(), 3);
|
|
||||||
|
|
||||||
// And the conversation still flows on the epoch the burst left behind.
|
|
||||||
let after = a.encrypt(b"a/after").expect("encrypt");
|
|
||||||
assert_eq!(b.decrypt(&after).expect("a/after"), b"a/after");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn out_of_order_within_one_chain() {
|
fn out_of_order_within_one_chain() {
|
||||||
let (mut a, mut b) = peers();
|
let (mut a, mut b) = peers();
|
||||||
|
|
@ -496,81 +372,6 @@ fn state_round_trips_and_rejects_garbage() {
|
||||||
assert!(RatchetState::from_bytes(&huge_count).is_err());
|
assert!(RatchetState::from_bytes(&huge_count).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fixed size of a v1 state blob's prefix: the version byte, the root key, the
|
|
||||||
/// local secret and public, the remote public, both chain keys, both counters,
|
|
||||||
/// `prev_send_len`, the established flag and the skipped-key count.
|
|
||||||
/// Documented in `src/ratchet.rs`'s `to_bytes` layout.
|
|
||||||
const STATE_PREFIX_LEN: usize = 1 + 32 + 32 + 32 + 32 + 32 + 4 + 32 + 4 + 4 + 1 + 4;
|
|
||||||
|
|
||||||
/// Freeze guard for the persisted wire format. A stored session is only
|
|
||||||
/// meaningful if both sides agree byte for byte on the layout, so a version
|
|
||||||
/// bump or a field insertion must break this test on purpose.
|
|
||||||
///
|
|
||||||
/// `0x01` is asserted as a literal: asserting `STATE_VERSION` would silently
|
|
||||||
/// follow a bump instead of catching it, which is the whole point of the
|
|
||||||
/// guard.
|
|
||||||
#[test]
|
|
||||||
fn ratchet_state_blob_is_frozen_at_version_v1() {
|
|
||||||
let local = RatchetKeyPair::from_secret([0x11u8; 32]);
|
|
||||||
let remote = RatchetKeyPair::from_secret([0x22u8; 32]);
|
|
||||||
let state = RatchetState::bootstrap(ROOT, local, remote.public());
|
|
||||||
let bytes = state.to_bytes();
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
STATE_VERSION, 1,
|
|
||||||
"the frozen version byte changed: this is a wire-format break, not a refactor"
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
bytes[0], 0x01,
|
|
||||||
"a state blob must start with the v1 version byte"
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
bytes.len(),
|
|
||||||
STATE_PREFIX_LEN,
|
|
||||||
"the fixed part of the v1 layout changed (a field was added, removed or resized)"
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
bytes.len(),
|
|
||||||
210,
|
|
||||||
"the documented v1 prefix is 210 bytes; a different number means the \
|
|
||||||
format moved and stored sessions need a migration path"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A blob written by another version must come back as a typed
|
|
||||||
/// `UnsupportedStateVersion`, never as a panic and never as a state decoded
|
|
||||||
/// under the wrong layout. The guard must also not be over-eager: the
|
|
||||||
/// untouched v1 blob still loads.
|
|
||||||
#[test]
|
|
||||||
fn ratchet_state_foreign_version_is_rejected_not_misread() {
|
|
||||||
let (mut a, mut b) = peers();
|
|
||||||
// Decrypting m2 first leaves m0/m1 in the skipped store, so the blob is
|
|
||||||
// longer than the fixed prefix and the check cannot pass by luck.
|
|
||||||
let frames: Vec<Vec<u8>> = (0..3)
|
|
||||||
.map(|i| a.encrypt(format!("m{i}").as_bytes()).expect("encrypt"))
|
|
||||||
.collect();
|
|
||||||
assert_eq!(b.decrypt(&frames[2]).expect("m2"), b"m2");
|
|
||||||
let bytes = b.to_bytes();
|
|
||||||
assert!(
|
|
||||||
bytes.len() > STATE_PREFIX_LEN,
|
|
||||||
"expected skipped keys in the blob, got {} bytes",
|
|
||||||
bytes.len()
|
|
||||||
);
|
|
||||||
|
|
||||||
for version in [0x00u8, 0x02, 0x7f, 0xff] {
|
|
||||||
let mut foreign = bytes.clone();
|
|
||||||
foreign[0] = version;
|
|
||||||
assert_eq!(
|
|
||||||
RatchetState::from_bytes(&foreign).expect_err("a foreign version must be rejected"),
|
|
||||||
Error::UnsupportedStateVersion(version),
|
|
||||||
"version {version:#04x} must be rejected under its own code, not misread or panicked on"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let reloaded = RatchetState::from_bytes(&bytes).expect("the untouched v1 blob still loads");
|
|
||||||
assert_eq!(reloaded.to_bytes(), bytes, "v1 round trip is not stable");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Mirrors the private `MIN_FRAME_LEN` in `src/ratchet.rs`
|
/// Mirrors the private `MIN_FRAME_LEN` in `src/ratchet.rs`
|
||||||
/// (`HEADER_OFFSET + HEADER_LEN + NONCE_LEN + TAG_LEN`), which the crate does
|
/// (`HEADER_OFFSET + HEADER_LEN + NONCE_LEN + TAG_LEN`), which the crate does
|
||||||
/// not export.
|
/// not export.
|
||||||
|
|
|
||||||
|
|
@ -130,27 +130,3 @@ fn rotate_prompt_text_matches_spec() {
|
||||||
assert!(t.contains("Type ROTATE to confirm"));
|
assert!(t.contains("Type ROTATE to confirm"));
|
||||||
assert!(t.contains("Esc to cancel"));
|
assert!(t.contains("Esc to cancel"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn f8_prekey_rotation_screen_text_matches_spec() {
|
|
||||||
let t = onionwire::tui::prekey_screen_text();
|
|
||||||
assert!(t.contains("Rotate prekey?"));
|
|
||||||
assert!(t.contains("Your identity and onion stay the same."));
|
|
||||||
assert!(
|
|
||||||
t.contains("F3-paste"),
|
|
||||||
"the re-paste requirement is the whole point of the screen"
|
|
||||||
);
|
|
||||||
assert!(t.contains("Type ROTATE to confirm"));
|
|
||||||
assert!(t.contains("Esc to cancel"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn f8_reuses_the_type_rotate_confirm_prompt() {
|
|
||||||
let mut p = RotatePrompt::new();
|
|
||||||
assert_eq!(p.on_esc(), RotateDecision::Cancel);
|
|
||||||
for c in "ROTA".chars() {
|
|
||||||
assert_eq!(p.on_char(c), RotateDecision::Pending);
|
|
||||||
}
|
|
||||||
assert_eq!(p.on_char('T'), RotateDecision::Pending);
|
|
||||||
assert_eq!(p.on_char('E'), RotateDecision::Confirm);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
//! Pin the crate's default TLS backend to Arti's `rustls` feature.
|
|
||||||
//!
|
|
||||||
//! The TUI/release build and the Android SDK are the same crate compiled with
|
|
||||||
//! different feature sets, and Arti's two TLS backends are non-additive. The
|
|
||||||
//! default must be `rustls` so no build pulls OpenSSL in for TLS (Android has
|
|
||||||
//! no OpenSSL in the NDK, and the released binaries should not need a system
|
|
||||||
//! OpenSSL).
|
|
||||||
|
|
||||||
// The default feature set must select `rustls`, not `native-tls`.
|
|
||||||
//
|
|
||||||
// Pinned at compile time: this test target is built with the crate's default
|
|
||||||
// features, so it stops compiling if `default` ever moves back off Arti's
|
|
||||||
// rustls backend.
|
|
||||||
const _: () = assert!(cfg!(feature = "rustls"));
|
|
||||||
const _: () = assert!(!cfg!(feature = "native-tls"));
|
|
||||||
|
|
||||||
/// Building a `rustls` config the way Arti does works with no manual provider
|
|
||||||
/// install, straight from the process default.
|
|
||||||
///
|
|
||||||
/// This is the load-bearing half: `tor-rtcompat` depends on rustls with
|
|
||||||
/// `default-features = false`, so unless *this* crate turns on rustls's `ring`
|
|
||||||
/// feature the TLS backend compiles with no `CryptoProvider` and Arti dies the
|
|
||||||
/// first time it builds a TLS config.
|
|
||||||
#[test]
|
|
||||||
fn rustls_resolves_a_crypto_provider_from_crate_features() {
|
|
||||||
assert!(
|
|
||||||
rustls::crypto::CryptoProvider::get_default().is_none(),
|
|
||||||
"another test in this binary installed a CryptoProvider first"
|
|
||||||
);
|
|
||||||
let _ = rustls::ClientConfig::builder();
|
|
||||||
assert!(
|
|
||||||
rustls::crypto::CryptoProvider::get_default().is_some(),
|
|
||||||
"rustls resolved no CryptoProvider — the crate feature that selects one \
|
|
||||||
(`ring`) is missing from the dependency graph"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -46,7 +46,6 @@ fn help_overlay_lists_core_bindings() {
|
||||||
"F4",
|
"F4",
|
||||||
"F5",
|
"F5",
|
||||||
"F6",
|
"F6",
|
||||||
"F8",
|
|
||||||
"send chat",
|
"send chat",
|
||||||
"/profile",
|
"/profile",
|
||||||
"/pay",
|
"/pay",
|
||||||
|
|
|
||||||
|
|
@ -531,10 +531,7 @@ fn identical_bodies_join_by_message_id_not_body() {
|
||||||
"delivered row (id 8) must keep its mark: {:?}",
|
"delivered row (id 8) must keep its mark: {:?}",
|
||||||
lines[1]
|
lines[1]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(summary.note().as_deref(), Some("1 queued"));
|
||||||
summary.note().as_deref(),
|
|
||||||
Some("peer unreachable, queued (1/8, retry 30s)")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -624,19 +621,13 @@ fn footer_summary_counts_queued_and_keeps_fail_closed() {
|
||||||
queued: 2,
|
queued: 2,
|
||||||
failed: 0,
|
failed: 0,
|
||||||
first_error: None,
|
first_error: None,
|
||||||
attempts: 3,
|
|
||||||
next_in_secs: Some(45),
|
|
||||||
};
|
};
|
||||||
assert_eq!(
|
assert_eq!(queued.note().as_deref(), Some("2 queued"));
|
||||||
queued.note().as_deref(),
|
|
||||||
Some("peer unreachable, queued (3/8, retry 45s)")
|
|
||||||
);
|
|
||||||
|
|
||||||
let failed = OutboxSummary {
|
let failed = OutboxSummary {
|
||||||
queued: 0,
|
queued: 0,
|
||||||
failed: 1,
|
failed: 1,
|
||||||
first_error: Some("connect peer.onion:80: connection timed out".into()),
|
first_error: Some("connect peer.onion:80: connection timed out".into()),
|
||||||
..OutboxSummary::default()
|
|
||||||
};
|
};
|
||||||
let note = failed.note().expect("failed rows must produce a note");
|
let note = failed.note().expect("failed rows must produce a note");
|
||||||
assert!(note.starts_with("send failed:"), "{note:?}");
|
assert!(note.starts_with("send failed:"), "{note:?}");
|
||||||
|
|
@ -646,15 +637,9 @@ fn footer_summary_counts_queued_and_keeps_fail_closed() {
|
||||||
queued: 3,
|
queued: 3,
|
||||||
failed: 1,
|
failed: 1,
|
||||||
first_error: Some("connect peer.onion:80: connection timed out".into()),
|
first_error: Some("connect peer.onion:80: connection timed out".into()),
|
||||||
attempts: 2,
|
|
||||||
next_in_secs: Some(60),
|
|
||||||
};
|
};
|
||||||
let mixed_note = mixed.note().expect("mixed rows must produce a note");
|
let mixed_note = mixed.note().expect("mixed rows must produce a note");
|
||||||
assert!(
|
assert!(mixed_note.contains("3 queued"), "{mixed_note:?}");
|
||||||
mixed_note.contains("queued (2/8, retry 1m)"),
|
|
||||||
"{mixed_note:?}"
|
|
||||||
);
|
|
||||||
assert!(mixed_note.starts_with("peer unreachable"), "{mixed_note:?}");
|
|
||||||
assert!(mixed_note.contains("send failed"), "{mixed_note:?}");
|
assert!(mixed_note.contains("send failed"), "{mixed_note:?}");
|
||||||
|
|
||||||
// Fail-closed copy stays visible in the real footer at the 80-col floor.
|
// Fail-closed copy stays visible in the real footer at the 80-col floor.
|
||||||
|
|
@ -668,10 +653,7 @@ fn footer_summary_counts_queued_and_keeps_fail_closed() {
|
||||||
assert!(line.contains("TOR") && line.contains("? help"), "{line:?}");
|
assert!(line.contains("TOR") && line.contains("? help"), "{line:?}");
|
||||||
|
|
||||||
let queued_line = status_footer(80, FP, ONION, queued.note().as_deref(), main_footer_hints());
|
let queued_line = status_footer(80, FP, ONION, queued.note().as_deref(), main_footer_hints());
|
||||||
assert!(
|
assert!(queued_line.contains("2 queued"), "{queued_line:?}");
|
||||||
queued_line.contains("queued (3/8, retry 45s)"),
|
|
||||||
"{queued_line:?}"
|
|
||||||
);
|
|
||||||
assert!(queued_line.chars().count() <= 80);
|
assert!(queued_line.chars().count() <= 80);
|
||||||
|
|
||||||
// `! ` ornament (colour off) still lands on the derived failing note.
|
// `! ` ornament (colour off) still lands on the derived failing note.
|
||||||
|
|
@ -749,7 +731,7 @@ fn chat_and_footer_rows_fit_80x24_and_wrap_instead_of_clipping() {
|
||||||
"long row was clipped, not wrapped:\n{screen}"
|
"long row was clipped, not wrapped:\n{screen}"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
screen.contains("peer unreachable, queued (3/8, retry 45s)"),
|
screen.contains("1 queued"),
|
||||||
"footer summary missing:\n{screen}"
|
"footer summary missing:\n{screen}"
|
||||||
);
|
);
|
||||||
println!("===== AFTER outbox 80x24 (real draw_chat + status_footer) =====\n{screen}");
|
println!("===== AFTER outbox 80x24 (real draw_chat + status_footer) =====\n{screen}");
|
||||||
|
|
@ -807,10 +789,7 @@ async fn renders_a_queued_row_from_a_real_outbox_send() {
|
||||||
"real outbox row did not render: {:?}",
|
"real outbox row did not render: {:?}",
|
||||||
lines[0]
|
lines[0]
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(summary.note().as_deref(), Some("1 queued"));
|
||||||
summary.note().as_deref(),
|
|
||||||
Some("peer unreachable, queued (1/8, retry 45s)")
|
|
||||||
);
|
|
||||||
|
|
||||||
// And once a send crosses the circuit the row is gone, so the same message
|
// And once a send crosses the circuit the row is gone, so the same message
|
||||||
// renders as delivered.
|
// renders as delivered.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue