[PHP-CVS] cvs: php-src /ext/hash hash.c /ext/mhash CREDITS config.m4 config.w32 mhash.c php_mhash.h

2008-11-27 Thread Scott MacVicar
scottmacThu Nov 27 21:11:51 2008 UTC

  Removed files:   
/php-src/ext/mhash  CREDITS config.m4 config.w32 mhash.c php_mhash.h 

  Modified files:  
/php-src/ext/hash   hash.c 
  Log:
  Move mhash extension registration code into the hash module startup. This 
allows extension_loaded('mhash'); to work.
  
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.51&r2=1.52&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.51 php-src/ext/hash/hash.c:1.52
--- php-src/ext/hash/hash.c:1.51Mon Nov 17 11:26:20 2008
+++ php-src/ext/hash/hash.c Thu Nov 27 21:11:51 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.51 2008/11/17 11:26:20 felipe Exp $ */
+/* $Id: hash.c,v 1.52 2008/11/27 21:11:51 scottmac Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -776,6 +776,27 @@
 
 #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];
@@ -791,6 +812,8 @@
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);
 }
 
 /* {{{ proto binary mhash(int hash, binary data [, binary key]) U



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/hash hash.c /ext/hash/tests mhash_001.phpt mhash_004.phpt

2008-09-18 Thread Scott MacVicar
scottmacThu Sep 18 11:52:12 2008 UTC

  Added files: 
/php-src/ext/hash/tests mhash_004.phpt 

  Modified files:  
/php-src/ext/hash   hash.c 
/php-src/ext/hash/tests mhash_001.phpt 
  Log:
  mhash algorithm parameter was modified when it was a zval, also update a test.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.47&r2=1.48&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.47 php-src/ext/hash/hash.c:1.48
--- php-src/ext/hash/hash.c:1.47Mon Jul 14 10:49:10 2008
+++ php-src/ext/hash/hash.c Thu Sep 18 11:52:12 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.47 2008/07/14 10:49:10 tony2001 Exp $ */
+/* $Id: hash.c,v 1.48 2008/09/18 11:52:12 scottmac Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -797,20 +797,22 @@
Hash data with hash */
 PHP_FUNCTION(mhash)
 {
-   zval *z_algorithm;
-   int algorithm;
+   zval **z_algorithm;
+   long algorithm;
 
-   if (zend_parse_parameters(1 TSRMLS_CC, "z", &z_algorithm) == FAILURE) {
+   if (zend_parse_parameters(1 TSRMLS_CC, "Z", &z_algorithm) == FAILURE) {
return;
}
 
-   algorithm = Z_LVAL_P(z_algorithm);
+   SEPARATE_ZVAL(z_algorithm);
+   convert_to_long_ex(z_algorithm);
+   algorithm = Z_LVAL_PP(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);
}
}
 
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/tests/mhash_001.phpt?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/hash/tests/mhash_001.phpt
diff -u php-src/ext/hash/tests/mhash_001.phpt:1.2 
php-src/ext/hash/tests/mhash_001.phpt:1.3
--- php-src/ext/hash/tests/mhash_001.phpt:1.2   Sat Jun 28 15:20:49 2008
+++ php-src/ext/hash/tests/mhash_001.phpt   Thu Sep 18 11:52:12 2008
@@ -33,7 +33,7 @@
echo "$hash: ";
var_dump($wanted);
echo "$hash: ";
-   var_dump($result);
+   var_dump(bin2hex($result));
}
echo "\n";
 }

http://cvs.php.net/viewvc.cgi/php-src/ext/hash/tests/mhash_004.phpt?view=markup&rev=1.1
Index: php-src/ext/hash/tests/mhash_004.phpt
+++ php-src/ext/hash/tests/mhash_004.phpt
--TEST--
mhash() modifying algorithm parameter
--INI--
magic_quotes_runtime=0
--SKIPIF--

--FILE--

--EXPECT--
int(1)
unicode(32) "098f6bcd4621d373cade4e832627b4f6"
int(1)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/hash hash.c

2008-07-14 Thread Antony Dovgal
tony2001Mon Jul 14 10:49:10 2008 UTC

  Modified files:  
/php-src/ext/hash   hash.c 
  Log:
  use long for "l"
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.46&r2=1.47&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.46 php-src/ext/hash/hash.c:1.47
--- php-src/ext/hash/hash.c:1.46Sat Jul  5 00:34:24 2008
+++ php-src/ext/hash/hash.c Mon Jul 14 10:49:10 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.46 2008/07/05 00:34:24 scottmac Exp $ */
+/* $Id: hash.c,v 1.47 2008/07/14 10:49:10 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -828,7 +828,7 @@
Gets the name of hash */
 PHP_FUNCTION(mhash_get_hash_name)
 {
-   int algorithm;
+   long algorithm;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &algorithm) 
== FAILURE) {
return;
@@ -859,7 +859,7 @@
Gets the block size of hash */
 PHP_FUNCTION(mhash_get_block_size)
 {
-   int algorithm;
+   long algorithm;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &algorithm) 
== FAILURE) {
return;
@@ -884,7 +884,7 @@
Generates a key using hash functions */
 PHP_FUNCTION(mhash_keygen_s2k)
 {
-   int algorithm, bytes;
+   long algorithm, bytes;
char *password, *salt;
int password_len, salt_len;
char padded_salt[SALT_SIZE];



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/hash hash.c

2008-07-04 Thread Scott MacVicar
scottmacSat Jul  5 00:34:24 2008 UTC

  Modified files:  
/php-src/ext/hash   hash.c 
  Log:
  MFB: Fix break caused by previous commit, warning and remove 
zend_get_parameters()
  
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.45&r2=1.46&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.45 php-src/ext/hash/hash.c:1.46
--- php-src/ext/hash/hash.c:1.45Fri Jul  4 21:01:26 2008
+++ php-src/ext/hash/hash.c Sat Jul  5 00:34:24 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.45 2008/07/04 21:01:26 pajoye Exp $ */
+/* $Id: hash.c,v 1.46 2008/07/05 00:34:24 scottmac Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -789,11 +789,7 @@
}
 
len = slprintf(buf, 127, "MHASH_%s", algorithm.mhash_name, 
strlen(algorithm.mhash_name));
-   {
-   char name[128];
-   memcpy(name, buf, len+1);
-   REGISTER_LONG_CONSTANT(name, algorithm.value, CONST_CS 
| CONST_PERSISTENT);
-   }
+   zend_register_long_constant(buf, len + 1, algorithm.value, 
CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
}
 }
 
@@ -801,20 +797,20 @@
Hash data with hash */
 PHP_FUNCTION(mhash)
 {
-   zval **z_algorithm;
+   zval *z_algorithm;
int algorithm;
 
-   if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_ex(1, &z_algorithm) == 
FAILURE) {
-   WRONG_PARAM_COUNT;
+   if (zend_parse_parameters(1 TSRMLS_CC, "z", &z_algorithm) == FAILURE) {
+   return;
}
 
-   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);
}
}
 
@@ -937,8 +933,8 @@
ops->hash_update(context, 
&null, 1);
}
ops->hash_update(context, (unsigned 
char *)padded_salt, salt_len);
-   ops->hash_update(context, password, 
password_len);
-   ops->hash_final(digest, context);
+   ops->hash_update(context, (unsigned 
char *)password, password_len);
+   ops->hash_final((unsigned char 
*)digest, context);
memcpy( &key[i*block_size], digest, 
block_size);
}
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/hash hash.c

2008-07-04 Thread Pierre-Alain Joye
pajoye  Fri Jul  4 21:01:26 2008 UTC

  Modified files:  
