/**
  * Returns as a binary string the final AES key used for decrypting
  * the database file, computed from the seeds and the master composite key.
  * @return string
  */
 private function transformKey()
 {
     $seed = $this->header->transformSeed;
     $keyHash = $this->key->getHash();
     /// does not yet support the case rounds >> 2**31
     $rounds = $this->header->rounds->asInt();
     $AESEncryptor = new CipherMcrypt(CipherMcrypt::AES128, 'ecb', $seed);
     $AESEncryptor->load();
     for ($i = 0; $i < $rounds; $i++) {
         $keyHash = $AESEncryptor->encrypt($keyHash);
     }
     $AESEncryptor->unload();
     $finalKey = HashHouse::hash($keyHash);
     $aesKey = HashHouse::hash($this->header->masterSeed . $finalKey);
     return $aesKey;
 }
Example #2
0
 /**
  * Stores the hash of the given password.
  * @param string $pwd The string to hash.
  */
 public function __construct($pwd)
 {
     $this->hash = HashHouse::hash($pwd);
 }