summaryrefslogtreecommitdiff
path: root/ext/hash
diff options
context:
space:
mode:
Diffstat (limited to 'ext/hash')
-rw-r--r--ext/hash/config.m43
-rw-r--r--ext/hash/config.w321
-rw-r--r--ext/hash/hash.c55
-rw-r--r--ext/hash/tests/mhash_001.phpt4
-rw-r--r--ext/hash/tests/mhash_003.phpt2
-rw-r--r--ext/hash/tests/skip_mhash.inc4
6 files changed, 30 insertions, 39 deletions
diff --git a/ext/hash/config.m4 b/ext/hash/config.m4
index dd4b275c69..1c61b89b04 100644
--- a/ext/hash/config.m4
+++ b/ext/hash/config.m4
@@ -1,9 +1,6 @@
dnl $Id$
dnl config.m4 for extension hash
-PHP_ARG_WITH(mhash, for mhash support,
-[ --with-mhash[=DIR] Include mhash support])
-
PHP_ARG_ENABLE(hash, whether to enable hash support,
[ --disable-hash Disable hash support], yes)
diff --git a/ext/hash/config.w32 b/ext/hash/config.w32
index d854f12db2..f80317a15e 100644
--- a/ext/hash/config.w32
+++ b/ext/hash/config.w32
@@ -2,7 +2,6 @@
// vim:ft=javascript
ARG_ENABLE("hash", "enable hash support", "yes");
-ARG_WITH("mhash", "mhash support", "no");
if (PHP_MHASH != "no") {
if (PHP_HASH == "no") {
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index 70e1915f6a..6d7c33b035 100644
--- a/ext/hash/hash.c
+++ b/ext/hash/hash.c
@@ -607,27 +607,6 @@ static void php_hash_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
#ifdef PHP_MHASH_BC
-PHP_MINFO_FUNCTION(mhash)
-{
- php_info_print_table_start();
- php_info_print_table_row(2, "MHASH support", "Enabled");
- php_info_print_table_row(2, "MHASH API Version", "Emulated Support");
- php_info_print_table_end();
-}
-
-zend_module_entry mhash_module_entry = {
- STANDARD_MODULE_HEADER,
- "mhash",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- PHP_MINFO(mhash),
- NO_VERSION_YET,
- STANDARD_MODULE_PROPERTIES,
-};
-
static void mhash_init(INIT_FUNC_ARGS)
{
char buf[128];
@@ -643,28 +622,24 @@ static void mhash_init(INIT_FUNC_ARGS)
len = slprintf(buf, 127, "MHASH_%s", algorithm.mhash_name, strlen(algorithm.mhash_name));
zend_register_long_constant(buf, len + 1, algorithm.value, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
}
-
- zend_register_module_ex(&mhash_module_entry TSRMLS_CC);
}
PHP_FUNCTION(mhash)
{
- zval **z_algorithm;
- long algorithm;
+ zval *z_algorithm;
+ int algorithm;
- if (zend_parse_parameters(1 TSRMLS_CC, "Z", &z_algorithm) == FAILURE) {
+ if (zend_parse_parameters(1 TSRMLS_CC, "z", &z_algorithm) == FAILURE) {
return;
}
- SEPARATE_ZVAL(z_algorithm);
- convert_to_long_ex(z_algorithm);
- algorithm = Z_LVAL_PP(z_algorithm);
+ algorithm = Z_LVAL_P(z_algorithm);
/* need to conver the first parameter from int to string */
if (algorithm >= 0 && algorithm < MHASH_NUM_ALGOS) {
struct mhash_bc_entry algorithm_lookup = mhash_to_hash[algorithm];
if (algorithm_lookup.hash_name) {
- ZVAL_STRING(*z_algorithm, algorithm_lookup.hash_name, 1);
+ ZVAL_STRING(z_algorithm, algorithm_lookup.hash_name, 1);
}
}
@@ -890,11 +865,13 @@ PHP_MINFO_FUNCTION(hash)
/* {{{ arginfo */
#ifdef PHP_HASH_MD5_NOT_IN_CORE
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_md5, 0, 0, 1)
ZEND_ARG_INFO(0, str)
ZEND_ARG_INFO(0, raw_output)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_md5_file, 0, 0, 1)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, raw_output)
@@ -902,29 +879,34 @@ ZEND_END_ARG_INFO()
#endif
#ifdef PHP_HASH_SHA1_NOT_IN_CORE
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_sha1, 0, 0, 1)
ZEND_ARG_INFO(0, str)
ZEND_ARG_INFO(0, raw_output)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_sha1_file, 0, 0, 1)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, raw_output)
ZEND_END_ARG_INFO()
#endif
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash, 0, 0, 2)
ZEND_ARG_INFO(0, algo)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(0, raw_output)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_file, 0, 0, 2)
ZEND_ARG_INFO(0, algo)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, raw_output)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_hmac, 0, 0, 3)
ZEND_ARG_INFO(0, algo)
ZEND_ARG_INFO(0, data)
@@ -932,6 +914,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_hmac, 0, 0, 3)
ZEND_ARG_INFO(0, raw_output)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_hmac_file, 0, 0, 3)
ZEND_ARG_INFO(0, algo)
ZEND_ARG_INFO(0, filename)
@@ -939,51 +922,61 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_hmac_file, 0, 0, 3)
ZEND_ARG_INFO(0, raw_output)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_init, 0, 0, 1)
ZEND_ARG_INFO(0, algo)
ZEND_ARG_INFO(0, options)
ZEND_ARG_INFO(0, key)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_hash_update, 0)
ZEND_ARG_INFO(0, context)
ZEND_ARG_INFO(0, data)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_update_stream, 0, 0, 2)
ZEND_ARG_INFO(0, context)
ZEND_ARG_INFO(0, handle)
ZEND_ARG_INFO(0, length)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_update_file, 0, 0, 2)
ZEND_ARG_INFO(0, context)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, context)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_hash_final, 0, 0, 1)
ZEND_ARG_INFO(0, context)
ZEND_ARG_INFO(0, raw_output)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_hash_copy, 0)
ZEND_ARG_INFO(0, context)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_hash_algos, 0)
ZEND_END_ARG_INFO()
/* BC Land */
#ifdef PHP_MHASH_BC
+static
ZEND_BEGIN_ARG_INFO(arginfo_mhash_get_block_size, 0)
ZEND_ARG_INFO(0, hash)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_mhash_get_hash_name, 0)
ZEND_ARG_INFO(0, hash)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_mhash_keygen_s2k, 0)
ZEND_ARG_INFO(0, hash)
ZEND_ARG_INFO(0, input_password)
@@ -991,9 +984,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_mhash_keygen_s2k, 0)
ZEND_ARG_INFO(0, bytes)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_mhash_count, 0)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_mhash, 0, 0, 2)
ZEND_ARG_INFO(0, hash)
ZEND_ARG_INFO(0, data)
diff --git a/ext/hash/tests/mhash_001.phpt b/ext/hash/tests/mhash_001.phpt
index b2a92839be..2d40e68d64 100644
--- a/ext/hash/tests/mhash_001.phpt
+++ b/ext/hash/tests/mhash_001.phpt
@@ -20,7 +20,7 @@ $supported_hash_al = array(
"MHASH_GOST" => "101b0a2552cebdf5137cadf15147f21e55b6432935bb9c2c03c7e28d188b2d9e",
"MHASH_TIGER" => "fdb9019a79c33a95677e2097abae91eb0de00b3054bb5c39",
"MHASH_CRC32" => "83041db8",
-"MHASH_CRC32B" => "df5ab7a4"
+"MHASH_CRC32B" => "a4b75adf"
);
$data = "This is the test of the mhash extension...";
@@ -33,7 +33,7 @@ foreach ($supported_hash_al as $hash=>$wanted) {
echo "$hash: ";
var_dump($wanted);
echo "$hash: ";
- var_dump(bin2hex($result));
+ var_dump($result);
}
echo "\n";
}
diff --git a/ext/hash/tests/mhash_003.phpt b/ext/hash/tests/mhash_003.phpt
index 7dcf247e1c..12e7a563ca 100644
--- a/ext/hash/tests/mhash_003.phpt
+++ b/ext/hash/tests/mhash_003.phpt
@@ -18,7 +18,7 @@ $supported_hash_al = array(
"MHASH_GOST" => "c044f669bd7e8643953d77c682fd179242d9df157dadf873be4d9601e4647c018234689359e7220ab0492a6240d184c478634073dea87f79be7f86fd4e2564f7d709b68a46440a121250e00fc7d57d45a9c07ee23a704ff4148c0dad7077ec527b194d87",
"MHASH_TIGER" => "67eac97b9dca0a47b1f6262f330264e4ce1c233760fe3255f642512fd3127929baccf1e758236b2768a4c2c0c06e118b19e40e2f04a5f745820fb8a99bdbc00698702a4d3120171856c4c94bda79ba1b4f60d509d7f8954da818a29797368dd47c1122aa",
"MHASH_CRC32" => "481c40148c26185f9a59ef18e86f51c5d2d0315b46711d22ae08c1ccdd669fe956c817380815e3a545f6ee453c9da48d1d994dbc3ac8ba85a572108412f06b2a16b1489cda75b118e82f7d9bdfdb68336957bbf19e4a3f76750d6985a53dd557229dfcf3",
-"MHASH_CRC32B" => "65ab6cb5fb7d3ea67f5da92a9bd746b6628a13368fcbcd43af49092e9c6a960fd030a5ce3c1f0ddb512ec698be96e77969748db66278b0fd837d24d8c898f50bd70993b48cc8accf4b44c54431e91385ddf04c7560a1a7368fc9e6f763457c90b07f04f1"
+"MHASH_CRC32B" => "b56cab65a63e7dfb2aa95d7fb646d79b36138a6243cdcb8f2e0949af0f966a9ccea530d0db0d1f3c98c62e5179e796beb68d7469fdb07862d8247d830bf598c8b49309d7cfacc88c44c5444b8513e931754cf0dd36a7a160f7e6c98f907c4563f1047fb0"
);
foreach ($supported_hash_al as $hash=>$wanted) {
diff --git a/ext/hash/tests/skip_mhash.inc b/ext/hash/tests/skip_mhash.inc
index 17e5fe7f9e..ff60bfff27 100644
--- a/ext/hash/tests/skip_mhash.inc
+++ b/ext/hash/tests/skip_mhash.inc
@@ -1,5 +1,5 @@
<?php
-if (!extension_loaded("mhash") || !function_exists("mhash")) {
+if (!extension_loaded("mhash")) {
die("skip mhash extension is not available");
}
-?>
+?> \ No newline at end of file