Skip to content

Commit 0d10f7b

Browse files
authored
Remove OpenSSL 1.0.2 related code (#18032)
This also removes old LibreSSL checks as minimum that compiles is 3.5.0
1 parent 9d4fd7f commit 0d10f7b

File tree

2 files changed

+2
-153
lines changed

2 files changed

+2
-153
lines changed

ext/openssl/openssl_backend_v1.c

Lines changed: 1 addition & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -27,159 +27,16 @@
2727
#include <openssl/engine.h>
2828
#endif
2929

30-
/* OpenSSL compatibility functions and macros */
31-
#if PHP_OPENSSL_API_VERSION < 0x10100
32-
33-
#define EVP_PKEY_get0_RSA(_pkey) _pkey->pkey.rsa
34-
#define EVP_PKEY_get0_DH(_pkey) _pkey->pkey.dh
35-
#define EVP_PKEY_get0_DSA(_pkey) _pkey->pkey.dsa
36-
#define EVP_PKEY_get0_EC_KEY(_pkey) _pkey->pkey.ec
37-
38-
static int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d)
39-
{
40-
r->n = n;
41-
r->e = e;
42-
r->d = d;
43-
44-
return 1;
45-
}
46-
47-
static int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q)
48-
{
49-
r->p = p;
50-
r->q = q;
51-
52-
return 1;
53-
}
54-
55-
static int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp)
56-
{
57-
r->dmp1 = dmp1;
58-
r->dmq1 = dmq1;
59-
r->iqmp = iqmp;
60-
61-
return 1;
62-
}
63-
64-
static void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
65-
{
66-
*n = r->n;
67-
*e = r->e;
68-
*d = r->d;
69-
}
70-
71-
static void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q)
72-
{
73-
*p = r->p;
74-
*q = r->q;
75-
}
76-
77-
static void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, const BIGNUM **iqmp)
78-
{
79-
*dmp1 = r->dmp1;
80-
*dmq1 = r->dmq1;
81-
*iqmp = r->iqmp;
82-
}
83-
84-
static void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
85-
{
86-
*p = dh->p;
87-
*q = dh->q;
88-
*g = dh->g;
89-
}
90-
91-
static int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
92-
{
93-
dh->p = p;
94-
dh->q = q;
95-
dh->g = g;
96-
97-
return 1;
98-
}
99-
100-
static void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key)
101-
{
102-
*pub_key = dh->pub_key;
103-
*priv_key = dh->priv_key;
104-
}
105-
106-
static int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key)
107-
{
108-
dh->pub_key = pub_key;
109-
dh->priv_key = priv_key;
110-
111-
return 1;
112-
}
113-
114-
static void DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
115-
{
116-
*p = d->p;
117-
*q = d->q;
118-
*g = d->g;
119-
}
120-
121-
int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g)
122-
{
123-
d->p = p;
124-
d->q = q;
125-
d->g = g;
126-
127-
return 1;
128-
}
129-
130-
static void DSA_get0_key(const DSA *d, const BIGNUM **pub_key, const BIGNUM **priv_key)
131-
{
132-
*pub_key = d->pub_key;
133-
*priv_key = d->priv_key;
134-
}
135-
136-
int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key)
137-
{
138-
d->pub_key = pub_key;
139-
d->priv_key = priv_key;
140-
141-
return 1;
142-
}
143-
144-
static const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *asn1)
145-
{
146-
return M_ASN1_STRING_data(asn1);
147-
}
148-
149-
static int EVP_PKEY_up_ref(EVP_PKEY *pkey)
150-
{
151-
return CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
152-
}
153-
154-
#if PHP_OPENSSL_API_VERSION < 0x10002
155-
156-
static int X509_get_signature_nid(const X509 *x)
157-
{
158-
return OBJ_obj2nid(x->sig_alg->algorithm);
159-
}
160-
161-
#endif
162-
163-
#define OpenSSL_version SSLeay_version
164-
#define OPENSSL_VERSION SSLEAY_VERSION
165-
#define X509_getm_notBefore X509_get_notBefore
166-
#define X509_getm_notAfter X509_get_notAfter
167-
#define EVP_CIPHER_CTX_reset EVP_CIPHER_CTX_cleanup
168-
169-
#endif
170-
17130
void php_openssl_backend_shutdown(void)
17231
{
173-
#ifdef LIBRESSL_VERSION_NUMBER
32+
#ifdef LIBRESSL_VERSION_NUMBER
17433
EVP_cleanup();
17534

17635
/* prevent accessing locking callback from unloaded extension */
17736
CRYPTO_set_locking_callback(NULL);
17837

179-
#ifndef OPENSSL_NO_ENGINE
18038
/* Free engine list initialized by OPENSSL_config */
18139
ENGINE_cleanup();
182-
#endif
18340

18441
/* free allocated error strings */
18542
ERR_free_strings();

ext/openssl/php_openssl.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,15 @@ extern zend_module_entry openssl_module_entry;
2626
#define PHP_OPENSSL_VERSION PHP_VERSION
2727

2828
#include <openssl/opensslv.h>
29-
#ifdef LIBRESSL_VERSION_NUMBER
30-
/* LibreSSL version check */
31-
#if LIBRESSL_VERSION_NUMBER < 0x20700000L
32-
#define PHP_OPENSSL_API_VERSION 0x10001
33-
#else
34-
#define PHP_OPENSSL_API_VERSION 0x10100
35-
#endif
36-
#else
3729
/* OpenSSL version check */
3830
#if OPENSSL_VERSION_NUMBER < 0x30000000L
31+
/* This includes LibreSSL that defines version 0x20000000L */
3932
#define PHP_OPENSSL_API_VERSION 0x10100
4033
#elif OPENSSL_VERSION_NUMBER < 0x30200000L
4134
#define PHP_OPENSSL_API_VERSION 0x30000
4235
#else
4336
#define PHP_OPENSSL_API_VERSION 0x30200
4437
#endif
45-
#endif
4638

4739
#define OPENSSL_RAW_DATA 1
4840
#define OPENSSL_ZERO_PADDING 2

0 commit comments

Comments
 (0)