freerdp-libressl.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. From 70ab61c8e6083080093fc42e8e7172969864e2bd Mon Sep 17 00:00:00 2001
  2. From: Aric Belsito <lluixhi@gmail.com>
  3. Date: Sun, 19 Mar 2017 13:58:24 -0700
  4. Subject: [PATCH] Support LibreSSL
  5. Broken by the addition of OpenSSL 1.1.0 support.
  6. ---
  7. libfreerdp/crypto/opensslcompat.c | 4 ++--
  8. libfreerdp/crypto/opensslcompat.h | 4 ++--
  9. libfreerdp/crypto/tls.c | 8 ++++----
  10. winpr/libwinpr/crypto/hash.c | 8 ++++----
  11. winpr/libwinpr/utils/ssl.c | 2 +-
  12. 5 files changed, 13 insertions(+), 13 deletions(-)
  13. diff --git a/libfreerdp/crypto/opensslcompat.c b/libfreerdp/crypto/opensslcompat.c
  14. index bb5aff7..701902d 100644
  15. --- a/libfreerdp/crypto/opensslcompat.c
  16. +++ b/libfreerdp/crypto/opensslcompat.c
  17. @@ -19,7 +19,7 @@
  18. #include "opensslcompat.h"
  19. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  20. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
  21. BIO_METHOD* BIO_meth_new(int type, const char* name)
  22. {
  23. @@ -41,4 +41,4 @@ void RSA_get0_key(const RSA* r, const BIGNUM** n, const BIGNUM** e, const BIGNUM
  24. *d = r->d;
  25. }
  26. -#endif /* OPENSSL < 1.1.0 */
  27. +#endif /* OPENSSL < 1.1.0 || LIBRESSL */
  28. diff --git a/libfreerdp/crypto/opensslcompat.h b/libfreerdp/crypto/opensslcompat.h
  29. index a599863..b42d32f 100644
  30. --- a/libfreerdp/crypto/opensslcompat.h
  31. +++ b/libfreerdp/crypto/opensslcompat.h
  32. @@ -30,7 +30,7 @@
  33. #include <openssl/opensslv.h>
  34. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  35. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
  36. #include <openssl/bio.h>
  37. #include <openssl/rsa.h>
  38. @@ -59,7 +59,7 @@
  39. BIO_METHOD* BIO_meth_new(int type, const char* name);
  40. void RSA_get0_key(const RSA* r, const BIGNUM** n, const BIGNUM** e, const BIGNUM** d);
  41. -#endif /* OPENSSL < 1.1.0 */
  42. +#endif /* OPENSSL < 1.1.0 || LIBRESSL */
  43. #endif /* WITH_OPENSSL */
  44. #endif /* FREERDP_CRYPTO_OPENSSLCOMPAT_H */
  45. diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c
  46. index 1071a2e..c415763 100644
  47. --- a/libfreerdp/crypto/tls.c
  48. +++ b/libfreerdp/crypto/tls.c
  49. @@ -323,7 +323,7 @@ static long bio_rdp_tls_ctrl(BIO* bio, int cmd, long num, void* ptr)
  50. case BIO_CTRL_PUSH:
  51. if (next_bio && (next_bio != ssl_rbio))
  52. {
  53. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  54. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
  55. SSL_set_bio(tls->ssl, next_bio, next_bio);
  56. CRYPTO_add(&(bio->next_bio->references), 1, CRYPTO_LOCK_BIO);
  57. #else
  58. @@ -346,7 +346,7 @@ static long bio_rdp_tls_ctrl(BIO* bio, int cmd, long num, void* ptr)
  59. if (ssl_rbio != ssl_wbio)
  60. BIO_free_all(ssl_wbio);
  61. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  62. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
  63. if (next_bio)
  64. CRYPTO_add(&(bio->next_bio->references), -1, CRYPTO_LOCK_BIO);
  65. tls->ssl->wbio = tls->ssl->rbio = NULL;
  66. @@ -384,7 +384,7 @@ static long bio_rdp_tls_ctrl(BIO* bio, int cmd, long num, void* ptr)
  67. BIO_push(ssl_rbio, next_bio);
  68. BIO_set_next(bio, ssl_rbio);
  69. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  70. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
  71. CRYPTO_add(&(ssl_rbio->references), 1, CRYPTO_LOCK_BIO);
  72. #else
  73. BIO_up_ref(ssl_rbio);
  74. @@ -1021,7 +1021,7 @@ BOOL tls_send_alert(rdpTls* tls)
  75. * SSL struct is opaqe now
  76. */
  77. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  78. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
  79. if (tls->alertDescription != TLS_ALERT_DESCRIPTION_CLOSE_NOTIFY)
  80. {
  81. /**
  82. diff --git a/winpr/libwinpr/crypto/hash.c b/winpr/libwinpr/crypto/hash.c
  83. index 949d687..27eb434 100644
  84. --- a/winpr/libwinpr/crypto/hash.c
  85. +++ b/winpr/libwinpr/crypto/hash.c
  86. @@ -146,7 +146,7 @@ WINPR_HMAC_CTX* winpr_HMAC_New(void)
  87. #if defined(WITH_OPENSSL)
  88. HMAC_CTX* hmac = NULL;
  89. -#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
  90. +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
  91. if (!(hmac = (HMAC_CTX*) calloc(1, sizeof(HMAC_CTX))))
  92. return NULL;
  93. HMAC_CTX_init(hmac);
  94. @@ -267,7 +267,7 @@ void winpr_HMAC_Free(WINPR_HMAC_CTX* ctx)
  95. HMAC_CTX* hmac = (HMAC_CTX*) ctx;
  96. if (hmac)
  97. {
  98. -#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
  99. +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
  100. HMAC_CTX_cleanup(hmac);
  101. free(hmac);
  102. #else
  103. @@ -317,7 +317,7 @@ WINPR_DIGEST_CTX* winpr_Digest_New(void)
  104. #if defined(WITH_OPENSSL)
  105. EVP_MD_CTX* mdctx;
  106. -#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
  107. +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
  108. mdctx = EVP_MD_CTX_create();
  109. #else
  110. mdctx = EVP_MD_CTX_new();
  111. @@ -406,7 +406,7 @@ void winpr_Digest_Free(WINPR_DIGEST_CTX* ctx)
  112. EVP_MD_CTX* mdctx = (EVP_MD_CTX*) ctx;
  113. if (mdctx)
  114. {
  115. -#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
  116. +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
  117. EVP_MD_CTX_destroy(mdctx);
  118. #else
  119. EVP_MD_CTX_free(mdctx);
  120. diff --git a/winpr/libwinpr/utils/ssl.c b/winpr/libwinpr/utils/ssl.c
  121. index 2f8100f..5fd6ac6 100644
  122. --- a/winpr/libwinpr/utils/ssl.c
  123. +++ b/winpr/libwinpr/utils/ssl.c
  124. @@ -45,7 +45,7 @@ static BOOL g_winpr_openssl_initialized_by_winpr = FALSE;
  125. * set locking callbacks to use OpenSSL in a multi-threaded environment.
  126. */
  127. -#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
  128. +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
  129. #define WINPR_OPENSSL_LOCKING_REQUIRED 1