/php-src/ext/hash   hash.c 
  Log:
  - MFB: fix compile error with VC6
  
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.44&r2=1.45&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.44 php-src/ext/hash/hash.c:1.45
--- php-src/ext/hash/hash.c:1.44Sat Jun 28 15:20:49 2008
+++ php-src/ext/hash/hash.c Fri Jul  4 21:01:26 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.44 2008/06/28 15:20:49 scottmac Exp $ */
+/* $Id: hash.c,v 1.45 2008/07/04 21:01:26 pajoye Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -790,7 +790,7 @@
 
len = slprintf(buf, 127, "MHASH_%s", algorithm.mhash_name, 
strlen(algorithm.mhash_name));
{
-   char name[len+1];
+   char name[128];
memcpy(name, buf, len+1);
REGISTER_LONG_CONSTANT(name, algorithm.value, CONST_CS 
| CONST_PERSISTENT);
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/hash hash.c

2008-06-03 Thread Scott MacVicar
scottmacTue Jun  3 17:27:10 2008 UTC

  Modified files:  
/php-src/ext/hash   hash.c 
  Log:
  MFB: Add snefru256 as an alias for snefru, since in reality that is the 
implementation.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.42&r2=1.43&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.42 php-src/ext/hash/hash.c:1.43
--- php-src/ext/hash/hash.c:1.42Mon Jun  2 14:13:49 2008
+++ php-src/ext/hash/hash.c Tue Jun  3 17:27:10 2008
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.42 2008/06/02 14:13:49 scottmac Exp $ */
+/* $Id: hash.c,v 1.43 2008/06/03 17:27:10 scottmac Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -761,6 +761,7 @@
php_hash_register_algo("tiger160,4",&php_hash_4tiger160_ops);
php_hash_register_algo("tiger192,4",&php_hash_4tiger192_ops);
php_hash_register_algo("snefru",&php_hash_snefru_ops);
+   php_hash_register_algo("snefru256", &php_hash_snefru_ops);
php_hash_register_algo("gost",  &php_hash_gost_ops);
php_hash_register_algo("adler32",   &php_hash_adler32_ops);
php_hash_register_algo("crc32", &php_hash_crc32_ops);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/hash hash.c hash_sha.c php_hash.h php_hash_sha.h /ext/hash/tests sha224.phpt

2008-06-02 Thread Scott MacVicar
scottmacMon Jun  2 14:13:49 2008 UTC

  Modified files:  
/php-src/ext/hash   hash.c hash_sha.c php_hash.h php_hash_sha.h 
/php-src/ext/hash/tests sha224.phpt 
  Log:
  MFB: Add sha224 support.
  http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.41&r2=1.42&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.41 php-src/ext/hash/hash.c:1.42
--- php-src/ext/hash/hash.c:1.41Mon Apr 21 15:37:07 2008
+++ php-src/ext/hash/hash.c Mon Jun  2 14:13:49 2008
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.41 2008/04/21 15:37:07 tony2001 Exp $ */
+/* $Id: hash.c,v 1.42 2008/06/02 14:13:49 scottmac Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -745,6 +745,7 @@
php_hash_register_algo("md4",   &php_hash_md4_ops);
php_hash_register_algo("md5",   &php_hash_md5_ops);
php_hash_register_algo("sha1",  &php_hash_sha1_ops);
+   php_hash_register_algo("sha224",&php_hash_sha224_ops);
php_hash_register_algo("sha256",&php_hash_sha256_ops);
php_hash_register_algo("sha384",&php_hash_sha384_ops);
php_hash_register_algo("sha512",&php_hash_sha512_ops);
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash_sha.c?r1=1.17&r2=1.18&diff_format=u
Index: php-src/ext/hash/hash_sha.c
diff -u php-src/ext/hash/hash_sha.c:1.17 php-src/ext/hash/hash_sha.c:1.18
--- php-src/ext/hash/hash_sha.c:1.17Mon Apr 21 15:37:07 2008
+++ php-src/ext/hash/hash_sha.c Mon Jun  2 14:13:49 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: hash_sha.c,v 1.17 2008/04/21 15:37:07 tony2001 Exp $ */
+/* $Id: hash_sha.c,v 1.18 2008/06/02 14:13:49 scottmac Exp $ */
 
 #include "php_hash.h"
 #include "php_hash_sha.h"
@@ -76,7 +76,7 @@
sizeof(PHP_SHA1_CTX)
 };
 
-/* sha256 */
+/* sha224/sha256 */
 
 const php_hash_ops php_hash_sha256_ops = {
(php_hash_init_func_t) PHP_SHA256Init,
@@ -88,6 +88,16 @@
sizeof(PHP_SHA256_CTX)
 };
 
+const php_hash_ops php_hash_sha224_ops = {
+   (php_hash_init_func_t) PHP_SHA224Init,
+   (php_hash_update_func_t) PHP_SHA224Update,
+   (php_hash_final_func_t) PHP_SHA224Final,
+   (php_hash_copy_func_t) php_hash_copy,
+   28,
+   64,
+   sizeof(PHP_SHA224_CTX)
+};
+
 #define ROTR32(b,x)((x >> b) | (x << (32 - b)))
 #define ROTR64(b,x)((x >> b) | (x << (64 - b)))
 #define SHR(b, x)  (x >> b)
@@ -175,6 +185,102 @@
 }
 /* }}} */
 
+/* {{{ PHP_SHA224Init
+ * SHA224 initialization. Begins an SHA224 operation, writing a new context.
+ */
+PHP_HASH_API void PHP_SHA224Init(PHP_SHA224_CTX * context)
+{
+   context->count[0] = context->count[1] = 0;
+   /* Load magic initialization constants.
+*/
+   context->state[0] = 0xc1059ed8;
+   context->state[1] = 0x367cd507;
+   context->state[2] = 0x3070dd17;
+   context->state[3] = 0xf70e5939;
+   context->state[4] = 0xffc00b31;
+   context->state[5] = 0x68581511;
+   context->state[6] = 0x64f98fa7;
+   context->state[7] = 0xbefa4fa4;
+}
+/* }}} */
+
+/* {{{ PHP_SHA224Update
+   SHA224 block update operation. Continues an SHA224 message-digest
+   operation, processing another message block, and updating the
+   context.
+ */
+PHP_HASH_API void PHP_SHA224Update(PHP_SHA224_CTX * context, const unsigned 
char *input, unsigned int inputLen)
+{
+   unsigned int i, index, partLen;
+
+   /* Compute number of bytes mod 64 */
+   index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
+
+   /* Update number of bits */
+   if ((context->count[0] += ((php_hash_uint32) inputLen << 3)) < 
((php_hash_uint32) inputLen << 3)) {
+   context->count[1]++;
+   }
+   context->count[1] += ((php_hash_uint32) inputLen >> 29);
+
+   partLen = 64 - index;
+
+   /* Transform as many times as possible.
+*/
+   if (inputLen >= partLen) {
+   memcpy((unsigned char*) & context->buffer[index], (unsigned 
char*) input, partLen);
+   SHA256Transform(context->state, context->buffer);
+
+   for (i = partLen; i + 63 < inputLen; i += 64) {
+   SHA256Transform(context->state, &input[i]);
+   }
+
+   index = 0;
+   } else {
+   i = 0;
+   }
+
+   /* Buffer remaining input */
+   memcpy((unsigned char*) & context->buffer[index], (unsigned char*) & 
input[i], inputLen - i);
+}
+/* }}} */
+
+/* {{{ PHP_SHA224Final
+   SHA224 finalization. Ends an SHA224 message-digest operation, writing the
+   the message digest and zeroizing the context.
+ */
+PHP_HASH_API void PHP_SHA224Final(unsigned char digest[28], PHP_SHA224_CTX * 
context)
+{
+   unsigned char bits[8];
+  

[PHP-CVS] cvs: php-src /ext/hash hash.c hash_adler32.c hash_crc32.c hash_gost.c hash_haval.c hash_md.c hash_ripemd.c hash_salsa.c hash_sha.c hash_snefru.c hash_tiger.c hash_whirlpool.c php_hash.h php_

2008-04-21 Thread Antony Dovgal
tony2001Mon Apr 21 15:37:07 2008 UTC

  Added files: 
/php-src/ext/hash/tests hash_copy_001.phpt hash_copy_002.phpt 

  Modified files:  
/php-src/ext/hash   hash_adler32.c hash.c hash_crc32.c hash_gost.c 
hash_haval.c hash_md.c hash_ripemd.c hash_salsa.c 
hash_sha.c hash_snefru.c hash_tiger.c 
hash_whirlpool.c php_hash_adler32.h 
php_hash_crc32.h php_hash.h 
  Log:
  [DOC] add hash_copy() to be able to copy hash resource
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash_adler32.c?r1=1.8&r2=1.9&diff_format=u
Index: php-src/ext/hash/hash_adler32.c
diff -u php-src/ext/hash/hash_adler32.c:1.8 php-src/ext/hash/hash_adler32.c:1.9
--- php-src/ext/hash/hash_adler32.c:1.8 Mon Dec 31 07:12:10 2007
+++ php-src/ext/hash/hash_adler32.c Mon Apr 21 15:37:07 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: hash_adler32.c,v 1.8 2007/12/31 07:12:10 sebastian Exp $ */
+/* $Id: hash_adler32.c,v 1.9 2008/04/21 15:37:07 tony2001 Exp $ */
 
 #include "php_hash.h"
 #include "php_hash_adler32.h"
@@ -49,10 +49,17 @@
context->state = 0;
 }
 
