Skip to content

feat: add ECDSA P-384/P-521 keygen, native ECDH, and extended PQC SSH KEX - #2043

Merged
lollipopkit merged 2 commits into
mainfrom
feat/ssh-nist-pqc-kex
Dec 3, 2026
Merged

lollipopkit merged 2 commits into
mainfrom
feat/ssh-nist-pqc-kex

Conversation

@lollipopkit

@lollipopkit lollipopkit commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Depends on lollipopkit/dartssh2#37.

Summary by CodeRabbit

  • New Features
    • Added ECDSA P-384 and P-521 key generation.
    • Expanded SSH key exchange support with NIST-curve ECDH, ML-KEM-1024, and SNTRUP761.
  • Bug Fixes
    • Improved handling of unsupported curves, malformed keys, and invalid input lengths, with errors reported for invalid operations.
  • Tests
    • Added coverage for the new key types and key exchanges, including compatibility checks with OpenSSH.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds native NIST ECDH, ML-KEM-1024, and SNTRUP761 operations, exposes them through the Flutter Rust Bridge and SSH crypto APIs, and adds ECDSA P-384/P-521 key generation. It also adds SSH key-exchange and ECDSA integration tests.

Changes: SSH Cryptography

Layer / File(s) Summary
Rust ECDH and KEM operations
crates/sbm_ffi/Cargo.toml, crates/sbm_ffi/src/api/ssh_asym.rs
Rust adds ECDH for P-256, P-384, and P-521, ML-KEM-1024, and SNTRUP761 operations. Shared ML-KEM helpers serve ML-KEM-768 and ML-KEM-1024. Tests cover round trips and invalid inputs.
Flutter Rust Bridge exposure
crates/sbm_ffi/src/frb_generated.rs, lib/src/rust/api/ssh_asym.dart, lib/src/rust/frb_generated*.dart
Generated bindings add the new operation calls, result types, wire handlers, dispatch entries, and codecs.
Dart SSH crypto and ECDSA key generation
lib/core/ssh/native_crypto.dart, lib/core/ssh/algorithms.dart, lib/core/ssh/keygen.dart, lib/view/page/private_key/generate.dart, test/widget/ssh_keygen_page_test.dart
The Dart SSH crypto layer adds native methods for ECDH, ML-KEM-1024, and SNTRUP761. Key generation and its UI add ECDSA P-384/P-521 options and labels.
SSH key-exchange validation
packages/dartssh2, test/e2e/ssh_pqc_openssh106_e2e_test.dart, test/unit/ssh/ssh_native_crypto_test.dart
Tests cover configured KEX algorithms, NIST ECDH, hybrid key exchanges, and ECDSA P-384/P-521 keys. The dartssh2 submodule pointer changes.

Sequence Diagram(s)

sequenceDiagram
  participant NativeSshCrypto
  participant RustLibApi
  participant ssh_asym
  NativeSshCrypto->>RustLibApi: Request ECDH keypair or shared secret
  RustLibApi->>ssh_asym: Call the ECDH operation
  ssh_asym-->>RustLibApi: Return keypair or shared secret
  RustLibApi-->>NativeSshCrypto: Return decoded result or error
Loading
Merge Risk: Minimal · up to 3086e · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

TruffleHog (3.99.8)

lib/src/rust/frb_generated.dart

TruffleHog scan timed out

lib/src/rust/frb_generated.io.dart

TruffleHog scan timed out

lib/src/rust/frb_generated.web.dart

TruffleHog scan timed out

  • 4 others
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: ee33a1b3-e56d-433a-b38b-a956e46881d3
Commits

Reviewing files that changed from the base of the PR and between 03e3f33 and 3086e1a.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 15

  • crates/sbm_ffi/Cargo.toml
  • crates/sbm_ffi/src/api/ssh_asym.rs
  • crates/sbm_ffi/src/frb_generated.rs
  • lib/core/ssh/algorithms.dart
  • lib/core/ssh/keygen.dart
  • lib/core/ssh/native_crypto.dart
  • lib/src/rust/api/ssh_asym.dart
  • lib/src/rust/frb_generated.dart
  • lib/src/rust/frb_generated.io.dart
  • lib/src/rust/frb_generated.web.dart
  • lib/view/page/private_key/generate.dart
  • packages/dartssh2
  • test/e2e/ssh_pqc_openssh106_e2e_test.dart
  • test/unit/ssh/ssh_native_crypto_test.dart
  • test/widget/ssh_keygen_page_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

Recent review details

Context from checks skipped due to timeout: 8

  • GitHub Check: tests (2/3)
  • GitHub Check: tests (1/3)
  • GitHub Check: tests (0/3)
  • GitHub Check: Monitor frontend
  • GitHub Check: Android unit tests
  • GitHub Check: Rust tests (ubuntu-latest)
  • GitHub Check: Rust tests (windows-latest)
  • GitHub Check: CodeRabbit
