]> granicus.if.org Git - php/commitdiff
improve libargon2/libsodium compatibility
authorRemi Collet <remi@php.net>
Wed, 10 Jul 2019 07:00:41 +0000 (09:00 +0200)
committerRemi Collet <remi@php.net>
Wed, 10 Jul 2019 07:00:41 +0000 (09:00 +0200)
ext/standard/password.c
ext/standard/tests/password/bug75221.phpt
ext/standard/tests/password/password_hash_error_argon2.phpt

index aacb30e61cb7e33e953ebca0335d9a6008a67b0b..a12590c0e083cc6e6571c4f1952687c17b05a029 100644 (file)
@@ -571,6 +571,21 @@ static const php_password_algo* php_password_algo_find_zval_ex(zval *arg, const
 #if HAVE_ARGON2LIB
                        case 2: return &php_password_algo_argon2i;
                        case 3: return &php_password_algo_argon2id;
+#else
+                       case 2:
+                               {
+                               zend_string *n = zend_string_init("argon2i", sizeof("argon2i")-1, 0);
+                               const php_password_algo* ret = php_password_algo_find(n);
+                               zend_string_release(n);
+                               return ret;
+                               }
+                       case 3:
+                               {
+                               zend_string *n = zend_string_init("argon2id", sizeof("argon2id")-1, 0);
+                               const php_password_algo* ret = php_password_algo_find(n);
+                               zend_string_release(n);
+                               return ret;
+                               }
 #endif
                }
                return NULL;
index ec03f92ea6cd37a13551c1a043162fc762d60d7b..bd6e386a164e687278775c34e594bef7d8f5bd13 100644 (file)
@@ -9,7 +9,7 @@ if (!defined('PASSWORD_ARGON2I')) die('skip password_hash not built with Argon2'
 $hash = password_hash(
     "php",
     PASSWORD_ARGON2I,
-    ['memory_cost' => 16384, 'time_cost' => 2, 'threads' => 4]
+    ['memory_cost' => 64 << 10, 'time_cost' => 4, 'threads' => 1]
 );
 var_dump(substr($hash, -1, 1) !== "\0");
 ?>
index 070d61656ab13b5dfca406771652992731ccdd15..2ea6b93627c0f86f1fb85578bbcdf13e19647dbc 100644 (file)
@@ -21,7 +21,7 @@ NULL
 Warning: password_hash(): Time cost is outside of allowed time range in %s on line %d
 NULL
 
-Warning: password_hash(): Invalid number of threads in %s on line %d
+Warning: password_hash(): %sthread%s
 NULL
 
 Warning: password_hash(): Memory cost is outside of allowed memory range in %s on line %d
@@ -30,5 +30,5 @@ NULL
 Warning: password_hash(): Time cost is outside of allowed time range in %s on line %d
 NULL
 
-Warning: password_hash(): Invalid number of threads in %s on line %d
+Warning: password_hash(): %sthread%s
 NULL