summaryrefslogtreecommitdiff
path: root/ext/openssl/openssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/openssl/openssl.c')
-rw-r--r--ext/openssl/openssl.c102
1 files changed, 39 insertions, 63 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 340e40a001..749751c07a 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -1103,10 +1103,7 @@ PHP_MINIT_FUNCTION(openssl)
{
char * config_filename;
- zend_class_entry ce;
- INIT_CLASS_ENTRY(ce, "OpenSSLCertificate", class_OpenSSLCertificate_methods);
- php_openssl_certificate_ce = zend_register_internal_class(&ce);
- php_openssl_certificate_ce->ce_flags |= ZEND_ACC_FINAL | ZEND_ACC_NO_DYNAMIC_PROPERTIES;
+ php_openssl_certificate_ce = register_class_OpenSSLCertificate();
php_openssl_certificate_ce->create_object = php_openssl_certificate_create_object;
php_openssl_certificate_ce->serialize = zend_class_serialize_deny;
php_openssl_certificate_ce->unserialize = zend_class_unserialize_deny;
@@ -1118,10 +1115,7 @@ PHP_MINIT_FUNCTION(openssl)
php_openssl_certificate_object_handlers.clone_obj = NULL;
php_openssl_certificate_object_handlers.compare = zend_objects_not_comparable;
- zend_class_entry csr_ce;
- INIT_CLASS_ENTRY(csr_ce, "OpenSSLCertificateSigningRequest", class_OpenSSLCertificateSigningRequest_methods);
- php_openssl_request_ce = zend_register_internal_class(&csr_ce);
- php_openssl_request_ce->ce_flags |= ZEND_ACC_FINAL | ZEND_ACC_NO_DYNAMIC_PROPERTIES;
+ php_openssl_request_ce = register_class_OpenSSLCertificateSigningRequest();
php_openssl_request_ce->create_object = php_openssl_request_create_object;
php_openssl_request_ce->serialize = zend_class_serialize_deny;
php_openssl_request_ce->unserialize = zend_class_unserialize_deny;
@@ -1133,10 +1127,7 @@ PHP_MINIT_FUNCTION(openssl)
php_openssl_request_object_handlers.clone_obj = NULL;
php_openssl_request_object_handlers.compare = zend_objects_not_comparable;
- zend_class_entry key_ce;
- INIT_CLASS_ENTRY(key_ce, "OpenSSLAsymmetricKey", class_OpenSSLAsymmetricKey_methods);
- php_openssl_pkey_ce = zend_register_internal_class(&key_ce);
- php_openssl_pkey_ce->ce_flags |= ZEND_ACC_FINAL | ZEND_ACC_NO_DYNAMIC_PROPERTIES;
+ php_openssl_pkey_ce = register_class_OpenSSLAsymmetricKey();
php_openssl_pkey_ce->create_object = php_openssl_pkey_create_object;
php_openssl_pkey_ce->serialize = zend_class_serialize_deny;
php_openssl_pkey_ce->unserialize = zend_class_unserialize_deny;
@@ -1154,13 +1145,6 @@ PHP_MINIT_FUNCTION(openssl)
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
OpenSSL_add_all_algorithms();
-
-#if !defined(OPENSSL_NO_AES) && defined(EVP_CIPH_CCM_MODE) && OPENSSL_VERSION_NUMBER < 0x100020000
- EVP_add_cipher(EVP_aes_128_ccm());
- EVP_add_cipher(EVP_aes_192_ccm());
- EVP_add_cipher(EVP_aes_256_ccm());
-#endif
-
SSL_load_error_strings();
#else
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL);
@@ -1483,7 +1467,7 @@ PHP_FUNCTION(openssl_x509_export_to_file)
zend_object *cert_obj;
zend_string *cert_str;
- zend_bool notext = 1;
+ bool notext = 1;
BIO * bio_out;
char * filename;
size_t filename_len;
@@ -1793,7 +1777,7 @@ PHP_FUNCTION(openssl_x509_export)
zend_object *cert_obj;
zend_string *cert_str;
zval *zout;
- zend_bool notext = 1;
+ bool notext = 1;
BIO * bio_out;
ZEND_PARSE_PARAMETERS_START(2, 3)
@@ -1839,7 +1823,7 @@ cleanup:
}
/* }}} */
-zend_string* php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_bool raw)
+zend_string* php_openssl_x509_fingerprint(X509 *peer, const char *method, bool raw)
{
unsigned char md[EVP_MAX_MD_SIZE];
const EVP_MD *mdtype;
@@ -1871,7 +1855,7 @@ PHP_FUNCTION(openssl_x509_fingerprint)
X509 *cert;
zend_object *cert_obj;
zend_string *cert_str;
- zend_bool raw_output = 0;
+ bool raw_output = 0;
char *method = "sha1";
size_t method_len;
zend_string *fingerprint;
@@ -2050,7 +2034,7 @@ PHP_FUNCTION(openssl_x509_parse)
zend_object *cert_obj;
zend_string *cert_str;
int i, sig_nid;
- zend_bool useshortnames = 1;
+ bool useshortnames = 1;
char * tmpstr;
zval subitem;
X509_EXTENSION *extension;
@@ -3045,7 +3029,7 @@ PHP_FUNCTION(openssl_csr_export_to_file)
X509_REQ *csr;
zend_object *csr_obj;
zend_string *csr_str;
- zend_bool notext = 1;
+ bool notext = 1;
char * filename = NULL;
size_t filename_len;
BIO * bio_out;
@@ -3099,7 +3083,7 @@ PHP_FUNCTION(openssl_csr_export)
zend_object *csr_obj;
zend_string *csr_str;
zval *zout;
- zend_bool notext = 1;
+ bool notext = 1;
BIO * bio_out;
ZEND_PARSE_PARAMETERS_START(2, 3)
@@ -3386,7 +3370,7 @@ PHP_FUNCTION(openssl_csr_get_subject)
X509_REQ *csr;
zend_object *csr_obj;
zend_string *csr_str;
- zend_bool use_shortnames = 1;
+ bool use_shortnames = 1;
X509_NAME *subject;
ZEND_PARSE_PARAMETERS_START(1, 2)
@@ -3417,7 +3401,7 @@ PHP_FUNCTION(openssl_csr_get_public_key)
X509_REQ *orig_csr, *csr;
zend_object *csr_obj;
zend_string *csr_str;
- zend_bool use_shortnames = 1;
+ bool use_shortnames = 1;
php_openssl_pkey_object *key_object;
EVP_PKEY *tpubkey;
@@ -3672,28 +3656,20 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req
case OPENSSL_KEYTYPE_RSA:
{
RSA* rsaparam;
-#if OPENSSL_VERSION_NUMBER < 0x10002000L
- /* OpenSSL 1.0.2 deprecates RSA_generate_key */
- PHP_OPENSSL_RAND_ADD_TIME();
- rsaparam = (RSA*)RSA_generate_key(req->priv_key_bits, RSA_F4, NULL, NULL);
-#else
- {
- BIGNUM *bne = (BIGNUM *)BN_new();
- if (BN_set_word(bne, RSA_F4) != 1) {
- BN_free(bne);
- php_error_docref(NULL, E_WARNING, "Failed setting exponent");
- return NULL;
- }
- rsaparam = RSA_new();
- PHP_OPENSSL_RAND_ADD_TIME();
- if (rsaparam == NULL || !RSA_generate_key_ex(rsaparam, req->priv_key_bits, bne, NULL)) {
- php_openssl_store_errors();
- RSA_free(rsaparam);
- rsaparam = NULL;
- }
+ BIGNUM *bne = (BIGNUM *)BN_new();
+ if (BN_set_word(bne, RSA_F4) != 1) {
BN_free(bne);
+ php_error_docref(NULL, E_WARNING, "Failed setting exponent");
+ return NULL;
}
-#endif
+ rsaparam = RSA_new();
+ PHP_OPENSSL_RAND_ADD_TIME();
+ if (rsaparam == NULL || !RSA_generate_key_ex(rsaparam, req->priv_key_bits, bne, NULL)) {
+ php_openssl_store_errors();
+ RSA_free(rsaparam);
+ rsaparam = NULL;
+ }
+ BN_free(bne);
if (rsaparam && EVP_PKEY_assign_RSA(req->priv_key, rsaparam)) {
return_val = req->priv_key;
} else {
@@ -3892,7 +3868,7 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey)
} while (0);
/* {{{ php_openssl_pkey_init_rsa */
-static zend_bool php_openssl_pkey_init_and_assign_rsa(EVP_PKEY *pkey, RSA *rsa, zval *data)
+static bool php_openssl_pkey_init_and_assign_rsa(EVP_PKEY *pkey, RSA *rsa, zval *data)
{
BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp;
@@ -3925,7 +3901,7 @@ static zend_bool php_openssl_pkey_init_and_assign_rsa(EVP_PKEY *pkey, RSA *rsa,
}
/* {{{ php_openssl_pkey_init_dsa */
-static zend_bool php_openssl_pkey_init_dsa(DSA *dsa, zval *data)
+static bool php_openssl_pkey_init_dsa(DSA *dsa, zval *data)
{
BIGNUM *p, *q, *g, *priv_key, *pub_key;
const BIGNUM *priv_key_const, *pub_key_const;
@@ -4003,7 +3979,7 @@ static BIGNUM *php_openssl_dh_pub_from_priv(BIGNUM *priv_key, BIGNUM *g, BIGNUM
/* }}} */
/* {{{ php_openssl_pkey_init_dh */
-static zend_bool php_openssl_pkey_init_dh(DH *dh, zval *data)
+static bool php_openssl_pkey_init_dh(DH *dh, zval *data)
{
BIGNUM *p, *q, *g, *priv_key, *pub_key;
@@ -6781,7 +6757,7 @@ static void php_openssl_add_method(const OBJ_NAME *name, void *arg) /* {{{ */
/* {{{ Return array of available digest algorithms */
PHP_FUNCTION(openssl_get_md_methods)
{
- zend_bool aliases = 0;
+ bool aliases = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &aliases) == FAILURE) {
RETURN_THROWS();
@@ -6796,7 +6772,7 @@ PHP_FUNCTION(openssl_get_md_methods)
/* {{{ Return array of available cipher algorithms */
PHP_FUNCTION(openssl_get_cipher_methods)
{
- zend_bool aliases = 0;
+ bool aliases = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &aliases) == FAILURE) {
RETURN_THROWS();
@@ -6841,7 +6817,7 @@ PHP_FUNCTION(openssl_get_curve_names)
/* {{{ Computes digest hash value for given data using given method, returns raw or binhex encoded string */
PHP_FUNCTION(openssl_digest)
{
- zend_bool raw_output = 0;
+ bool raw_output = 0;
char *data, *method;
size_t data_len, method_len;
const EVP_MD *mdtype;
@@ -6890,10 +6866,10 @@ PHP_FUNCTION(openssl_digest)
/* Cipher mode info */
struct php_openssl_cipher_mode {
- zend_bool is_aead;
- zend_bool is_single_run_aead;
- zend_bool set_tag_length_always;
- zend_bool set_tag_length_when_encrypting;
+ bool is_aead;
+ bool is_single_run_aead;
+ bool set_tag_length_always;
+ bool set_tag_length_when_encrypting;
int aead_get_tag_flag;
int aead_set_tag_flag;
int aead_ivlen_flag;
@@ -6945,7 +6921,7 @@ static void php_openssl_load_cipher_mode(struct php_openssl_cipher_mode *mode, c
/* }}} */
static int php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv_required_len,
- zend_bool *free_iv, EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode) /* {{{ */
+ bool *free_iv, EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode) /* {{{ */
{
char *iv_new;
@@ -6998,8 +6974,8 @@ static int php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv_
static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode,
- const char **ppassword, size_t *ppassword_len, zend_bool *free_password,
- const char **piv, size_t *piv_len, zend_bool *free_iv,
+ const char **ppassword, size_t *ppassword_len, bool *free_password,
+ const char **piv, size_t *piv_len, bool *free_iv,
const char *tag, int tag_len, zend_long options, int enc) /* {{{ */
{
unsigned char *key;
@@ -7124,7 +7100,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
EVP_CIPHER_CTX *cipher_ctx;
struct php_openssl_cipher_mode mode;
int i = 0, outlen;
- zend_bool free_iv = 0, free_password = 0;
+ bool free_iv = 0, free_password = 0;
zend_string *outbuf = NULL;
PHP_OPENSSL_CHECK_SIZE_T_TO_INT_NULL_RETURN(data_len, data);
@@ -7238,7 +7214,7 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(
struct php_openssl_cipher_mode mode;
int i = 0, outlen;
zend_string *base64_str = NULL;
- zend_bool free_iv = 0, free_password = 0;
+ bool free_iv = 0, free_password = 0;
zend_string *outbuf = NULL;
PHP_OPENSSL_CHECK_SIZE_T_TO_INT_NULL_RETURN(data_len, data);