Additional context used

Code guidelines: 3

.claude/skills/serverbox-onboarding/SKILL.md — Agent Skill
crates/sbm_ffi/CLAUDE.md — auto-discovered
CLAUDE.md — auto-discovered
Path-based instructions: 3

Source excerpt: **Regenerate after changing an annotated model** (`freezed`, `json_serializable`, `riverpod`, hive): `make gen`.

CodeRabbit inference engine (.claude/skills/serverbox-onboarding/SKILL.md)

Files:

  • lib/src/rust/api/ssh_asym.dart
  • lib/src/rust/frb_generated.dart
  • lib/src/rust/frb_generated.io.dart
  • lib/src/rust/frb_generated.web.dart
Source excerpt: `api/ssh_crypto.rs` is the **record layer** — AES-CTR, AES-CBC, HMAC, and AES-GCM through dartssh2's `createAead` (keyed once per direction, one `seal`/`open` per packet) — run on every packet.

CodeRabbit inference engine (crates/sbm_ffi/CLAUDE.md)

Files:

  • crates/sbm_ffi/Cargo.toml
  • crates/sbm_ffi/src/api/ssh_asym.rs
  • crates/sbm_ffi/src/frb_generated.rs
Source excerpt: **In `lib/`, a page is `AppRoute.go`, `AppPageRoute` or `AppPage` (fl_lib), never a bare `MaterialPageRoute` / `MaterialPage`**: a predictive back (Android, and the iOS/macOS edge swipe) pops every route current in its own n...

CodeRabbit inference engine (CLAUDE.md)

Files:

  • lib/core/ssh/algorithms.dart
  • lib/core/ssh/keygen.dart
  • lib/core/ssh/native_crypto.dart
  • lib/src/rust/api/ssh_asym.dart
  • lib/src/rust/frb_generated.dart
  • lib/src/rust/frb_generated.io.dart
  • lib/src/rust/frb_generated.web.dart
  • lib/view/page/private_key/generate.dart
Learnings: 2

Learning: 2026-10-19T12:04:33.194Z

Learnt from: CR
Repo: lollipopkit/flutter_server_box PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-10-19T12:04:33.194Z
Learning: Source excerpt:
# CLAUDE.md

## Architecture

### Connection methods

- SSH is direct, jump server or `ProxyCommand` (`genClient`); host keys are always verified.

Applied to files:

  • lib/core/ssh/algorithms.dart
  • test/e2e/ssh_pqc_openssh106_e2e_test.dart
Learning: 2026-11-15T05:29:17.858Z

Learnt from: CR
Repo: lollipopkit/flutter_server_box PR: 0
File: .claude/skills/serverbox-onboarding/SKILL.md:0-0
Timestamp: 2026-11-15T05:29:17.858Z
Learning: Applies to {**/*.g.dart,**/*.freezed.dart,lib/src/rust/**} : Source excerpt:
# ServerBox onboarding

## What costs people an afternoon

- **Regenerate after changing an annotated model** (`freezed`,
  `json_serializable`, `riverpod`, hive): `make gen`. Never hand-edit
  `*.g.dart`, `*.freezed.dart` or anything under `lib/src/rust/`.

Applied to files:

  • lib/src/rust/api/ssh_asym.dart
  • lib/src/rust/frb_generated.dart
  • lib/src/rust/frb_generated.io.dart
  • lib/src/rust/frb_generated.web.dart
Additional comments: 2

packages/dartssh2: 2

1-1: Stability & Availability

The claimed failure does not occur at this pinned revision. _supportedKexAlgorithms removes SNTRUP key exchanges when the installed backend does not support them, and _sendKexInit advertises only that filtered list. The server therefore cannot select an SNTRUP name that the client did not offer, so the connection does not fail for this reason. The review finding is based on a premise that the inspected code contradicts.

1-1: Functional Correctness

The pinned submodule registers all three requested KEX names.

At 40a925fc74322ff8806b5706fbf149e2455b0775, ssh_kex_type.dart defines sntrup761x25519-sha512, sntrup761x25519-sha512@openssh.com, and diffie-hellman-group18-sha512. The sntrup names have an implementation in kex_sntrup761_x25519.dart, and the group18 path is exercised by a test in the pinned tree. A server that offers one of these names is not rejected because the name is missing from the pin.

The sntrup names depend on an installed SSHCryptoBackend that reports supportsSntrup761. This is the documented gating behavior, and this submodule update does not change it. Checking whether the application installs such a backend belongs to the parent repository's wiring, not this pin.

@socket-security

socket-security Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​sntrup-kem@​0.1.0-rc.010010093100100

View full report

@lollipopkit
lollipopkit marked this pull request as ready for review December 3, 2026 11:28
@lollipopkit
lollipopkit merged commit a45234c into main Dec 3, 2026
22 checks passed
@lollipopkit
lollipopkit deleted the feat/ssh-nist-pqc-kex branch December 3, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant