diff options
Diffstat (limited to 'ext/hash')
-rw-r--r-- | ext/hash/config.m4 | 2 | ||||
-rw-r--r-- | ext/hash/config.w32 | 2 | ||||
-rw-r--r-- | ext/hash/hash.c | 14 | ||||
-rw-r--r-- | ext/hash/tests/hash_error.phpt | 21 | ||||
-rw-r--r-- | ext/hash/tests/hash_file_error.phpt | 17 | ||||
-rw-r--r-- | ext/hash/tests/hash_hkdf_error.phpt | 20 | ||||
-rw-r--r-- | ext/hash/tests/hash_hmac_error.phpt | 25 | ||||
-rw-r--r-- | ext/hash/tests/hash_hmac_file_basic.phpt | 12 | ||||
-rw-r--r-- | ext/hash/tests/hash_hmac_file_error.phpt | 24 | ||||
-rw-r--r-- | ext/hash/tests/hash_init_error.phpt | 7 | ||||
-rw-r--r-- | ext/hash/tests/hash_pbkdf2_error.phpt | 28 |
11 files changed, 5 insertions, 167 deletions
diff --git a/ext/hash/config.m4 b/ext/hash/config.m4 index 91c5241b00..ab550fcc8e 100644 --- a/ext/hash/config.m4 +++ b/ext/hash/config.m4 @@ -11,8 +11,6 @@ if test "$PHP_MHASH" != "no"; then AC_DEFINE(PHP_MHASH_BC, 1, [ ]) fi -AC_DEFINE(HAVE_HASH_EXT,1,[Have HASH Extension]) - if test $ac_cv_c_bigendian_php = yes; then EXT_HASH_SHA3_SOURCES="hash_sha3.c" AC_DEFINE(HAVE_SLOW_HASH3, 1, [Define is hash3 algo is available]) diff --git a/ext/hash/config.w32 b/ext/hash/config.w32 index bb3b339952..5d6be6b922 100644 --- a/ext/hash/config.w32 +++ b/ext/hash/config.w32 @@ -6,8 +6,6 @@ if (PHP_MHASH != 'no') { AC_DEFINE('PHP_MHASH_BC', 1); } -AC_DEFINE('HAVE_HASH_EXT', 1); - PHP_HASH = 'yes'; EXTENSION('hash', 'hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c ' + diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 449665a268..5b0c8570c9 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -570,7 +570,7 @@ PHP_FUNCTION(hash_copy) return; } - RETVAL_OBJ(Z_OBJ_HANDLER_P(zhash, clone_obj)(zhash)); + RETVAL_OBJ(Z_OBJ_HANDLER_P(zhash, clone_obj)(Z_OBJ_P(zhash))); if (php_hashcontext_from_object(Z_OBJ_P(return_value))->context == NULL) { zval_ptr_dtor(return_value); @@ -1138,12 +1138,12 @@ static void php_hashcontext_dtor(zend_object *obj) { /* }}} */ /* {{{ php_hashcontext_clone */ -static zend_object *php_hashcontext_clone(zval *pzv) { - php_hashcontext_object *oldobj = php_hashcontext_from_object(Z_OBJ_P(pzv)); - zend_object *znew = php_hashcontext_create(Z_OBJCE_P(pzv)); +static zend_object *php_hashcontext_clone(zend_object *zobj) { + php_hashcontext_object *oldobj = php_hashcontext_from_object(zobj); + zend_object *znew = php_hashcontext_create(zobj->ce); php_hashcontext_object *newobj = php_hashcontext_from_object(znew); - zend_objects_clone_members(znew, Z_OBJ_P(pzv)); + zend_objects_clone_members(znew, zobj); newobj->ops = oldobj->ops; newobj->options = oldobj->options; @@ -1488,7 +1488,3 @@ zend_module_entry hash_module_entry = { STANDARD_MODULE_PROPERTIES }; /* }}} */ - -#ifdef COMPILE_DL_HASH -ZEND_GET_MODULE(hash) -#endif diff --git a/ext/hash/tests/hash_error.phpt b/ext/hash/tests/hash_error.phpt index e760819e69..f879d491d7 100644 --- a/ext/hash/tests/hash_error.phpt +++ b/ext/hash/tests/hash_error.phpt @@ -10,14 +10,6 @@ Hash: hash() function : error conditions */ echo "*** Testing hash() : error conditions ***\n"; -echo "\n-- Testing hash() function with less than expected no. of arguments --\n"; -var_dump(hash()); -var_dump(hash('adler32')); - -echo "\n-- Testing hash() function with more than expected no. of arguments --\n"; -$extra_arg= 10; -var_dump(hash('adler32', '', false, $extra_arg)); - echo "\n-- Testing hash() function with invalid hash algorithm --\n"; var_dump(hash('foo', '')); @@ -26,19 +18,6 @@ var_dump(hash('foo', '')); --EXPECTF-- *** Testing hash() : error conditions *** --- Testing hash() function with less than expected no. of arguments -- - -Warning: hash() expects at least 2 parameters, 0 given in %s on line %d -NULL - -Warning: hash() expects at least 2 parameters, 1 given in %s on line %d -NULL - --- Testing hash() function with more than expected no. of arguments -- - -Warning: hash() expects at most 3 parameters, 4 given in %s on line %d -NULL - -- Testing hash() function with invalid hash algorithm -- Warning: hash(): Unknown hashing algorithm: foo in %s on line %d diff --git a/ext/hash/tests/hash_file_error.phpt b/ext/hash/tests/hash_file_error.phpt index a634070de5..b001001861 100644 --- a/ext/hash/tests/hash_file_error.phpt +++ b/ext/hash/tests/hash_file_error.phpt @@ -24,13 +24,6 @@ var_dump( hash_file( 'foobar', $filename ) ); echo "\n-- Testing hash_file() function with a non-existent file --\n"; var_dump( hash_file( 'md5', 'nonexistent.txt' ) ); -echo "\n-- Testing hash_file() function with less than expected no. of arguments --\n"; -var_dump( hash_file( 'md5' ) ); - -echo "\n-- Testing hash_file() function with more than expected no. of arguments --\n"; -$extra_arg = 10; -var_dump( hash_file( 'md5', $filename, false, $extra_arg ) ); - ?> ===DONE=== --CLEAN-- @@ -52,14 +45,4 @@ bool(false) Warning: hash_file(%s): failed to open stream: No such file or directory in %s on line %d bool(false) - --- Testing hash_file() function with less than expected no. of arguments -- - -Warning: hash_file() expects at least 2 parameters, 1 given in %s on line %d -NULL - --- Testing hash_file() function with more than expected no. of arguments -- - -Warning: hash_file() expects at most 3 parameters, 4 given in %s on line %d -NULL ===DONE=== diff --git a/ext/hash/tests/hash_hkdf_error.phpt b/ext/hash/tests/hash_hkdf_error.phpt index b833054e80..e5903f126a 100644 --- a/ext/hash/tests/hash_hkdf_error.phpt +++ b/ext/hash/tests/hash_hkdf_error.phpt @@ -12,13 +12,6 @@ $ikm = 'input key material'; echo "*** Testing hash_hkdf(): error conditions ***\n"; -echo "\n-- Testing hash_hkdf() function with less than expected no. of arguments --\n"; -var_dump(hash_hkdf()); -var_dump(hash_hkdf('sha1')); - -echo "\n-- Testing hash_hkdf() function with more than expected no. of arguments --\n"; -var_dump(hash_hkdf('sha1', $ikm, 20, '', '', 'extra parameter')); - echo "\n-- Testing hash_hkdf() function with invalid hash algorithm --\n"; var_dump(hash_hkdf('foo', $ikm)); @@ -41,19 +34,6 @@ var_dump(hash_hkdf('sha1', $ikm, 20 * 255 + 1)); // Length can't be more than 25 --EXPECTF-- *** Testing hash_hkdf(): error conditions *** --- Testing hash_hkdf() function with less than expected no. of arguments -- - -Warning: hash_hkdf() expects at least 2 parameters, 0 given in %s on line %d -NULL - -Warning: hash_hkdf() expects at least 2 parameters, 1 given in %s on line %d -NULL - --- Testing hash_hkdf() function with more than expected no. of arguments -- - -Warning: hash_hkdf() expects at most 5 parameters, 6 given in %s on line %d -NULL - -- Testing hash_hkdf() function with invalid hash algorithm -- Warning: hash_hkdf(): Unknown hashing algorithm: foo in %s on line %d diff --git a/ext/hash/tests/hash_hmac_error.phpt b/ext/hash/tests/hash_hmac_error.phpt index 89d29b8df8..1ed3e54127 100644 --- a/ext/hash/tests/hash_hmac_error.phpt +++ b/ext/hash/tests/hash_hmac_error.phpt @@ -12,15 +12,6 @@ echo "*** Testing hash_hmac() : error conditions ***\n"; $data = "This is a sample string used to test the hash_hmac function with various hashing algorithms"; $key = 'secret'; -echo "\n-- Testing hash_hmac() function with less than expected no. of arguments --\n"; -var_dump(hash_hmac()); -var_dump(hash_hmac('md5')); -var_dump(hash_hmac('md5', $data)); - -echo "\n-- Testing hash_hmac() function with more than expected no. of arguments --\n"; -$extra_arg = 10; -var_dump(hash_hmac('md5', $data, $key, TRUE, $extra_arg)); - echo "\n-- Testing hash_hmac() function with invalid hash algorithm --\n"; var_dump(hash_hmac('foo', $data, $key)); @@ -32,22 +23,6 @@ var_dump(hash_hmac('crc32', $data, $key)); --EXPECTF-- *** Testing hash_hmac() : error conditions *** --- Testing hash_hmac() function with less than expected no. of arguments -- - -Warning: hash_hmac() expects at least 3 parameters, 0 given in %s on line %d -NULL - -Warning: hash_hmac() expects at least 3 parameters, 1 given in %s on line %d -NULL - -Warning: hash_hmac() expects at least 3 parameters, 2 given in %s on line %d -NULL - --- Testing hash_hmac() function with more than expected no. of arguments -- - -Warning: hash_hmac() expects at most 4 parameters, 5 given in %s on line %d -NULL - -- Testing hash_hmac() function with invalid hash algorithm -- Warning: hash_hmac(): Unknown hashing algorithm: foo in %s on line %d diff --git a/ext/hash/tests/hash_hmac_file_basic.phpt b/ext/hash/tests/hash_hmac_file_basic.phpt index 6e4b4da078..7ce5cba7c4 100644 --- a/ext/hash/tests/hash_hmac_file_basic.phpt +++ b/ext/hash/tests/hash_hmac_file_basic.phpt @@ -54,11 +54,6 @@ echo "whirlpool: " . hash_hmac_file('whirlpool', $file, $key) . "\n"; echo "md5(raw): " . bin2hex(hash_hmac_file('md5', $file, $key, TRUE)). "\n"; echo "sha256(raw): " . bin2hex(hash_hmac_file('sha256', $file, $key, TRUE)). "\n"; -echo "Error cases:\n"; -hash_hmac_file(); -hash_hmac_file('foo', $file); -hash_hmac_file('foo', $file, $key, TRUE, 10); - unlink($file); ?> @@ -83,11 +78,4 @@ tiger192,3: ca89badf843ba68e3fae5832635aa848a72a4bc11676edd4 whirlpool: 37a0fbb90547690d5e5e11c046f6654ffdb7bab15e16d9d79c7d85765cc4bdcbfd9df8db7a3ce9558f3f244fead00ca29cf05297f75596555195a0683f15d69f md5(raw): 8bddf39dd1c566c27acc7fa85ec36acf sha256(raw): 9135286ca4c84dec711e4b831f6cd39e672e5ff93d011321274eb76733cc1e40 -Error cases: - -Warning: hash_hmac_file() expects at least 3 parameters, 0 given in %s on line %d - -Warning: hash_hmac_file() expects at least 3 parameters, 2 given in %s on line %d - -Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d ===Done=== diff --git a/ext/hash/tests/hash_hmac_file_error.phpt b/ext/hash/tests/hash_hmac_file_error.phpt index a3718ebb85..67a4a8550f 100644 --- a/ext/hash/tests/hash_hmac_file_error.phpt +++ b/ext/hash/tests/hash_hmac_file_error.phpt @@ -14,15 +14,6 @@ echo "*** Testing hash() : error conditions ***\n"; $file = __DIR__ . "hash_file.txt"; $key = 'secret'; -echo "\n-- Testing hash_hmac_file() function with less than expected no. of arguments --\n"; -var_dump(hash_hmac_file()); -var_dump(hash_hmac_file('crc32')); -var_dump(hash_hmac_file('crc32', $file)); - -echo "\n-- Testing hash_hmac_file() function with more than expected no. of arguments --\n"; -$extra_arg = 10; -hash_hmac_file('crc32', $file, $key, TRUE, $extra_arg); - echo "\n-- Testing hash_hmac_file() function with invalid hash algorithm --\n"; hash_hmac_file('foo', $file, $key, TRUE); @@ -37,21 +28,6 @@ hash_hmac_file('md5', $file.chr(0).$file, $key, TRUE); --EXPECTF-- *** Testing hash() : error conditions *** --- Testing hash_hmac_file() function with less than expected no. of arguments -- - -Warning: hash_hmac_file() expects at least 3 parameters, 0 given in %s on line %d -NULL - -Warning: hash_hmac_file() expects at least 3 parameters, 1 given in %s on line %d -NULL - -Warning: hash_hmac_file() expects at least 3 parameters, 2 given in %s on line %d -NULL - --- Testing hash_hmac_file() function with more than expected no. of arguments -- - -Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d - -- Testing hash_hmac_file() function with invalid hash algorithm -- Warning: hash_hmac_file(): Unknown hashing algorithm: foo in %s on line %d diff --git a/ext/hash/tests/hash_init_error.phpt b/ext/hash/tests/hash_init_error.phpt index e941aabca5..9105b96801 100644 --- a/ext/hash/tests/hash_init_error.phpt +++ b/ext/hash/tests/hash_init_error.phpt @@ -4,9 +4,6 @@ Hash: hash_init() function - errors test <?php echo "*** Testing hash_init(): error conditions ***\n"; -echo "-- Testing hash_init() function with no parameters --\n"; -var_dump(hash_init()); - echo "-- Testing hash_init() function with unknown algorithms --\n"; var_dump(hash_init('dummy')); @@ -19,10 +16,6 @@ var_dump(hash_init('md5', HASH_HMAC, null)); ?> --EXPECTF-- *** Testing hash_init(): error conditions *** --- Testing hash_init() function with no parameters -- - -Warning: hash_init() expects at least 1 parameter, 0 given in %s on line %d -NULL -- Testing hash_init() function with unknown algorithms -- Warning: hash_init(): Unknown hashing algorithm: dummy in %s on line %d diff --git a/ext/hash/tests/hash_pbkdf2_error.phpt b/ext/hash/tests/hash_pbkdf2_error.phpt index c0a76e17b4..a7fd08649b 100644 --- a/ext/hash/tests/hash_pbkdf2_error.phpt +++ b/ext/hash/tests/hash_pbkdf2_error.phpt @@ -12,15 +12,6 @@ echo "*** Testing hash_pbkdf2() : error conditions ***\n"; $password = 'password'; $salt = 'salt'; -echo "\n-- Testing hash_pbkdf2() function with less than expected no. of arguments --\n"; -var_dump(hash_pbkdf2()); -var_dump(hash_pbkdf2('md5')); -var_dump(hash_pbkdf2('md5', $password)); -var_dump(hash_pbkdf2('md5', $password, $salt)); - -echo "\n-- Testing hash_pbkdf2() function with more than expected no. of arguments --\n"; -var_dump(hash_pbkdf2('md5', $password, $salt, 10, 10, true, 'extra arg')); - echo "\n-- Testing hash_pbkdf2() function with invalid hash algorithm --\n"; var_dump(hash_pbkdf2('foo', $password, $salt, 1)); @@ -39,25 +30,6 @@ var_dump(hash_pbkdf2('md5', $password, $salt, 1, -1)); --EXPECTF-- *** Testing hash_pbkdf2() : error conditions *** --- Testing hash_pbkdf2() function with less than expected no. of arguments -- - -Warning: hash_pbkdf2() expects at least 4 parameters, 0 given in %s on line %d -NULL - -Warning: hash_pbkdf2() expects at least 4 parameters, 1 given in %s on line %d -NULL - -Warning: hash_pbkdf2() expects at least 4 parameters, 2 given in %s on line %d -NULL - -Warning: hash_pbkdf2() expects at least 4 parameters, 3 given in %s on line %d -NULL - --- Testing hash_pbkdf2() function with more than expected no. of arguments -- - -Warning: hash_pbkdf2() expects at most 6 parameters, 7 given in %s on line %d -NULL - -- Testing hash_pbkdf2() function with invalid hash algorithm -- Warning: hash_pbkdf2(): Unknown hashing algorithm: foo in %s on line %d |