Skip to content

Commit 56d6635

Browse files
committed
Hash fixes
1 parent 3448a4c commit 56d6635

8 files changed

+0
-154
lines changed

ext/hash/tests/hash_error.phpt

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ Hash: hash() function : error conditions
1010
*/
1111
echo "*** Testing hash() : error conditions ***\n";
1212

13-
echo "\n-- Testing hash() function with less than expected no. of arguments --\n";
14-
var_dump(hash());
15-
var_dump(hash('adler32'));
16-
17-
echo "\n-- Testing hash() function with more than expected no. of arguments --\n";
18-
$extra_arg= 10;
19-
var_dump(hash('adler32', '', false, $extra_arg));
20-
2113
echo "\n-- Testing hash() function with invalid hash algorithm --\n";
2214
var_dump(hash('foo', ''));
2315

@@ -26,19 +18,6 @@ var_dump(hash('foo', ''));
2618
--EXPECTF--
2719
*** Testing hash() : error conditions ***
2820

29-
-- Testing hash() function with less than expected no. of arguments --
30-
31-
Warning: hash() expects at least 2 parameters, 0 given in %s on line %d
32-
NULL
33-
34-
Warning: hash() expects at least 2 parameters, 1 given in %s on line %d
35-
NULL
36-
37-
-- Testing hash() function with more than expected no. of arguments --
38-
39-
Warning: hash() expects at most 3 parameters, 4 given in %s on line %d
40-
NULL
41-
4221
-- Testing hash() function with invalid hash algorithm --
4322

4423
Warning: hash(): Unknown hashing algorithm: foo in %s on line %d

ext/hash/tests/hash_file_error.phpt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ var_dump( hash_file( 'foobar', $filename ) );
2424
echo "\n-- Testing hash_file() function with a non-existent file --\n";
2525
var_dump( hash_file( 'md5', 'nonexistent.txt' ) );
2626

27-
echo "\n-- Testing hash_file() function with less than expected no. of arguments --\n";
28-
var_dump( hash_file( 'md5' ) );
29-
30-
echo "\n-- Testing hash_file() function with more than expected no. of arguments --\n";
31-
$extra_arg = 10;
32-
var_dump( hash_file( 'md5', $filename, false, $extra_arg ) );
33-
3427
?>
3528
===DONE===
3629
--CLEAN--
@@ -52,14 +45,4 @@ bool(false)
5245

5346
Warning: hash_file(%s): failed to open stream: No such file or directory in %s on line %d
5447
bool(false)
55-
56-
-- Testing hash_file() function with less than expected no. of arguments --
57-
58-
Warning: hash_file() expects at least 2 parameters, 1 given in %s on line %d
59-
NULL
60-
61-
-- Testing hash_file() function with more than expected no. of arguments --
62-
63-
Warning: hash_file() expects at most 3 parameters, 4 given in %s on line %d
64-
NULL
6548
===DONE===

ext/hash/tests/hash_hkdf_error.phpt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ $ikm = 'input key material';
1212

1313
echo "*** Testing hash_hkdf(): error conditions ***\n";
1414

15-
echo "\n-- Testing hash_hkdf() function with less than expected no. of arguments --\n";
16-
var_dump(hash_hkdf());
17-
var_dump(hash_hkdf('sha1'));
18-
19-
echo "\n-- Testing hash_hkdf() function with more than expected no. of arguments --\n";
20-
var_dump(hash_hkdf('sha1', $ikm, 20, '', '', 'extra parameter'));
21-
2215
echo "\n-- Testing hash_hkdf() function with invalid hash algorithm --\n";
2316
var_dump(hash_hkdf('foo', $ikm));
2417

@@ -41,19 +34,6 @@ var_dump(hash_hkdf('sha1', $ikm, 20 * 255 + 1)); // Length can't be more than 25
4134
--EXPECTF--
4235
*** Testing hash_hkdf(): error conditions ***
4336

44-
-- Testing hash_hkdf() function with less than expected no. of arguments --
45-
46-
Warning: hash_hkdf() expects at least 2 parameters, 0 given in %s on line %d
47-
NULL
48-
49-
Warning: hash_hkdf() expects at least 2 parameters, 1 given in %s on line %d
50-
NULL
51-
52-
-- Testing hash_hkdf() function with more than expected no. of arguments --
53-
54-
Warning: hash_hkdf() expects at most 5 parameters, 6 given in %s on line %d
55-
NULL
56-
5737
-- Testing hash_hkdf() function with invalid hash algorithm --
5838

5939
Warning: hash_hkdf(): Unknown hashing algorithm: foo in %s on line %d

ext/hash/tests/hash_hmac_error.phpt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ echo "*** Testing hash_hmac() : error conditions ***\n";
1212
$data = "This is a sample string used to test the hash_hmac function with various hashing algorithms";
1313
$key = 'secret';
1414

15-
echo "\n-- Testing hash_hmac() function with less than expected no. of arguments --\n";
16-
var_dump(hash_hmac());
17-
var_dump(hash_hmac('md5'));
18-
var_dump(hash_hmac('md5', $data));
19-
20-
echo "\n-- Testing hash_hmac() function with more than expected no. of arguments --\n";
21-
$extra_arg = 10;
22-
var_dump(hash_hmac('md5', $data, $key, TRUE, $extra_arg));
23-
2415
echo "\n-- Testing hash_hmac() function with invalid hash algorithm --\n";
2516
var_dump(hash_hmac('foo', $data, $key));
2617

@@ -32,22 +23,6 @@ var_dump(hash_hmac('crc32', $data, $key));
3223
--EXPECTF--
3324
*** Testing hash_hmac() : error conditions ***
3425

35-
-- Testing hash_hmac() function with less than expected no. of arguments --
36-
37-
Warning: hash_hmac() expects at least 3 parameters, 0 given in %s on line %d
38-
NULL
39-
40-
Warning: hash_hmac() expects at least 3 parameters, 1 given in %s on line %d
41-
NULL
42-
43-
Warning: hash_hmac() expects at least 3 parameters, 2 given in %s on line %d
44-
NULL
45-
46-
-- Testing hash_hmac() function with more than expected no. of arguments --
47-
48-
Warning: hash_hmac() expects at most 4 parameters, 5 given in %s on line %d
49-
NULL
50-
5126
-- Testing hash_hmac() function with invalid hash algorithm --
5227

5328
Warning: hash_hmac(): Unknown hashing algorithm: foo in %s on line %d

ext/hash/tests/hash_hmac_file_basic.phpt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ echo "whirlpool: " . hash_hmac_file('whirlpool', $file, $key) . "\n";
5454
echo "md5(raw): " . bin2hex(hash_hmac_file('md5', $file, $key, TRUE)). "\n";
5555
echo "sha256(raw): " . bin2hex(hash_hmac_file('sha256', $file, $key, TRUE)). "\n";
5656

57-
echo "Error cases:\n";
58-
hash_hmac_file();
59-
hash_hmac_file('foo', $file);
60-
hash_hmac_file('foo', $file, $key, TRUE, 10);
61-
6257
unlink($file);
6358

6459
?>
@@ -83,11 +78,4 @@ tiger192,3: ca89badf843ba68e3fae5832635aa848a72a4bc11676edd4
8378
whirlpool: 37a0fbb90547690d5e5e11c046f6654ffdb7bab15e16d9d79c7d85765cc4bdcbfd9df8db7a3ce9558f3f244fead00ca29cf05297f75596555195a0683f15d69f
8479
md5(raw): 8bddf39dd1c566c27acc7fa85ec36acf
8580
sha256(raw): 9135286ca4c84dec711e4b831f6cd39e672e5ff93d011321274eb76733cc1e40
86-
Error cases:
87-
88-
Warning: hash_hmac_file() expects at least 3 parameters, 0 given in %s on line %d
89-
90-
Warning: hash_hmac_file() expects at least 3 parameters, 2 given in %s on line %d
91-
92-
Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d
9381
===Done===

ext/hash/tests/hash_hmac_file_error.phpt

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ echo "*** Testing hash() : error conditions ***\n";
1414
$file = dirname(__FILE__) . "hash_file.txt";
1515
$key = 'secret';
1616

17-
echo "\n-- Testing hash_hmac_file() function with less than expected no. of arguments --\n";
18-
var_dump(hash_hmac_file());
19-
var_dump(hash_hmac_file('crc32'));
20-
var_dump(hash_hmac_file('crc32', $file));
21-
22-
echo "\n-- Testing hash_hmac_file() function with more than expected no. of arguments --\n";
23-
$extra_arg = 10;
24-
hash_hmac_file('crc32', $file, $key, TRUE, $extra_arg);
25-
2617
echo "\n-- Testing hash_hmac_file() function with invalid hash algorithm --\n";
2718
hash_hmac_file('foo', $file, $key, TRUE);
2819

