Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3 vs v4 naming issue and kdbx v4 support #24

Closed
Evidlo opened this issue May 17, 2018 · 1 comment
Closed

v3 vs v4 naming issue and kdbx v4 support #24

Evidlo opened this issue May 17, 2018 · 1 comment

Comments

@Evidlo
Copy link
Member

Evidlo commented May 17, 2018

It seems like there is some confusion in the codebase over v3 vs v4 databases. From what I can tell, libkeepass supports KeePass 1.x databases (.kdb) and a subset of KeePass 2.x datbases (.kdbx v3.x only).

The newer kdbx v4 databases have a number of significant changes in supported algorithms and structure of binary data. Here is a summary of the important changes in the spec:

  • support for argon2 key derivation
    kdbx v3.x supports AES-KDF only. v4 supports both and defaults to argon2

  • key derivation information has been moved

    • transform seed and transform rounds header items have been deprecated
    • a new dynamically sized header item with id 11 has been defined
  • stream information for salsa20/chacha20 has been moved

    • a new dynamically sized binary "inner header" has been defined, immediately preceeding the XML data
    • are inner stream key and inner stream id deprecated now? spec didn't say yes
  • payload block decryption now uses HMAC-SHA256 instead of just SHA256

  • header hash has been moved

    • <HeaderHash> in the decrypted XML has been deprecated
    • a 32 byte SHA256 hash of the header immediately follows the header
    • a 32 byte HMAC-SHA256 hash immediately follows the previous SHA256 hash.
      this hash is calculated like so:
      hmac_key = hashlib.sha512(b'\xff' * 8 + hashlib.sha512(master_seed + transformed_key + b'x01').digest()).digest()
      hmac_hash = hmac.new(hmac_key, header_bytes, hashlib.sha256).digest()
  • new CustomData field on Entries and Groups

I've been working on some code that demonstrates decrypting kdbx v3 and kdbx v4 in a step-by-step fashion.

@Evidlo
Copy link
Member Author

Evidlo commented Nov 3, 2018

pykeepass now supports KDBX4

@Evidlo Evidlo closed this as completed Nov 3, 2018
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

No branches or pull requests

1 participant