Skip to content

Commit 0c669fe

Browse files
UnbreakableMJclaude
andcommitted
feat(vault-core): M1 — parse and decrypt Bitwarden encrypted exports
Implement the offline-decrypt path for password-protected Bitwarden .json exports per PRD §12 (M1 gate). New modules: - enc_string: type-2 EncString parser/encoder (AES-256-CBC + HMAC- SHA-256, Encrypt-then-MAC, constant-time MAC verify via subtle). Legacy unauthenticated types 0/1 are explicitly rejected. - kdf: PBKDF2-SHA-256 and Argon2id master-key derivation, plus the HKDF-SHA-256 stretch into a 64-byte (enc, mac) pair using the Bitwarden info labels ("enc" / "mac"). - export: serde envelope for the encrypted .json export and a decrypt() that validates the password via encKeyValidation_DO_NOT_EDIT before touching the data payload. - error: thiserror-backed Error / Result. Tests (9, all green): EncString round-trip, serialize/parse, tampering detection (MAC catches a single-bit flip), legacy-type rejection, end-to-end PBKDF2 export decrypt, end-to-end Argon2id export decrypt, wrong-password rejection, envelope-shape rejection, HKDF stretch sanity. Dependencies added at workspace level: aes, cbc, cipher, hmac, sha2, pbkdf2, argon2, hkdf, subtle, base64, hex, getrandom, rand. All RustCrypto, MIT/Apache-2.0 — GPL-3.0-or-later compatible. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 4775846 commit 0c669fe

10 files changed

Lines changed: 1021 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,16 @@ range may break in any release.
1818
`LICENSE`, `CREDITS.md`, `CHANGELOG.md`.
1919
- `PRD.md` — full product requirements document.
2020
- CI configuration: `fmt`, `clippy -D warnings`, `cargo audit`, `cargo deny`.
21+
- **M1 — offline export decrypt.** `vault-core` now ships:
22+
- `EncString` (Bitwarden type 2: AES-256-CBC + HMAC-SHA-256, Encrypt-then-MAC
23+
with constant-time verification; legacy types 0/1 explicitly rejected).
24+
- `kdf::{KdfType, KdfParams}` and `derive_master_key` covering
25+
PBKDF2-SHA-256 and Argon2id (with Bitwarden's SHA-256 salt preprocessing).
26+
- `stretch_master_key` — HKDF-SHA-256 expansion of a 32-byte master key
27+
into a 64-byte `(enc, mac)` pair using the official `info="enc"` /
28+
`info="mac"` labels.
29+
- `EncryptedExport` — parser and decryptor for password-protected Bitwarden
30+
`.json` exports, validating the password against `encKeyValidation_DO_NOT_EDIT`
31+
before touching the data payload.
32+
- 9 integration tests covering round-trip, tampering detection, both KDFs,
33+
wrong-password rejection, and envelope-shape validation.

0 commit comments

Comments
 (0)