Skip to content

Support Argon2id key derivation in KDBX 4 - #119

Open
rory12392 wants to merge 1 commit into
jorabin:developfrom
rory12392:argon2id
Open

rory12392 wants to merge 1 commit into
jorabin:developfrom
rory12392:argon2id

Conversation

@rory12392

Copy link
Copy Markdown

KeePass and KeePassXC can use Argon2id as the KDBX 4 key derivation function instead of Argon2d. The two variants take the same parameters and are told apart only by the KDF UUID in the outer header (9E298B19-56DB-4773-B23D-FC3EC6F0A1E6 for Argon2id, EF636DDF-8C29-444B-91F7-A9A403E30A0C for Argon2d). KeePassJava2 only knows the Argon2d UUID, so loading an Argon2id file fails with IllegalArgumentException: Unknown Cipher UUID from Encryption.KeyDerivationFunction.getKdf.

Change

  • Argon2 is parameterised by UUID, name and Bouncy Castle Argon2 type, with two singletons: getInstance() (Argon2d, unchanged behaviour and name) and the new getArgon2idInstance() (Argon2id). createKdfParameters() now writes the instance's own UUID.
  • Encryption.KeyDerivationFunction gains ARGON2ID, so getKdf() finds Argon2id on load, saving a loaded database keeps it, and a new KDBX 4 file can choose it with kdbxHeader.setKeyDerivationFunction(Encryption.KeyDerivationFunction.ARGON2ID).
  • No existing API changes; ARGON2 still means Argon2d.
  • CHANGELOG entry under 2.2.7.

Tests

  • New test resource test/src/test/resources/V4-AES-Argon2id-probe1234.kdbx: written by KeePassXC 2.7.12, KDBX 4.1, AES-256, Argon2id 64 MiB / 2 iterations / parallelism 4, password probe1234, three dummy entries (2 KB).
  • kdbx module, Argon2idTest: KDF UUIDs and lookup, createKdfParameters() UUIDs, Argon2d and Argon2id give different keys for the same parameters, reading the header of the KeePassXC file, decrypting it, wrong password still fails, writing and reading back a KDBX 4 stream with Argon2id.
  • jackson module, JacksonArgon2idTest: open the KeePassXC file, save it and reload it (KDF still Argon2id, entries unchanged), and save a new database with Argon2id chosen and reload it.
  • All 10 new tests fail without the change in database.

mvn -B -P inhibitConsoleOutput clean verify with JDK 11 (Temurin 11.0.32.1): BUILD SUCCESS, 268 tests, 0 failures, 0 errors, 27 skipped (258 / 27 skipped on develop before this change).

This is against develop (2.x). I'm happy to open the same change against v3-develop if you'd like it there too.

🤖 Generated with Claude Code

KeePass and KeePassXC can use Argon2id instead of Argon2d; the two are
told apart by the KDF UUID in the KDBX 4 header and take the same
parameters. Loading such a file failed with "Unknown Cipher UUID".

Argon2 now has an Argon2d instance (getInstance(), unchanged) and an
Argon2id instance (getArgon2idInstance()), and
Encryption.KeyDerivationFunction gains ARGON2ID, so Argon2id files can
be loaded, saved with their KDF kept, and new files can choose it with
KdbxHeader.setKeyDerivationFunction(ARGON2ID).

Tests use a KeePassXC-created KDBX 4.1 file (AES-256, Argon2id 64 MiB,
2 iterations, parallelism 4, password "probe1234", dummy content).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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