summaryrefslogtreecommitdiff
blob: 07efa9ccb8fd0a7bad06757366a574c75f9322df (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
Index: /third_party/srtp/crypto/hash/hmac_ossl.c
===================================================================
--- /third_party/srtp/crypto/hash/hmac_ossl.c	(revision 5725)
+++ /third_party/srtp/crypto/hash/hmac_ossl.c	(revision 5726)
@@ -52,6 +52,8 @@
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
+#include <openssl/opensslv.h>
 
 #define SHA1_DIGEST_SIZE		20
+#define USING_LIBRESSL (defined(LIBRESSL_VERSION_NUMBER))
 
 /* the debug module for authentiation */
@@ -77,5 +79,5 @@
 /* OpenSSL 1.1.0 made HMAC_CTX an opaque structure, which must be allocated
    using HMAC_CTX_new.  But this function doesn't exist in OpenSSL 1.0.x. */
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if USING_LIBRESSL || OPENSSL_VERSION_NUMBER < 0x10100000L
     {
         /* allocate memory for auth and HMAC_CTX structures */
@@ -122,5 +124,5 @@
     hmac_ctx = (HMAC_CTX*)a->state;
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if USING_LIBRESSL || OPENSSL_VERSION_NUMBER < 0x10100000L
     HMAC_CTX_cleanup(hmac_ctx);
 
Index: /pjlib/src/pj/ssl_sock_ossl.c
===================================================================
--- /pjlib/src/pj/ssl_sock_ossl.c	(revision 5725)
+++ /pjlib/src/pj/ssl_sock_ossl.c	(revision 5726)
@@ -56,6 +56,10 @@
 #include <openssl/rand.h>
 #include <openssl/opensslconf.h>
-
-#if !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER >= 0x1000200fL
+#include <openssl/opensslv.h>
+
+#define USING_LIBRESSL (defined(LIBRESSL_VERSION_NUMBER))
+
+#if !USING_LIBRESSL && !defined(OPENSSL_NO_EC) \
+	&& OPENSSL_VERSION_NUMBER >= 0x1000200fL
 
 #   include <openssl/obj_mac.h>
@@ -115,5 +119,5 @@
 
 
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#if !USING_LIBRESSL && OPENSSL_VERSION_NUMBER >= 0x10100000L
 #  define OPENSSL_NO_SSL2	    /* seems to be removed in 1.1.0 */
 #  define M_ASN1_STRING_data(x)	    ASN1_STRING_get0_data(x)
@@ -539,5 +543,5 @@
 
     /* Init OpenSSL lib */
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if USING_LIBRESSL || OPENSSL_VERSION_NUMBER < 0x10100000L
     SSL_library_init();
     SSL_load_error_strings();
@@ -560,5 +564,7 @@
 	const char *cname;
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if (USING_LIBRESSL && LIBRESSL_VERSION_NUMBER < 0x2020100fL)\
+    || OPENSSL_VERSION_NUMBER < 0x10100000L
+
 	meth = (SSL_METHOD*)SSLv23_server_method();
 	if (!meth)
@@ -603,5 +609,6 @@
 	SSL_set_session(ssl, SSL_SESSION_new());
 
-#if !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER >= 0x1000200fL
+#if !USING_LIBRESSL && !defined(OPENSSL_NO_EC) \
+    && OPENSSL_VERSION_NUMBER >= 0x1000200fL
 	openssl_curves_num = SSL_get_shared_curve(ssl,-1);
 	if (openssl_curves_num > PJ_ARRAY_SIZE(openssl_curves))
@@ -795,5 +802,6 @@
 
     /* Determine SSL method to use */
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if (USING_LIBRESSL && LIBRESSL_VERSION_NUMBER < 0x2020100fL)\
+    || OPENSSL_VERSION_NUMBER < 0x10100000L
     switch (ssock->param.proto) {
     case PJ_SSL_SOCK_PROTO_TLS1:
@@ -1232,5 +1240,6 @@
 static pj_status_t set_curves_list(pj_ssl_sock_t *ssock)
 {
-#if !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER >= 0x1000200fL
+#if !USING_LIBRESSL && !defined(OPENSSL_NO_EC) \
+    && OPENSSL_VERSION_NUMBER >= 0x1000200fL
     int ret;
     int curves[PJ_SSL_SOCK_MAX_CURVES];
@@ -1263,5 +1272,5 @@
 static pj_status_t set_sigalgs(pj_ssl_sock_t *ssock)
 {
-#if OPENSSL_VERSION_NUMBER >= 0x1000200fL
+#if !USING_LIBRESSL && OPENSSL_VERSION_NUMBER >= 0x1000200fL
     int ret;