+PHP_HASH_API int PHP_ADLER32Copy(const php_hash_ops *ops, PHP_ADLER32_CTX 
*orig_context, PHP_ADLER32_CTX *copy_context)
+{
+   copy_context->state = orig_context->state;
+   return SUCCESS;
+}
+
 const php_hash_ops php_hash_adler32_ops = {
(php_hash_init_func_t) PHP_ADLER32Init,
(php_hash_update_func_t) PHP_ADLER32Update,
(php_hash_final_func_t) PHP_ADLER32Final,
+   (php_hash_copy_func_t) PHP_ADLER32Copy,
4, /* what to say here? */
4,
sizeof(PHP_ADLER32_CTX)
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.40&r2=1.41&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.40 php-src/ext/hash/hash.c:1.41
--- php-src/ext/hash/hash.c:1.40Fri Apr  4 07:47:18 2008
+++ php-src/ext/hash/hash.c Mon Apr 21 15:37:07 2008
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.40 2008/04/04 07:47:18 tony2001 Exp $ */
+/* $Id: hash.c,v 1.41 2008/04/21 15:37:07 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -63,6 +63,15 @@
 }
 /* }}} */
 
+PHP_HASH_API int php_hash_copy(const void *ops, void *orig_context, void 
*dest_context) /* {{{ */
+{
+   php_hash_ops *hash_ops = (php_hash_ops *)ops;
+
+   memcpy(dest_context, orig_context, hash_ops->context_size);
+   return SUCCESS;
+}
+/* }}} */
+
 /* Userspace */
 
 static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename) /* 
{{{ */
@@ -378,7 +387,7 @@
}
 
 #if PHP_MAJOR_VERSION >= 6
-   if (key_type == IS_UNICODE) {
+   if (key && key_type == IS_UNICODE) {
key = zend_unicode_to_ascii((UChar*)key, key_len TSRMLS_CC);
if (!key) {
/* Non-ASCII Unicode key passed for raw hashing */
@@ -422,7 +431,7 @@
}
 
 #if PHP_MAJOR_VERSION >= 6
-   if (key_type == IS_UNICODE) {
+   if (key && key_type == IS_UNICODE) {
efree(key);
}
 #endif
@@ -638,6 +647,41 @@
 }
 /* }}} */
 
+/* {{{ proto resource hash_copy(resource context) U
+Copy hash resource */
+PHP_FUNCTION(hash_copy)
+{
+   zval *zhash;
+   php_hash_data *hash, *copy_hash;
+   void *context;
+   int res;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zhash) == 
FAILURE) {
+   return;
+   }
+
+   ZEND_FETCH_RESOURCE(hash, php_hash_data*, &zhash, -1, PHP_HASH_RESNAME, 
php_hash_le_hash);
+
+
+   context = emalloc(hash->ops->context_size);
+   hash->ops->hash_init(context);
+
+   res = hash->ops->hash_copy(hash->ops, hash->context, context);
+   if (res != SUCCESS) {
+   efree(context);
+   RETURN_FALSE;
+   }
+
+   copy_hash = emalloc(sizeof(php_hash_data));
+   copy_hash->ops = hash->ops;
+   copy_hash->context = context;
+   copy_hash->options = hash->options;
+   copy_hash->key = hash->key;
+   
+   ZEND_REGISTER_RESOURCE(return_value, copy_hash, php_hash_le_hash);
+}
+/* }}} */
+
 /* {{{ proto array hash_algos(void) U
 Return a list of registered hashing algorithms */
 PHP_FUNCTION(hash_algos)
@@ -854,6 +898,11 @@
 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()
 
@@ -877,6 +926,7 @@
PHP_HASH_FE(hash_update_stream)
PHP_HASH_FE(hash_update_file)
PHP_HASH_FE(hash_final)
+   PHP_HASH_FE(hash_copy)
 
PHP_HASH_FE(hash_algos)
 
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash_crc32.c?r1=1.6&r2=1.7&diff_format=u
Index: php-src/ext/hash/hash_crc32.c
di

[PHP-CVS] cvs: php-src /ext/hash hash.c

2008-04-04 Thread Antony Dovgal
tony2001Fri Apr  4 07:47:18 2008 UTC

  Modified files:  
/php-src/ext/hash   hash.c 
  Log:
  fix folding
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.39&r2=1.40&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.39 php-src/ext/hash/hash.c:1.40
--- php-src/ext/hash/hash.c:1.39Mon Dec 31 07:12:10 2007
+++ php-src/ext/hash/hash.c Fri Apr  4 07:47:18 2008
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.39 2007/12/31 07:12:10 sebastian Exp $ */
+/* $Id: hash.c,v 1.40 2008/04/04 07:47:18 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -37,7 +37,7 @@
 
 /* Hash Registry Access */
 
-PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, int 
algo_len)
+PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, int 
algo_len) /* {{{ */
 {
php_hash_ops *ops;
char *lower = estrndup(algo, algo_len);
@@ -50,8 +50,9 @@
 
return ops;
 }
+/* }}} */
 
-PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops 
*ops)
+PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops 
*ops) /* {{{ */
 {
int algo_len = strlen(algo);
char *lower = estrndup(algo, algo_len);
@@ -60,10 +61,11 @@
zend_hash_add(&php_hash_hashtable, lower, algo_len + 1, (void*)ops, 
sizeof(php_hash_ops), NULL);
efree(lower);
 }
+/* }}} */
 
 /* Userspace */
 
-static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename)
+static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename) /* 
{{{ */
 {
char *algo, *data, *digest;
int algo_len, data_len;
@@ -157,11 +159,13 @@
efree(data);
}
 }
+/* }}} */
 
 /* {{{ proto string hash(string algo, string data[, bool raw_output = false]) U
 Generate a hash of a given input string
 Returns lowercase hexits by default */
-PHP_FUNCTION(hash) {
+PHP_FUNCTION(hash)
+{
php_hash_do_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
 }
 /* }}} */
@@ -169,12 +173,13 @@
 /* {{{ proto string hash_file(string algo, string filename[, bool raw_output = 
false]) U
 Generate a hash of a given file
 Returns lowercase hexits by default */
-PHP_FUNCTION(hash_file) {
+PHP_FUNCTION(hash_file)
+{
php_hash_do_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
 }
 /* }}} */
 
-static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename)
+static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int 
isfilename) /* {{{ */
 {
char *algo, *data, *digest, *key, *K;
int algo_len, data_len, key_len, i;
@@ -317,11 +322,13 @@
efree(key);
}
 }
+/* }}} */
 
 /* {{{ proto string hash_hmac(string algo, string data, string key[, bool 
raw_output = false]) U
 Generate a hash of a given input string with a key using HMAC
 Returns lowercase hexits by default */
-PHP_FUNCTION(hash_hmac) {
+PHP_FUNCTION(hash_hmac)
+{
php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
 }
 /* }}} */
@@ -329,7 +336,8 @@
 /* {{{ proto string hash_hmac_file(string algo, string filename, string key[, 
bool raw_output = false]) U
 Generate a hash of a given file with a key using HMAC
 Returns lowercase hexits by default */
-PHP_FUNCTION(hash_hmac_file) {
+PHP_FUNCTION(hash_hmac_file)
+{
php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
 }
 /* }}} */
@@ -659,7 +667,7 @@
 
 /* Module Housekeeping */
 
-static void php_hash_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void php_hash_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
 {
php_hash_data *hash = (php_hash_data*)rsrc->ptr;
 
@@ -677,6 +685,7 @@
}
efree(hash);
 }
+/* }}} */
 
 #define PHP_HASH_HAVAL_REGISTER(p,b)   php_hash_register_algo("haval" #b "," 
#p , &php_hash_##p##haval##b##_ops);
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/hash hash.c

2007-05-25 Thread Sara Golemon
pollita Sat May 26 03:56:41 2007 UTC

  Modified files:  
/php-src/ext/hash   hash.c 
  Log:
  MFB(r-1.18.2.5.2.7) Use slprintf() instead of snprintf() - Bad Ilia, no 
biscuit for you.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.34&r2=1.35&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.34 php-src/ext/hash/hash.c:1.35
--- php-src/ext/hash/hash.c:1.34Mon Jan  8 22:29:52 2007
+++ php-src/ext/hash/hash.c Sat May 26 03:56:41 2007
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.34 2007/01/08 22:29:52 nlopess Exp $ */
+/* $Id: hash.c,v 1.35 2007/05/26 03:56:41 pollita Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -751,9 +751,9 @@
(type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, 
NULL, &idx, 0, &pos)) != HASH_KEY_NON_EXISTANT;
zend_hash_move_forward_ex(&php_hash_hashtable, &pos)) {
 #if (PHP_MAJOR_VERSION >= 6)
-   s += snprintf(s, e - s, "%s ", str.s);
+   s += slprintf(s, e - s, "%s ", str.s);
 #else
-   s += snprintf(s, e - s, "%s ", str);
+   s += slprintf(s, e - s, "%s ", str);
 #endif
}
*s = 0;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/hash hash.c hash_adler32.c hash_crc32.c hash_gost.c hash_haval.c hash_md.c hash_ripemd.c hash_salsa.c hash_sha.c hash_snefru.c hash_tiger.c hash_whirlpool.c php_hash.h

2007-01-08 Thread Nuno Lopes
nlopess Mon Jan  8 22:29:52 2007 UTC

  Modified files:  
/php-src/ext/hash   hash.c hash_adler32.c hash_crc32.c hash_gost.c 
hash_haval.c hash_md.c hash_ripemd.c hash_salsa.c 
hash_sha.c hash_snefru.c hash_tiger.c 
hash_whirlpool.c php_hash.h 
  Log:
  MFB: constify
  http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.33&r2=1.34&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.33 php-src/ext/hash/hash.c:1.34
--- php-src/ext/hash/hash.c:1.33Mon Jan  1 09:29:24 2007
+++ php-src/ext/hash/hash.c Mon Jan  8 22:29:52 2007
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.33 2007/01/01 09:29:24 sebastian Exp $ */
+/* $Id: hash.c,v 1.34 2007/01/08 22:29:52 nlopess Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -37,7 +37,7 @@
 
 /* Hash Registry Access */
 
-PHP_HASH_API php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_len)
+PHP_HASH_API const php_hash_ops *php_hash_fetch_ops(const char *algo, int 
algo_len)
 {
php_hash_ops *ops;
char *lower = estrndup(algo, algo_len);
@@ -51,13 +51,13 @@
return ops;
 }
 
