diff options
Diffstat (limited to 'ext/mhash')
-rw-r--r-- | ext/mhash/CREDITS | 2 | ||||
-rw-r--r-- | ext/mhash/config.m4 | 25 | ||||
-rw-r--r-- | ext/mhash/mhash.c | 284 | ||||
-rw-r--r-- | ext/mhash/mhash.dsp | 115 | ||||
-rw-r--r-- | ext/mhash/php_mhash.h | 27 |
5 files changed, 0 insertions, 453 deletions
diff --git a/ext/mhash/CREDITS b/ext/mhash/CREDITS deleted file mode 100644 index 54851e1ac7..0000000000 --- a/ext/mhash/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -mhash -Sascha Schumann diff --git a/ext/mhash/config.m4 b/ext/mhash/config.m4 deleted file mode 100644 index e53bd28f61..0000000000 --- a/ext/mhash/config.m4 +++ /dev/null @@ -1,25 +0,0 @@ -dnl -dnl $Id$ -dnl - -PHP_ARG_WITH(mhash, for mhash support, -[ --with-mhash[=DIR] Include mhash support.]) - -if test "$PHP_MHASH" != "no"; then - for i in /usr/local /usr /opt/mhash $PHP_MHASH; do - if test -f $i/include/mhash.h; then - MHASH_DIR=$i - fi - done - - if test -z "$MHASH_DIR"; then - AC_MSG_ERROR(Please reinstall libmhash - I cannot find mhash.h) - fi - PHP_ADD_INCLUDE($MHASH_DIR/include) - PHP_ADD_LIBRARY_WITH_PATH(mhash, $MHASH_DIR/lib, MHASH_SHARED_LIBADD) - PHP_SUBST(MHASH_SHARED_LIBADD) - - AC_DEFINE(HAVE_LIBMHASH,1,[ ]) - - PHP_NEW_EXTENSION(mhash, mhash.c, $ext_shared) -fi diff --git a/ext/mhash/mhash.c b/ext/mhash/mhash.c deleted file mode 100644 index e7ba9ed85b..0000000000 --- a/ext/mhash/mhash.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.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: Sascha Schumann <sascha@schumann.cx> | - | Nikos Mavroyanopoulos <nmav@hellug.gr> (HMAC, KEYGEN) | - +----------------------------------------------------------------------+ - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" - -#if HAVE_LIBMHASH - -#include "fcntl.h" -#include "php_mhash.h" -#include "mhash.h" -#include "php_ini.h" -#include "php_globals.h" -#include "ext/standard/info.h" - -function_entry mhash_functions[] = { - PHP_FE(mhash_get_block_size, NULL) - PHP_FE(mhash_get_hash_name, NULL) - PHP_FE(mhash_keygen_s2k, NULL) - PHP_FE(mhash_count, NULL) - PHP_FE(mhash, NULL) - {NULL, NULL, NULL} -}; - -static PHP_MINIT_FUNCTION(mhash); - -zend_module_entry mhash_module_entry = { - STANDARD_MODULE_HEADER, - "mhash", - mhash_functions, - PHP_MINIT(mhash), NULL, - NULL, NULL, - NULL, - NO_VERSION_YET, - STANDARD_MODULE_PROPERTIES, -}; - -#ifdef COMPILE_DL_MHASH -ZEND_GET_MODULE(mhash) -#endif -#define MHASH_FAILED_MSG "mhash initialization failed" -#define MHASH_KEYGEN_FAILED_MSG "mhash key generation failed" -static PHP_MINIT_FUNCTION(mhash) -{ - int i; - char *name; - char buf[128]; - - for (i = 0; i <= mhash_count(); i++) { - name = mhash_get_hash_name(i); - if (name) { - snprintf(buf, 127, "MHASH_%s", name); - zend_register_long_constant(buf, strlen(buf) + 1, - i, CONST_PERSISTENT, - module_number TSRMLS_CC); - free(name); - } - } - - return SUCCESS; -} - -/* {{{ proto int mhash_count(void) - Gets the number of available hashes */ -PHP_FUNCTION(mhash_count) -{ - if (ZEND_NUM_ARGS() != 0) { - WRONG_PARAM_COUNT; - } - - RETURN_LONG(mhash_count()); -} - -/* }}} */ - -/* {{{ proto int mhash_get_block_size(int hash) - Gets the block size of hash */ -PHP_FUNCTION(mhash_get_block_size) -{ - pval **hash; - - if (ZEND_NUM_ARGS() != 1 - || zend_get_parameters_ex(1, &hash) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_long_ex(hash); - - RETURN_LONG(mhash_get_block_size(Z_LVAL_PP(hash))); -} - -/* }}} */ - -/* {{{ proto string mhash_get_hash_name(int hash) - Gets the name of hash */ -PHP_FUNCTION(mhash_get_hash_name) -{ - pval **hash; - char *name; - - if (ZEND_NUM_ARGS() != 1 - || zend_get_parameters_ex(1, &hash) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_long_ex(hash); - - name = mhash_get_hash_name(Z_LVAL_PP(hash)); - if (name) { - RETVAL_STRING(name, 1); - free(name); - } else { - RETVAL_FALSE; - } -} - -/* }}} */ - -/* {{{ proto string mhash(int hash, string data [, string key]) - Hash data with hash */ -PHP_FUNCTION(mhash) -{ - pval **hash, **data, **key; - MHASH td; - int bsize; - unsigned char *hash_data; - int num_args; - - num_args = ZEND_NUM_ARGS(); - - if (num_args < 2 || num_args > 3) { - WRONG_PARAM_COUNT; - } - if (num_args == 2) { /* 2 arguments, just hash */ - if (zend_get_parameters_ex(2, &hash, &data) == FAILURE) { - WRONG_PARAM_COUNT; - } - } else { /* 3 arguments, do HMAC hash (keyed hash) */ - if (zend_get_parameters_ex(3, &hash, &data, &key) == - FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(key); - } - - convert_to_long_ex(hash); - convert_to_string_ex(data); - - bsize = mhash_get_block_size(Z_LVAL_PP(hash)); - - if (num_args == 3) { - if (mhash_get_hash_pblock(Z_LVAL_PP(hash)) == 0) { - php_error(E_WARNING, MHASH_FAILED_MSG); - RETURN_FALSE; - } - td = mhash_hmac_init(Z_LVAL_PP(hash), - Z_STRVAL_PP(key), - Z_STRLEN_PP(key), - mhash_get_hash_pblock(Z_LVAL_PP(hash))); - } else { - td = mhash_init(Z_LVAL_PP(hash)); - } - if (td == MHASH_FAILED) { - php_error(E_WARNING, MHASH_FAILED_MSG); - RETURN_FALSE; - } - - mhash(td, Z_STRVAL_PP(data), Z_STRLEN_PP(data)); - - if (num_args == 3) { - hash_data = (unsigned char *) mhash_hmac_end(td); - } else { - hash_data = (unsigned char *) mhash_end(td); - } - if (hash_data) { - RETVAL_STRINGL(hash_data, bsize, 1); - mhash_free(hash_data); - } else { - RETURN_FALSE; - } -} - -/* }}} */ - -/* {{{ proto string mhash_keygen_s2k(int hash, string input_password, string salt, int bytes) - Generates a key using hash functions */ -/* SALTED S2K uses a fixed salt */ -#define SALT_SIZE 8 -PHP_FUNCTION(mhash_keygen_s2k) -{ - pval **hash, **input_password, **bytes, **input_salt; - int password_len, salt_len; - int hashid, size=0, val; - KEYGEN keystruct; - char salt[SALT_SIZE], *ret; - char* password, error[128]; - - if (ZEND_NUM_ARGS() != 4) { - WRONG_PARAM_COUNT; - } - if (zend_get_parameters_ex(4, &hash, &input_password, &input_salt, &bytes) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(hash); - convert_to_string_ex(input_password); - convert_to_string_ex(input_salt); - convert_to_long_ex(bytes); - - password = Z_STRVAL_PP(input_password); - password_len = Z_STRLEN_PP(input_password); - - salt_len = MIN(Z_STRLEN_PP(input_salt), SALT_SIZE); - - if (salt_len > mhash_get_keygen_salt_size(KEYGEN_S2K_SALTED)) { - sprintf( error, "The specified salt [%d] is more bytes than the required by the algorithm [%d]\n", salt_len, mhash_get_keygen_salt_size(KEYGEN_S2K_SALTED)); - - php_error(E_WARNING, error); - } - - memcpy(salt, Z_STRVAL_PP(input_salt), salt_len); - if (salt_len < SALT_SIZE) - memset(salt + salt_len, 0, SALT_SIZE - salt_len); - salt_len=SALT_SIZE; - -/* if (salt_len==0) { - * php_error(E_WARNING, "Not using salt is really not recommended); - * } - */ - - hashid = Z_LVAL_PP(hash); - size = Z_LVAL_PP(bytes); - - keystruct.hash_algorithm[0]=hashid; - keystruct.hash_algorithm[1]=hashid; - keystruct.count=0; - keystruct.salt = salt; - keystruct.salt_size = salt_len; - - ret = emalloc(size); - if (ret==NULL) { - php_error(E_WARNING, MHASH_KEYGEN_FAILED_MSG); - RETURN_FALSE; - } - - val = mhash_keygen_ext( KEYGEN_S2K_SALTED, keystruct, ret, size, password, password_len); - if (val >= 0) { - RETVAL_STRINGL(ret, size, 0); - } else { - php_error(E_WARNING, MHASH_KEYGEN_FAILED_MSG); - efree(ret); - RETURN_FALSE; - } -} -/* }}} */ - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/mhash/mhash.dsp b/ext/mhash/mhash.dsp deleted file mode 100644 index 12525935d8..0000000000 --- a/ext/mhash/mhash.dsp +++ /dev/null @@ -1,115 +0,0 @@ -# Microsoft Developer Studio Project File - Name="mhash" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=mhash - Win32 Release_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "mhash.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "mhash.mak" CFG="mhash - Win32 Release_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "mhash - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "mhash - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "mhash - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\..\Zend" /I "..\..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_MHASH" /D ZTS=1 /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /I "..\..\win32" /D "WIN32" /D "MHASH_EXPORTS" /D "COMPILE_DL_MHASH" /D HAVE_LIBMHASH=1 /D ZEND_DEBUG=0 /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ZEND_WIN32" /D "PHP_WIN32" /D ZTS=1 /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x406 /d "NDEBUG"
-# ADD RSC /l 0x406 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /dll /machine:I386
-# ADD LINK32 php4ts.lib libmhash.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_mhash.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "mhash - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_MHASH" /D ZTS=1 /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /I "..\..\win32" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MHASH_EXPORTS" /D "COMPILE_DL_MHASH" /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_MHASH=1 /D ZTS=1 /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x406 /d "NDEBUG"
-# ADD RSC /l 0x406 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts_debug.lib /nologo /dll /machine:I386
-# ADD LINK32 php4ts_debug.lib libmhash.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Debug_TS/php_mhash.dll" /libpath:"..\..\Debug_TS"
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF
-
-# Begin Target
-
-# Name "mhash - Win32 Release_TS"
-# Name "mhash - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\mhash.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_mhash.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/ext/mhash/php_mhash.h b/ext/mhash/php_mhash.h deleted file mode 100644 index 9acd447d81..0000000000 --- a/ext/mhash/php_mhash.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef PHP_MHASH_H -#define PHP_MHASH_H - -#if HAVE_LIBMHASH - -#if PHP_API_VERSION < 19990421 -#define zend_module_entry zend_module_entry -#include "zend_modules.h" -#include "internal_functions.h" -#endif - -extern zend_module_entry mhash_module_entry; -#define mhash_module_ptr &mhash_module_entry - -PHP_FUNCTION(mhash_get_block_size); -PHP_FUNCTION(mhash_get_hash_name); -PHP_FUNCTION(mhash_count); -PHP_FUNCTION(mhash_keygen_s2k); -PHP_FUNCTION(mhash); - -#else -#define mhash_module_ptr NULL -#endif - -#define phpext_mhash_ptr mhash_module_ptr - -#endif |