@@ -37,21 +28,6 @@ hash_hmac_file('md5', $file.chr(0).$file, $key, TRUE);
3728
--EXPECTF--
3829
*** Testing hash() : error conditions ***
3930

40-
-- Testing hash_hmac_file() function with less than expected no. of arguments --
41-
42-
Warning: hash_hmac_file() expects at least 3 parameters, 0 given in %s on line %d
43-
NULL
44-
45-
Warning: hash_hmac_file() expects at least 3 parameters, 1 given in %s on line %d
46-
NULL
47-
48-
Warning: hash_hmac_file() expects at least 3 parameters, 2 given in %s on line %d
49-
NULL
50-
51-
-- Testing hash_hmac_file() function with more than expected no. of arguments --
52-
53-
Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d
54-
5531
-- Testing hash_hmac_file() function with invalid hash algorithm --
5632

5733
Warning: hash_hmac_file(): Unknown hashing algorithm: foo in %s on line %d

ext/hash/tests/hash_init_error.phpt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ Hash: hash_init() function - errors test
44
<?php
55
echo "*** Testing hash_init(): error conditions ***\n";
66

7-
echo "-- Testing hash_init() function with no parameters --\n";
8-
var_dump(hash_init());
9-
107
echo "-- Testing hash_init() function with unknown algorithms --\n";
118
var_dump(hash_init('dummy'));
129

@@ -19,10 +16,6 @@ var_dump(hash_init('md5', HASH_HMAC, null));
1916
?>
2017
--EXPECTF--
2118
*** Testing hash_init(): error conditions ***
22-
-- Testing hash_init() function with no parameters --
23-
24-
Warning: hash_init() expects at least 1 parameter, 0 given in %s on line %d
25-
NULL
2619
-- Testing hash_init() function with unknown algorithms --
2720

2821
Warning: hash_init(): Unknown hashing algorithm: dummy in %s on line %d

ext/hash/tests/hash_pbkdf2_error.phpt

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ echo "*** Testing hash_pbkdf2() : error conditions ***\n";
1212
$password = 'password';
1313
$salt = 'salt';
1414

15-
echo "\n-- Testing hash_pbkdf2() function with less than expected no. of arguments --\n";
16-
var_dump(hash_pbkdf2());
17-
var_dump(hash_pbkdf2('md5'));
18-
var_dump(hash_pbkdf2('md5', $password));
19-
var_dump(hash_pbkdf2('md5', $password, $salt));
20-
21-
echo "\n-- Testing hash_pbkdf2() function with more than expected no. of arguments --\n";
22-
var_dump(hash_pbkdf2('md5', $password, $salt, 10, 10, true, 'extra arg'));
23-
2415
echo "\n-- Testing hash_pbkdf2() function with invalid hash algorithm --\n";
2516
var_dump(hash_pbkdf2('foo', $password, $salt, 1));
2617

@@ -39,25 +30,6 @@ var_dump(hash_pbkdf2('md5', $password, $salt, 1, -1));
3930
--EXPECTF--
4031
*** Testing hash_pbkdf2() : error conditions ***
4132

42-
-- Testing hash_pbkdf2() function with less than expected no. of arguments --
43-
44-
Warning: hash_pbkdf2() expects at least 4 parameters, 0 given in %s on line %d
45-
NULL
46-
47-
Warning: hash_pbkdf2() expects at least 4 parameters, 1 given in %s on line %d
48-
NULL
49-
50-
Warning: hash_pbkdf2() expects at least 4 parameters, 2 given in %s on line %d
51-
NULL
52-
53-
Warning: hash_pbkdf2() expects at least 4 parameters, 3 given in %s on line %d
54-
NULL
55-
56-
-- Testing hash_pbkdf2() function with more than expected no. of arguments --
57-
58-
Warning: hash_pbkdf2() expects at most 6 parameters, 7 given in %s on line %d
59-
NULL
60-
6133
-- Testing hash_pbkdf2() function with invalid hash algorithm --
6234

6335
Warning: hash_pbkdf2(): Unknown hashing algorithm: foo in %s on line %d

0 commit comments

Comments
 (0)