Module: Keepassx

Defined in:
lib/keepassx/entry.rb,
lib/keepassx/group.rb,
lib/keepassx/header.rb,
lib/keepassx/database.rb,
lib/keepassx/aes_crypt.rb,
lib/keepassx/entry_field.rb,
lib/keepassx/group_field.rb

Overview

The keepass file header.

From the KeePass doc:

Database header: [DBHDR]

4 bytes

DWORD dwSignature1 = 0x9AA2D903

4 bytes

DWORD dwSignature2 = 0xB54BFB65

4 bytes

DWORD dwFlags

4 bytes

DWORD dwVersion { Ve.Ve.Mj.Mj:Mn.Mn.Bl.Bl }

16 bytes

BYTE16 aMasterSeed

16 bytes

BYTE16 aEncryptionIV

4 bytes

DWORD dwGroups Number of groups in database

4 bytes

DWORD dwEntries Number of entries in database

32 bytes

BYTE32 aContentsHash SHA-256 hash value of the plain contents

32 bytes

BYTE32 aMasterSeed2 Used for the dwKeyEncRounds AES

master key transformations
4 bytes

DWORD dwKeyEncRounds See above; number of transformations

Notes:

  • dwFlags is a bitmap, which can include:

    • PWM_FLAG_SHA2 (1) for SHA-2.

    • PWM_FLAG_RIJNDAEL (2) for AES (Rijndael).

    • PWM_FLAG_ARCFOUR (4) for ARC4.

    • PWM_FLAG_TWOFISH (8) for Twofish.

  • aMasterSeed is a salt that gets hashed with the transformed user master key to form the final database data encryption/decryption key.

    • FinalKey = SHA-256(aMasterSeed, TransformedUserMasterKey)

  • aEncryptionIV is the initialization vector used by AES/Twofish for encrypting/decrypting the database data.

  • aContentsHash: “plain contents” refers to the database file, minus the database header, decrypted by FinalKey.

    • PlainContents = Decrypt_with_FinalKey(DatabaseFile - DatabaseHeader)

Defined Under Namespace

Modules: AESCrypt Classes: Database, Entry, EntryField, Group, GroupField, Header