Skip to content

Conversation

@coreyleavitt
Copy link
Owner

Summary

  • Add new security/keyfile.py module for creating KeePass keyfiles
  • Support all four keyfile formats: XML v2.0, XML v1.0, RAW_32, HEX_64
  • New public API: create_keyfile(), create_keyfile_bytes(), parse_keyfile(), KeyFileVersion
  • Refactor _process_keyfile() from kdf.py to parse_keyfile() in keyfile module

Test plan

  • 23 new tests for keyfile creation and parsing
  • All 609 existing tests pass
  • 99% code coverage on new keyfile module

Add new security/keyfile.py module with support for creating KeePass
keyfiles in all supported formats:

- XML v2.0 (.keyx): Recommended format with hex-encoded key and SHA-256
  hash verification
- XML v1.0 (.key): Legacy format with base64-encoded key
- RAW_32: Raw 32-byte binary key
- HEX_64: 64-character hex string

New public API:
- create_keyfile(path, version) - create keyfile at path
- create_keyfile_bytes(version) - return keyfile as bytes
- parse_keyfile(data) - parse keyfile and extract key
- KeyFileVersion enum for format selection

Refactored _process_keyfile() from kdf.py to parse_keyfile() in the
new keyfile module for better organization.

Closes #47
@coreyleavitt coreyleavitt force-pushed the feature/keyfile-creation branch from 0d04ffe to 2dfa2f2 Compare December 10, 2025 06:51
@coreyleavitt coreyleavitt merged commit fbef7fb into master Dec 10, 2025
4 checks passed
millerjason pushed a commit to millerjason/kdbxtool that referenced this pull request Jan 11, 2026
Add keyfile creation support

Add new security/keyfile.py module with support for creating KeePass
keyfiles in all supported formats:

- XML v2.0 (.keyx): Recommended format with hex-encoded key and SHA-256
  hash verification
- XML v1.0 (.key): Legacy format with base64-encoded key
- RAW_32: Raw 32-byte binary key
- HEX_64: 64-character hex string

New public API:
- create_keyfile(path, version) - create keyfile at path
- create_keyfile_bytes(version) - return keyfile as bytes
- parse_keyfile(data) - parse keyfile and extract key
- KeyFileVersion enum for format selection

Refactored _process_keyfile() from kdf.py to parse_keyfile() in the
new keyfile module for better organization.

Closes coreyleavitt#47
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.

2 participants