kopete-openssl-1.1.patch 10 KB

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