-PHP_HASH_API void php_hash_register_algo(const char *algo, php_hash_ops *ops)
+PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops 
*ops)
 {
int algo_len = strlen(algo);
char *lower = estrndup(algo, algo_len);

zend_str_tolower(lower, algo_len);
-   zend_hash_add(&php_hash_hashtable, lower, algo_len + 1, ops, 
sizeof(php_hash_ops), NULL);
+   zend_hash_add(&php_hash_hashtable, lower, algo_len + 1, (void*)ops, 
sizeof(php_hash_ops), NULL);
efree(lower);
 }
 
@@ -69,7 +69,7 @@
int algo_len, data_len;
zend_uchar data_type = IS_STRING;
zend_bool raw_output = 0;
-   php_hash_ops *ops;
+   const php_hash_ops *ops;
void *context;
php_stream *stream = NULL;
 
@@ -180,7 +180,7 @@
int algo_len, data_len, key_len, i;
zend_uchar data_type = IS_STRING, key_type = IS_STRING;
zend_bool raw_output = 0;
-   php_hash_ops *ops;
+   const php_hash_ops *ops;
void *context;
php_stream *stream = NULL;
 
@@ -344,7 +344,7 @@
zend_uchar key_type;
long options = 0;
void *context;
-   php_hash_ops *ops;
+   const php_hash_ops *ops;
php_hash_data *hash;
 
if (zend_parse_parameters(argc TSRMLS_CC, "s|lt", &algo, &algo_len, 
&options, &key, &key_len, &key_type) == FAILURE) {
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash_adler32.c?r1=1.6&r2=1.7&diff_format=u
Index: php-src/ext/hash/hash_adler32.c
diff -u php-src/ext/hash/hash_adler32.c:1.6 php-src/ext/hash/hash_adler32.c:1.7
--- php-src/ext/hash/hash_adler32.c:1.6 Mon Jan  1 09:29:24 2007
+++ php-src/ext/hash/hash_adler32.c Mon Jan  8 22:29:52 2007
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: hash_adler32.c,v 1.6 2007/01/01 09:29:24 sebastian Exp $ */
+/* $Id: hash_adler32.c,v 1.7 2007/01/08 22:29:52 nlopess Exp $ */
 
 #include "php_hash.h"
 #include "php_hash_adler32.h"
@@ -49,7 +49,7 @@
context->state = 0;
 }
 
-php_hash_ops php_hash_adler32_ops = {
+const php_hash_ops php_hash_adler32_ops = {
(php_hash_init_func_t) PHP_ADLER32Init,
(php_hash_update_func_t) PHP_ADLER32Update,
(php_hash_final_func_t) PHP_ADLER32Final,
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash_crc32.c?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/hash/hash_crc32.c
diff -u php-src/ext/hash/hash_crc32.c:1.4 php-src/ext/hash/hash_crc32.c:1.5
--- php-src/ext/hash/hash_crc32.c:1.4   Mon Jan  1 09:29:24 2007
+++ php-src/ext/hash/hash_crc32.c   Mon Jan  8 22:29:52 2007
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: hash_crc32.c,v 1.4 2007/01/01 09:29:24 sebastian Exp $ */
+/* $Id: hash_crc32.c,v 1.5 2007/01/08 22:29:52 nlopess Exp $ */
 
 #include "php_hash.h"
 #include "php_hash_crc32.h"
@@ -56,7 +56,7 @@
context->state = 0;
 }
 
-php_hash_ops php_hash_crc32_ops = {
+const php_hash_ops php_hash_crc32_ops = {
(php_hash_init_func_t) PHP_CRC32Init,
(php_hash_update_func_t) PHP_CRC32Update,
(php_hash_final_func_t) PHP_CRC32Final,
@@ -65,7 +65,7 @@
sizeof(PHP_CRC32_CTX)
 };
 
-php_hash_ops php_hash_crc32b_ops = {
+const php_hash_ops php_hash_crc32b_ops = {
(php_hash_init_func_t) PHP_CRC32Init,
(php_hash_update_func_t) PHP_CRC32BUpdate,
(php_hash_final_func_t) PHP_CRC32Final,
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash_gost.c?r1=1.4&r2=1.5&diff_format=u
Index: php-src/ext/hash/hash_gost.c
diff -u php-src/ext/hash/hash_gost.c:1.4 php-src/ext/hash/hash_gost.c:1.5
--- php-src/ext/hash/hash_gost.c:1.4Mon Jan  1 09:29:

[PHP-CVS] cvs: php-src /ext/hash hash.c /ext/hash/tests adler32.phpt crc32.phpt gost.phpt haval.phpt hmac-md5.phpt md2.phpt md4.phpt md5.phpt ripemd128.phpt ripemd160.phpt ripemd256.phpt ripemd320.ph

2006-10-01 Thread Sara Golemon
pollita Mon Oct  2 01:38:06 2006 UTC

  Modified files:  
/php-src/ext/hash   hash.c 
/php-src/ext/hash/tests adler32.phpt crc32.phpt gost.phpt 
haval.phpt hmac-md5.phpt md2.phpt md4.phpt 
md5.phpt ripemd128.phpt ripemd160.phpt 
ripemd256.phpt ripemd320.phpt sha1.phpt 
sha256.phpt sha384.phpt sha512.phpt 
snefru.phpt tiger.phpt whirlpool.phpt 
  Log:
  Allow hash()/hash_hmac() to accept ascii-unicode data,
  Update tests to work in unicode.semantics mode.
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.31&r2=1.32&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.31 php-src/ext/hash/hash.c:1.32
--- php-src/ext/hash/hash.c:1.31Wed Sep 20 01:48:06 2006
+++ php-src/ext/hash/hash.c Mon Oct  2 01:38:05 2006
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.31 2006/09/20 01:48:06 pollita Exp $ */
+/* $Id: hash.c,v 1.32 2006/10/02 01:38:05 pollita Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -84,9 +84,12 @@
RETURN_FALSE;
}
} else {
-   /* Unicode string passed for raw hashing */
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unicode 
strings can not be hashed.  Convert to a binary type.");
-   RETURN_FALSE;
+   data = zend_unicode_to_ascii((UChar*)data, data_len 
TSRMLS_CC);
+   if (!data) {
+   /* Non-ASCII Unicode string passed for raw 
hashing */
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received");
+   RETURN_FALSE;
+   }
}
}
 #else
@@ -94,25 +97,19 @@
return;
}
 #endif
+   /* Assume failure */
+   RETVAL_FALSE;
 
ops = php_hash_fetch_ops(algo, algo_len);
if (!ops) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown hashing 
algorithm: %s", algo);
-   if (data_type != IS_STRING) {
-   /* Original filename was UNICODE, this string is a 
converted copy */
-   efree(data);
-   }
-   RETURN_FALSE;
+   goto hash_done;
}
if (isfilename) {
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, 
NULL, DEFAULT_CONTEXT);
-   if (data_type != IS_STRING) {
-   /* Original filename was UNICODE, this string is a 
converted copy */
-   efree(data);
-   }
if (!stream) {
/* Stream will report errors opening file */
-   RETURN_FALSE;
+   goto hash_done;
}
}
 
@@ -137,14 +134,27 @@
 
