Fix dir.uvf encryption: magic bytes, AAD chunk size, and seed key#134
Open
daniel-marthaler wants to merge 1 commit intoshift7-ch:feature/cipherduck-uvffrom
Open
Conversation
Three fixes in encryptFile() to match Java cryptolib (v3/UVF draft): 1. Magic bytes: 0x75766601 -> 0x75766600 (cryptolib uses UVF draft, version byte is 0x00 not 0x01) 2. Chunk AAD: 4-byte -> 8-byte chunk number (Java long, big-endian) 3. Header key: use seed for given seedId, not always initialSeed The magic bytes mismatch caused the GCM authentication tag to fail because the general header (magic + seedId) is used as AAD for the file key wrap operation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Three fixes in
encryptFile()(universalVaultFormat.ts) to match the Java cryptolib (cryptolib 2.3.0.uvfdraft-SNAPSHOT):0x75766601→0x75766600(cryptolib uses UVF_DRAFT, version byte is0x00)long, big-endian)seedId, not alwaysinitialSeedBackground
The
dir.uvffiles created by the web frontend could not be decrypted by the Katta desktop client (Cyberduck-based). The desktop client threw:The root cause was that AES-GCM includes the AAD in the authentication tag. Any mismatch in AAD between encryption (TypeScript) and decryption (Java cryptolib) causes GCM tag verification to fail. The magic bytes mismatch (
0x01vs0x00) affected the header AAD, and the chunk number size mismatch (4 vs 8 bytes) affected the block AAD.dir.uvf format (UVF Draft)
Changes
frontend/src/common/universalVaultFormat.tsfrontend/test/common/universalVaultFormat.spec.tsTest plan
🤖 Generated with Claude Code