OPL-4574: Envelope v2 with key slots and device-p256 wrapping - #2
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a versioned envelope so one encrypted
.bepcan be unlocked by more than one credential (key slots), including a device-bound P-256 key that uses the same ECIES layout as the Secure Enclave helper (ECDH P-256, HKDF-SHA256 with infose-vault-v1, AES-256-GCM;ephemeralPub(65) || nonce(12) || ct || tag(16)). Existing v1 files decrypt unchanged;decryptBackuptransparently opens v2 files through their pbkdf2 slots.New API:
sealBackup,openBackup,inspectEnvelope,addSlot,removeSlot,rewrapBackup,isEnvelopeV2,eciesEncrypt,eciesDecrypt, and aDerivationDescriptortype available on WIF, account, and master payloads. CLI gainsbbackup slots <file>to inspect a file without a passphrase.Byte layout:
BEP2magic, version byte0x02, u16 header length, JSON header ({v, slots[], descriptor?}), theniv(12) || AES-256-GCM(contentKey, payload). Header validation runs before any decrypt call; unknown versions, slot types, or truncated bytes fail closed.Implemented by a Muse Spark 1.3 worker via Orchestra, then reviewed and revised in the main session: duplicated payload validation and parsing were replaced with the existing
crypto.tsimplementations, forwarding wrappers inindex.tsreplaced with re-exports, and a double parse inrewrapBackupremoved.Verification:
bun run lint,bun test(173 pass),bun run build.Linear: OPL-4574
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.