if (raw_output) {
digest[ops->digest_size] = 0;
-   RETURN_STRINGL(digest, ops->digest_size, 0);
+
+   /* Raw output is binary only */
+   RETVAL_STRINGL(digest, ops->digest_size, 0);
} else {
char *hex_digest = safe_emalloc(ops->digest_size, 2, 1);
 
php_hash_bin2hex(hex_digest, (unsigned char *) digest, 
ops->digest_size);
hex_digest[2 * ops->digest_size] = 0;
efree(digest);
-   RETURN_STRINGL(hex_digest, 2 * ops->digest_size, 0);
+
+   /* hexits can be binary or unicode */
+#if PHP_MAJOR_VERSION >= 6
+   RETVAL_RT_STRINGL(hex_digest, 2 * ops->digest_size, 
ZSTR_AUTOFREE);
+#else
+   RETVAL_STRINGL(hex_digest, 2 * ops->digest_size, 0);
+#endif
+   }
+
+hash_done:
+   if (data_type != IS_STRING) {
+   efree(data);
}
 }
 
@@ -168,14 +178,14 @@
 {
char *algo, *data, *digest, *key, *K;
int algo_len, data_len, key_len, i;
-   zend_uchar data_type = IS_STRING;
+   zend_uchar data_type = IS_STRING, key_type = IS_STRING;
zend_bool raw_output = 0;
php_hash_ops *ops;
void *context;
php_stream *stream = NULL;
 
 #if PHP_MAJOR_VERSION >= 6
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "stS|b", &algo, 
&algo_len, &data, &data_len, &data_type, &key, &key_len, &raw_output) == 
FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "stt|b", &algo, 
&algo_len, &data, &data_len, &data_type, &key, &key_len, &key_type, 
&raw_output) == FAILURE) {
return;
}
 
@@ -185,8 +195,22 @@
RETURN_FALSE;
}
} else {
-   /* Uni

[PHP-CVS] cvs: php-src /ext/hash hash.c hash_ripemd.c php_hash.h php_hash_ripemd.h /ext/hash/tests ripemd256.phpt ripemd320.phpt

2006-09-19 Thread Sara Golemon
pollita Wed Sep 20 01:48:06 2006 UTC

  Added files: 
/php-src/ext/hash/tests ripemd256.phpt ripemd320.phpt 

  Modified files:  
/php-src/ext/hash   hash.c hash_ripemd.c php_hash.h php_hash_ripemd.h 
  Log:
  Add ripemd256 and ripemd320 algos
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.30&r2=1.31&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.30 php-src/ext/hash/hash.c:1.31
--- php-src/ext/hash/hash.c:1.30Wed Sep 20 00:32:54 2006
+++ php-src/ext/hash/hash.c Wed Sep 20 01:48:06 2006
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.30 2006/09/20 00:32:54 pollita Exp $ */
+/* $Id: hash.c,v 1.31 2006/09/20 01:48:06 pollita Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -613,6 +613,8 @@
php_hash_register_algo("sha512",&php_hash_sha512_ops);
php_hash_register_algo("ripemd128", 
&php_hash_ripemd128_ops);
php_hash_register_algo("ripemd160", 
&php_hash_ripemd160_ops);
+   php_hash_register_algo("ripemd256", 
&php_hash_ripemd256_ops);
+   php_hash_register_algo("ripemd320", 
&php_hash_ripemd320_ops);
php_hash_register_algo("whirlpool", 
&php_hash_whirlpool_ops);
php_hash_register_algo("tiger128,3",&php_hash_3tiger128_ops);
php_hash_register_algo("tiger160,3",&php_hash_3tiger160_ops);
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash_ripemd.c?r1=1.6&r2=1.7&diff_format=u
Index: php-src/ext/hash/hash_ripemd.c
diff -u php-src/ext/hash/hash_ripemd.c:1.6 php-src/ext/hash/hash_ripemd.c:1.7
--- php-src/ext/hash/hash_ripemd.c:1.6  Sun Jan  1 13:09:50 2006
+++ php-src/ext/hash/hash_ripemd.c  Wed Sep 20 01:48:06 2006
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash_ripemd.c,v 1.6 2006/01/01 13:09:50 sniper Exp $ */
+/* $Id: hash_ripemd.c,v 1.7 2006/09/20 01:48:06 pollita Exp $ */
 
 /* Heavily borrowed from md5.c & sha1.c of PHP archival fame
Note that ripemd laughs in the face of logic and uses
@@ -43,6 +43,24 @@
sizeof(PHP_RIPEMD160_CTX)
 };
 
+php_hash_ops php_hash_ripemd256_ops = {
+   (php_hash_init_func_t) PHP_RIPEMD256Init,
+   (php_hash_update_func_t) PHP_RIPEMD256Update,
+   (php_hash_final_func_t) PHP_RIPEMD256Final,
+   32,
+   64,
+   sizeof(PHP_RIPEMD256_CTX)
+};
+
+php_hash_ops php_hash_ripemd320_ops = {
+   (php_hash_init_func_t) PHP_RIPEMD320Init,
+   (php_hash_update_func_t) PHP_RIPEMD320Update,
+   (php_hash_final_func_t) PHP_RIPEMD320Final,
+   40,
+   64,
+   sizeof(PHP_RIPEMD320_CTX)
+};
+
 /* {{{ PHP_RIPEMD128Init
  * ripemd128 initialization. Begins a ripemd128 operation, writing a new 
context.
  */
@@ -58,8 +76,27 @@
 }
 /* }}} */
 
+/* {{{ PHP_RIPEMD256Init
+ * ripemd256 initialization. Begins a ripemd256 operation, writing a new 
context.
+ */
+PHP_HASH_API void PHP_RIPEMD256Init(PHP_RIPEMD256_CTX * context)
+{
+   context->count[0] = context->count[1] = 0;
+   /* Load magic initialization constants.
+*/
+   context->state[0] = 0x67452301;
+   context->state[1] = 0xEFCDAB89;
+   context->state[2] = 0x98BADCFE;
+   context->state[3] = 0x10325476; 
+   context->state[4] = 0x76543210;
+   context->state[5] = 0xFEDCBA98;
+   context->state[6] = 0x89ABCDEF;
+   context->state[7] = 0x01234567;
+}
+/* }}} */
+
 /* {{{ PHP_RIPEMD160Init
- * ripemd128 initialization. Begins a ripemd128 operation, writing a new 
context.
+ * ripemd160 initialization. Begins a ripemd160 operation, writing a new 
context.
  */
 PHP_HASH_API void PHP_RIPEMD160Init(PHP_RIPEMD160_CTX * context)
 {
@@ -74,6 +111,27 @@
 }
 /* }}} */
 
+/* {{{ PHP_RIPEMD320Init
+ * ripemd320 initialization. Begins a ripemd320 operation, writing a new 
context.
+ */
+PHP_HASH_API void PHP_RIPEMD320Init(PHP_RIPEMD320_CTX * context)
+{
+   context->count[0] = context->count[1] = 0;
+   /* Load magic initialization constants.
+*/
+   context->state[0] = 0x67452301;
+   context->state[1] = 0xEFCDAB89;
+   context->state[2] = 0x98BADCFE;
+   context->state[3] = 0x10325476; 
+   context->state[4] = 0xC3D2E1F0;
+   context->state[5] = 0x76543210;
+   context->state[6] = 0xFEDCBA98;
+   context->state[7] = 0x89ABCDEF;
+   context->state[8] = 0x01234567;
+   context->state[9] = 0x3C2D1E0F;
+}
+/* }}} */
+
 /* Basic ripemd function */
 #define F0(x,y,z)  ((x) ^ (y) ^ (z))
 #define F1(x,y,z)  (((x) & (y)) | ((~(x)) & (z)))
@@ -81,9 +139,9 @@
 #define F3(x,y,z)  (((x) & (z)) | ((y) & (~(z
 #define F4(x,y,z)  ((x) ^ ((y) | (~(z
 
-static php_hash_uint32 K_values[5]  = { 0x, 0x5A827999, 0x6ED9EBA1, 
0x8F1BBCDC, 0xA953FD4E };
-static php_hash_uin

[PHP-CVS] cvs: php-src /ext/hash hash.c /ext/hash/tests adler32.phpt crc32.phpt gost.phpt haval.phpt hmac-md5.phpt md2.phpt md4.phpt md5.phpt ripemd128.phpt ripemd160.phpt sha1.phpt sha256.phpt sha38

2006-09-19 Thread Sara Golemon
pollita Wed Sep 20 00:32:54 2006 UTC

  Modified files:  
