Add KDF parameter customization and builder module refactor#2
Merged
Conversation
This change adds support for customizing Argon2 key derivation parameters: - Add argon2_iterations, argon2_memory, argon2_parallelism properties with getters and setters to PyKeePass class - Rewrite create_database() to build KDBX4 structure from scratch instead of copying a template file - Add encryption and kdf parameters to create_database() - Remove blank_database.kdbx template (no longer needed) The new create_database() supports: - Custom encryption algorithm (aes256, chacha20, twofish) - Custom KDF (argon2id, argon2) - Custom Argon2 parameters (iterations, memory, parallelism) KDF parameters can also be modified on existing databases using the new property setters, which properly invalidate the header cache to ensure changes are persisted on save.
- Extract _build_kdbx4_structure() to kdbx_parsing/builder.py - Add KDBX3 database creation support - Replace string params with type-safe dataclasses: - Argon2Config with .standard(), .high_security(), .fast() presets - AesKdfConfig with .standard(), .high_security() presets - Cipher and KdfAlgorithm StrEnums - Add 14 new tests for KDBX3 creation and config presets
- Add transform_rounds getter/setter for KDBX3 AES-KDF round modification - Add argon2_variant getter/setter to switch between argon2id and argon2d - Add 4 new tests for the new properties
coreyleavitt
added a commit
that referenced
this pull request
Nov 30, 2025
Add KDF parameter customization and builder module refactor
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
KDF Parameter Customization
KDBX4 (Argon2):
argon2_iterations- get/set time costargon2_memory- get/set memory cost (KiB)argon2_parallelism- get/set thread countargon2_variant- get/set variant (argon2id or argon2d)KDBX3 (AES-KDF):
transform_rounds- get/set AES transformation roundsDatabase Creation Rewrite
create_database()to build KDBX structure from scratch instead of copying a template fileblank_database.kdbxtemplate (no longer needed)version=3parameterBuilder Module
Extract database creation logic into
kdbx_parsing/builder.pywith type-safe API:Argon2Configdataclass with.standard(),.high_security(),.fast()presetsAesKdfConfigdataclass with.standard(),.high_security()presetsCipherenum (AES256, CHACHA20, TWOFISH)KdfAlgorithmenum (ARGON2ID, ARGON2D, AES_KDF)Other Changes
Example Usage
Test Plan