Skip to content

Introduce re-usable PSKs#33

Draft
abergs wants to merge 2 commits intomainfrom
stable-psk
Draft

Introduce re-usable PSKs#33
abergs wants to merge 2 commits intomainfrom
stable-psk

Conversation

@abergs
Copy link
Member

@abergs abergs commented Mar 9, 2026

🎟️ Tracking

📔 Objective

For use cases where the client is ephmeral, or lack proper storage for a noise tunnel, allow re-using a PSK.
This allows for use cases like Github Action.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

abergs added 2 commits March 9, 2026 10:24
Stored PSKs (~/.bw-remote/psk_*.hex) are loaded on every listener
startup and accepted for incoming handshakes regardless of pairing
mode. The new --psk-reusable [name] flag generates a persistent PSK
for CI/automation use cases where the token must survive restarts.

- Add Psk::id() (first 4 bytes of SHA-256) for keychain lookup
- Add psk_id field to HandshakeInit for multi-PSK disambiguation
- Change UserClient from single PSK to HashMap-based PSK keychain
- Add PskStorage for persistent hex-encoded PSK files
- Update enable_psk() to accept an explicit PSK parameter
- Extract shared ensure_storage_dir() in storage/mod.rs, used by both
  FileIdentityStorage and PskStorage (removes duplicated home dir +
  mkdir logic)
- Psk::Debug now delegates to self.id() instead of duplicating SHA-256
- load_psks() takes impl IntoIterator<Item = Psk> instead of leaking
  the internal HashMap<[u8; 4], Psk> key format to callers
- PskStorage::load_all() returns Vec<Psk> instead of HashMap
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

@github-actions
Copy link

github-actions bot commented Mar 9, 2026

Logo
Checkmarx One – Scan Summary & Details24bce3f1-0008-474e-ba63-1f748dac9699

Great job! No new security vulnerabilities introduced in this pull request

use sha2::{Digest, Sha256 as Sha256Hash};
let hash = Sha256Hash::digest(self.0);
[hash[0], hash[1], hash[2], hash[3]]
}
Copy link
Member Author

@abergs abergs Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is 4 bytes enough? I believe it is.

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