[prev in list] [next in list] [prev in thread] [next in thread]
List: php-cvs
Subject: [PHP-CVS] cvs: php-src(PHP_5_2) / NEWS /ext/mcrypt mcrypt.c /ext/mcrypt/tests blowfish.phpt bug375
From: "Derick Rethans" <derick () php ! net>
Date: 2006-05-31 20:09:07
Message-ID: cvsderick1149106147 () cvsserver
[Download RAW message or body]
derick Wed May 31 20:09:07 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src NEWS
/php-src/ext/mcrypt mcrypt.c
/php-src/ext/mcrypt/tests blowfish.phpt bug37595.phpt
Log:
- There was nothing wrong here, bug report #37595 is bogus.
- Added a new test case to demonstrate a longer plain text.
http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2027.2.547.2.68&r2=1.2027.2.547.2.69&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.68 php-src/NEWS:1.2027.2.547.2.69
--- php-src/NEWS:1.2027.2.547.2.68 Wed May 31 12:06:36 2006
+++ php-src/NEWS Wed May 31 20:09:07 2006
@@ -55,8 +55,6 @@
- Fixed bug #37616 (DATE_RFC822 does not product RFC 822 dates).
(Hannes Magnusson, Derick)
- Fixed bug #37614 (Class name lowercased in error message). (Johannes)
-- Fixed bug #37595 (mcrypt_generic calculates data length in wrong way).
- (Tony)
- Fixed bug #37587 (var without attribute causes segfault). (Marcus)
- Fixed bug #37586 (Bumped minimum PCRE version to 6.6, needed for recursion
limit support). (Ilia)
http://cvs.php.net/viewcvs.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.91.2.3.2.2&r2=1.91.2.3.2.3&diff_format=u
Index: php-src/ext/mcrypt/mcrypt.c
diff -u php-src/ext/mcrypt/mcrypt.c:1.91.2.3.2.2 php-src/ext/mcrypt/mcrypt.c:1.91.2.3.2.3
--- php-src/ext/mcrypt/mcrypt.c:1.91.2.3.2.2 Wed May 31 12:06:36 2006
+++ php-src/ext/mcrypt/mcrypt.c Wed May 31 20:09:07 2006
@@ -16,7 +16,7 @@
| Derick Rethans <derick@derickrethans.nl> |
+----------------------------------------------------------------------+
*/
-/* $Id: mcrypt.c,v 1.91.2.3.2.2 2006/05/31 12:06:36 tony2001 Exp $ */
+/* $Id: mcrypt.c,v 1.91.2.3.2.3 2006/05/31 20:09:07 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.3&r2=1.3.6.1&diff_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.3.6.1
--- 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:09:07 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 @@
FFFFFFFFFFFFFFFF 0000000000000000 f21e9a77b71c49bc f21e9a77b71c49bc OK
0123456789ABCDEF 0000000000000000 245946885754369a 245946885754369a OK
FEDCBA9876543210 FFFFFFFFFFFFFFFF 6b5c5a9c5d9e0a5a 6b5c5a9c5d9e0a5a OK
+
+6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc
http://cvs.php.net/viewcvs.cgi/php-src/ext/mcrypt/tests/bug37595.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic