Exemplo n.º 1
0
 public function __construct($key, $iv)
 {
     if ($key == null || strlen($key) != self::KEY_LEN) {
         return;
     }
     if ($iv == null || strlen($iv) != self::IV_LEN) {
         return;
     }
     $this->state = array();
     for ($i = 0; $i < self::STATE_LEN; $i++) {
         $this->state[$i] = 0;
     }
     $this->output = array();
     for ($i = 0; $i < self::OUTPUT_LEN; $i++) {
         $this->output[$i] = 0;
     }
     $this->outputPos = self::OUTPUT_LEN;
     $this->keySetup(Binary::fromString($key, self::KEY_LEN));
     $this->ivSetup(Binary::fromString($iv, self::IV_LEN));
 }
Exemplo n.º 2
0
 public function readByte()
 {
     $s = $this->read(1);
     return Binary::fromString($s, 1);
 }
Exemplo n.º 3
0
 /**
  * Adds the given debug string $msg, then the given binary string $bin as an
  * hex string, to the debug data if debug mode is on.
  * @param string $msg The 'normal' string to add to the debug data.
  * @param string $bin The binary string to print in hexa.
  */
 public static function printDebugHexa($msg, $bin)
 {
     if (self::$debug) {
         self::$errordump .= self::makePrintable($msg . " :: " . Binary::fromString($bin)->asHexString()) . "\n";
     }
 }
Exemplo n.º 4
0
 /**
  * Prints the header if debug mode is on.
  */
 public function printHeader()
 {
     if (KeePassPHP::$debug) {
         echo "<pre>", "cipher := ", $this->cipher == null ? "null" : CipherMcrypt::AES128, "\ncompression := ", $this->compression, "\nmasterSeed := ", Binary::fromString($this->masterSeed)->asHexString(), "\ntransformSeed := ", Binary::fromString($this->transformSeed)->asHexString(), "\nrounds := ", $this->rounds == null ? "null" : "0x" . $this->rounds->asHexString(), "\nencryptionIV := ", Binary::fromString($this->encryptionIV)->asHexString(), "\nstreamStartBytes := ", Binary::fromString($this->startBytes)->asHexString(), "</pre>";
     }
 }