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
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 = {
15 BIO_METHOD* BIO_s_socket2() { return(&methods_socket); }
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))
32 + return methods_socket;
36 BIO* BIO_new_socket(talk_base::AsyncSocket* socket) {
37 + const BIO_METHOD *socket2 = BIO_s_socket2();
38 + if (socket2 == NULL) {
41 - BIO* ret = BIO_new(BIO_s_socket2());
42 + BIO* ret = BIO_new(socket2);
47 + BIO_set_data(ret, socket);
51 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
52 static int socket_new(BIO* b) {
60 +static int socket_new(BIO* b) {
61 + BIO_set_shutdown(b, 0);
68 static int socket_free(BIO* b) {
71 static int socket_read(BIO* b, char* out, int outl) {
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);
80 - } else if (result == 0) {
82 } else if (socket->IsBlocking()) {
83 BIO_set_retry_read(b);
86 static int socket_write(BIO* b, const char* in, int inl) {
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);
99 case BIO_CTRL_WPENDING:
100 case BIO_CTRL_PENDING:
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 @@
116 ext_str = ASN1_item_d2i(NULL, ext_value_data_ptr,
117 - extension->value->length,
119 ASN1_ITEM_ptr(meth->it));
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
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);
143 OpenSSLDigest::~OpenSSLDigest() {
144 - EVP_MD_CTX_cleanup(&ctx_);
145 + EVP_MD_CTX_destroy(ctx_);
148 size_t OpenSSLDigest::Size() const {
153 - EVP_DigestUpdate(&ctx_, buf, len);
154 + EVP_DigestUpdate(ctx_, buf, len);
157 size_t OpenSSLDigest::Finish(void* buf, size_t 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());
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
177 + EVP_MD_CTX* ctx_ = EVP_MD_CTX_create();
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
187 void OpenSSLKeyPair::AddReference() {
188 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
189 CRYPTO_add(&pkey_->references, 1, CRYPTO_LOCK_EVP_PKEY);
191 + EVP_PKEY_up_ref(pkey_);
200 void OpenSSLCertificate::AddReference() {
201 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
202 CRYPTO_add(&x509_->references, 1, CRYPTO_LOCK_X509);
204 + X509_up_ref(x509_);
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
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 = {
220 @@ -101,17 +102,37 @@
223 static BIO_METHOD* BIO_s_stream() { return(&methods_stream); }
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))
240 + return methods_stream;
244 static BIO* BIO_new_stream(StreamInterface* stream) {
245 BIO* ret = BIO_new(BIO_s_stream());
249 + BIO_set_data(ret, stream);
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) {
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);
272 static int stream_free(BIO* b) {
274 @@ -129,15 +158,13 @@
275 static int stream_read(BIO* b, char* out, int outl) {
278 - StreamInterface* stream = static_cast<StreamInterface*>(b->ptr);
279 + StreamInterface* stream = static_cast<StreamInterface*>(BIO_get_data(b));
280 BIO_clear_retry_flags(b);
283 StreamResult result = stream->Read(out, outl, &read, &error);
284 if (result == SR_SUCCESS) {
286 - } else if (result == SR_EOS) {
288 } else if (result == SR_BLOCK) {
289 BIO_set_retry_read(b);
292 static int stream_write(BIO* b, const char* in, int inl) {
295 - StreamInterface* stream = static_cast<StreamInterface*>(b->ptr);
296 + StreamInterface* stream = static_cast<StreamInterface*>(BIO_get_data(b));
297 BIO_clear_retry_flags(b);
305 case BIO_CTRL_WPENDING:
306 case BIO_CTRL_PENDING: