Skip to content

Commit

Permalink
fix derivedk calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Stricted committed Jul 13, 2015
1 parent 9d6ff8a commit aebf6b7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions SpeedportHybrid.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ public function login ($password) {
}

// calculate derivedk
if (version_compare(phpversion(), '5.5.0', '<')) {
if (!function_exists("hash_pbkdf2")) {
require_once 'CryptLib/CryptLib.php';
$pbkdf2 = new CryptLib\Key\Derivation\PBKDF\PBKDF2();
$this->derivedk = $pbkdf2->derive(hash('sha256', $password), substr($this->challenge, 0, 16), 1000, 32);
$pbkdf2 = new CryptLib\Key\Derivation\PBKDF\PBKDF2(array('hash' => 'sha1'));
$this->derivedk = bin2hex($pbkdf2->derive(hash('sha256', $password), substr($this->challenge, 0, 16), 1000, 32));
$this->derivedk = substr($this->derivedk, 0, 32);
}
else {
$this->derivedk = hash_pbkdf2('sha1', hash('sha256', $password), substr($this->challenge, 0, 16), 1000, 32);
Expand Down

0 comments on commit aebf6b7

Please sign in to comment.