Пример #1
0
 /**
  * Stores the hash of the given password.
  * @param string $pwd The string to hash.
  */
 public function __construct($pwd)
 {
     $this->hash = HashHouse::hash($pwd);
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * Starts the KeePassPHP application. Must be called before any other method
  * of KeePassPHP. If $debug is true, debug and error data will be added in
  * the static variable KeePassPHP::$errordump ; if $debug is false,
  * KeePass::$errordump will be non empty only if an error occurs.
  * Regardless of the value of $debug, the property KeePassPHP::$isError is
  * set to true if an error occurs. This way, a client application can check
  * if KeePassPHP detected an error, and retrieve some information from
  * KeePassPHP::$errordump (this information will probably not be useful
  * if $debug is false, though).
  * 
  * @param boolean $debug True to enable debug mode, false otherwise.
  */
 public static function init($debug = false)
 {
     if (self::$started) {
         return;
     }
     self::$isError = false;
     self::$debug = $debug;
     self::$errordump = "";
     HashHouse::setDefault(self::DEFAULT_HASH);
     self::$iconmanager = new IconManager(self::DIR_KEEPASSPHP . self::DIR_DATA . self::DIR_ICONS, self::PREFIX_ICON, false, false);
     self::$dbmanager = new FileManager(self::DIR_KEEPASSPHP . self::DIR_DATA . self::DIR_SECURE . self::DIR_KPHPDB, self::PREFIX_DATABASE, true, false);
     self::$kdbxmanager = new UploadManager(self::DIR_KEEPASSPHP . self::DIR_DATA . self::DIR_SECURE . self::DIR_KDBX, self::PREFEXT_KDBX);
     self::$keymanager = new UploadManager(self::DIR_KEEPASSPHP . self::DIR_DATA . self::DIR_SECURE . self::DIR_KEY, self::PREFEXT_KEY);
     self::$started = true;
     self::printDebug("KeePassPHP application started !");
 }