[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c
kalle Tue May 19 17:46:56 2009 UTC Modified files: /php-src/ext/mcrypt mcrypt.c Log: Fix compiler warning http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.121r2=1.122diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.121 php-src/ext/mcrypt/mcrypt.c:1.122 --- php-src/ext/mcrypt/mcrypt.c:1.121 Tue Mar 10 23:39:27 2009 +++ php-src/ext/mcrypt/mcrypt.c Tue May 19 17:46:56 2009 @@ -16,7 +16,7 @@ | Derick Rethans der...@derickrethans.nl| +--+ */ -/* $Id: mcrypt.c,v 1.121 2009/03/10 23:39:27 helly Exp $ */ +/* $Id: mcrypt.c,v 1.122 2009/05/19 17:46:56 kalle Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1226,7 +1226,7 @@ case PHP_MCRYPT_IV_SOURCE_RAND: *iv_len = size; while (size) { - (*iv_str)[--size] = 255.0 * php_rand(TSRMLS_C) / RAND_MAX; + (*iv_str)[--size] = (char) (255.0 * php_rand(TSRMLS_C) / RAND_MAX); } break; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c
tony2001Wed Sep 10 07:31:12 2008 UTC Modified files: /php-src/ext/mcrypt mcrypt.c Log: check for NULL before freeing http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.115r2=1.116diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.115 php-src/ext/mcrypt/mcrypt.c:1.116 --- php-src/ext/mcrypt/mcrypt.c:1.115 Sun Sep 7 22:53:20 2008 +++ php-src/ext/mcrypt/mcrypt.c Wed Sep 10 07:31:12 2008 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.115 2008/09/07 22:53:20 felipe Exp $ */ +/* $Id: mcrypt.c,v 1.116 2008/09/10 07:31:12 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1275,7 +1275,7 @@ int php_mcrypt_func(php_mcrypt_op op, char *cipher, char *mode, char *key_str, int key_len, char *iv_str, int iv_len, char *data_str, int data_len, char **data_copy, int *data_size TSRMLS_DC) { MCRYPT td; - char *cipher_dir_string, *module_dir_string, *key_copy, *iv_copy; + char *cipher_dir_string, *module_dir_string, *key_copy, *iv_copy = NULL; int i, status = SUCCESS, count, *key_sizes, key_size, iv_size, block_size; MCRYPT_GET_INI @@ -1362,7 +1362,9 @@ } efree(key_copy); - efree(iv_copy); + if (iv_copy) { + efree(iv_copy); + } return status; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c /ext/mcrypt/tests bug46010.phpt
felipe Sun Sep 7 22:53:21 2008 UTC Added files: /php-src/ext/mcrypt/tests bug46010.phpt Modified files: /php-src/ext/mcrypt mcrypt.c Log: - Fixed bug #46010 (warnings incorrectly generated for iv in ecb mode) http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.114r2=1.115diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.114 php-src/ext/mcrypt/mcrypt.c:1.115 --- php-src/ext/mcrypt/mcrypt.c:1.114 Wed Jul 16 08:00:43 2008 +++ php-src/ext/mcrypt/mcrypt.c Sun Sep 7 22:53:20 2008 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.114 2008/07/16 08:00:43 tony2001 Exp $ */ +/* $Id: mcrypt.c,v 1.115 2008/09/07 22:53:20 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1276,7 +1276,7 @@ { MCRYPT td; char *cipher_dir_string, *module_dir_string, *key_copy, *iv_copy; - int i, status = SUCCESS, count, *key_sizes, key_size, iv_size, block_size, iv_req; + int i, status = SUCCESS, count, *key_sizes, key_size, iv_size, block_size; MCRYPT_GET_INI @@ -1314,20 +1314,20 @@ mcrypt_free(key_sizes); iv_size = mcrypt_enc_get_iv_size(td); - iv_req = mcrypt_enc_mode_has_iv(td); - if (iv_len) { - if (iv_len == iv_size) { - iv_copy = estrndup(iv_str, iv_len); + /* IV is required */ + if (mcrypt_enc_mode_has_iv(td) == 1) { + if (iv_len) { + if (iv_len == iv_size) { + iv_copy = estrndup(iv_str, iv_len); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, MCRYPT_IV_WRONG_SIZE); + iv_copy = ecalloc(1, iv_size); + memcpy(iv_copy, iv_str, MIN(iv_len, iv_size)); + } } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, MCRYPT_IV_WRONG_SIZE); - iv_copy = ecalloc(1, iv_size); - memcpy(iv_copy, iv_str, MIN(iv_len, iv_size)); - } - } else { - if (iv_req) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Attempt to use an empty IV, which is NOT recommended); + iv_copy = ecalloc(1, iv_size); } - iv_copy = ecalloc(1, iv_size); } if (mcrypt_enc_is_block_mode(td) == 1) { http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/tests/bug46010.phpt?view=markuprev=1.1 Index: php-src/ext/mcrypt/tests/bug46010.phpt +++ php-src/ext/mcrypt/tests/bug46010.phpt --TEST--- Bug #46010 (warnings incorrectly generated for iv in ecb mode) --FILE-- ?php var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, key, data, MCRYPT_MODE_ECB))); var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, key, data, MCRYPT_MODE_ECB, a))); var_dump(bin2hex(mcrypt_encrypt(MCRYPT_TRIPLEDES, key, data, MCRYPT_MODE_ECB, 12345678))); ? --EXPECTF-- string(16) 372eeb4a524b8d31 string(16) 372eeb4a524b8d31 string(16) 372eeb4a524b8d31 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c
tony2001Wed Jul 16 08:00:43 2008 UTC Modified files: /php-src/ext/mcrypt mcrypt.c Log: fix build http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.113r2=1.114diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.113 php-src/ext/mcrypt/mcrypt.c:1.114 --- php-src/ext/mcrypt/mcrypt.c:1.113 Tue Jul 15 17:04:17 2008 +++ php-src/ext/mcrypt/mcrypt.c Wed Jul 16 08:00:43 2008 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.113 2008/07/15 17:04:17 pajoye Exp $ */ +/* $Id: mcrypt.c,v 1.114 2008/07/16 08:00:43 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1232,7 +1232,7 @@ *iv_len = size; #else size_t read_bytes = 0; - int fd; + int fd, n; fd = open(source == PHP_MCRYPT_IV_SOURCE_RANDOM ? /dev/random : /dev/urandom, O_RDONLY); if (fd 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c
felipe Tue Jul 1 19:44:18 2008 UTC Modified files: /php-src/ext/mcrypt mcrypt.c Log: - MFB: Added arginfo http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.111r2=1.112diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.111 php-src/ext/mcrypt/mcrypt.c:1.112 --- php-src/ext/mcrypt/mcrypt.c:1.111 Sun May 18 19:52:46 2008 +++ php-src/ext/mcrypt/mcrypt.c Tue Jul 1 19:44:18 2008 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.111 2008/05/18 19:52:46 dsp Exp $ */ +/* $Id: mcrypt.c,v 1.112 2008/07/01 19:44:18 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -44,49 +44,273 @@ zend_bool init; } php_mcrypt; +/* {{{ arginfo */ +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_module_open, 0, 0, 4) + ZEND_ARG_INFO(0, cipher) + ZEND_ARG_INFO(0, cipher_directory) + ZEND_ARG_INFO(0, mode) + ZEND_ARG_INFO(0, mode_directory) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_generic_init, 0, 0, 3) + ZEND_ARG_INFO(0, td) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, iv) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_generic, 0, 0, 2) + ZEND_ARG_INFO(0, td) + ZEND_ARG_INFO(0, data) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mdecrypt_generic, 0, 0, 2) + ZEND_ARG_INFO(0, td) + ZEND_ARG_INFO(0, data) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_enc_get_supported_key_sizes, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_enc_self_test, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_module_close, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_generic_deinit, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_enc_is_block_algorithm_mode, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_enc_is_block_algorithm, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_enc_is_block_mode, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_enc_get_block_size, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_enc_get_key_size, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_enc_get_iv_size, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_enc_get_algorithms_name, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_enc_get_modes_name, 0, 0, 1) + ZEND_ARG_INFO(0, td) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_module_self_test, 0, 0, 1) + ZEND_ARG_INFO(0, algorithm) + ZEND_ARG_INFO(0, lib_dir) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_module_is_block_algorithm_mode, 0, 0, 1) + ZEND_ARG_INFO(0, mode) + ZEND_ARG_INFO(0, lib_dir) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_module_is_block_algorithm, 0, 0, 1) + ZEND_ARG_INFO(0, algorithm) + ZEND_ARG_INFO(0, lib_dir) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_module_is_block_mode, 0, 0, 1) + ZEND_ARG_INFO(0, mode) + ZEND_ARG_INFO(0, lib_dir) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_module_get_algo_block_size, 0, 0, 1) + ZEND_ARG_INFO(0, algorithm) + ZEND_ARG_INFO(0, lib_dir) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_module_get_algo_key_size, 0, 0, 1) + ZEND_ARG_INFO(0, algorithm) + ZEND_ARG_INFO(0, lib_dir) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_module_get_supported_key_sizes, 0, 0, 1) + ZEND_ARG_INFO(0, algorithm) + ZEND_ARG_INFO(0, lib_dir) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_list_algorithms, 0, 0, 0) + ZEND_ARG_INFO(0, lib_dir) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_list_modes, 0, 0, 0) + ZEND_ARG_INFO(0, lib_dir) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_get_key_size, 0, 0, 2) + ZEND_ARG_INFO(0, cipher) + ZEND_ARG_INFO(0, module) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_get_block_size, 0, 0, 2) + ZEND_ARG_INFO(0, cipher) + ZEND_ARG_INFO(0, module) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_mcrypt_get_iv_size, 0,
[PHP-CVS] Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c /ext/mcrypt/tests mcrypt_enc_self_test.phpt
On Sun, 18 May 2008, Hannes Magnusson wrote: On Sun, May 18, 2008 at 8:14 PM, David Soria Parra [EMAIL PROTECTED] wrote: Hannes Magnusson wrote: This is a massive BC break... Imagine people who did if (mcrypt_enc_self_test($td) == 0) { ... } that has now changed from dealing with success to failure. I'd say rather fix the docs Yes I noticed that, that's why its not in 5.2. I think it's kind of cleaning up as mcrypt_module_self_test return a boolean too and the docs say it too. Maybe it's just in my opinion that the function itself is not that often used as it would be real issue, but if people have objections for sure we can revert that. The point is this is a very subtle change and not something people will suspect when their applications stop working out of the blue, without so much as a single warning. A function rename would be obvious as it would give a fatal error, but this is a return value change from false to true... Yes, and changes should also be passed by the extension's maintainer. regards, Derick -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c /ext/mcrypt/tests mcrypt_enc_self_test.phpt
dsp Sun May 18 17:15:08 2008 UTC Modified files: /php-src/ext/mcrypt mcrypt.c /php-src/ext/mcrypt/tests mcrypt_enc_self_test.phpt Log: MFB: Make mcrypt_enc_self_test() return value compatible with documentation and mcrypt_module_self_test() http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.109r2=1.110diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.109 php-src/ext/mcrypt/mcrypt.c:1.110 --- php-src/ext/mcrypt/mcrypt.c:1.109 Mon Dec 31 07:12:11 2007 +++ php-src/ext/mcrypt/mcrypt.c Sun May 18 17:15:08 2008 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.109 2007/12/31 07:12:11 sebastian Exp $ */ +/* $Id: mcrypt.c,v 1.110 2008/05/18 17:15:08 dsp Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -476,7 +476,12 @@ PHP_FUNCTION(mcrypt_enc_self_test) { MCRYPT_GET_TD_ARG - RETURN_LONG(mcrypt_enc_self_test(pm-td)); + + if (mcrypt_enc_self_test(pm-td) == 0) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt diff -u php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.1 php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.2 --- php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.1 Sat May 17 23:27:42 2008 +++ php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt Sun May 18 17:15:08 2008 @@ -7,4 +7,4 @@ $td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, ''); var_dump(mcrypt_enc_self_test($td)); --EXPECT-- -int(0) \ No newline at end of file +bool(true) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c /ext/mcrypt/tests mcrypt_enc_self_test.phpt
On Sun, May 18, 2008 at 7:15 PM, David Soria Parra [EMAIL PROTECTED] wrote: dsp Sun May 18 17:15:08 2008 UTC Modified files: /php-src/ext/mcrypt mcrypt.c /php-src/ext/mcrypt/tests mcrypt_enc_self_test.phpt Log: MFB: Make mcrypt_enc_self_test() return value compatible with documentation and mcrypt_module_self_test() http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.109r2=1.110diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.109 php-src/ext/mcrypt/mcrypt.c:1.110 --- php-src/ext/mcrypt/mcrypt.c:1.109 Mon Dec 31 07:12:11 2007 +++ php-src/ext/mcrypt/mcrypt.c Sun May 18 17:15:08 2008 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.109 2007/12/31 07:12:11 sebastian Exp $ */ +/* $Id: mcrypt.c,v 1.110 2008/05/18 17:15:08 dsp Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -476,7 +476,12 @@ PHP_FUNCTION(mcrypt_enc_self_test) { MCRYPT_GET_TD_ARG - RETURN_LONG(mcrypt_enc_self_test(pm-td)); + + if (mcrypt_enc_self_test(pm-td) == 0) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt diff -u php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.1 php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.2 --- php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.1 Sat May 17 23:27:42 2008 +++ php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt Sun May 18 17:15:08 2008 @@ -7,4 +7,4 @@ $td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, ''); var_dump(mcrypt_enc_self_test($td)); --EXPECT-- -int(0) \ No newline at end of file +bool(true) This is a massive BC break... Imagine people who did if (mcrypt_enc_self_test($td) == 0) { ... } that has now changed from dealing with success to failure. I'd say rather fix the docs -Hannes -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c /ext/mcrypt/tests mcrypt_enc_self_test.phpt
Hannes Magnusson wrote: On Sun, May 18, 2008 at 7:15 PM, David Soria Parra [EMAIL PROTECTED] wrote: dsp Sun May 18 17:15:08 2008 UTC Modified files: /php-src/ext/mcrypt mcrypt.c /php-src/ext/mcrypt/tests mcrypt_enc_self_test.phpt Log: MFB: Make mcrypt_enc_self_test() return value compatible with documentation and mcrypt_module_self_test() http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.109r2=1.110diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.109 php-src/ext/mcrypt/mcrypt.c:1.110 --- php-src/ext/mcrypt/mcrypt.c:1.109 Mon Dec 31 07:12:11 2007 +++ php-src/ext/mcrypt/mcrypt.c Sun May 18 17:15:08 2008 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.109 2007/12/31 07:12:11 sebastian Exp $ */ +/* $Id: mcrypt.c,v 1.110 2008/05/18 17:15:08 dsp Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -476,7 +476,12 @@ PHP_FUNCTION(mcrypt_enc_self_test) { MCRYPT_GET_TD_ARG - RETURN_LONG(mcrypt_enc_self_test(pm-td)); + + if (mcrypt_enc_self_test(pm-td) == 0) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt diff -u php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.1 php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.2 --- php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.1 Sat May 17 23:27:42 2008 +++ php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt Sun May 18 17:15:08 2008 @@ -7,4 +7,4 @@ $td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, ''); var_dump(mcrypt_enc_self_test($td)); --EXPECT-- -int(0) \ No newline at end of file +bool(true) This is a massive BC break... Imagine people who did if (mcrypt_enc_self_test($td) == 0) { ... } that has now changed from dealing with success to failure. I'd say rather fix the docs -Hannes Yes I noticed that, that's why its not in 5.2. I think it's kind of cleaning up as mcrypt_module_self_test return a boolean too and the docs say it too. Maybe it's just in my opinion that the function itself is not that often used as it would be real issue, but if people have objections for sure we can revert that. -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c /ext/mcrypt/tests mcrypt_enc_self_test.phpt
Hannes Magnusson wrote: On Sun, May 18, 2008 at 8:14 PM, David Soria Parra [EMAIL PROTECTED] wrote: Hannes Magnusson wrote: On Sun, May 18, 2008 at 7:15 PM, David Soria Parra [EMAIL PROTECTED] wrote: dsp Sun May 18 17:15:08 2008 UTC Modified files: /php-src/ext/mcrypt mcrypt.c /php-src/ext/mcrypt/tests mcrypt_enc_self_test.phpt Log: MFB: Make mcrypt_enc_self_test() return value compatible with documentation and mcrypt_module_self_test() http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.109r2=1.110diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.109 php-src/ext/mcrypt/mcrypt.c:1.110 --- php-src/ext/mcrypt/mcrypt.c:1.109 Mon Dec 31 07:12:11 2007 +++ php-src/ext/mcrypt/mcrypt.c Sun May 18 17:15:08 2008 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.109 2007/12/31 07:12:11 sebastian Exp $ */ +/* $Id: mcrypt.c,v 1.110 2008/05/18 17:15:08 dsp Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -476,7 +476,12 @@ PHP_FUNCTION(mcrypt_enc_self_test) { MCRYPT_GET_TD_ARG - RETURN_LONG(mcrypt_enc_self_test(pm-td)); + + if (mcrypt_enc_self_test(pm-td) == 0) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt diff -u php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.1 php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.2 --- php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt:1.1 Sat May 17 23:27:42 2008 +++ php-src/ext/mcrypt/tests/mcrypt_enc_self_test.phpt Sun May 18 17:15:08 2008 @@ -7,4 +7,4 @@ $td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, ''); var_dump(mcrypt_enc_self_test($td)); --EXPECT-- -int(0) \ No newline at end of file +bool(true) This is a massive BC break... Imagine people who did if (mcrypt_enc_self_test($td) == 0) { ... } that has now changed from dealing with success to failure. I'd say rather fix the docs -Hannes Yes I noticed that, that's why its not in 5.2. I think it's kind of cleaning up as mcrypt_module_self_test return a boolean too and the docs say it too. Maybe it's just in my opinion that the function itself is not that often used as it would be real issue, but if people have objections for sure we can revert that. The point is this is a very subtle change and not something people will suspect when their applications stop working out of the blue, without so much as a single warning. A function rename would be obvious as it would give a fatal error, but this is a return value change from false to true... IMO this should be reverted and the docs fixed. reverted. -Hannes -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c /ext/mcrypt/tests bug43143.phpt
derick Sat Dec 1 17:19:46 2007 UTC Added files: /php-src/ext/mcrypt/tests bug43143.phpt Modified files: /php-src/ext/mcrypt mcrypt.c Log: - Fixed bug #43143 (Warning about empty IV with MCRYPT_MODE_ECB). http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.107r2=1.108diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.107 php-src/ext/mcrypt/mcrypt.c:1.108 --- php-src/ext/mcrypt/mcrypt.c:1.107 Thu Sep 27 18:28:40 2007 +++ php-src/ext/mcrypt/mcrypt.c Sat Dec 1 17:19:45 2007 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.107 2007/09/27 18:28:40 dmitry Exp $ */ +/* $Id: mcrypt.c,v 1.108 2007/12/01 17:19:45 derick Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1030,7 +1030,7 @@ { MCRYPT td; char *cipher_dir_string, *module_dir_string, *key_copy, *iv_copy; - int i, status = SUCCESS, count, *key_sizes, key_size, iv_size, block_size; + int i, status = SUCCESS, count, *key_sizes, key_size, iv_size, block_size, iv_req; MCRYPT_GET_INI @@ -1068,6 +1068,7 @@ mcrypt_free(key_sizes); iv_size = mcrypt_enc_get_iv_size(td); + iv_req = mcrypt_enc_mode_has_iv(td); if (iv_len) { if (iv_len == iv_size) { iv_copy = estrndup(iv_str, iv_len); @@ -1077,7 +1078,9 @@ memcpy(iv_copy, iv_str, MIN(iv_len, iv_size)); } } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Attempt to use an empty IV, which is NOT recommended); + if (iv_req) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Attempt to use an empty IV, which is NOT recommended); + } iv_copy = ecalloc(1, iv_size); } http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/tests/bug43143.phpt?view=markuprev=1.1 Index: php-src/ext/mcrypt/tests/bug43143.phpt +++ php-src/ext/mcrypt/tests/bug43143.phpt --TEST-- Bug #43143 (Warning about empty IV with MCRYPT_MODE_ECB) --SKIPIF-- ?php if (!extension_loaded(mcrypt)) print skip; ? --FILE-- ?php echo ECB\n; $input = 'to be encrypted'; $mkey = hash('sha256', 'secret key', TRUE); $data = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $mkey, $input, MCRYPT_MODE_ECB); echo CFB\n; $input = 'to be encrypted'; $mkey = hash('sha256', 'secret key', TRUE); $data = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $mkey, $input, MCRYPT_MODE_CFB); echo END\n; ? --EXPECTF-- ECB CFB Warning: mcrypt_encrypt(): Attempt to use an empty IV, which is NOT recommended in %sbug43143.php on line 9 END -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c
tony2001Thu Jul 19 14:25:37 2007 UTC Modified files: /php-src/ext/mcrypt mcrypt.c Log: fix ws folding http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.105r2=1.106diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.105 php-src/ext/mcrypt/mcrypt.c:1.106 --- php-src/ext/mcrypt/mcrypt.c:1.105 Mon May 28 23:00:25 2007 +++ php-src/ext/mcrypt/mcrypt.c Thu Jul 19 14:25:37 2007 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.105 2007/05/28 23:00:25 iliaa Exp $ */ +/* $Id: mcrypt.c,v 1.106 2007/07/19 14:25:37 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -44,7 +44,7 @@ zend_bool init; } php_mcrypt; -zend_function_entry mcrypt_functions[] = { +zend_function_entry mcrypt_functions[] = { /* {{{ */ PHP_FE(mcrypt_ecb, NULL) PHP_FE(mcrypt_cbc, NULL) PHP_FE(mcrypt_cfb, NULL) @@ -89,6 +89,7 @@ PHP_FE(mcrypt_module_close, NULL) {NULL, NULL, NULL} }; +/* }}} */ static PHP_MINFO_FUNCTION(mcrypt); static PHP_MINIT_FUNCTION(mcrypt); @@ -155,7 +156,7 @@ STD_PHP_INI_ENTRY(mcrypt.modes_dir, NULL, PHP_INI_ALL, OnUpdateString, modes_dir, zend_mcrypt_globals, mcrypt_globals) PHP_INI_END() -static void php_mcrypt_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) +static void php_mcrypt_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */ { php_mcrypt *pm = (php_mcrypt *) rsrc-ptr; if (pm) { @@ -165,9 +166,9 @@ rsrc-ptr = NULL; } } - +/* }}} */ -static PHP_MINIT_FUNCTION(mcrypt) +static PHP_MINIT_FUNCTION(mcrypt) /* {{{ */ { le_mcrypt = zend_register_list_destructors_ex(php_mcrypt_module_dtor, NULL, mcrypt, module_number); @@ -222,16 +223,18 @@ REGISTER_INI_ENTRIES(); return SUCCESS; } +/* }}} */ -static PHP_MSHUTDOWN_FUNCTION(mcrypt) +static PHP_MSHUTDOWN_FUNCTION(mcrypt) /* {{{ */ { UNREGISTER_INI_ENTRIES(); return SUCCESS; } +/* }}} */ #include ext/standard/php_smart_str.h -PHP_MINFO_FUNCTION(mcrypt) +PHP_MINFO_FUNCTION(mcrypt) /* {{{ */ { char **modules; char mcrypt_api_no[16]; @@ -275,7 +278,7 @@ DISPLAY_INI_ENTRIES(); } - +/* }}} */ /* {{{ proto resource mcrypt_module_open(string cipher, string cipher_directory, string mode, string mode_directory) U Opens the module of the algorithm and the mode to be used */ @@ -315,7 +318,6 @@ } /* }}} */ - /* {{{ proto int mcrypt_generic_init(resource td, binary key, binary iv) U This function initializes all buffers for the specific module */ PHP_FUNCTION(mcrypt_generic_init) @@ -372,7 +374,6 @@ } /* }}} */ - /* {{{ proto binary mcrypt_generic(resource td, binary data) U This function encrypts the plaintext */ PHP_FUNCTION(mcrypt_generic) @@ -412,7 +413,6 @@ } /* }}} */ - /* {{{ proto binary mdecrypt_generic(resource td, binary data) U This function decrypts the plaintext */ PHP_FUNCTION(mdecrypt_generic) @@ -451,7 +451,6 @@ } /* }}} */ - /* {{{ proto array mcrypt_enc_get_supported_key_sizes(resource td) U This function decrypts the crypttext */ PHP_FUNCTION(mcrypt_enc_get_supported_key_sizes) @@ -472,7 +471,6 @@ } /* }}} */ - /* {{{ proto int mcrypt_enc_self_test(resource td) U This function runs the self test on the algorithm specified by the descriptor td */ PHP_FUNCTION(mcrypt_enc_self_test) @@ -492,7 +490,6 @@ } /* }}} */ - /* {{{ proto bool mcrypt_generic_deinit(resource td) U This function terminates encrypt specified by the descriptor td */ PHP_FUNCTION(mcrypt_generic_deinit) @@ -507,7 +504,6 @@ } /* }}} */ - /* {{{ proto bool mcrypt_enc_is_block_algorithm_mode(resource td) U Returns TRUE if the mode is for use with block algorithms */ PHP_FUNCTION(mcrypt_enc_is_block_algorithm_mode) @@ -522,7 +518,6 @@ } /* }}} */ - /* {{{ proto bool mcrypt_enc_is_block_algorithm(resource td) U Returns TRUE if the alrogithm is a block algorithms */ PHP_FUNCTION(mcrypt_enc_is_block_algorithm) @@ -537,7 +532,6 @@ } /* }}} */ - /* {{{ proto bool mcrypt_enc_is_block_mode(resource td) U Returns TRUE if the mode outputs blocks */ PHP_FUNCTION(mcrypt_enc_is_block_mode) @@ -552,7 +546,6 @@ } /* }}} */ - /* {{{ proto int mcrypt_enc_get_block_size(resource td) U Returns the block size of the cipher specified by the descriptor td */ PHP_FUNCTION(mcrypt_enc_get_block_size) @@ -562,7 +555,6 @@ } /* }}} */ - /* {{{ proto int mcrypt_enc_get_key_size(resource td) U Returns the maximum supported key size in bytes of the algorithm specified by the descriptor td */ PHP_FUNCTION(mcrypt_enc_get_key_size) @@ -572,7 +564,6 @@ } /* }}} */ - /* {{{ proto int mcrypt_enc_get_iv_size(resource td) U Returns the size of
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c
tony2001Sun Apr 8 08:04:31 2007 UTC Modified files: /php-src/ext/mcrypt mcrypt.c Log: MFB: fix #40999 (mcrypt_create_iv() not using random seed) http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.103r2=1.104diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.103 php-src/ext/mcrypt/mcrypt.c:1.104 --- php-src/ext/mcrypt/mcrypt.c:1.103 Mon Jan 1 09:29:25 2007 +++ php-src/ext/mcrypt/mcrypt.c Sun Apr 8 08:04:30 2007 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.103 2007/01/01 09:29:25 sebastian Exp $ */ +/* $Id: mcrypt.c,v 1.104 2007/04/08 08:04:30 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -35,6 +35,7 @@ #include php_ini.h #include php_globals.h #include ext/standard/info.h +#include ext/standard/php_rand.h static int le_mcrypt; @@ -1039,8 +1040,7 @@ case PHP_MCRYPT_IV_SOURCE_RAND: *iv_len = size; while (size) { - unsigned int ctx; - (*iv_str)[--size] = 255.0 * php_rand_r(ctx) / RAND_MAX; + (*iv_str)[--size] = 255.0 * php_rand(TSRMLS_C) / RAND_MAX; } break; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c /ext/soap php_http.c
iliaa Tue Nov 28 00:24:16 2006 UTC Modified files: /php-src/ext/mcrypt mcrypt.c /php-src/ext/soap php_http.c Log: MFB: Replace non-threadsafe rand() with php_rand_r() http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.101r2=1.102diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.101 php-src/ext/mcrypt/mcrypt.c:1.102 --- php-src/ext/mcrypt/mcrypt.c:1.101 Wed Nov 15 22:51:45 2006 +++ php-src/ext/mcrypt/mcrypt.c Tue Nov 28 00:24:16 2006 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.101 2006/11/15 22:51:45 mike Exp $ */ +/* $Id: mcrypt.c,v 1.102 2006/11/28 00:24:16 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1039,7 +1039,8 @@ case PHP_MCRYPT_IV_SOURCE_RAND: *iv_len = size; while (size) { - (*iv_str)[--size] = 255.0 * rand() / RAND_MAX; + unsigned int ctx; + (*iv_str)[--size] = 255.0 * php_rand_r(ctx) / RAND_MAX; } break; } http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_http.c?r1=1.97r2=1.98diff_format=u Index: php-src/ext/soap/php_http.c diff -u php-src/ext/soap/php_http.c:1.97 php-src/ext/soap/php_http.c:1.98 --- php-src/ext/soap/php_http.c:1.97Wed Sep 6 11:03:59 2006 +++ php-src/ext/soap/php_http.c Tue Nov 28 00:24:16 2006 @@ -17,7 +17,7 @@ | Dmitry Stogov [EMAIL PROTECTED] | +--+ */ -/* $Id: php_http.c,v 1.97 2006/09/06 11:03:59 dmitry Exp $ */ +/* $Id: php_http.c,v 1.98 2006/11/28 00:24:16 iliaa Exp $ */ #include php_soap.h #include ext/standard/base64.h @@ -462,9 +462,10 @@ char HA1[33], HA2[33], response[33], cnonce[33], nc[9]; PHP_MD5_CTX md5ctx; unsigned char hash[16]; + unsigned int ctx; PHP_MD5Init(md5ctx); - sprintf(cnonce, %d, rand()); + sprintf(cnonce, %d, php_rand_r(ctx)); PHP_MD5Update(md5ctx, (unsigned char*)cnonce, strlen(cnonce)); PHP_MD5Final(hash, md5ctx); make_digest(cnonce, hash); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c php_mcrypt.h /ext/mcrypt/tests basic.phpt blowfish.phpt bug35496.phpt bug37595.phpt
mikeWed Nov 15 22:51:45 2006 UTC Added files: /php-src/ext/mcrypt/tests basic.phpt Modified files: /php-src/ext/mcrypt mcrypt.c php_mcrypt.h /php-src/ext/mcrypt/tests blowfish.phpt bug35496.phpt bug37595.phpt Log: - unicode upgrade - fix typo: ENIGNA-ENIGMA - add and fix tests http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.100r2=1.101diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.100 php-src/ext/mcrypt/mcrypt.c:1.101 --- php-src/ext/mcrypt/mcrypt.c:1.100 Sun Oct 8 13:34:22 2006 +++ php-src/ext/mcrypt/mcrypt.c Wed Nov 15 22:51:45 2006 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.100 2006/10/08 13:34:22 bjori Exp $ */ +/* $Id: mcrypt.c,v 1.101 2006/11/15 22:51:45 mike Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -114,122 +114,41 @@ ZEND_GET_MODULE(mcrypt) #endif -#define MCRYPT_ARGS2 \ - zval **cipher, **data, **key, **mode; \ - int td; \ - char *ndata; \ - size_t bsize; \ - size_t nr; \ - size_t nsize - -#define MCRYPT_ARGS \ - MCRYPT_ARGS2; \ - zval **iv - -#define MCRYPT_CONVERT \ - convert_to_string_ex(cipher); \ - convert_to_string_ex(mode); \ - convert_to_string_ex(data); \ - convert_to_string_ex(key) -#define MCRYPT_CONVERT_WO_MODE \ - convert_to_string_ex(cipher); \ - convert_to_string_ex(data); \ - convert_to_string_ex(key) - -#define MCRYPT_SIZE \ - bsize = mcrypt_get_block_size(Z_LVAL_PP(cipher)); \ - nr = (Z_STRLEN_PP(data) + bsize - 1) / bsize; \ - nsize = nr * bsize - -#define MCRYPT_CHECK_TD_CPY \ - if (td 0) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, MCRYPT_FAILED); \ - RETURN_FALSE; \ - } \ - ndata = ecalloc(nr, bsize); \ - memcpy(ndata, Z_STRVAL_PP(data), Z_STRLEN_PP(data)) - -#define MCRYPT_CHECK_IV \ - convert_to_string_ex(iv); \ - if (Z_STRLEN_PP(iv) != bsize) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, MCRYPT_IV_WRONG_SIZE); \ - RETURN_FALSE; \ - } - -#define MCRYPT_ACTION(x) \ - if (Z_LVAL_PP(mode) == 0) { \ - mcrypt_##x(td, ndata, nsize); \ - } else { \ - mdecrypt_##x(td, ndata, nsize); \ - }
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c php_mcrypt.h /ext/mysql php_mysql.c /ext/standard basic_functions.c streamsfuncs.c streamsfuncs.h
bjori Mon Jun 26 11:31:19 2006 UTC Modified files: /php-src/ext/mcrypt mcrypt.c php_mcrypt.h /php-src/ext/mysql php_mysql.c /php-src/ext/standard basic_functions.c streamsfuncs.c streamsfuncs.h Log: Removed custom deprecate error messages Use the fancy ZEND_ACC_DEPRECATED flag. http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.98r2=1.99diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.98 php-src/ext/mcrypt/mcrypt.c:1.99 --- php-src/ext/mcrypt/mcrypt.c:1.98Tue Jun 13 13:12:18 2006 +++ php-src/ext/mcrypt/mcrypt.c Mon Jun 26 11:31:19 2006 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.98 2006/06/13 13:12:18 dmitry Exp $ */ +/* $Id: mcrypt.c,v 1.99 2006/06/26 11:31:19 bjori Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -63,7 +63,7 @@ PHP_FE(mcrypt_generic_init, NULL) PHP_FE(mcrypt_generic, NULL) PHP_FE(mdecrypt_generic, NULL) - PHP_FE(mcrypt_generic_end, NULL) + PHP_DEP_FALIAS(mcrypt_generic_end, mcrypt_generic_deinit, NULL) PHP_FE(mcrypt_generic_deinit, NULL) PHP_FE(mcrypt_enc_self_test, NULL) @@ -604,16 +604,6 @@ /* }}} */ -/* {{{ proto bool mcrypt_generic_end(resource td) - This function terminates encrypt specified by the descriptor td */ -PHP_FUNCTION(mcrypt_generic_end) -{ - php_error_docref(NULL TSRMLS_CC, E_WARNING, This function is deprecated, please use mcrypt_generic_deinit()); - zif_mcrypt_generic_deinit(INTERNAL_FUNCTION_PARAM_PASSTHRU); -} -/* }}} */ - - /* {{{ proto bool mcrypt_generic_deinit(resource td) This function terminates encrypt specified by the descriptor td */ PHP_FUNCTION(mcrypt_generic_deinit) http://cvs.php.net/viewvc.cgi/php-src/ext/mcrypt/php_mcrypt.h?r1=1.27r2=1.28diff_format=u Index: php-src/ext/mcrypt/php_mcrypt.h diff -u php-src/ext/mcrypt/php_mcrypt.h:1.27 php-src/ext/mcrypt/php_mcrypt.h:1.28 --- php-src/ext/mcrypt/php_mcrypt.h:1.27Sun Jan 1 13:09:51 2006 +++ php-src/ext/mcrypt/php_mcrypt.h Mon Jun 26 11:31:19 2006 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: php_mcrypt.h,v 1.27 2006/01/01 13:09:51 sniper Exp $ */ +/* $Id: php_mcrypt.h,v 1.28 2006/06/26 11:31:19 bjori Exp $ */ #ifndef PHP_MCRYPT_H #define PHP_MCRYPT_H @@ -52,7 +52,6 @@ PHP_FUNCTION(mcrypt_generic_init); PHP_FUNCTION(mcrypt_generic); PHP_FUNCTION(mdecrypt_generic); -PHP_FUNCTION(mcrypt_generic_end); PHP_FUNCTION(mcrypt_generic_deinit); PHP_FUNCTION(mcrypt_enc_self_test); http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/php_mysql.c?r1=1.223r2=1.224diff_format=u Index: php-src/ext/mysql/php_mysql.c diff -u php-src/ext/mysql/php_mysql.c:1.223 php-src/ext/mysql/php_mysql.c:1.224 --- php-src/ext/mysql/php_mysql.c:1.223 Tue Jun 13 13:12:19 2006 +++ php-src/ext/mysql/php_mysql.c Mon Jun 26 11:31:19 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: php_mysql.c,v 1.223 2006/06/13 13:12:19 dmitry Exp $ */ +/* $Id: php_mysql.c,v 1.224 2006/06/26 11:31:19 bjori Exp $ */ /* TODO: * @@ -126,15 +126,15 @@ PHP_FE(mysql_select_db, NULL) #ifndef NETWARE/* The below two functions not supported on NetWare */ #if MYSQL_VERSION_ID 4 - PHP_FE(mysql_create_db, NULL) - PHP_FE(mysql_drop_db, NULL) + PHP_DEP_FE(mysql_create_db, NULL) + PHP_DEP_FE(mysql_drop_db, NULL) #endif #endif /* NETWARE */ PHP_FE(mysql_query, NULL) PHP_FE(mysql_unbuffered_query, NULL) PHP_FE(mysql_db_query, NULL) PHP_FE(mysql_list_dbs, NULL) - PHP_FE(mysql_list_tables, NULL) + PHP_DEP_FE(mysql_list_tables, NULL) PHP_FE(mysql_list_fields, NULL) PHP_FE(mysql_list_processes, NULL) PHP_FE(mysql_error, NULL) @@ -185,15 +185,15 @@ PHP_FALIAS(mysql_selectdb,
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c /ext/mcrypt/tests bug37595.phpt
tony2001Wed May 31 12:04:53 2006 UTC Added files: /php-src/ext/mcrypt/tests bug37595.phpt Modified files: /php-src/ext/mcrypt mcrypt.c Log: fix #37595 (mcrypt_generic calculates data length in wrong way) http://cvs.php.net/viewcvs.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.95r2=1.96diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.95 php-src/ext/mcrypt/mcrypt.c:1.96 --- php-src/ext/mcrypt/mcrypt.c:1.95Sun Jan 1 13:09:51 2006 +++ php-src/ext/mcrypt/mcrypt.c Wed May 31 12:04:52 2006 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.95 2006/01/01 13:09:51 sniper Exp $ */ +/* $Id: mcrypt.c,v 1.96 2006/05/31 12:04:52 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -496,7 +496,7 @@ /* Check blocksize */ if (mcrypt_enc_is_block_mode(pm-td) == 1) { /* It's a block algorithm */ block_size = mcrypt_enc_get_block_size(pm-td); - data_size = (((Z_STRLEN_PP(data) - 1) / block_size) + 1) * block_size; + data_size = ((Z_STRLEN_PP(data) / block_size) + 1) * block_size; data_s = emalloc(data_size + 1); memset(data_s, 0, data_size); memcpy(data_s, Z_STRVAL_PP(data), Z_STRLEN_PP(data)); http://cvs.php.net/viewcvs.cgi/php-src/ext/mcrypt/tests/bug37595.phpt?view=markuprev=1.1 Index: php-src/ext/mcrypt/tests/bug37595.phpt +++ php-src/ext/mcrypt/tests/bug37595.phpt --TEST-- bug #37595 (mcrypt_generic calculates data length in wrong way) --FILE-- ?php $cipher_alg = MCRYPT_BLOWFISH; $skey = array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); $key=''; foreach($skey as $t) { $key .= chr($t); } $sstr = array(1,2,3,4,5,6,7,8); $iv=''; foreach($sstr as $s) { $iv .= chr($s); } $str = 12345678; $td = mcrypt_module_open(MCRYPT_BLOWFISH,'',MCRYPT_MODE_CBC,''); $data = Array( '12345678', '123456789', \x001234567, '', '1234567812345678', '12345678123456789' ); foreach ($data as $val) { mcrypt_generic_init($td, $key, $iv); $enc = mcrypt_generic($td, $val); mcrypt_generic_deinit($td); mcrypt_generic_init($td, $key, $iv); var_dump($dec = mdecrypt_generic($td, $enc)); } mcrypt_module_close($td); echo Done\n; ? --EXPECT-- string(16) 12345678 string(16) 123456789 string(16) string(8) string(24) 1234567812345678 string(24) 12345678123456789 Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c /ext/mcrypt/tests blowfish.phpt bug37595.phpt
derick Wed May 31 20:13:14 2006 UTC Modified files: /php-src/ext/mcrypt mcrypt.c /php-src/ext/mcrypt/tests blowfish.phpt bug37595.phpt Log: - MF52: There was nothing wrong here, bug report #37595 is bogus. - MF52: Added a new test case to demonstrate a longer plain text. http://cvs.php.net/viewcvs.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.96r2=1.97diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.96 php-src/ext/mcrypt/mcrypt.c:1.97 --- php-src/ext/mcrypt/mcrypt.c:1.96Wed May 31 12:04:52 2006 +++ php-src/ext/mcrypt/mcrypt.c Wed May 31 20:13:13 2006 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.96 2006/05/31 12:04:52 tony2001 Exp $ */ +/* $Id: mcrypt.c,v 1.97 2006/05/31 20:13:13 derick Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -492,11 +492,15 @@ ZEND_FETCH_RESOURCE(pm, php_mcrypt *, mcryptind, -1, MCrypt, le_mcrypt); PHP_MCRYPT_INIT_CHECK convert_to_string_ex(data); + if (Z_STRLEN_PP(data) == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, An empty string was passed); + RETURN_FALSE + } /* Check blocksize */ if (mcrypt_enc_is_block_mode(pm-td) == 1) { /* It's a block algorithm */ block_size = mcrypt_enc_get_block_size(pm-td); - data_size = ((Z_STRLEN_PP(data) / block_size) + 1) * block_size; + data_size = (((Z_STRLEN_PP(data) - 1) / block_size) + 1) * block_size; data_s = emalloc(data_size + 1); memset(data_s, 0, data_size); memcpy(data_s, Z_STRVAL_PP(data), Z_STRLEN_PP(data)); @@ -533,6 +537,10 @@ ZEND_FETCH_RESOURCE(pm, php_mcrypt * , mcryptind, -1, MCrypt, le_mcrypt); PHP_MCRYPT_INIT_CHECK convert_to_string_ex(data); + if (Z_STRLEN_PP(data) == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, An empty string was passed); + RETURN_FALSE + } /* Check blocksize */ if (mcrypt_enc_is_block_mode(pm-td) == 1) { /* It's a block algorithm */ http://cvs.php.net/viewcvs.cgi/php-src/ext/mcrypt/tests/blowfish.phpt?r1=1.3r2=1.4diff_format=u Index: php-src/ext/mcrypt/tests/blowfish.phpt diff -u php-src/ext/mcrypt/tests/blowfish.phpt:1.3 php-src/ext/mcrypt/tests/blowfish.phpt:1.4 --- php-src/ext/mcrypt/tests/blowfish.phpt:1.3 Wed May 19 08:54:52 2004 +++ php-src/ext/mcrypt/tests/blowfish.phpt Wed May 31 20:13:14 2006 @@ -36,7 +36,19 @@ ($crypt==$guess ? OK : BAD) ); } -} +} + +// Longer test case from http://www.schneier.com/code/vectors.txt +$td = mcrypt_module_open (blowfish, , MCRYPT_MODE_CBC, ); + +$key = hex2bin( 0123456789ABCDEFF0E1D2C3B4A59687 ); +$iv = hex2bin( FEDCBA9876543210 ); +$plain = hex2bin( 37363534333231204E6F77206973207468652074696D6520666F722000 ); + +mcrypt_generic_init( $td, $key, $iv ); +$guess = bin2hex( mcrypt_generic( $td, $plain ) ); + +echo \n, $guess, \n; ? --EXPECT-- key plain crypt guess stat @@ -73,3 +85,5 @@ f21e9a77b71c49bc f21e9a77b71c49bc OK 0123456789ABCDEF 245946885754369a 245946885754369a OK FEDCBA9876543210 6b5c5a9c5d9e0a5a 6b5c5a9c5d9e0a5a OK + +6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc http://cvs.php.net/viewcvs.cgi/php-src/ext/mcrypt/tests/bug37595.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/mcrypt/tests/bug37595.phpt -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c /ext/mcrypt/tests bug35496.phpt
iliaa Wed Nov 30 18:53:47 2005 EDT Modified files: /php-src/ext/mcrypt mcrypt.c /php-src/ext/mcrypt/tests bug35496.phpt Log: MFB51: Fixed bug #35496 (Crash in mcrypt_generic()/mdecrypt_generic() without proper init). http://cvs.php.net/diff.php/php-src/ext/mcrypt/mcrypt.c?r1=1.92r2=1.93ty=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.92 php-src/ext/mcrypt/mcrypt.c:1.93 --- php-src/ext/mcrypt/mcrypt.c:1.92Thu Sep 15 12:19:43 2005 +++ php-src/ext/mcrypt/mcrypt.c Wed Nov 30 18:53:44 2005 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.92 2005/09/15 16:19:43 derick Exp $ */ +/* $Id: mcrypt.c,v 1.93 2005/11/30 23:53:44 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -38,6 +38,11 @@ static int le_mcrypt; +typedef struct _php_mcrypt { + MCRYPT td; + zend_bool init; +} php_mcrypt; + function_entry mcrypt_functions[] = { PHP_FE(mcrypt_ecb, NULL) PHP_FE(mcrypt_cbc, NULL) @@ -194,11 +199,11 @@ #define MCRYPT_GET_TD_ARG \ zval **mcryptind; \ - MCRYPT td; \ + php_mcrypt *pm; \ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, mcryptind) == FAILURE) { \ WRONG_PARAM_COUNT \ } \ - ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, MCrypt, le_mcrypt); + ZEND_FETCH_RESOURCE (pm, php_mcrypt *, mcryptind, -1, MCrypt, le_mcrypt); #define MCRYPT_GET_MODE_DIR_ARGS(DIRECTORY) \ char *dir = NULL; \ @@ -215,6 +220,12 @@ #define MCRYPT_ENTRY2_2_4(a,b) REGISTER_STRING_CONSTANT(MCRYPT_ #a, b, CONST_PERSISTENT) #define MCRYPT_ENTRY2_4(a) MCRYPT_ENTRY_NAMED(a, a) +#define PHP_MCRYPT_INIT_CHECK \ + if (!pm-init) {\ + php_error_docref(NULL TSRMLS_CC, E_WARNING, Operation disallowed prior to mcrypt_generic_init().);\ + RETURN_FALSE; \ + } \ + PHP_INI_BEGIN() STD_PHP_INI_ENTRY(mcrypt.algorithms_dir, NULL, PHP_INI_ALL, OnUpdateString, algorithms_dir, zend_mcrypt_globals, mcrypt_globals) STD_PHP_INI_ENTRY(mcrypt.modes_dir, NULL, PHP_INI_ALL, OnUpdateString, modes_dir, zend_mcrypt_globals, mcrypt_globals) @@ -222,9 +233,13 @@ static void php_mcrypt_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { - MCRYPT td = (MCRYPT) rsrc-ptr; - mcrypt_generic_deinit(td); - mcrypt_module_close (td); + php_mcrypt *pm = (php_mcrypt *) rsrc-ptr; + if (pm) { + mcrypt_generic_deinit(pm-td); + mcrypt_module_close(pm-td); + efree(pm); + pm = NULL; + } } @@ -357,6 +372,7 @@ int cipher_len, cipher_dir_len; int mode_len, mode_dir_len; MCRYPT td; + php_mcrypt *pm; if (zend_parse_parameters (ZEND_NUM_ARGS() TSRMLS_CC, , cipher, cipher_len, cipher_dir, cipher_dir_len, @@ -375,7 +391,10 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, Could not open encryption module); RETURN_FALSE; } else { - ZEND_REGISTER_RESOURCE(return_value, td, le_mcrypt); + pm = emalloc(sizeof(php_mcrypt)); + pm-td = td; + pm-init = 0; + ZEND_REGISTER_RESOURCE(return_value, pm, le_mcrypt); } } /* }}} */ @@ -389,7 +408,7 @@ zval **mcryptind; unsigned char *key_s, *iv_s; int max_key_size, key_size, iv_size; - MCRYPT td; + php_mcrypt *pm; int argc; int result = 0; @@ -397,12 +416,12 @@ MCRYPT_CHECK_PARAM_COUNT (3,3) zend_get_parameters_ex(3, mcryptind, key, iv); - ZEND_FETCH_RESOURCE(td, MCRYPT, mcryptind, -1, MCrypt, le_mcrypt); + ZEND_FETCH_RESOURCE(pm, php_mcrypt *, mcryptind, -1, MCrypt, le_mcrypt); convert_to_string_ex(key);
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c
derick Sun Apr 18 10:04:49 2004 EDT Modified files: /php-src/ext/mcrypt mcrypt.c Log: - Whitespace http://cvs.php.net/diff.php/php-src/ext/mcrypt/mcrypt.c?r1=1.89r2=1.90ty=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.89 php-src/ext/mcrypt/mcrypt.c:1.90 --- php-src/ext/mcrypt/mcrypt.c:1.89Thu Jan 8 03:16:00 2004 +++ php-src/ext/mcrypt/mcrypt.c Sun Apr 18 10:04:48 2004 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.89 2004/01/08 08:16:00 andi Exp $ */ +/* $Id: mcrypt.c,v 1.90 2004/04/18 14:04:48 derick Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -216,8 +216,8 @@ #define MCRYPT_ENTRY2_4(a) MCRYPT_ENTRY_NAMED(a, a) PHP_INI_BEGIN() - STD_PHP_INI_ENTRY(mcrypt.algorithms_dir, NULL, PHP_INI_ALL, OnUpdateString, algorithms_dir, zend_mcrypt_globals, mcrypt_globals) - STD_PHP_INI_ENTRY(mcrypt.modes_dir, NULL, PHP_INI_ALL, OnUpdateString, modes_dir, zend_mcrypt_globals, mcrypt_globals) + STD_PHP_INI_ENTRY(mcrypt.algorithms_dir, NULL, PHP_INI_ALL, OnUpdateString, algorithms_dir, zend_mcrypt_globals, mcrypt_globals) + STD_PHP_INI_ENTRY(mcrypt.modes_dir, NULL, PHP_INI_ALL, OnUpdateString, modes_dir, zend_mcrypt_globals, mcrypt_globals) PHP_INI_END() static void php_mcrypt_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/mcrypt mcrypt.c
iliaa Thu Oct 30 23:33:52 2003 EDT Modified files: /php-src/ext/mcrypt mcrypt.c Log: Fixed bug #26042 (memory leak if mcrypt_generic_deinit() is not called after every mcrypt_generic_init() call). # This will be MFHed into 4.3.X tree after release. Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.87 php-src/ext/mcrypt/mcrypt.c:1.88 --- php-src/ext/mcrypt/mcrypt.c:1.87Mon Oct 13 05:33:00 2003 +++ php-src/ext/mcrypt/mcrypt.c Thu Oct 30 23:33:51 2003 @@ -16,7 +16,7 @@ | Derick Rethans [EMAIL PROTECTED]| +--+ */ -/* $Id: mcrypt.c,v 1.87 2003/10/13 09:33:00 derick Exp $ */ +/* $Id: mcrypt.c,v 1.88 2003/10/31 04:33:51 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -223,6 +223,7 @@ static void php_mcrypt_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { MCRYPT td = (MCRYPT) rsrc-ptr; + mcrypt_generic_deinit(td); mcrypt_module_close (td); } @@ -426,6 +427,7 @@ } memcpy(iv_s, Z_STRVAL_PP(iv), iv_size); + mcrypt_generic_deinit(td); result = mcrypt_generic_init(td, key_s, key_size, iv_s); /* If this function fails, close the mcrypt module to prevent crashes -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php