2009-01-07 14:32:46 +00:00
|
|
|
--TEST--
|
2018-10-14 16:03:31 +00:00
|
|
|
Hash: hash_hmac_file() function : basic functionality
|
2009-01-07 14:32:46 +00:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
echo "*** Testing hash() : error conditions ***\n";
|
|
|
|
|
2019-03-15 21:55:30 +00:00
|
|
|
$file = __DIR__ . "hash_file.txt";
|
2009-01-07 14:32:46 +00:00
|
|
|
$key = 'secret';
|
|
|
|
|
|
|
|
echo "\n-- Testing hash_hmac_file() function with invalid hash algorithm --\n";
|
2020-02-03 21:52:20 +00:00
|
|
|
try {
|
2019-08-26 21:34:50 +00:00
|
|
|
var_dump(hash_hmac_file('foo', $file, $key, TRUE));
|
|
|
|
}
|
|
|
|
catch (\Error $e) {
|
|
|
|
echo $e->getMessage() . "\n";
|
|
|
|
}
|
2009-01-07 14:32:46 +00:00
|
|
|
|
2017-01-16 13:51:13 +00:00
|
|
|
echo "\n-- Testing hash_hmac_file() function with non-cryptographic hash algorithm --\n";
|
2019-08-26 21:34:50 +00:00
|
|
|
try {
|
|
|
|
var_dump(hash_hmac_file('crc32', $file, $key, TRUE));
|
|
|
|
}
|
|
|
|
catch (\Error $e) {
|
|
|
|
echo $e->getMessage() . "\n";
|
|
|
|
}
|
2017-01-16 13:51:13 +00:00
|
|
|
|
2015-04-05 23:01:24 +00:00
|
|
|
echo "\n-- Testing hash_hmac_file() function with bad path --\n";
|
2019-08-26 21:34:50 +00:00
|
|
|
try {
|
|
|
|
var_dump(hash_hmac_file('md5', $file.chr(0).$file, $key, TRUE));
|
|
|
|
}
|
2020-09-08 10:12:26 +00:00
|
|
|
catch (ValueError $e) {
|
2019-08-26 21:34:50 +00:00
|
|
|
echo $e->getMessage() . "\n";
|
|
|
|
}
|
2015-04-05 23:01:24 +00:00
|
|
|
|
2009-01-07 14:32:46 +00:00
|
|
|
?>
|
2019-08-26 21:34:50 +00:00
|
|
|
--EXPECT--
|
2009-01-07 14:32:46 +00:00
|
|
|
*** Testing hash() : error conditions ***
|
|
|
|
|
|
|
|
-- Testing hash_hmac_file() function with invalid hash algorithm --
|
2020-03-18 19:58:45 +00:00
|
|
|
hash_hmac_file(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
|
2015-04-05 23:01:24 +00:00
|
|
|
|
2017-01-16 13:51:13 +00:00
|
|
|
-- Testing hash_hmac_file() function with non-cryptographic hash algorithm --
|
2020-03-18 19:58:45 +00:00
|
|
|
hash_hmac_file(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
|
2017-01-16 13:51:13 +00:00
|
|
|
|
2015-04-05 23:01:24 +00:00
|
|
|
-- Testing hash_hmac_file() function with bad path --
|
2020-09-08 10:12:26 +00:00
|
|
|
hash_hmac_file(): Argument #2 ($data) must not contain any null bytes
|