fix travis build
[GitHub/Stricted/speedport-hybrid-php-api.git] / SpeedportHybrid.class.php
index 3e40be4b1c7acc952a83751a0e5d56677c2a6344..81152c31498f3ed9a3e90e66a8e631254e7dab53 100644 (file)
@@ -95,7 +95,15 @@ class SpeedportHybrid {
                                }
                                
                                // calculate derivedk
-                               $this->derivedk = hash_pbkdf2('sha1', hash('sha256', $password), substr($this->challenge, 0, 16), 1000, 32);
+                               if (!function_exists("hash_pbkdf2")) {
+                                       require_once 'CryptLib/CryptLib.php';
+                                       $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);
+                               }
                                
                                // get the csrf_token
                                $this->token = $this->getToken();