1--TEST-- 2Test error operation of password_hash() with Argon2i and Argon2id 3--SKIPIF-- 4<?php 5if (!defined('PASSWORD_ARGON2I')) die('skip password_hash not built with Argon2'); 6if (!defined('PASSWORD_ARGON2ID')) die('skip password_hash not built with Argon2'); 7if (PASSWORD_ARGON2_PROVIDER != 'standard') die('skip argon2 not provided by standard'); 8?> 9--FILE-- 10<?php 11try { 12 password_hash('test', PASSWORD_ARGON2I, ['memory_cost' => 0]); 13} catch (ValueError $exception) { 14 echo $exception->getMessage() . "\n"; 15} 16 17try { 18 password_hash('test', PASSWORD_ARGON2I, ['time_cost' => 0]); 19} catch (ValueError $exception) { 20 echo $exception->getMessage() . "\n"; 21} 22 23try { 24 password_hash('test', PASSWORD_ARGON2I, ['threads' => 0]); 25} catch (ValueError $exception) { 26 echo $exception->getMessage() . "\n"; 27} 28 29try { 30 password_hash('test', PASSWORD_ARGON2ID, ['memory_cost' => 0]); 31} catch (ValueError $exception) { 32 echo $exception->getMessage() . "\n"; 33} 34 35try { 36 password_hash('test', PASSWORD_ARGON2ID, ['time_cost' => 0]); 37} catch (ValueError $exception) { 38 echo $exception->getMessage() . "\n"; 39} 40 41try { 42 password_hash('test', PASSWORD_ARGON2ID, ['threads' => 0]); 43} catch (ValueError $exception) { 44 echo $exception->getMessage() . "\n"; 45} 46?> 47--EXPECT-- 48Memory cost is outside of allowed memory range 49Time cost is outside of allowed time range 50Invalid number of threads 51Memory cost is outside of allowed memory range 52Time cost is outside of allowed time range 53Invalid number of threads 54