Commit 0c669fe
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
- crates/vault-core
- src
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
0 commit comments