Module: Keepassx

Defined in:
lib/keepassx/entry.rb,
lib/keepassx.rb,
lib/keepassx/item.rb,
lib/keepassx/field.rb,
lib/keepassx/group.rb,
lib/keepassx/header.rb,
lib/keepassx/database.rb,
lib/keepassx/aes_crypt.rb,
lib/keepassx/utilities.rb,
lib/keepassx/exceptions.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, Field, Item, Utilities Classes: Database, Entry, EntryField, Group, GroupField, HashError, Header, MalformedDataError

Class Method Summary collapse

Class Method Details

.new(opts) {|opts| ... } ⇒ Keepassx::Database

Create Keepassx database

Parameters:

  • opts (Hash)

    Keepassx database options.

Yields:

  • (opts)

Yield Returns:

  • (Fixnum)

Returns:



50
51
52
53
54
# File 'lib/keepassx.rb', line 50

def new opts
  db = Database.new opts
  return db unless block_given?
  yield db
end

.open(opts) {|opts| ... } ⇒ Keepassx::Database

Read Keepassx database from file storage.

Parameters:

  • opts (Hash)

    Keepassx database options.

Yields:

  • (opts)

Yield Returns:

  • (Fixnum)

Returns:



63
64
65
66
67
# File 'lib/keepassx.rb', line 63

def open opts
  db = Database.open opts
  return db unless block_given?
  yield db
end