|  | 
|  | 1 | +--TEST-- | 
|  | 2 | +Test error operation of password_hash() with Yescrypt | 
|  | 3 | +--FILE-- | 
|  | 4 | +<?php | 
|  | 5 | +try { | 
|  | 6 | +    password_hash('test', PASSWORD_YESCRYPT, ['block_count' => 3]); | 
|  | 7 | +} catch (ValueError $exception) { | 
|  | 8 | +    echo $exception->getMessage() . "\n"; | 
|  | 9 | +} | 
|  | 10 | + | 
|  | 11 | +try { | 
|  | 12 | +    password_hash('test', PASSWORD_YESCRYPT, ['block_count' => -1]); | 
|  | 13 | +} catch (ValueError $exception) { | 
|  | 14 | +    echo $exception->getMessage() . "\n"; | 
|  | 15 | +} | 
|  | 16 | + | 
|  | 17 | +try { | 
|  | 18 | +    password_hash('test', PASSWORD_YESCRYPT, ['block_count' => []]); | 
|  | 19 | +} catch (ValueError $exception) { | 
|  | 20 | +    echo $exception->getMessage() . "\n"; | 
|  | 21 | +} | 
|  | 22 | + | 
|  | 23 | +try { | 
|  | 24 | +    password_hash('test', PASSWORD_YESCRYPT, ['block_size' => 0]); | 
|  | 25 | +} catch (ValueError $exception) { | 
|  | 26 | +    echo $exception->getMessage() . "\n"; | 
|  | 27 | +} | 
|  | 28 | + | 
|  | 29 | +try { | 
|  | 30 | +    password_hash('test', PASSWORD_YESCRYPT, ['block_size' => []]); | 
|  | 31 | +} catch (ValueError $exception) { | 
|  | 32 | +    echo $exception->getMessage() . "\n"; | 
|  | 33 | +} | 
|  | 34 | + | 
|  | 35 | +try { | 
|  | 36 | +    password_hash('test', PASSWORD_YESCRYPT, ['parallelism' => 0]); | 
|  | 37 | +} catch (ValueError $exception) { | 
|  | 38 | +    echo $exception->getMessage() . "\n"; | 
|  | 39 | +} | 
|  | 40 | + | 
|  | 41 | +try { | 
|  | 42 | +    password_hash('test', PASSWORD_YESCRYPT, ['parallelism' => []]); | 
|  | 43 | +} catch (ValueError $exception) { | 
|  | 44 | +    echo $exception->getMessage() . "\n"; | 
|  | 45 | +} | 
|  | 46 | + | 
|  | 47 | +try { | 
|  | 48 | +    password_hash('test', PASSWORD_YESCRYPT, ['time' => -1]); | 
|  | 49 | +} catch (ValueError $exception) { | 
|  | 50 | +    echo $exception->getMessage() . "\n"; | 
|  | 51 | +} | 
|  | 52 | + | 
|  | 53 | +try { | 
|  | 54 | +    password_hash('test', PASSWORD_YESCRYPT, ['time' => []]); | 
|  | 55 | +} catch (ValueError $exception) { | 
|  | 56 | +    echo $exception->getMessage() . "\n"; | 
|  | 57 | +} | 
|  | 58 | + | 
|  | 59 | +?> | 
|  | 60 | +--EXPECT-- | 
|  | 61 | +Parameter "block_count" must be between 4 and 4294967295 | 
|  | 62 | +Parameter "block_count" must be between 4 and 4294967295 | 
|  | 63 | +Parameter "block_count" cannot be converted to int | 
|  | 64 | +Parameter "block_size" must be greater than 0 | 
|  | 65 | +Parameter "block_size" cannot be converted to int | 
|  | 66 | +Parameter "parallelism" must be greater than 0 | 
|  | 67 | +Parameter "parallelism" cannot be converted to int | 
|  | 68 | +Parameter "time" must be greater than or equal to 0 | 
|  | 69 | +Parameter "time" cannot be converted to int | 
0 commit comments