diff options
author | Jakub Zelenka <bukka@php.net> | 2016-02-29 20:07:03 +0000 |
---|---|---|
committer | Jakub Zelenka <bukka@php.net> | 2016-07-17 17:33:42 +0100 |
commit | 84a291d4dac1a666dd961f68f87554ab37824c7e (patch) | |
tree | f96b450a0f76d8820458f043fdf88f12155cd2cd | |
parent | fd9142a64744958997f7c9611ef6277c57172933 (diff) | |
download | php-git-84a291d4dac1a666dd961f68f87554ab37824c7e.tar.gz |
Wrap pkey id and rsa getters
-rw-r--r-- | ext/openssl/openssl.c | 16 | ||||
-rw-r--r-- | ext/openssl/php_openssl.h | 4 |
2 files changed, 12 insertions, 8 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 7b687e1393..e794908aca 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -5048,13 +5048,13 @@ PHP_FUNCTION(openssl_private_encrypt) cryptedlen = EVP_PKEY_size(pkey); cryptedbuf = zend_string_alloc(cryptedlen, 0); - switch (pkey->type) { + switch (EVP_PKEY_id(pkey)) { case EVP_PKEY_RSA: case EVP_PKEY_RSA2: successful = (RSA_private_encrypt((int)data_len, (unsigned char *)data, (unsigned char *)ZSTR_VAL(cryptedbuf), - pkey->pkey.rsa, + EVP_PKEY_get0_RSA(pkey), (int)padding) == cryptedlen); break; default: @@ -5110,13 +5110,13 @@ PHP_FUNCTION(openssl_private_decrypt) cryptedlen = EVP_PKEY_size(pkey); crypttemp = emalloc(cryptedlen + 1); - switch (pkey->type) { + switch (EVP_PKEY_id(pkey)) { case EVP_PKEY_RSA: case EVP_PKEY_RSA2: cryptedlen = RSA_private_decrypt((int)data_len, (unsigned char *)data, crypttemp, - pkey->pkey.rsa, + EVP_PKEY_get0_RSA(pkey), (int)padding); if (cryptedlen != -1) { cryptedbuf = zend_string_alloc(cryptedlen, 0); @@ -5178,13 +5178,13 @@ PHP_FUNCTION(openssl_public_encrypt) cryptedlen = EVP_PKEY_size(pkey); cryptedbuf = zend_string_alloc(cryptedlen, 0); - switch (pkey->type) { + switch (EVP_PKEY_id(pkey)) { case EVP_PKEY_RSA: case EVP_PKEY_RSA2: successful = (RSA_public_encrypt((int)data_len, (unsigned char *)data, (unsigned char *)ZSTR_VAL(cryptedbuf), - pkey->pkey.rsa, + EVP_PKEY_get0_RSA(pkey), (int)padding) == cryptedlen); break; default: @@ -5241,13 +5241,13 @@ PHP_FUNCTION(openssl_public_decrypt) cryptedlen = EVP_PKEY_size(pkey); crypttemp = emalloc(cryptedlen + 1); - switch (pkey->type) { + switch (EVP_PKEY_id(pkey)) { case EVP_PKEY_RSA: case EVP_PKEY_RSA2: cryptedlen = RSA_public_decrypt((int)data_len, (unsigned char *)data, crypttemp, - pkey->pkey.rsa, + EVP_PKEY_get0_RSA(pkey), (int)padding); if (cryptedlen != -1) { cryptedbuf = zend_string_alloc(cryptedlen, 0); diff --git a/ext/openssl/php_openssl.h b/ext/openssl/php_openssl.h index 03f8953985..9407e50d23 100644 --- a/ext/openssl/php_openssl.h +++ b/ext/openssl/php_openssl.h @@ -132,6 +132,10 @@ PHP_FUNCTION(openssl_get_cert_locations); #endif +#if OPENSSL_VERSION_NUMBER < 0x10100000L +#define EVP_PKEY_get0_RSA(_pkey) _pkey->pkey.rsa +#endif + #endif /* |