if test "$PHP_HASH" != "no"; then
AC_DEFINE(HAVE_HASH_EXT,1,[Have HASH Extension])
- PHP_NEW_EXTENSION(hash, hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c, $ext_shared)
+
+ EXT_HASH_SOURCES="hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c \
+ hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c hash_adler32.c"
+ EXT_HASH_HEADERS="php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h \
+ php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h \
+ php_hash_whirlpool.h php_hash_adler32.h"
+
+ PHP_NEW_EXTENSION(hash, $EXT_HASH_SOURCES, $ext_shared)
ifdef([PHP_INSTALL_HEADERS], [
- PHP_INSTALL_HEADERS(ext/hash, php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h php_hash_whirlpool.h)
+ PHP_INSTALL_HEADERS(ext/hash, $EXT_HASH_HEADERS)
])
fi
if (PHP_HASH != "no") {
AC_DEFINE('HAVE_HASH_EXT', 1);
- EXTENSION("hash", "hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c");
+ EXTENSION("hash", "hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c "
+ + "hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c "
+ + "hash_adler32.c");
}
{
php_hash_le_hash = zend_register_list_destructors_ex(php_hash_dtor, NULL, PHP_HASH_RESNAME, module_number);
- zend_hash_init(&php_hash_hashtable, 30, NULL, NULL, 1);
+ zend_hash_init(&php_hash_hashtable, 35, NULL, NULL, 1);
php_hash_register_algo("md5", &php_hash_md5_ops);
php_hash_register_algo("sha1", &php_hash_sha1_ops);
php_hash_register_algo("tiger192,4", &php_hash_4tiger192_ops);
php_hash_register_algo("snefru", &php_hash_snefru_ops);
php_hash_register_algo("gost", &php_hash_gost_ops);
+ php_hash_register_algo("adler32", &php_hash_adler32_ops);
PHP_HASH_HAVAL_REGISTER(3,128);
PHP_HASH_HAVAL_REGISTER(3,160);
--- /dev/null
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2005 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.0 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_0.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Michael Wallner <mike@php.net> |
+ | Sara Golemon <pollita@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#include "php_hash.h"
+#include "php_hash_adler32.h"
+
+PHP_HASH_API PHP_ADLER32Init(PHP_ADLER32_CTX *context)
+{
+ context->state = 1;
+}
+
+PHP_HASH_API PHP_ADLER32Update(PHP_ADLER32_CTX *context, const unsigned char *input, size_t len)
+{
+ php_uint32 i, s[2] = { context->state & 0xffff, (context->state >> 16) & 0xffff };
+
+ for (i = 0; i < len; ++i) {
+ s[0] = (s[0] + input[i]) % 65521;
+ s[1] = (s[1] + s[0]) % 65521;
+ }
+ context->state = s[0] + (s[1] << 16);
+}
+
+PHP_HASH_API PHP_ADLER32Final(unsigned char digest[4], PHP_ADLER32_CTX *context)
+{
+ digest[3] = (unsigned char) ((context->state >> 24) & 0xff);
+ digest[2] = (unsigned char) ((context->state >> 16) & 0xff);
+ digest[1] = (unsigned char) ((context->state >> 8) & 0xff);
+ digest[0] = (unsigned char) (context->state & 0xff);
+ context->state = 0;
+}
+
+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,
+ 4, /* what to say here? */
+ 4,
+ sizeof(PHP_ADLER32_CTX)
+};
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: sw=4 ts=4 fdm=marker
+ * vim<600: sw=4 ts=4
+ */
* sha1, sha256, sha384, sha512
* ripemd128, ripemd160
* tiger128, tiger160, tiger192
- * gost, snefru, whirlpool
+ * adler32, gost, snefru, whirlpool
</notes>
</release>
<file role="src" name="hash_gost.c"/>
<file role="src" name="php_hash_gost.h"/>
<file role="src" name="php_hash_gost_tables.h"/>
+ <file role="src" name="hash_adler32.c"/>
+ <file role="src" name="php_hash_adler32.h"/>
<file role="doc" name="README"/>
<dir role="test" name="tests">
<file role="test" name="hmac-md5.phpt"/>
extern php_hash_ops php_hash_4tiger192_ops;
extern php_hash_ops php_hash_snefru_ops;
extern php_hash_ops php_hash_gost_ops;
+extern php_hash_ops php_hash_adler32_ops;
#define PHP_HASH_HAVAL_OPS(p,b) extern php_hash_ops php_hash_##p##haval##b##_ops;
PHP_HASH_API php_hash_ops *php_hash_fetch_ops(const char *algo, int algo_len);
PHP_HASH_API void php_hash_register_algo(const char *algo, php_hash_ops *ops);
-static inline void php_hash_bin2hex(char *out, unsigned char *in, int in_len)
+static inline void php_hash_bin2hex(char *out, const unsigned char *in, int in_len)
{
static const char hexits[16] = "0123456789abcdef";
int i;
--- /dev/null
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2005 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.0 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_0.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Michael Wallner <mike@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef PHP_HASH_ADLER32_H
+#define PHP_HASH_ADLER32_H
+
+#include "ext/standard/basic_functions.h"
+
+typedef struct {
+ php_uint32 state;
+} PHP_ADLER32_CTX;
+
+PHP_HASH_API PHP_ADLER32Init(PHP_ADLER32_CTX *context);
+PHP_HASH_API PHP_ADLER32Update(PHP_ADLER32_CTX *context, const unsigned char *input, size_t len);
+PHP_HASH_API PHP_ADLER32Final(unsigned char digest[4], PHP_ADLER32_CTX *context);
+
+#endif
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: sw=4 ts=4 fdm=marker
+ * vim<600: sw=4 ts=4
+ */