/php-src/ext/hash   hash.c 
/php-src/ext/hash/tests adler32.phpt crc32.phpt gost.phpt 
haval.phpt hmac-md5.phpt md2.phpt md4.phpt 
md5.phpt ripemd128.phpt ripemd160.phpt 
sha1.phpt sha256.phpt sha384.phpt 
sha512.phpt snefru.phpt tiger.phpt 
whirlpool.phpt 
  Log:
  PHP6 Updates
  http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.29&r2=1.30&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.29 php-src/ext/hash/hash.c:1.30
--- php-src/ext/hash/hash.c:1.29Tue Sep 19 23:42:49 2006
+++ php-src/ext/hash/hash.c Wed Sep 20 00:32:54 2006
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.29 2006/09/19 23:42:49 pollita Exp $ */
+/* $Id: hash.c,v 1.30 2006/09/20 00:32:54 pollita Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -67,22 +67,49 @@
 {
char *algo, *data, *digest;
int algo_len, data_len;
+   zend_uchar data_type = IS_STRING;
zend_bool raw_output = 0;
php_hash_ops *ops;
void *context;
php_stream *stream = NULL;
 
+#if PHP_MAJOR_VERSION >= 6
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "st|b", &algo, 
&algo_len, &data, &data_len, &data_type, &raw_output) == FAILURE) {
+   return;
+   }
+
+   if (data_type == IS_UNICODE) {
+   if (isfilename) {
+   if (php_stream_path_encode(NULL, &data, &data_len, 
(UChar *)data, data_len, REPORT_ERRORS, FG(default_context)) == FAILURE) {
+   RETURN_FALSE;
+   }
+   } else {
+   /* Unicode string passed for raw hashing */
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unicode 
strings can not be hashed.  Convert to a binary type.");
+   RETURN_FALSE;
+   }
+   }
+#else
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &algo, 
&algo_len, &data, &data_len, &raw_output) == FAILURE) {
return;
}
+#endif
 
ops = php_hash_fetch_ops(algo, algo_len);
if (!ops) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown hashing 
algorithm: %s", algo);
+   if (data_type != IS_STRING) {
+   /* Original filename was UNICODE, this string is a 
converted copy */
+   efree(data);
+   }
RETURN_FALSE;
}
if (isfilename) {
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, 
NULL, DEFAULT_CONTEXT);
+   if (data_type != IS_STRING) {
+   /* Original filename was UNICODE, this string is a 
converted copy */
+   efree(data);
+   }
if (!stream) {
/* Stream will report errors opening file */
RETURN_FALSE;
@@ -121,7 +148,7 @@
}
 }
 
-/* {{{ proto string hash(string algo, string data[, bool raw_output = false])
+/* {{{ proto string hash(string algo, string data[, bool raw_output = false]) U
 Generate a hash of a given input string
 Returns lowercase hexits by default */
 PHP_FUNCTION(hash) {
@@ -129,7 +156,7 @@
 }
 /* }}} */
 
-/* {{{ proto string hash_file(string algo, string filename[, bool raw_output = 
false])
+/* {{{ proto string hash_file(string algo, string filename[, bool raw_output = 
false]) U
 Generate a hash of a given file
 Returns lowercase hexits by default */
 PHP_FUNCTION(hash_file) {
@@ -141,23 +168,49 @@
 {
char *algo, *data, *digest, *key, *K;
int algo_len, data_len, key_len, i;
+   zend_uchar data_type = IS_STRING;
zend_bool raw_output = 0;
php_hash_ops *ops;
void *context;
php_stream *stream = NULL;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|b", &algo, 
&algo_len, &data, &data_len, 
-   
  &key, &key_len, &raw_output) 
== FAILURE) {
+#if PHP_MAJOR_VERSION >= 6
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "stS|b", &algo, 
&algo_len, &data, &data_len, &data_type, &key, &key_len, &raw_output) == 
FAILURE) {
+   return;
+   }
+
+   if (data_type == IS_UNICODE) {
+   if (isfilename) {
+   if (php_stream_path_encode(NULL, &data, &data_len, 
(UChar *)data, data_len, REPORT_ERRORS, FG(default_context)) == FAILURE) {
+   RETURN_FALSE;
+   }
+   } else {
+   /* Unicode string passed for raw hashing */
+ 

[PHP-CVS] cvs: php-src /ext/hash hash.c hash_md.c hash_sha.c php_hash_md.h php_hash_sha.h

2006-09-19 Thread Sara Golemon
pollita Tue Sep 19 23:42:49 2006 UTC

  Modified files:  
/php-src/ext/hash   hash.c hash_md.c hash_sha.c php_hash_md.h 
php_hash_sha.h 
  Log:
  Strip unused implementations of md5(), md5_file(), sha1(), and sha1_file()
  from this extension.
  
  It was decided a few months ago that those implementations would simply
  stay in ext/standard and never leave. 
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.28&r2=1.29&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.28 php-src/ext/hash/hash.c:1.29
--- php-src/ext/hash/hash.c:1.28Fri Jul 28 14:27:17 2006
+++ php-src/ext/hash/hash.c Tue Sep 19 23:42:49 2006
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.28 2006/07/28 14:27:17 iliaa Exp $ */
+/* $Id: hash.c,v 1.29 2006/09/19 23:42:49 pollita Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -615,34 +615,6 @@
 /* }}} */
 
 /* {{{ 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)
-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)
@@ -729,17 +701,6 @@
 
PHP_FE(hash_algos,  
arginfo_hash_algos)
 
-   /* BC Land */
-#ifdef PHP_HASH_MD5_NOT_IN_CORE
-   PHP_NAMED_FE(md5, php_if_md5,   
arginfo_hash_md5)
-   PHP_NAMED_FE(md5_file, php_if_md5_file, 
arginfo_hash_md5_file)
-#endif /* PHP_HASH_MD5_NOT_IN_CORE */
-
-#ifdef PHP_HASH_SHA1_NOT_IN_CORE
-   PHP_NAMED_FE(sha1, php_if_sha1, 
arginfo_hash_sha1)
-   PHP_NAMED_FE(sha1_file, php_if_sha1_file,   
arginfo_hash_sha1_file)
-#endif /* PHP_HASH_SHA1_NOT_IN_CORE */
-
{NULL, NULL, NULL}
 };
 /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash_md.c?r1=1.10&r2=1.11&diff_format=u
Index: php-src/ext/hash/hash_md.c
diff -u php-src/ext/hash/hash_md.c:1.10 php-src/ext/hash/hash_md.c:1.11
--- php-src/ext/hash/hash_md.c:1.10 Tue Feb 21 20:37:12 2006
+++ php-src/ext/hash/hash_md.c  Tue Sep 19 23:42:49 2006
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash_md.c,v 1.10 2006/02/21 20:37:12 pollita Exp $ */
+/* $Id: hash_md.c,v 1.11 2006/09/19 23:42:49 pollita Exp $ */
 
 #include "php_hash.h"
 #include "php_hash_md.h"
@@ -88,358 +88,6 @@
 }
 /* }}} */
 
-#ifdef PHP_HASH_MD5_NOT_IN_CORE
-
-/* MD5 */
-
-PHP_HASH_API void make_digest(char *md5str, unsigned char *digest)
-{
-   php_hash_bin2hex(md5str, digest, 16);
-   md5str[32] = '\0';
-}
-
-/* {{{ proto string md5(string str, [ bool raw_output])
-   Calculate the md5 hash of a string */
-PHP_NAMED_FUNCTION(php_if_md5)
-{
-   char *arg;
-   int arg_len;
-   zend_bool raw_output = 0;
-   char md5str[33];
-   PHP_MD5_CTX context;
-   unsigned char digest[16];
-   
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, 
&arg_len, &raw_output) == FAILURE) {
-   return;
-   }
-   
-   md5str[0] = '\0';
-   PHP_MD5Init(&context);
-   PHP_MD5Update(&context, arg, arg_len);
-   PHP_MD5Final(digest, &context);
-   if (raw_output) {
-   RETURN_STRINGL(digest, 16, 1);
-   } else {
-   make_digest(md5str, digest);
-   RETVAL_STRING(md5str, 1);
-   }
-
-}
-/* }}} */
-
-/* {{{ proto string md5_file(string filename [, bool raw_output])
-   Calculate the md5 hash of given filename */
-PHP_NAMED_FUNCTION(php_if_md5_file)
-{
-   char  *arg;
-   int   arg_len;
-   zend_bool raw_output = 0;
-   char  md5str[33];
-   unsigned char buf[1024];
-   unsigned char digest[16];
-   PHP_MD5_CTX   context;
-   int   n;
-   php_stream*stream;
-
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, 
&arg_len, &raw_output) == FAILURE) {
-   return;
-   }
-   
-   stream = php_stream_open_wrapper(arg, "rb", REPORT_ERRORS, NULL);
-   if (!stream) {
-   RETURN_FALSE;
-   }
-
-   PHP_MD5Init(&context);
-
-   while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
-

