dmitry Thu Sep 27 08:46:00 2007 UTC
Modified files: (Branch: PHP_5_3)
/php-srcNEWS
/php-src/ext/opensslopenssl.c
Log:
MFH: Improved ext/openssl
. Added support for OpenSSL digest functions
. Added support for OpenSSL cipher functions
. Added access to internal values of DSA, RSA and DH keys
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.2r2=1.2027.2.547.2.965.2.3diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.2 php-src/NEWS:1.2027.2.547.2.965.2.3
--- php-src/NEWS:1.2027.2.547.2.965.2.2 Thu Sep 27 08:23:58 2007
+++ php-src/NEWSThu Sep 27 08:45:59 2007
@@ -1,6 +1,10 @@
PHPNEWS
|||
?? ??? 20??, PHP 5.3.0
+- Improved ext/openssl (Dmitry)
+ . Added support for OpenSSL digest functions
+ . Added support for OpenSSL cipher functions
+ . Added access to internal values of DSA, RSA and DH keys
- Improved and cleaned CGI code. FastCGI is now always enabled and can not be
disabled. See sapi/cgi/CHANGES for more details. (Dmitry)
- Added support for dynamic access of static members using $foo::myFunc().
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/openssl.c?r1=1.98.2.5.2.41r2=1.98.2.5.2.41.2.1diff_format=u
Index: php-src/ext/openssl/openssl.c
diff -u php-src/ext/openssl/openssl.c:1.98.2.5.2.41
php-src/ext/openssl/openssl.c:1.98.2.5.2.41.2.1
--- php-src/ext/openssl/openssl.c:1.98.2.5.2.41 Wed Aug 8 06:29:46 2007
+++ php-src/ext/openssl/openssl.c Thu Sep 27 08:46:00 2007
@@ -20,7 +20,7 @@
+--+
*/
-/* $Id: openssl.c,v 1.98.2.5.2.41 2007/08/08 06:29:46 pajoye Exp $ */
+/* $Id: openssl.c,v 1.98.2.5.2.41.2.1 2007/09/27 08:46:00 dmitry Exp $ */
#ifdef HAVE_CONFIG_H
#include config.h
@@ -33,6 +33,8 @@
#include ext/standard/file.h
#include ext/standard/info.h
#include ext/standard/php_fopen_wrappers.h
+#include ext/standard/md5.h
+#include ext/standard/base64.h
/* OpenSSL includes */
#include openssl/evp.h
@@ -88,6 +90,15 @@
PHP_OPENSSL_CIPHER_DEFAULT = PHP_OPENSSL_CIPHER_RC2_40
};
+PHP_FUNCTION(openssl_get_md_methods);
+PHP_FUNCTION(openssl_get_cipher_methods);
+
+PHP_FUNCTION(openssl_digest);
+PHP_FUNCTION(openssl_encrypt);
+PHP_FUNCTION(openssl_decrypt);
+
+PHP_FUNCTION(openssl_dh_compute_key);
+
/* {{{ openssl_functions[]
*/
zend_function_entry openssl_functions[] = {
@@ -126,10 +137,13 @@
PHP_FE(openssl_csr_get_subject, NULL)
PHP_FE(openssl_csr_get_public_key, NULL)
- PHP_FE(openssl_sign,second_arg_force_ref)
- PHP_FE(openssl_verify, NULL)
- PHP_FE(openssl_seal,arg2and3_force_ref)
- PHP_FE(openssl_open,second_arg_force_ref)
+ PHP_FE(openssl_digest, NULL)
+ PHP_FE(openssl_encrypt, NULL)
+ PHP_FE(openssl_decrypt, NULL)
+ PHP_FE(openssl_sign,second_arg_force_ref)
+ PHP_FE(openssl_verify, NULL)
+ PHP_FE(openssl_seal,arg2and3_force_ref)
+ PHP_FE(openssl_open,second_arg_force_ref)
/* for S/MIME handling */
PHP_FE(openssl_pkcs7_verify,NULL)
@@ -142,6 +156,11 @@
PHP_FE(openssl_public_encrypt, second_arg_force_ref)
PHP_FE(openssl_public_decrypt, second_arg_force_ref)
+ PHP_FE(openssl_get_md_methods, NULL)
+ PHP_FE(openssl_get_cipher_methods, NULL)
+
+ PHP_FE(openssl_dh_compute_key, NULL)
+
PHP_FE(openssl_error_string, NULL)
{NULL, NULL, NULL}
};
@@ -645,6 +664,34 @@
return mdtype;
}
/* }}} */
+
+static const EVP_CIPHER * php_openssl_get_evp_cipher_from_algo(long algo) { /*
{{{ */
+ switch (algo) {
+#ifndef OPENSSL_NO_RC2
+ case PHP_OPENSSL_CIPHER_RC2_40:
+ return EVP_rc2_40_cbc();
+ break;
+ case PHP_OPENSSL_CIPHER_RC2_64:
+ return EVP_rc2_64_cbc();
+ break;
+ case PHP_OPENSSL_CIPHER_RC2_128:
+ return EVP_rc2_cbc();
+ break;
+#endif
+
+#ifndef OPENSSL_NO_DES
+ case PHP_OPENSSL_CIPHER_DES:
+ return EVP_des_cbc();
+ break;
+ case PHP_OPENSSL_CIPHER_3DES:
+ return EVP_des_ede3_cbc();
+ break;
+#endif
+ default:
+ return NULL;
+ break;
+ }
+}
/* }}} */
/* {{{ PHP_MINIT_FUNCTION
@@ -2433,6 +2480,25 @@
}