pajoye Tue Aug 15 00:38:04 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src NEWS
/php-src/ext/openssl openssl.c php_openssl.h
Log:
- add OPENSSL_KEYTYPE_EC constant
- openssl_pkey_get_details(), returns the key details
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.202&r2=1.2027.2.547.2.203&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.202 php-src/NEWS:1.2027.2.547.2.203
--- php-src/NEWS:1.2027.2.547.2.202 Mon Aug 14 20:11:52 2006
+++ php-src/NEWS Tue Aug 15 00:38:04 2006
@@ -26,9 +26,9 @@
- Improved OpenSSL extension: (Pierre)
. Added support for all supported algorithms in openssl_verify
- . Implement #36732 (req/x509 extensions support for openssl_csr_new and
- openssl_csr_sign) (ben at psc dot edu, Pierre)
- . Implement #28382 (openssl_x509_parse() extensions support)
+ . Added openssl_pkey_get_details, returns the details of a key
+ . Added x509 v3 extensions support
+ . Added a new constant OPENSSL_KEYTYPE_EC
- Fixed overflow on 64bit systems in str_repeat() and wordwrap(). (Stefan E.)
- Disabled CURLOPT_FOLLOWLOCATION in curl when open_basedir or safe_mode are
@@ -106,8 +106,11 @@
destruction). (Ilia)
- Fixed bug #37265 (Added missing safe_mode & open_basedir checks to
imap_body()). (Ilia)
+- Implement #36732 (req/x509 extensions support for openssl_csr_new and
+ openssl_csr_sign) (ben at psc dot edu, Pierre)
- Fixed bug #35973 (Error ORA-24806 occurs when trying to fetch a NCLOB
field). (Tony)
+- Implement #28382 (openssl_x509_parse() extensions support) (Pierre)
24 Jul 2006, PHP 5.2.0RC1
- Updated bundled MySQL client library to version 5.0.22 in the Windows
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/openssl.c?r1=1.98.2.5.2.9&r2=1.98.2.5.2.10&diff_format=u
Index: php-src/ext/openssl/openssl.c
diff -u php-src/ext/openssl/openssl.c:1.98.2.5.2.9
php-src/ext/openssl/openssl.c:1.98.2.5.2.10
--- php-src/ext/openssl/openssl.c:1.98.2.5.2.9 Mon Jul 31 03:41:19 2006
+++ php-src/ext/openssl/openssl.c Tue Aug 15 00:38:04 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: openssl.c,v 1.98.2.5.2.9 2006/07/31 03:41:19 iliaa Exp $ */
+/* $Id: openssl.c,v 1.98.2.5.2.10 2006/08/15 00:38:04 pajoye Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -60,11 +60,17 @@
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO();
+/* FIXME: Use the openssl constants instead of
+ * enum. It is now impossible to match real values
+ * against php constants. Also sorry to break the
+ * enum principles here, BC...
+ */
enum php_openssl_key_type {
OPENSSL_KEYTYPE_RSA,
OPENSSL_KEYTYPE_DSA,
OPENSSL_KEYTYPE_DH,
- OPENSSL_KEYTYPE_DEFAULT = OPENSSL_KEYTYPE_RSA
+ OPENSSL_KEYTYPE_DEFAULT = OPENSSL_KEYTYPE_RSA,
+ OPENSSL_KEYTYPE_EC = OPENSSL_KEYTYPE_DH +1
};
enum php_openssl_cipher_type {
@@ -87,6 +93,7 @@
PHP_FE(openssl_pkey_export_to_file, NULL)
PHP_FE(openssl_pkey_get_private, NULL)
PHP_FE(openssl_pkey_get_public, NULL)
+ PHP_FE(openssl_pkey_get_details, NULL)
PHP_FALIAS(openssl_free_key, openssl_pkey_free,
NULL)
PHP_FALIAS(openssl_get_privatekey, openssl_pkey_get_private,
NULL)
@@ -680,6 +687,7 @@
REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_DSA", OPENSSL_KEYTYPE_DSA,
CONST_CS|CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_DH", OPENSSL_KEYTYPE_DH,
CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("OPENSSL_KEYTYPE_EC", OPENSSL_KEYTYPE_EC,
CONST_CS|CONST_PERSISTENT);
/* Determine default SSL configuration file */
config_filename = getenv("OPENSSL_CONF");
@@ -2216,6 +2224,61 @@
/* }}} */
+/* {{{ proto resource openssl_pkey_get_details(resource key)
+ returns an array with the key details (bits, pkey, type)*/
+PHP_FUNCTION(openssl_pkey_get_details)
+{
+ zval *key;
+ EVP_PKEY *pkey;
+ BIO *out;
+ unsigned int pbio_len;
+ char *pbio;
+ long ktype;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &key) ==
FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(pkey, EVP_PKEY *, &key, -1, "OpenSSL key", le_key);
+ if (!pkey) {
+ RETURN_FALSE;
+ }
+ out = BIO_new(BIO_s_mem());
+ PEM_write_bio_PUBKEY(out, pkey);
+ pbio_len = BIO_get_mem_data(out, &pbio);
+
+ array_init(return_value);
+ add_assoc_long(return_value, "bits", EVP_PKEY_bits(pkey));
+ add_assoc_stringl(return_value, "key", pbio, pbio_len, 1);
+ /*TODO: Use the real values once the openssl constants are used
+ * See the enum at the top of this file
+ */
+ switch (EVP_PKEY_type(pkey->type)) {
+ case EVP_PKEY_RSA:
+ case EVP_PKEY_RSA2:
+ ktype = OPENSSL_KEYTYPE_RSA;
+ break;
+ case EVP_PKEY_DSA:
+ case EVP_PKEY_DSA2:
+ case EVP_PKEY_DSA3:
+ case EVP_PKEY_DSA4:
+ ktype = OPENSSL_KEYTYPE_DSA;
+ break;
+ case EVP_PKEY_DH:
+ ktype = OPENSSL_KEYTYPE_DH;
+ break;
+ case EVP_PKEY_EC:
+ ktype = OPENSSL_KEYTYPE_EC;
+ break;
+ default:
+ ktype = -1;
+ break;
+ }
+ add_assoc_long(return_value, "type", ktype);
+
+ BIO_free(out);
+}
+/* }}} */
+
/* }}} */
/* {{{ PKCS7 S/MIME functions */
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/php_openssl.h?r1=1.16.2.1&r2=1.16.2.1.2.1&diff_format=u
Index: php-src/ext/openssl/php_openssl.h
diff -u php-src/ext/openssl/php_openssl.h:1.16.2.1
php-src/ext/openssl/php_openssl.h:1.16.2.1.2.1
--- php-src/ext/openssl/php_openssl.h:1.16.2.1 Sun Jan 1 12:50:10 2006
+++ php-src/ext/openssl/php_openssl.h Tue Aug 15 00:38:04 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_openssl.h,v 1.16.2.1 2006/01/01 12:50:10 sniper Exp $ */
+/* $Id: php_openssl.h,v 1.16.2.1.2.1 2006/08/15 00:38:04 pajoye Exp $ */
#ifndef PHP_OPENSSL_H
#define PHP_OPENSSL_H
@@ -38,6 +38,7 @@
PHP_FUNCTION(openssl_pkey_new);
PHP_FUNCTION(openssl_pkey_export);
PHP_FUNCTION(openssl_pkey_export_to_file);
+PHP_FUNCTION(openssl_pkey_get_details);
PHP_FUNCTION(openssl_sign);
PHP_FUNCTION(openssl_verify);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php