[PHP-CVS] cvs: php-src /ext/hash hash.c

2006-07-28 Thread Ilia Alshanetsky
iliaa   Fri Jul 28 14:27:17 2006 UTC

  Modified files:  
/php-src/ext/hash   hash.c 
  Log:
  MFB: cleanup of the phpinfo() output.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/hash/hash.c?r1=1.27&r2=1.28&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.27 php-src/ext/hash/hash.c:1.28
--- php-src/ext/hash/hash.c:1.27Sat Jun 17 13:00:21 2006
+++ php-src/ext/hash/hash.c Fri Jul 28 14:27:17 2006
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.27 2006/06/17 13:00:21 bjori Exp $ */
+/* $Id: hash.c,v 1.28 2006/07/28 14:27:17 iliaa Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -608,8 +608,8 @@
*s = 0;
 
php_info_print_table_start();
-   php_info_print_table_header(2, "hash support", "enabled");
-   php_info_print_table_header(2, "Hashing Engines", buffer);
+   php_info_print_table_row(2, "hash support", "enabled");
+   php_info_print_table_row(2, "Hashing Engines", buffer);
php_info_print_table_end();
 }
 /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /ext/hash hash.c /ext/iconv iconv.c /ext/libxml libxml.c

2006-06-17 Thread Hannes Magnusson
bjori   Sat Jun 17 13:00:21 2006 UTC

  Modified files:  
/php-src/ext/iconv  iconv.c 
/php-src/ext/hash   hash.c 
/php-src/ext/libxml libxml.c 
  Log:
  Added argument info
  Fixed protos
  Fixed vim folding
  
  http://cvs.php.net/viewcvs.cgi/php-src/ext/iconv/iconv.c?r1=1.136&r2=1.137&diff_format=u
Index: php-src/ext/iconv/iconv.c
diff -u php-src/ext/iconv/iconv.c:1.136 php-src/ext/iconv/iconv.c:1.137
--- php-src/ext/iconv/iconv.c:1.136 Tue Jun 13 15:57:46 2006
+++ php-src/ext/iconv/iconv.c   Sat Jun 17 13:00:20 2006
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: iconv.c,v 1.136 2006/06/13 15:57:46 andrei Exp $ */
+/* $Id: iconv.c,v 1.137 2006/06/17 13:00:20 bjori Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -62,20 +62,97 @@
 #define _php_iconv_memequal(a, b, c) \
   ((c) == sizeof(unsigned long) ? *((unsigned long *)(a)) == *((unsigned long 
*)(b)) : ((c) == sizeof(unsigned int) ? *((unsigned int *)(a)) == *((unsigned 
int *)(b)) : memcmp(a, b, c) == 0))
 
+/* {{{ arginfo */
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_strlen, 0, 0, 1)
+   ZEND_ARG_INFO(0, str)
+   ZEND_ARG_INFO(0, charset)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_substr, 0, 0, 2)
+   ZEND_ARG_INFO(0, str)
+   ZEND_ARG_INFO(0, offset)
+   ZEND_ARG_INFO(0, length)
+   ZEND_ARG_INFO(0, charset)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_strpos, 0, 0, 2)
+   ZEND_ARG_INFO(0, haystack)
+   ZEND_ARG_INFO(0, needle)
+   ZEND_ARG_INFO(0, offset)
+   ZEND_ARG_INFO(0, charset)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_strrpos, 0, 0, 2)
+   ZEND_ARG_INFO(0, haystack)
+   ZEND_ARG_INFO(0, needle)
+   ZEND_ARG_INFO(0, charset)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_mime_encode, 0, 0, 2)
+   ZEND_ARG_INFO(0, field_name)
+   ZEND_ARG_INFO(0, field_value)
+   ZEND_ARG_INFO(0, preference) /* ZEND_ARG_ARRAY_INFO(0, preference, 1) */
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_mime_decode, 0, 0, 1)
+   ZEND_ARG_INFO(0, encoded_string)
+   ZEND_ARG_INFO(0, mode)
+   ZEND_ARG_INFO(0, charset)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_mime_decode_headers, 0, 0, 1)
+   ZEND_ARG_INFO(0, headers)
+   ZEND_ARG_INFO(0, mode)
+   ZEND_ARG_INFO(0, charset)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_iconv, 0)
+   ZEND_ARG_INFO(0, in_charset)
+   ZEND_ARG_INFO(0, out_charset)
+   ZEND_ARG_INFO(0, str)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_ob_iconv_handler, 0)
+   ZEND_ARG_INFO(0, contents)
+   ZEND_ARG_INFO(0, status)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_iconv_set_encoding, 0)
+   ZEND_ARG_INFO(0, type)
+   ZEND_ARG_INFO(0, charset)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_iconv_get_encoding, 0, 0, 0)
+   ZEND_ARG_INFO(0, type)
+ZEND_END_ARG_INFO()
+
+/* }}} */
+
 /* {{{ iconv_functions[]
  */
 zend_function_entry iconv_functions[] = {
-   PHP_NAMED_FE(iconv,php_if_iconv,NULL)
-   PHP_FE(ob_iconv_handler,
NULL)
-   PHP_FE(iconv_get_encoding,  
NULL)
-   PHP_FE(iconv_set_encoding,  
NULL)
-   PHP_FE(iconv_strlen,
NULL)
-   PHP_FE(iconv_substr,
NULL)
-   PHP_FE(iconv_strpos,
NULL)
-   PHP_FE(iconv_strrpos,   
NULL)
-   PHP_FE(iconv_mime_encode,   
NULL)
-   PHP_FE(iconv_mime_decode,   
NULL)
-   PHP_FE(iconv_mime_decode_headers,   NULL)
+   PHP_NAMED_FE(iconv,php_if_iconv,
arginfo_iconv)
+   PHP_FE(ob_iconv_handler,
arginfo_ob_iconv_handler)
+   PHP_FE(iconv_get_encoding,  
arginfo_iconv_get_encoding)
+   PHP_FE(iconv_set_encoding,  
arginfo_iconv_set_encoding)
+   PHP_FE(iconv_strlen,
arginfo_iconv_strlen)
+   PHP_FE(iconv_substr,
arginfo_iconv_substr)
+   PHP_FE(iconv_strpos,
arginfo_iconv_strpos)
+   PHP_FE(iconv_strrpos,   
arginfo_iconv_strrpos)
+   PHP_FE(iconv_mime_en

[PHP-CVS] cvs: php-src /ext/hash hash.c

2006-05-19 Thread Michael Wallner
mikeFri May 19 14:30:48 2006 UTC

  Modified files:  
/php-src/ext/hash   hash.c 
  Log:
  MF52: nuke compiler warnings
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/hash/hash.c?r1=1.25&r2=1.26&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.25 php-src/ext/hash/hash.c:1.26
--- php-src/ext/hash/hash.c:1.25Fri Mar  3 20:44:05 2006
+++ php-src/ext/hash/hash.c Fri May 19 14:30:48 2006
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.25 2006/03/03 20:44:05 mike Exp $ */
+/* $Id: hash.c,v 1.26 2006/05/19 14:30:48 mike Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -43,7 +43,7 @@
char *lower = estrndup(algo, algo_len);
 
zend_str_tolower(lower, algo_len);
-   if (SUCCESS != zend_hash_find(&php_hash_hashtable, lower, algo_len + 1, 
(void**)&ops)) {
+   if (SUCCESS != zend_hash_find(&php_hash_hashtable, lower, algo_len + 1, 
(void*)&ops)) {
ops = NULL;
}
efree(lower);
@@ -97,15 +97,15 @@
int n;
 
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
-   ops->hash_update(context, buf, n);
+   ops->hash_update(context, (unsigned char *) buf, n);
}
php_stream_close(stream);
} else {
-   ops->hash_update(context, data, data_len);
+   ops->hash_update(context, (unsigned char *) data, data_len);
}
 
digest = emalloc(ops->digest_size + 1);
-   ops->hash_final(digest, context);
+   ops->hash_final((unsigned char *) digest, context);
efree(context);
 
if (raw_output) {
@@ -114,7 +114,7 @@
} else {
char *hex_digest = safe_emalloc(ops->digest_size, 2, 1);
 
-   php_hash_bin2hex(hex_digest, digest, ops->digest_size);
+   php_hash_bin2hex(hex_digest, (unsigned char *) digest, 
ops->digest_size);
hex_digest[2 * ops->digest_size] = 0;
efree(digest);
RETURN_STRINGL(hex_digest, 2 * ops->digest_size, 0);
@@ -172,8 +172,8 @@
 
if (key_len > ops->block_size) {
/* Reduce the key first */
-   ops->hash_update(context, key, key_len);
-   ops->hash_final(K, context);
+   ops->hash_update(context, (unsigned char *) key, key_len);
+   ops->hash_final((unsigned char *) K, context);
/* Make the context ready to start over */
ops->hash_init(context);
} else {
@@ -184,22 +184,22 @@
for(i=0; i < ops->block_size; i++) {
K[i] ^= 0x36;
}
-   ops->hash_update(context, K, ops->block_size);
+   ops->hash_update(context, (unsigned char *) K, ops->block_size);
 
if (isfilename) {
char buf[1024];
int n;
 
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
-   ops->hash_update(context, buf, n);
+   ops->hash_update(context, (unsigned char *) buf, n);
}
php_stream_close(stream);
} else {
-   ops->hash_update(context, data, data_len);
+   ops->hash_update(context, (unsigned char *) data, data_len);
}
 
digest = emalloc(ops->digest_size + 1);
-   ops->hash_final(digest, context);
+   ops->hash_final((unsigned char *) digest, context);
 
/* Convert K to opad -- 0x6A = 0x36 ^ 0x5C */
for(i=0; i < ops->block_size; i++) {
@@ -208,9 +208,9 @@
 
/* Feed this result into the outter hash */
ops->hash_init(context);
-   ops->hash_update(context, K, ops->block_size);
-   ops->hash_update(context, digest, ops->digest_size);
-   ops->hash_final(digest, context);
+   ops->hash_update(context, (unsigned char *) K, ops->block_size);
+   ops->hash_update(context, (unsigned char *) digest, ops->digest_size);
+   ops->hash_final((unsigned char *) digest, context);
 
/* Zero the key */
memset(K, 0, ops->block_size);
@@ -223,7 +223,7 @@
} else {
char *hex_digest = safe_emalloc(ops->digest_size, 2, 1);
 
-   php_hash_bin2hex(hex_digest, digest, ops->digest_size);
+   php_hash_bin2hex(hex_digest, (unsigned char *) digest, 
ops->digest_size);
hex_digest[2 * ops->digest_size] = 0;
efree(digest);
RETURN_STRINGL(hex_digest, 2 * ops->digest_size, 0);
@@ -292,8 +292,8 @@
 
if (key_len > ops->block_size) {
/* Reduce the key first */
-   ops->hash_update(context, key, key_len);
-   ops->hash_final(K, context);
+   ops->hash_update(context, (unsigned char *) key, 
key_len);
+   ops->hash

[PHP-CVS] cvs: php-src /ext/hash hash.c hash_md.c package.xml php_hash.h php_hash_md.h /ext/hash/tests md2.phpt

2006-02-21 Thread Sara Golemon
pollita Tue Feb 21 20:37:12 2006 UTC

  Added files: 
/php-src/ext/hash/tests md2.phpt 

  Modified files:  
/php-src/ext/hash   hash.c hash_md.c php_hash.h php_hash_md.h 
package.xml 
  Log:
  Add md2 algo support
  http://cvs.php.net/viewcvs.cgi/php-src/ext/hash/hash.c?r1=1.23&r2=1.24&diff_format=u
Index: php-src/ext/hash/hash.c
diff -u php-src/ext/hash/hash.c:1.23 php-src/ext/hash/hash.c:1.24
--- php-src/ext/hash/hash.c:1.23Tue Feb 21 20:12:42 2006
+++ php-src/ext/hash/hash.c Tue Feb 21 20:37:12 2006
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash.c,v 1.23 2006/02/21 20:12:42 dmitry Exp $ */
+/* $Id: hash.c,v 1.24 2006/02/21 20:37:12 pollita Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -516,6 +516,7 @@
 
zend_hash_init(&php_hash_hashtable, 35, NULL, NULL, 1);
 
+   php_hash_register_algo("md2",   &php_hash_md2_ops);
php_hash_register_algo("md4",   &php_hash_md4_ops);
php_hash_register_algo("md5",   &php_hash_md5_ops);
php_hash_register_algo("sha1",  &php_hash_sha1_ops);
http://cvs.php.net/viewcvs.cgi/php-src/ext/hash/hash_md.c?r1=1.9&r2=1.10&diff_format=u
Index: php-src/ext/hash/hash_md.c
diff -u php-src/ext/hash/hash_md.c:1.9 php-src/ext/hash/hash_md.c:1.10
--- php-src/ext/hash/hash_md.c:1.9  Sun Feb 19 04:29:40 2006
+++ php-src/ext/hash/hash_md.c  Tue Feb 21 20:37:12 2006
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: hash_md.c,v 1.9 2006/02/19 04:29:40 andi Exp $ */
+/* $Id: hash_md.c,v 1.10 2006/02/21 20:37:12 pollita Exp $ */
 
 #include "php_hash.h"
 #include "php_hash_md.h"
@@ -39,6 +39,15 @@
sizeof(PHP_MD4_CTX)
 };
 
+php_hash_ops php_hash_md2_ops = {
+   (php_hash_init_func_t) PHP_MD2Init,
+   (php_hash_update_func_t) PHP_MD2Update,
+   (php_hash_final_func_t) PHP_MD2Final,
+   16,
+   16,
+   sizeof(PHP_MD2_CTX)
+};
+
 /* MD common stuff */
 
 static unsigned char PADDING[64] =
@@ -579,6 +588,95 @@
 }
 /* }}} */
 
+/* MD2 */
+
+static unsigned char MD2_S[256] = {
+41,  46,  67, 201, 162, 216, 124,   1,  61,  54,  84, 161, 236, 240,   
6,  19,
+98, 167,   5, 243, 192, 199, 115, 140, 152, 147,  43, 217, 188,  76, 
130, 202,
+30, 155,  87,  60, 253, 212, 224,  22, 103,  66, 111,  24, 138,  23, 
229,  18,
+   190,  78, 196, 214, 218, 158, 222,  73, 160, 251, 245, 142, 187,  47, 
238, 122,
+   169, 104, 121, 145,  21, 178,   7,  63, 148, 194,  16, 137,  11,  34,  
95,  33,
+   128, 127,  93, 154,  90, 144,  50,  39,  53,  62, 204, 231, 191, 247, 
151,   3,
+   255,  25,  48, 179,  72, 165, 181, 209, 215,  94, 146,  42, 172,  86, 
170, 198,
+79, 184,  56, 210, 150, 164, 125, 182, 118, 252, 107, 226, 156, 116,   
4, 241,
+69, 157, 112,  89, 100, 113, 135,  32, 134,  91, 207, 101, 230,  45, 
168,   2,
+27,  96,  37, 173, 174, 176, 185, 246,  28,  70,  97, 105,  52,  64, 
126,  15,
+85,  71, 163,  35, 221,  81, 175,  58, 195,  92, 249, 206, 186, 197, 
234,  38,
+44,  83,  13, 110, 133,  40, 132,   9, 211, 223, 205, 244,  65, 129,  
77,  82,
+   106, 220,  55, 200, 108, 193, 171, 250,  36, 225, 123,   8,  12, 189, 
177,  74,
+   120, 136, 149, 139, 227,  99, 232, 109, 233, 203, 213, 254,  59,   0,  
29,  57,
+   242, 239, 183,  14, 102,  88, 208, 228, 166, 119, 114, 248, 235, 117,  
75,  10,
+49,  68,  80, 180, 143, 237,  31,  26, 219, 153, 141,  51, 159,  17, 
131,  20 };
+
+PHP_HASH_API void PHP_MD2Init(PHP_MD2_CTX *context)
+{
+   memset(context, 0, sizeof(PHP_MD2_CTX));
+}
+
+static void MD2_Transform(PHP_MD2_CTX *context, const unsigned char *block)
+{
+   unsigned char i,j,t = 0;
+
+   for(i = 0; i < 16; i++) {
+   context->state[16+i] = block[i];
+   context->state[32+i] = (context->state[16+i] ^ 
context->state[i]);
+   }
+
+   for(i = 0; i < 18; i++) {
+   for(j = 0; j < 48; j++) {
+   t = context->state[j] = context->state[j] ^ MD2_S[t];
+   }
+   t += i;
+   }
+
+   /* Update checksum -- must be after transform to avoid fouling up last 
message block */
+   t = context->checksum[15];
+   for(i = 0; i < 16; i++) {
+   t = context->checksum[i] ^= MD2_S[block[i] ^ t];
+   }
+}
+
+PHP_HASH_API void PHP_MD2Update(PHP_MD2_CTX *context, const unsigned char 
*buf, unsigned int len)
+{
+   const unsigned char *p = buf, *e = buf + len;
+
+   if (context->in_buffer) {
+   if (context->in_buffer + len < 16) {
+   /* Not enough for block, just pass into buffer */
+   memcpy(context->buffer + context->in_buffer, p, len);
+   context->in_buffer +=