archrelease: copy trunk to extra-x86_64
[arch-packages.git] / kopete / trunk / kopete-openssl-1.1.patch
blob1d34e0e5c046dcf6f19f5732dd0c19e76f0ef2f3
1 diff -ur kopete-17.08.3/protocols/jabber/libjingle/talk/base/openssladapter.cc kopete-17.08.3-openssl-1.1/protocols/jabber/libjingle/talk/base/openssladapter.cc
2 --- kopete-17.08.3/protocols/jabber/libjingle/talk/base/openssladapter.cc 2017-09-30 12:08:16.000000000 +0200
3 +++ kopete-17.08.3-openssl-1.1/protocols/jabber/libjingle/talk/base/openssladapter.cc 2018-01-05 22:49:27.805070408 +0100
4 @@ -84,6 +84,7 @@
5 static int socket_new(BIO* h);
6 static int socket_free(BIO* data);
8 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
9 static BIO_METHOD methods_socket = {
10 BIO_TYPE_BIO,
11 "socket",
12 @@ -98,16 +99,40 @@
15 BIO_METHOD* BIO_s_socket2() { return(&methods_socket); }
16 +#else
17 +static BIO_METHOD *methods_socket = NULL;
19 +static const BIO_METHOD * BIO_s_socket2(void) {
20 + if (methods_socket == NULL) {
21 + methods_socket = BIO_meth_new (BIO_TYPE_BIO | BIO_get_new_index (), "socket");
22 + if (methods_socket == NULL ||
23 + BIO_meth_set_write (methods_socket, socket_write) ||
24 + BIO_meth_set_read (methods_socket, socket_read) ||
25 + BIO_meth_set_puts (methods_socket, socket_puts) ||
26 + BIO_meth_set_gets (methods_socket, 0) ||
27 + BIO_meth_set_ctrl (methods_socket, socket_ctrl) ||
28 + BIO_meth_set_create (methods_socket, socket_new) ||
29 + BIO_meth_set_destroy (methods_socket, socket_free))
30 + return NULL;
31 + }
32 + return methods_socket;
34 +#endif
36 BIO* BIO_new_socket(talk_base::AsyncSocket* socket) {
37 + const BIO_METHOD *socket2 = BIO_s_socket2();
38 + if (socket2 == NULL) {
39 + return NULL;
40 + }
41 - BIO* ret = BIO_new(BIO_s_socket2());
42 + BIO* ret = BIO_new(socket2);
43 if (ret == NULL) {
44 return NULL;
46 - ret->ptr = socket;
47 + BIO_set_data(ret, socket);
48 return ret;
51 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
52 static int socket_new(BIO* b) {
53 b->shutdown = 0;
54 b->init = 1;
55 @@ -115,6 +136,14 @@
56 b->ptr = 0;
57 return 1;
59 +#else
60 +static int socket_new(BIO* b) {
61 + BIO_set_shutdown(b, 0);
62 + BIO_set_init(b, 1);
63 + BIO_set_data(b, 0);
64 + return 1;
66 +#endif
68 static int socket_free(BIO* b) {
69 if (b == NULL)
70 @@ -125,13 +154,11 @@
71 static int socket_read(BIO* b, char* out, int outl) {
72 if (!out)
73 return -1;
74 - talk_base::AsyncSocket* socket = static_cast<talk_base::AsyncSocket*>(b->ptr);
75 + talk_base::AsyncSocket* socket = static_cast<talk_base::AsyncSocket*>(BIO_get_data(b));
76 BIO_clear_retry_flags(b);
77 int result = socket->Recv(out, outl);
78 if (result > 0) {
79 return result;
80 - } else if (result == 0) {
81 - b->num = 1;
82 } else if (socket->IsBlocking()) {
83 BIO_set_retry_read(b);
85 @@ -141,7 +168,7 @@
86 static int socket_write(BIO* b, const char* in, int inl) {
87 if (!in)
88 return -1;
89 - talk_base::AsyncSocket* socket = static_cast<talk_base::AsyncSocket*>(b->ptr);
90 + talk_base::AsyncSocket* socket = static_cast<talk_base::AsyncSocket*>(BIO_get_data(b));
91 BIO_clear_retry_flags(b);
92 int result = socket->Send(in, inl);
93 if (result > 0) {
94 @@ -164,7 +191,6 @@
95 case BIO_CTRL_RESET:
96 return 0;
97 case BIO_CTRL_EOF:
98 - return b->num;
99 case BIO_CTRL_WPENDING:
100 case BIO_CTRL_PENDING:
101 return 0;
102 @@ -696,7 +722,9 @@
103 // We assign this to a local variable, instead of passing the address
104 // directly to ASN1_item_d2i.
105 // See http://readlist.com/lists/openssl.org/openssl-users/0/4761.html.
106 - unsigned char* ext_value_data = extension->value->data;
107 + ASN1_OCTET_STRING *extension_data = X509_EXTENSION_get_data(extension);
108 + unsigned char* ext_value_data = extension_data->data;
109 + long length = extension_data->length;
111 #if OPENSSL_VERSION_NUMBER >= 0x0090800fL
112 const unsigned char **ext_value_data_ptr =
113 @@ -707,10 +735,10 @@
115 if (meth->it) {
116 ext_str = ASN1_item_d2i(NULL, ext_value_data_ptr,
117 - extension->value->length,
118 + length,
119 ASN1_ITEM_ptr(meth->it));
120 } else {
121 - ext_str = meth->d2i(NULL, ext_value_data_ptr, extension->value->length);
122 + ext_str = meth->d2i(NULL, ext_value_data_ptr, length);
125 STACK_OF(CONF_VALUE)* value = meth->i2v(meth, ext_str, NULL);
126 diff -ur kopete-17.08.3/protocols/jabber/libjingle/talk/base/openssldigest.cc kopete-17.08.3-openssl-1.1/protocols/jabber/libjingle/talk/base/openssldigest.cc
127 --- kopete-17.08.3/protocols/jabber/libjingle/talk/base/openssldigest.cc 2017-09-30 12:08:16.000000000 +0200
128 +++ kopete-17.08.3-openssl-1.1/protocols/jabber/libjingle/talk/base/openssldigest.cc 2018-01-05 22:49:27.869069361 +0100
129 @@ -32,16 +32,16 @@
130 namespace talk_base {
132 OpenSSLDigest::OpenSSLDigest(const std::string& algorithm) {
133 - EVP_MD_CTX_init(&ctx_);
134 + EVP_MD_CTX_init(ctx_);
135 if (GetDigestEVP(algorithm, &md_)) {
136 - EVP_DigestInit_ex(&ctx_, md_, NULL);
137 + EVP_DigestInit_ex(ctx_, md_, NULL);
138 } else {
139 md_ = NULL;
143 OpenSSLDigest::~OpenSSLDigest() {
144 - EVP_MD_CTX_cleanup(&ctx_);
145 + EVP_MD_CTX_destroy(ctx_);
148 size_t OpenSSLDigest::Size() const {
149 @@ -55,7 +55,7 @@
150 if (!md_) {
151 return;
153 - EVP_DigestUpdate(&ctx_, buf, len);
154 + EVP_DigestUpdate(ctx_, buf, len);
157 size_t OpenSSLDigest::Finish(void* buf, size_t len) {
158 @@ -63,8 +63,8 @@
159 return 0;
161 unsigned int md_len;
162 - EVP_DigestFinal_ex(&ctx_, static_cast<unsigned char*>(buf), &md_len);
163 - EVP_DigestInit_ex(&ctx_, md_, NULL); // prepare for future Update()s
164 + EVP_DigestFinal_ex(ctx_, static_cast<unsigned char*>(buf), &md_len);
165 + EVP_DigestInit_ex(ctx_, md_, NULL); // prepare for future Update()s
166 ASSERT(md_len == Size());
167 return md_len;
169 diff -ur kopete-17.08.3/protocols/jabber/libjingle/talk/base/openssldigest.h kopete-17.08.3-openssl-1.1/protocols/jabber/libjingle/talk/base/openssldigest.h
170 --- kopete-17.08.3/protocols/jabber/libjingle/talk/base/openssldigest.h 2017-09-30 12:08:16.000000000 +0200
171 +++ kopete-17.08.3-openssl-1.1/protocols/jabber/libjingle/talk/base/openssldigest.h 2018-01-05 22:49:27.869069361 +0100
172 @@ -55,7 +55,7 @@
173 size_t* len);
175 private:
176 - EVP_MD_CTX ctx_;
177 + EVP_MD_CTX* ctx_ = EVP_MD_CTX_create();
178 const EVP_MD* md_;
181 diff -ur kopete-17.08.3/protocols/jabber/libjingle/talk/base/opensslidentity.cc kopete-17.08.3-openssl-1.1/protocols/jabber/libjingle/talk/base/opensslidentity.cc
182 --- kopete-17.08.3/protocols/jabber/libjingle/talk/base/opensslidentity.cc 2017-09-30 12:08:16.000000000 +0200
183 +++ kopete-17.08.3-openssl-1.1/protocols/jabber/libjingle/talk/base/opensslidentity.cc 2018-01-05 22:49:27.867069394 +0100
184 @@ -169,7 +169,12 @@
187 void OpenSSLKeyPair::AddReference() {
188 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
189 CRYPTO_add(&pkey_->references, 1, CRYPTO_LOCK_EVP_PKEY);
190 +#else
191 + EVP_PKEY_up_ref(pkey_);
192 +#endif
196 #ifdef _DEBUG
197 @@ -275,7 +280,11 @@
200 void OpenSSLCertificate::AddReference() {
201 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
202 CRYPTO_add(&x509_->references, 1, CRYPTO_LOCK_X509);
203 +#else
204 + X509_up_ref(x509_);
205 +#endif
208 OpenSSLIdentity* OpenSSLIdentity::Generate(const std::string& common_name) {
209 diff -ur kopete-17.08.3/protocols/jabber/libjingle/talk/base/opensslstreamadapter.cc kopete-17.08.3-openssl-1.1/protocols/jabber/libjingle/talk/base/opensslstreamadapter.cc
210 --- kopete-17.08.3/protocols/jabber/libjingle/talk/base/opensslstreamadapter.cc 2017-09-30 12:08:16.000000000 +0200
211 +++ kopete-17.08.3-openssl-1.1/protocols/jabber/libjingle/talk/base/opensslstreamadapter.cc 2018-01-05 22:49:27.868069378 +0100
212 @@ -87,6 +87,7 @@
213 static int stream_new(BIO* h);
214 static int stream_free(BIO* data);
216 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
217 static BIO_METHOD methods_stream = {
218 BIO_TYPE_BIO,
219 "stream",
220 @@ -101,17 +102,37 @@
223 static BIO_METHOD* BIO_s_stream() { return(&methods_stream); }
224 +#else
225 +static BIO_METHOD *methods_stream = NULL;
227 +static const BIO_METHOD * BIO_s_stream(void) {
228 + if (methods_stream == NULL) {
229 + methods_stream = BIO_meth_new (BIO_TYPE_BIO | BIO_get_new_index (), "stream");
230 + if (methods_stream == NULL ||
231 + BIO_meth_set_write (methods_stream, stream_write) ||
232 + BIO_meth_set_read (methods_stream, stream_read) ||
233 + BIO_meth_set_puts (methods_stream, stream_puts) ||
234 + BIO_meth_set_gets (methods_stream, 0) ||
235 + BIO_meth_set_ctrl (methods_stream, stream_ctrl) ||
236 + BIO_meth_set_create (methods_stream, stream_new) ||
237 + BIO_meth_set_destroy (methods_stream, stream_free))
238 + return NULL;
240 + return methods_stream;
242 +#endif
244 static BIO* BIO_new_stream(StreamInterface* stream) {
245 BIO* ret = BIO_new(BIO_s_stream());
246 if (ret == NULL)
247 return NULL;
248 - ret->ptr = stream;
249 + BIO_set_data(ret, stream);
250 return ret;
253 // bio methods return 1 (or at least non-zero) on success and 0 on failure.
255 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
256 static int stream_new(BIO* b) {
257 b->shutdown = 0;
258 b->init = 1;
259 @@ -119,6 +140,14 @@
260 b->ptr = 0;
261 return 1;
263 +#else
264 +static int stream_new(BIO* b) {
265 + BIO_set_shutdown(b, 0);
266 + BIO_set_init(b, 1);
267 + BIO_set_data(b, 0);
268 + return 1;
270 +#endif
272 static int stream_free(BIO* b) {
273 if (b == NULL)
274 @@ -129,15 +158,13 @@
275 static int stream_read(BIO* b, char* out, int outl) {
276 if (!out)
277 return -1;
278 - StreamInterface* stream = static_cast<StreamInterface*>(b->ptr);
279 + StreamInterface* stream = static_cast<StreamInterface*>(BIO_get_data(b));
280 BIO_clear_retry_flags(b);
281 size_t read;
282 int error;
283 StreamResult result = stream->Read(out, outl, &read, &error);
284 if (result == SR_SUCCESS) {
285 return read;
286 - } else if (result == SR_EOS) {
287 - b->num = 1;
288 } else if (result == SR_BLOCK) {
289 BIO_set_retry_read(b);
291 @@ -147,7 +174,7 @@
292 static int stream_write(BIO* b, const char* in, int inl) {
293 if (!in)
294 return -1;
295 - StreamInterface* stream = static_cast<StreamInterface*>(b->ptr);
296 + StreamInterface* stream = static_cast<StreamInterface*>(BIO_get_data(b));
297 BIO_clear_retry_flags(b);
298 size_t written;
299 int error;
300 @@ -172,7 +199,6 @@
301 case BIO_CTRL_RESET:
302 return 0;
303 case BIO_CTRL_EOF:
304 - return b->num;
305 case BIO_CTRL_WPENDING:
306 case BIO_CTRL_PENDING:
307 return 0;