summaryrefslogtreecommitdiff
blob: cbb79bcc1d3184ce7ba69089d06b483efc57252b (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
From 70ab61c8e6083080093fc42e8e7172969864e2bd Mon Sep 17 00:00:00 2001
From: Aric Belsito <lluixhi@gmail.com>
Date: Sun, 19 Mar 2017 13:58:24 -0700
Subject: [PATCH] Support LibreSSL

Broken by the addition of OpenSSL 1.1.0 support.
---
 libfreerdp/crypto/opensslcompat.c | 4 ++--
 libfreerdp/crypto/opensslcompat.h | 4 ++--
 libfreerdp/crypto/tls.c           | 8 ++++----
 winpr/libwinpr/crypto/hash.c      | 8 ++++----
 winpr/libwinpr/utils/ssl.c        | 2 +-
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libfreerdp/crypto/opensslcompat.c b/libfreerdp/crypto/opensslcompat.c
index bb5aff7..701902d 100644
--- a/libfreerdp/crypto/opensslcompat.c
+++ b/libfreerdp/crypto/opensslcompat.c
@@ -19,7 +19,7 @@
 
 #include "opensslcompat.h"
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
 
 BIO_METHOD* BIO_meth_new(int type, const char* name)
 {
@@ -41,4 +41,4 @@ void RSA_get0_key(const RSA* r, const BIGNUM** n, const BIGNUM** e, const BIGNUM
 		*d = r->d;
 }
 
-#endif /* OPENSSL < 1.1.0 */
+#endif /* OPENSSL < 1.1.0 || LIBRESSL */
diff --git a/libfreerdp/crypto/opensslcompat.h b/libfreerdp/crypto/opensslcompat.h
index a599863..b42d32f 100644
--- a/libfreerdp/crypto/opensslcompat.h
+++ b/libfreerdp/crypto/opensslcompat.h
@@ -30,7 +30,7 @@
 
 #include <openssl/opensslv.h>
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
 
 #include <openssl/bio.h>
 #include <openssl/rsa.h>
@@ -59,7 +59,7 @@
 BIO_METHOD* BIO_meth_new(int type, const char* name);
 void RSA_get0_key(const RSA* r, const BIGNUM** n, const BIGNUM** e, const BIGNUM** d);
 
-#endif /* OPENSSL < 1.1.0 */
+#endif /* OPENSSL < 1.1.0 || LIBRESSL */
 #endif /* WITH_OPENSSL */
 
 #endif /* FREERDP_CRYPTO_OPENSSLCOMPAT_H */
diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c
index 1071a2e..c415763 100644
--- a/libfreerdp/crypto/tls.c
+++ b/libfreerdp/crypto/tls.c
@@ -323,7 +323,7 @@ static long bio_rdp_tls_ctrl(BIO* bio, int cmd, long num, void* ptr)
 		case BIO_CTRL_PUSH:
 			if (next_bio && (next_bio != ssl_rbio))
 			{
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
 				SSL_set_bio(tls->ssl, next_bio, next_bio);
 				CRYPTO_add(&(bio->next_bio->references), 1, CRYPTO_LOCK_BIO);
 #else
@@ -346,7 +346,7 @@ static long bio_rdp_tls_ctrl(BIO* bio, int cmd, long num, void* ptr)
 				if (ssl_rbio != ssl_wbio)
 					BIO_free_all(ssl_wbio);
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
 				if (next_bio)
 					CRYPTO_add(&(bio->next_bio->references), -1, CRYPTO_LOCK_BIO);
 				tls->ssl->wbio = tls->ssl->rbio = NULL;
@@ -384,7 +384,7 @@ static long bio_rdp_tls_ctrl(BIO* bio, int cmd, long num, void* ptr)
 					BIO_push(ssl_rbio, next_bio);
 
 				BIO_set_next(bio, ssl_rbio);
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
 				CRYPTO_add(&(ssl_rbio->references), 1, CRYPTO_LOCK_BIO);
 #else
 				BIO_up_ref(ssl_rbio);
@@ -1021,7 +1021,7 @@ BOOL tls_send_alert(rdpTls* tls)
  *        SSL struct is opaqe now
  */
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
 	if (tls->alertDescription != TLS_ALERT_DESCRIPTION_CLOSE_NOTIFY)
 	{
 		/**
diff --git a/winpr/libwinpr/crypto/hash.c b/winpr/libwinpr/crypto/hash.c
index 949d687..27eb434 100644
--- a/winpr/libwinpr/crypto/hash.c
+++ b/winpr/libwinpr/crypto/hash.c
@@ -146,7 +146,7 @@ WINPR_HMAC_CTX* winpr_HMAC_New(void)
 
 #if defined(WITH_OPENSSL)
 	HMAC_CTX* hmac = NULL;
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
 	if (!(hmac = (HMAC_CTX*) calloc(1, sizeof(HMAC_CTX))))
 		return NULL;
 	HMAC_CTX_init(hmac);
@@ -267,7 +267,7 @@ void winpr_HMAC_Free(WINPR_HMAC_CTX* ctx)
 	HMAC_CTX* hmac = (HMAC_CTX*) ctx;
 	if (hmac)
 	{
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
 		HMAC_CTX_cleanup(hmac);
 		free(hmac);
 #else
@@ -317,7 +317,7 @@ WINPR_DIGEST_CTX* winpr_Digest_New(void)
 
 #if defined(WITH_OPENSSL)
 	EVP_MD_CTX* mdctx;
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
 	mdctx = EVP_MD_CTX_create();
 #else
 	mdctx = EVP_MD_CTX_new();
@@ -406,7 +406,7 @@ void winpr_Digest_Free(WINPR_DIGEST_CTX* ctx)
 	EVP_MD_CTX* mdctx = (EVP_MD_CTX*) ctx;
 	if (mdctx)
 	{
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
 		EVP_MD_CTX_destroy(mdctx);
 #else
 		EVP_MD_CTX_free(mdctx);
diff --git a/winpr/libwinpr/utils/ssl.c b/winpr/libwinpr/utils/ssl.c
index 2f8100f..5fd6ac6 100644
--- a/winpr/libwinpr/utils/ssl.c
+++ b/winpr/libwinpr/utils/ssl.c
@@ -45,7 +45,7 @@ static BOOL g_winpr_openssl_initialized_by_winpr = FALSE;
  * set locking callbacks to use OpenSSL in a multi-threaded environment.
  */
 
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
 
 #define WINPR_OPENSSL_LOCKING_REQUIRED 1