aboutsummaryrefslogtreecommitdiff
path: root/libraries/ptlib/ptlib-2.10.11-openssl11.patch
blob: 38d296eb2da664b09710edb752a34f00bc3fdf55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
https://build.opensuse.org/package/view_file/network:telephony/libpt2/libpt2-openssl11.patch
by mgorse@suse.com, see also:

 - https://build.opensuse.org/request/show/518821
 - https://bugzilla.opensuse.org/show_bug.cgi?id=1055477

--- ptlib-2.10.11/src/ptclib/pssl.cxx			2013-08-14 18:20:27.000000000 -0500
+++ ptlib-2.10.11/src/ptclib/pssl.cxx.openssl11		2017-08-25 17:25:44.824287596 -0500
@@ -140,7 +140,11 @@ PFACTORY_CREATE_SINGLETON(PProcessStartu
 class PSSL_BIO
 {
   public:
+#if OPENSSL_VERSION_NUMBER >= 0x10100000
+    PSSL_BIO(const BIO_METHOD *method = BIO_s_file())
+#else
     PSSL_BIO(BIO_METHOD *method = BIO_s_file_internal())
+#endif
       { bio = BIO_new(method); }
 
     ~PSSL_BIO()
@@ -627,10 +631,18 @@ PSSLDiffieHellman::PSSLDiffieHellman(con
   if (dh == NULL)
     return;
 
+#if OPENSSL_VERSION_NUMBER >= 0x10100000l
+  DH_set0_pqg (dh, BN_bin2bn(pData, pSize, NULL), NULL, BN_bin2bn(gData, gSize, NULL));
+  const BIGNUM *p, *g;
+  DH_get0_pqg(dh, &p, NULL, &g);
+  if (p != NULL && g != NULL)
+    return;
+#else
   dh->p = BN_bin2bn(pData, pSize, NULL);
   dh->g = BN_bin2bn(gData, gSize, NULL);
   if (dh->p != NULL && dh->g != NULL)
     return;
+#endif
 
   DH_free(dh);
   dh = NULL;
@@ -805,9 +817,11 @@ void PSSLContext::Construct(Method metho
   SSL_METHOD * meth;
 
   switch (method) {
+#ifndef OPENSSL_NO_SSL3
     case SSLv3:
       meth = SSLv3_method();
       break;
+#endif
     case TLSv1:
       meth = TLSv1_method(); 
       break;
@@ -1117,7 +1131,11 @@ PBoolean PSSLChannel::RawSSLRead(void *
 //
 
 
+#if OPENSSL_VERSION_NUMBER >= 0x10100000l
+#define PSSLCHANNEL(bio)      ((PSSLChannel *)(BIO_get_data (bio)))
+#else
 #define PSSLCHANNEL(bio)      ((PSSLChannel *)(bio->ptr))
+#endif
 
 extern "C" {
 
@@ -1130,10 +1148,16 @@ typedef long (*lfptr)();
 
 static int Psock_new(BIO * bio)
 {
+#if OPENSSL_VERSION_NUMBER >= 0x10100000l
+  BIO_set_init (bio, 0);
+  BIO_set_data (bio, NULL);;    // this is really (PSSLChannel *)
+  BIO_set_flags (bio, 0);
+#else
   bio->init     = 0;
   bio->num      = 0;
   bio->ptr      = NULL;    // this is really (PSSLChannel *)
   bio->flags    = 0;
+#endif
 
   return(1);
 }
@@ -1144,13 +1168,23 @@ static int Psock_free(BIO * bio)
   if (bio == NULL)
     return 0;
 
+#if OPENSSL_VERSION_NUMBER >= 0x10100000l
+  if (BIO_get_shutdown (bio)) {
+    if (BIO_get_init (bio)) {
+#else
   if (bio->shutdown) {
     if (bio->init) {
+#endif
       PSSLCHANNEL(bio)->Shutdown(PSocket::ShutdownReadAndWrite);
       PSSLCHANNEL(bio)->Close();
     }
+#if OPENSSL_VERSION_NUMBER >= 0x10100000l
+    BIO_set_init (bio, 0);
+    BIO_set_flags (bio, 0);
+#else
     bio->init  = 0;
     bio->flags = 0;
+#endif
   }
   return 1;
 }
@@ -1160,11 +1194,19 @@ static long Psock_ctrl(BIO * bio, int cm
 {
   switch (cmd) {
     case BIO_CTRL_SET_CLOSE:
+#if OPENSSL_VERSION_NUMBER >= 0x10100000l
+      BIO_set_shutdown (bio, (int)num);
+#else
       bio->shutdown = (int)num;
+#endif
       return 1;
 
     case BIO_CTRL_GET_CLOSE:
+#if OPENSSL_VERSION_NUMBER >= 0x10100000l
+      return BIO_get_shutdown (bio);
+#else
       return bio->shutdown;
+#endif
 
     case BIO_CTRL_FLUSH:
       return 1;
@@ -1239,41 +1281,64 @@ static int Psock_puts(BIO * bio, const c
 };
 
 
-static BIO_METHOD methods_Psock =
-{
-  BIO_TYPE_SOCKET,
-  "PTLib-PSSLChannel",
-#if (OPENSSL_VERSION_NUMBER < 0x00906000)
-  (ifptr)Psock_write,
-  (ifptr)Psock_read,
-  (ifptr)Psock_puts,
-  NULL,
-  (lfptr)Psock_ctrl,
-  (ifptr)Psock_new,
-  (ifptr)Psock_free
-#else
-  Psock_write,
-  Psock_read,
-  Psock_puts,
-  NULL,
-  Psock_ctrl,
-  Psock_new,
-  Psock_free
-#endif
-};
-
 
 PBoolean PSSLChannel::OnOpen()
 {
+#if OPENSSL_VERSION_NUMBER >= 0x10100000l
+  static BIO_METHOD *methods_pSock = NULL;
+
+  if (methods_pSock == NULL) {
+    methods_pSock = BIO_meth_new (BIO_TYPE_SOCKET, "PTLib-PSSLChannel");
+    if (!methods_pSock)
+      return FALSE;
+    BIO_meth_set_write (methods_pSock, Psock_write);
+    BIO_meth_set_read (methods_pSock, Psock_read);
+    BIO_meth_set_puts (methods_pSock, Psock_puts);
+    BIO_meth_set_ctrl (methods_pSock, Psock_ctrl);
+    BIO_meth_set_create (methods_pSock, Psock_new);
+    BIO_meth_set_destroy (methods_pSock, Psock_free);
+  }
+
+  BIO * bio = BIO_new(methods_pSock);
+#else
+  static BIO_METHOD methods_Psock =
+  {
+    BIO_TYPE_SOCKET,
+    "PTLib-PSSLChannel",
+  #if (OPENSSL_VERSION_NUMBER < 0x00906000)
+    (ifptr)Psock_write,
+    (ifptr)Psock_read,
+    (ifptr)Psock_puts,
+    NULL,
+    (lfptr)Psock_ctrl,
+    (ifptr)Psock_new,
+    (ifptr)Psock_free
+  #else
+    Psock_write,
+    Psock_read,
+    Psock_puts,
+    NULL,
+    Psock_ctrl,
+    Psock_new,
+    Psock_free
+  #endif
+  };
+
   BIO * bio = BIO_new(&methods_Psock);
+#endif
   if (bio == NULL) {
     SSLerr(SSL_F_SSL_SET_FD,ERR_R_BUF_LIB);
     return PFalse;
   }
 
   // "Open" then bio
+#if OPENSSL_VERSION_NUMBER >= 0x10100000l
+  BIO_set_data (bio, this);
+  BIO_set_init (bio, 1);
+#else
   bio->ptr  = this;
   bio->init = 1;
+#endif
 
   SSL_set_bio(ssl, bio, bio);
   return PTrue;