com php-src: Use opaque EVP_PKEY in php_openssl_is_ private_key: ext/openssl/openssl.c ext/openssl/php_ openssl.h

From: Date: Sun, 17 Jul 2016 16:33:42 +0000
Subject: com php-src: Use opaque EVP_PKEY in php_openssl_is_ private_key: ext/openssl/openssl.c ext/openssl/php_ openssl.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-93255@lists.php.net to get a copy of this message
Commit: f1de72293e4c55683bc52d40fa69d4abe08ad272 Author: Jakub Zelenka <bukka@php.net> Thu, 3 Mar 2016 19:43:29 +0000 Parents: 0598a8da2bc005b3a0be2801033b5347020f8316 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f1de72293e4c55683bc52d40fa69d4abe08ad272 Log: Use opaque EVP_PKEY in php_openssl_is_private_key Changed paths: M ext/openssl/openssl.c M ext/openssl/php_openssl.h Diff: diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index d1c104e..dcaa2c8 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -3776,13 +3776,15 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey) { assert(pkey != NULL); - switch (pkey->type) { + switch (EVP_PKEY_id(pkey)) { #ifndef NO_RSA case EVP_PKEY_RSA: case EVP_PKEY_RSA2: - assert(pkey->pkey.rsa != NULL); - if (pkey->pkey.rsa != NULL && (NULL == pkey->pkey.rsa->p || NULL == pkey->pkey.rsa->q)) { - return 0; + { + RSA *rsa = EVP_PKEY_get0_RSA(pkey); + if (rsa != NULL && (rsa->p == NULL || rsa->q == NULL)) { + return 0; + } } break; #endif @@ -3792,30 +3794,32 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey) case EVP_PKEY_DSA2: case EVP_PKEY_DSA3: case EVP_PKEY_DSA4: - assert(pkey->pkey.dsa != NULL); - - if (NULL == pkey->pkey.dsa->p || NULL == pkey->pkey.dsa->q || NULL == pkey->pkey.dsa->priv_key){ - return 0; + { + DSA *dsa = EVP_PKEY_get0_DSA(pkey); + if (dsa != NULL && (dsa->p == NULL || dsa->q == NULL || dsa->priv_key == NULL)) { + return 0; + } } break; #endif #ifndef NO_DH case EVP_PKEY_DH: - assert(pkey->pkey.dh != NULL); - - if (NULL == pkey->pkey.dh->p || NULL == pkey->pkey.dh->priv_key) { - return 0; + { + DH *dh = EVP_PKEY_get0_DH(pkey); + if (dh != NULL && (NULL == dh->p || dh->priv_key == NULL)) { + return 0; + } } break; #endif #ifdef HAVE_EVP_PKEY_EC case EVP_PKEY_EC: - assert(pkey->pkey.ec != NULL); - - if ( NULL == EC_KEY_get0_private_key(pkey->pkey.ec)) { - return 0; + { + EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey); + if (ec != NULL && NULL == EC_KEY_get0_private_key(ec)) { + return 0; + } } - break; #endif default: php_error_docref(NULL, E_WARNING, "key type not supported in this PHP build!"); diff --git a/ext/openssl/php_openssl.h b/ext/openssl/php_openssl.h index 9407e50..48d82b7 100644 --- a/ext/openssl/php_openssl..h +++ b/ext/openssl/php_openssl.h @@ -134,6 +134,9 @@ PHP_FUNCTION(openssl_get_cert_locations); #if OPENSSL_VERSION_NUMBER < 0x10100000L #define EVP_PKEY_get0_RSA(_pkey) _pkey->pkey.rsa +#define EVP_PKEY_get0_DSA(_pkey) _pkey->pkey.dsa +#define EVP_PKEY_get0_DH(_pkey) _pkey->pkey.dh +#define EVP_PKEY_get0_EC_KEY(_pkey) _pkey->pkey.ec #endif #endif

« previous php.cvs (#93255) next »