diff options
-rw-r--r-- | ext/mcrypt/config.m4 | 6 | ||||
-rw-r--r-- | ext/mcrypt/mcrypt.c | 38 | ||||
-rw-r--r-- | ext/mcrypt/php_mcrypt.h | 6 |
3 files changed, 37 insertions, 13 deletions
diff --git a/ext/mcrypt/config.m4 b/ext/mcrypt/config.m4 index 78dd7fb497..b1ff3d465a 100644 --- a/ext/mcrypt/config.m4 +++ b/ext/mcrypt/config.m4 @@ -9,10 +9,14 @@ AC_ARG_WITH(mcrypt, [ if test "$withval" != "no"; then for i in /usr/local /usr $withval; do - if test -f $i/include/lcrypt.h; then + if test -f $i/include/mcrypt.h; then MCRYPT_DIR=$i fi done + if test "$MCRYPT_DIR" = ""; then + AC_MSG_ERROR(Please install mcrypt.h and libmcrypt.a accordingly to the do +cumentation - I cannot find mcrypt.h) + fi INCLUDES="$INCLUDES -I$MCRYPT_DIR/include" EXTRA_LIBS="$EXTRA_LIBS -L$MCRYPT_DIR/lib -lmcrypt" diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index 79bd4d75c9..500edfd645 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -31,17 +31,12 @@ #if HAVE_LIBMCRYPT -#if PHP_API_VERSION < 19990421 -#define zend_module_entry php3_module_entry -#include "modules.h" -#include "internal_functions.h" -#endif - -#include "fcntl.h" - #include "php_mcrypt.h" +#include "fcntl.h" -#include "lcrypt.h" +/* we should find a way to figure out whether RC6/IDEA are available */ +#define NON_FREE +#include "mcrypt.h" function_entry mcrypt_functions[] = { PHP_FE(mcrypt_ecb, NULL) @@ -143,15 +138,29 @@ static int php_minit_mcrypt(INIT_FUNC_ARGS) MCRYPT_ENTRY(TripleDES); MCRYPT_ENTRY(ThreeWAY); MCRYPT_ENTRY(GOST); +#ifdef MCRYPT2 + MCRYPT_ENTRY(CRYPT); + MCRYPT_ENTRY(DES_COMPAT); +#endif MCRYPT_ENTRY(SAFER64); MCRYPT_ENTRY(SAFER128); MCRYPT_ENTRY(CAST128); MCRYPT_ENTRY(TEAN); - MCRYPT_ENTRY(TWOFISH); MCRYPT_ENTRY(RC2); -#ifdef CRYPT - MCRYPT_ENTRY(CRYPT); +#ifdef TWOFISH + MCRYPT_ENTRY(TWOFISH); +#elif defined(TWOFISH128) + MCRYPT_ENTRY(TWOFISH128); + MCRYPT_ENTRY(TWOFISH192); + MCRYPT_ENTRY(TWOFISH256); +#endif +#ifdef RC6 + MCRYPT_ENTRY(RC6); +#endif +#ifdef IDEA + MCRYPT_ENTRY(IDEA); #endif + return SUCCESS; } @@ -179,6 +188,11 @@ PHP_FUNCTION(mcrypt_create_iv) source = psource->value.lval; i = size->value.lval; + if(i <= 0) { + php3_error(E_WARNING, "illegal size input parameter"); + RETURN_FALSE; + } + iv = ecalloc(i, 1); if(source == RANDOM || source == URANDOM) { diff --git a/ext/mcrypt/php_mcrypt.h b/ext/mcrypt/php_mcrypt.h index 97ca367b7d..5d511a4816 100644 --- a/ext/mcrypt/php_mcrypt.h +++ b/ext/mcrypt/php_mcrypt.h @@ -3,6 +3,12 @@ #if HAVE_LIBMCRYPT +#if PHP_API_VERSION < 19990421 +#define zend_module_entry php3_module_entry +#include "modules.h" +#include "internal_functions.h" +#endif + extern zend_module_entry mcrypt_module_entry; #define mcrypt_module_ptr &mcrypt_module_entry |