cvs: php4 /ext/openssl openssl.c
| From: | Stig Venaas | Date: | Fri, 17 Nov 2000 19:49:12 +0000 |
| Subject: | cvs: php4 /ext/openssl openssl.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-2668@lists.php.net to get a copy of this message | ||
venaas Fri Nov 17 11:49:12 2000 EDT
Modified files:
/php4/ext/openssl openssl.c
Log:
Added optional passphrase argument to openssl_get_privatekey()
@- Added OpenSSL extension (Stig Venaas)
Index: php4/ext/openssl/openssl.c
diff -u php4/ext/openssl/openssl.c:1.4 php4/ext/openssl/openssl.c:1.5
--- php4/ext/openssl/openssl.c:1.4 Fri Nov 17 11:17:06 2000
+++ php4/ext/openssl/openssl.c Fri Nov 17 11:49:12 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: openssl.c,v 1.4 2000/11/17 19:17:06 venaas Exp $ */
+/* $Id: openssl.c,v 1.5 2000/11/17 19:49:12 venaas Exp $ */
#include "php.h"
#include "php_openssl.h"
@@ -105,20 +105,25 @@
return SUCCESS;
}
-/* {{{ proto int openssl_get_privatekey(string key)
+/* {{{ proto int openssl_get_privatekey(string key [, string passphrase])
Get private key */
PHP_FUNCTION(openssl_get_privatekey)
{
- zval **key;
+ zval **key, **passphrase;
BIO *b;
EVP_PKEY *pkey;
+ int argc;
- if (ZEND_NUM_ARGS() != 1 ||
- zend_get_parameters_ex(1, &key) == FAILURE) {
+ argc = ZEND_NUM_ARGS();
+ if (argc < 1 || argc > 2 ||
+ zend_get_parameters_ex(argc, &key, &passphrase) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(key);
-
+ if (argc == 2) {
+ convert_to_string_ex(passphrase);
+ }
+
b = BIO_new_mem_buf(Z_STRVAL_PP(key), Z_STRLEN_PP(key));
if (b == NULL) {
RETURN_FALSE;
@@ -126,7 +131,8 @@
pkey = (EVP_PKEY *) PEM_ASN1_read_bio((char *(*)())d2i_PrivateKey,
PEM_STRING_EVP_PKEY, b,
- NULL, NULL, NULL);
+ NULL, NULL, argc == 2 ?
+ Z_STRVAL_PP(passphrase) : NULL);
BIO_free(b);
if (pkey == NULL) {