Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lua/lua-openssl/files/, dev-lua/lua-openssl/
Date: Sat, 06 Oct 2018 07:11:33
Message-Id: 1538809860.762dee6c53a540946e0c270d7d585464086782e5.mgorny@gentoo
1 commit: 762dee6c53a540946e0c270d7d585464086782e5
2 Author: Matthias Hauber <crito <AT> fnordpipe <DOT> org>
3 AuthorDate: Mon Oct 1 21:31:27 2018 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 6 07:11:00 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=762dee6c
7
8 dev-lua/lua-openssl: fix libressl build
9
10 backports libressl compat from master branch and disables
11 cms, sm2 and srp.
12 Additionally set dependency to libressl < 2.7.0 because there
13 are changes in the libressl-2.7 api that raises
14 a lot of incompatible pointer types.
15
16 Closes: https://bugs.gentoo.org/667390
17 Signed-off-by: Matthias Hauber <crito <AT> fnordpipe.org>
18 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
19 Closes: https://github.com/gentoo/gentoo/pull/10039
20
21 .../files/0001-fix-libressl-compat.patch | 433 +++++++++++++++++++++
22 dev-lua/lua-openssl/lua-openssl-0.7.3.ebuild | 4 +-
23 2 files changed, 436 insertions(+), 1 deletion(-)
24
25 diff --git a/dev-lua/lua-openssl/files/0001-fix-libressl-compat.patch b/dev-lua/lua-openssl/files/0001-fix-libressl-compat.patch
26 new file mode 100644
27 index 00000000000..19b0539c082
28 --- /dev/null
29 +++ b/dev-lua/lua-openssl/files/0001-fix-libressl-compat.patch
30 @@ -0,0 +1,433 @@
31 +From 44d5360d0caed1f4f364691f789fe825fcd17a3e Mon Sep 17 00:00:00 2001
32 +From: crito <crito@×××××××××.org>
33 +Date: Mon, 1 Oct 2018 20:10:05 +0200
34 +Subject: [PATCH] fix libressl compat
35 +
36 +add conditions to build with libressl and add missing functions.
37 +backported from upstream repo.
38 +---
39 + src/compat.c | 11 ++++++++---
40 + src/digest.c | 2 +-
41 + src/ec.c | 2 +-
42 + src/engine.c | 10 +++++-----
43 + src/lhash.c | 7 ++++---
44 + src/openssl.c | 12 ++++++++++--
45 + src/ots.c | 5 +++++
46 + src/pkcs7.c | 24 ++++++++++++------------
47 + src/private.h | 7 ++++---
48 + src/sm2.c | 2 +-
49 + src/srp.c | 3 ++-
50 + src/x509.c | 2 +-
51 + 12 files changed, 54 insertions(+), 33 deletions(-)
52 +
53 +diff --git a/src/compat.c b/src/compat.c
54 +index cc4cc21..cc45845 100644
55 +--- a/src/compat.c
56 ++++ b/src/compat.c
57 +@@ -5,7 +5,7 @@
58 + #include "openssl.h"
59 + #include "private.h"
60 +
61 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
62 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
63 + int BIO_up_ref(BIO *b)
64 + {
65 + CRYPTO_add(&b->references, 1, CRYPTO_LOCK_BIO);
66 +@@ -16,6 +16,11 @@ int X509_up_ref(X509 *x)
67 + CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
68 + return 1;
69 + }
70 ++int X509_CRL_up_ref(X509_CRL *x)
71 ++{
72 ++ int refs = CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509_CRL);
73 ++ return (refs > 1) ? 1 : 0;
74 ++}
75 + int X509_STORE_up_ref(X509_STORE *s)
76 + {
77 + CRYPTO_add(&s->references, 1, CRYPTO_LOCK_X509_STORE);
78 +@@ -464,7 +469,7 @@ const ASN1_BIT_STRING *TS_STATUS_INFO_get0_failure_info(const TS_STATUS_INFO *a)
79 + return a->failure_info;
80 + }
81 +
82 +-#if OPENSSL_VERSION_NUMBER < 0x10002000L
83 ++#if OPENSSL_VERSION_NUMBER < 0x10002000L || defined(LIBRESSL_VERSION_NUMBER)
84 + int i2d_re_X509_tbs(X509 *x, unsigned char **pp)
85 + {
86 + x->cert_info->enc.modified = 1;
87 +@@ -527,4 +532,4 @@ unsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx,
88 + return ctx->imprint;
89 + }
90 +
91 +-#endif /* < 1.1.0 */
92 +\ No newline at end of file
93 ++#endif /* < 1.1.0 */
94 +diff --git a/src/digest.c b/src/digest.c
95 +index 02e8fe1..0dcf65b 100644
96 +--- a/src/digest.c
97 ++++ b/src/digest.c
98 +@@ -468,7 +468,7 @@ restore md data
99 + static LUA_FUNCTION(openssl_digest_ctx_data)
100 + {
101 + EVP_MD_CTX *ctx = CHECK_OBJECT(1, EVP_MD_CTX, "openssl.evp_digest_ctx");
102 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
103 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
104 + if (lua_isnone(L, 2))
105 + {
106 + lua_pushlstring(L, ctx->md_data, ctx->digest->ctx_size);
107 +diff --git a/src/ec.c b/src/ec.c
108 +index f0d2b6b..5db32db 100644
109 +--- a/src/ec.c
110 ++++ b/src/ec.c
111 +@@ -611,7 +611,7 @@ static int openssl_ecdsa_set_method(lua_State *L)
112 + {
113 + EC_KEY *ec = CHECK_OBJECT(1, EC_KEY, "openssl.ec_key");
114 + ENGINE *e = CHECK_OBJECT(2, ENGINE, "openssl.engine");
115 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
116 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
117 + const ECDSA_METHOD *m = ENGINE_get_ECDSA(e);
118 + if (m) {
119 + int r = ECDSA_set_method(ec, m);
120 +diff --git a/src/engine.c b/src/engine.c
121 +index 1a26d8b..f12ca53 100644
122 +--- a/src/engine.c
123 ++++ b/src/engine.c
124 +@@ -14,7 +14,7 @@ enum
125 + {
126 + TYPE_RSA,
127 + TYPE_DSA,
128 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
129 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
130 + TYPE_ECDH,
131 + TYPE_ECDSA,
132 + #else
133 +@@ -24,7 +24,7 @@ enum
134 + TYPE_RAND,
135 + TYPE_CIPHERS,
136 + TYPE_DIGESTS,
137 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
138 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
139 + TYPE_STORE,
140 + #else
141 + TYPE_PKEY_METHODS,
142 +@@ -150,7 +150,7 @@ static int openssl_engine_register(lua_State*L)
143 + else
144 + ENGINE_register_DSA(eng);
145 + break;
146 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
147 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
148 + case TYPE_ECDH:
149 + if (unregister)
150 + ENGINE_unregister_ECDH(eng);
151 +@@ -183,7 +183,7 @@ static int openssl_engine_register(lua_State*L)
152 + else
153 + ENGINE_register_RAND(eng);
154 + break;
155 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
156 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
157 + case TYPE_STORE:
158 + if (unregister)
159 + ENGINE_unregister_STORE(eng);
160 +@@ -392,7 +392,7 @@ static int openssl_engine_set_default(lua_State*L)
161 + case TYPE_DSA:
162 + ret = ENGINE_set_default_DSA(eng);
163 + break;
164 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
165 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
166 + case TYPE_ECDH:
167 + ret = ENGINE_set_default_ECDH(eng);
168 + break;
169 +diff --git a/src/lhash.c b/src/lhash.c
170 +index 564bb52..8057efb 100644
171 +--- a/src/lhash.c
172 ++++ b/src/lhash.c
173 +@@ -130,21 +130,22 @@ static void dump_value_doall_arg(CONF_VALUE *a, lua_State *L)
174 + }
175 + }
176 +
177 +-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
178 ++#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
179 + IMPLEMENT_LHASH_DOALL_ARG_CONST(CONF_VALUE, lua_State);
180 + #elif OPENSSL_VERSION_NUMBER >= 0x10000002L
181 + static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_value, CONF_VALUE, lua_State)
182 + #endif
183 ++#if !defined(LIBRESSL_VERSION_NUMBER)
184 + #define LHM_lh_doall_arg(type, lh, fn, arg_type, arg) \
185 + lh_doall_arg(CHECKED_LHASH_OF(type, lh), fn, CHECKED_PTR_OF(arg_type, arg))
186 +-
187 ++#endif
188 +
189 + static LUA_FUNCTION(openssl_lhash_parse)
190 + {
191 + LHASH* lhash = CHECK_OBJECT(1, LHASH, "openssl.lhash");
192 +
193 + lua_newtable(L);
194 +-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
195 ++#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
196 + lh_CONF_VALUE_doall_lua_State(lhash, dump_value_doall_arg, L);
197 + #elif OPENSSL_VERSION_NUMBER >= 0x10000002L
198 + lh_CONF_VALUE_doall_arg(lhash, LHASH_DOALL_ARG_FN(dump_value), lua_State, L);
199 +diff --git a/src/openssl.c b/src/openssl.c
200 +index 994c22b..debea63 100644
201 +--- a/src/openssl.c
202 ++++ b/src/openssl.c
203 +@@ -338,6 +338,9 @@ get FIPS mode
204 + */
205 + static int openssl_fips_mode(lua_State *L)
206 + {
207 ++#if defined(LIBRESSL_VERSION_NUMBER)
208 ++ return 0;
209 ++#else
210 + int ret =0, on = 0;
211 + if(lua_isnone(L, 1))
212 + {
213 +@@ -353,6 +356,7 @@ static int openssl_fips_mode(lua_State *L)
214 + else
215 + ret = openssl_pushresult(L, ret);
216 + return ret;
217 ++#endif
218 + }
219 +
220 + #ifndef OPENSSL_NO_CRYPTO_MDEBUG
221 +@@ -405,7 +409,9 @@ void CRYPTO_thread_cleanup(void);
222 +
223 + static int luaclose_openssl(lua_State *L)
224 + {
225 ++#if !defined(LIBRESSL_VERSION_NUMBER)
226 + FIPS_mode_set(0);
227 ++#endif
228 + #if defined(OPENSSL_THREADS)
229 + CRYPTO_thread_cleanup();
230 + #endif
231 +@@ -421,7 +427,7 @@ static int luaclose_openssl(lua_State *L)
232 + CRYPTO_cleanup_all_ex_data();
233 + #ifndef OPENSSL_NO_CRYPTO_MDEBUG
234 + #if !(defined(OPENSSL_NO_STDIO) || defined(OPENSSL_NO_FP_API))
235 +-#if OPENSSL_VERSION_NUMBER < 0x10101000L
236 ++#if OPENSSL_VERSION_NUMBER < 0x10101000L || defined(LIBRESSL_VERSION_NUMBER)
237 + CRYPTO_mem_leaks_fp(stderr);
238 + #else
239 + if(CRYPTO_mem_leaks_fp(stderr)!=1)
240 +@@ -541,13 +547,15 @@ LUALIB_API int luaopen_openssl(lua_State*L)
241 + luaopen_dh(L);
242 + lua_setfield(L, -2, "dh");
243 +
244 +-#if (OPENSSL_VERSION_NUMBER >= 0x10101007L) && !defined(OPENSSL_NO_SM2)
245 ++#if (OPENSSL_VERSION_NUMBER >= 0x10101007L) && !defined(OPENSSL_NO_SM2) && !defined(LIBRESSL_VERSION_NUMBER)
246 + luaopen_sm2(L);
247 + lua_setfield(L, -2, "sm2");
248 + #endif
249 +
250 ++#if !defined(LIBRESSL_VERSION_NUMBER)
251 + luaopen_srp(L);
252 + lua_setfield(L, -2, "srp");
253 ++#endif
254 +
255 + #ifdef ENABLE_OPENSSL_GLOBAL
256 + lua_pushvalue(L, -1);
257 +diff --git a/src/ots.c b/src/ots.c
258 +index 6b75946..762d17e 100644
259 +--- a/src/ots.c
260 ++++ b/src/ots.c
261 +@@ -1265,7 +1265,12 @@ static LUA_FUNCTION(openssl_ts_resp_ctx_set_time_cb)
262 + arg->cb_arg = luaL_ref(L, LUA_REGISTRYINDEX);
263 +
264 + openssl_valueset(L, ctx, time_cb_key);
265 ++#if defined(LIBRESSL_VERSION_NUMBER)
266 ++ ctx->time_cb = openssl_time_cb;
267 ++ ctx->time_cb_data = L;
268 ++#else
269 + TS_RESP_CTX_set_time_cb(ctx, openssl_time_cb, L);
270 ++#endif
271 + return 0;
272 + }
273 +
274 +diff --git a/src/pkcs7.c b/src/pkcs7.c
275 +index f043c86..f0e5221 100644
276 +--- a/src/pkcs7.c
277 ++++ b/src/pkcs7.c
278 +@@ -346,7 +346,7 @@ static int openssl_pkcs7_dataFinal(PKCS7 *p7, BIO *bio)
279 + os = p7->d.signed_and_enveloped->enc_data->enc_data;
280 + if (!os)
281 + {
282 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
283 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
284 + os = M_ASN1_OCTET_STRING_new();
285 + #else
286 + os = ASN1_OCTET_STRING_new();
287 +@@ -364,7 +364,7 @@ static int openssl_pkcs7_dataFinal(PKCS7 *p7, BIO *bio)
288 + os = p7->d.enveloped->enc_data->enc_data;
289 + if (!os)
290 + {
291 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
292 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
293 + os = M_ASN1_OCTET_STRING_new();
294 + #else
295 + os = ASN1_OCTET_STRING_new();
296 +@@ -383,7 +383,7 @@ static int openssl_pkcs7_dataFinal(PKCS7 *p7, BIO *bio)
297 + /* If detached data then the content is excluded */
298 + if (PKCS7_type_is_data(p7->d.sign->contents) && p7->detached)
299 + {
300 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
301 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
302 + M_ASN1_OCTET_STRING_free(os);
303 + #else
304 + ASN1_OCTET_STRING_free(os);
305 +@@ -398,7 +398,7 @@ static int openssl_pkcs7_dataFinal(PKCS7 *p7, BIO *bio)
306 + /* If detached data then the content is excluded */
307 + if (PKCS7_type_is_data(p7->d.digest->contents) && p7->detached)
308 + {
309 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
310 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
311 + M_ASN1_OCTET_STRING_free(os);
312 + #else
313 + ASN1_OCTET_STRING_free(os);
314 +@@ -474,7 +474,7 @@ static int openssl_pkcs7_dataFinal(PKCS7 *p7, BIO *bio)
315 + goto err;
316 + if (!EVP_DigestFinal_ex(mdc, md_data, &md_len))
317 + goto err;
318 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
319 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
320 + M_ASN1_OCTET_STRING_set(p7->d.digest->digest, md_data, md_len);
321 + #else
322 + ASN1_OCTET_STRING_set(p7->d.digest->digest, md_data, md_len);
323 +@@ -577,7 +577,7 @@ int PKCS7_signatureVerify_digest(PKCS7 *p7, PKCS7_SIGNER_INFO *si, X509 *x509,
324 +
325 + md_type = OBJ_obj2nid(si->digest_alg->algorithm);
326 + md = EVP_get_digestbynid(md_type);
327 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
328 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
329 + if (!md || !data || (hash && len != (size_t) md->ctx_size) )
330 + goto err;
331 +
332 +@@ -1137,7 +1137,7 @@ static LUA_FUNCTION(openssl_pkcs7_sign_digest)
333 + os = p7->d.signed_and_enveloped->enc_data->enc_data;
334 + if (!os)
335 + {
336 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
337 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
338 + os = M_ASN1_OCTET_STRING_new();
339 + #else
340 + os = ASN1_OCTET_STRING_new();
341 +@@ -1155,7 +1155,7 @@ static LUA_FUNCTION(openssl_pkcs7_sign_digest)
342 + os = p7->d.enveloped->enc_data->enc_data;
343 + if (!os)
344 + {
345 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
346 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
347 + os = M_ASN1_OCTET_STRING_new();
348 + #else
349 + os = ASN1_OCTET_STRING_new();
350 +@@ -1174,7 +1174,7 @@ static LUA_FUNCTION(openssl_pkcs7_sign_digest)
351 + /* If detached data then the content is excluded */
352 + if (PKCS7_type_is_data(p7->d.sign->contents) && p7->detached)
353 + {
354 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
355 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
356 + M_ASN1_OCTET_STRING_free(os);
357 + #else
358 + ASN1_OCTET_STRING_free(os);
359 +@@ -1189,7 +1189,7 @@ static LUA_FUNCTION(openssl_pkcs7_sign_digest)
360 + /* If detached data then the content is excluded */
361 + if (PKCS7_type_is_data(p7->d.digest->contents) && p7->detached)
362 + {
363 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
364 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
365 + M_ASN1_OCTET_STRING_free(os);
366 + #else
367 + ASN1_OCTET_STRING_free(os);
368 +@@ -1217,7 +1217,7 @@ static LUA_FUNCTION(openssl_pkcs7_sign_digest)
369 +
370 + if (hash)
371 + {
372 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
373 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
374 + if (l == (size_t) mdc->digest->ctx_size)
375 + {
376 + memcpy(mdc->md_data, data, l);
377 +@@ -1272,7 +1272,7 @@ static LUA_FUNCTION(openssl_pkcs7_sign_digest)
378 + unsigned int md_len;
379 + md = EVP_get_digestbynid(OBJ_obj2nid(p7->d.digest->md->algorithm));
380 + EVP_DigestInit_ex(mdc, md, NULL);
381 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
382 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
383 + if (l == (size_t) mdc->digest->ctx_size)
384 + {
385 + memcpy(mdc->md_data, data, l);
386 +diff --git a/src/private.h b/src/private.h
387 +index 8e9d5b8..7140cae 100644
388 +--- a/src/private.h
389 ++++ b/src/private.h
390 +@@ -46,9 +46,10 @@ extern "C" {
391 + luaL_getmetatable(L,"openssl.bn"); \
392 + lua_setmetatable(L,-2)
393 +
394 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
395 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
396 + int BIO_up_ref(BIO *b);
397 + int X509_up_ref(X509 *x);
398 ++int X509_CRL_up_ref(X509_CRL *x);
399 + int X509_STORE_up_ref(X509_STORE *s);
400 + int EVP_PKEY_up_ref(EVP_PKEY *pkey);
401 +
402 +@@ -124,12 +125,12 @@ STACK_OF(X509) *TS_VERIFY_CTS_set_certs(TS_VERIFY_CTX *ctx,
403 + unsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx,
404 + unsigned char *hexstr, long len);
405 +
406 +-#if OPENSSL_VERSION_NUMBER < 0x10002000L
407 ++#if OPENSSL_VERSION_NUMBER < 0x10002000L || defined(LIBRESSL_VERSION_NUMBER)
408 + int i2d_re_X509_tbs(X509 *x, unsigned char **pp);
409 ++#endif
410 + void X509_get0_signature(ASN1_BIT_STRING **psig, X509_ALGOR **palg,
411 + const X509 *x);
412 + int X509_get_signature_nid(const X509 *x);
413 +-#endif
414 +
415 + #endif
416 +
417 +diff --git a/src/sm2.c b/src/sm2.c
418 +index 0655888..1db3198 100644
419 +--- a/src/sm2.c
420 ++++ b/src/sm2.c
421 +@@ -1,7 +1,7 @@
422 + #include "openssl.h"
423 + #include "private.h"
424 +
425 +-#if (OPENSSL_VERSION_NUMBER >= 0x10101007L) && !defined(OPENSSL_NO_SM2)
426 ++#if (OPENSSL_VERSION_NUMBER >= 0x10101007L) && !defined(OPENSSL_NO_SM2) && !defined(LIBRESSL_VERSION_NUMBER)
427 +
428 + # include <openssl/sm2.h>
429 +
430 +diff --git a/src/srp.c b/src/srp.c
431 +index 85626b5..6fb0a50 100644
432 +--- a/src/srp.c
433 ++++ b/src/srp.c
434 +@@ -1,6 +1,7 @@
435 + #include "openssl.h"
436 + #include "private.h"
437 +
438 ++#if !defined(LIBRESSL_VERSION_NUMBER)
439 + #include <openssl/srp.h>
440 + #include <openssl/bn.h>
441 +
442 +@@ -198,4 +199,4 @@ int luaopen_srp(lua_State *L)
443 + lua_settable(L, -3);
444 + return 1;
445 + }
446 +-
447 ++#endif
448 +diff --git a/src/x509.c b/src/x509.c
449 +index 94e9982..07adb54 100644
450 +--- a/src/x509.c
451 ++++ b/src/x509.c
452 +@@ -1196,7 +1196,7 @@ static int openssl_x509_extensions(lua_State* L)
453 + else
454 + {
455 + STACK_OF(X509_EXTENSION) *others = (STACK_OF(X509_EXTENSION) *)openssl_sk_x509_extension_fromtable(L, 2);
456 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
457 ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
458 + sk_X509_EXTENSION_pop_free(self->cert_info->extensions, X509_EXTENSION_free);
459 + self->cert_info->extensions = others;
460 + #else
461 +--
462 +2.16.4
463 +
464
465 diff --git a/dev-lua/lua-openssl/lua-openssl-0.7.3.ebuild b/dev-lua/lua-openssl/lua-openssl-0.7.3.ebuild
466 index 7f3d2b11e5e..564518d7fb1 100644
467 --- a/dev-lua/lua-openssl/lua-openssl-0.7.3.ebuild
468 +++ b/dev-lua/lua-openssl/lua-openssl-0.7.3.ebuild
469 @@ -21,13 +21,15 @@ IUSE="libressl luajit"
470 RDEPEND="
471 luajit? ( dev-lang/luajit:2 )
472 !luajit? ( >=dev-lang/lua-5.1:0 )
473 - libressl? ( dev-libs/libressl:0= )
474 + libressl? ( <dev-libs/libressl-2.7.0:0= )
475 !libressl? ( dev-libs/openssl:0=[-bindist] )
476 !dev-lua/luaossl
477 "
478 DEPEND="${RDEPEND}
479 virtual/pkgconfig"
480
481 +PATCHES=("${FILESDIR}/0001-fix-libressl-compat.patch")
482 +
483 src_unpack() {
484 unpack "${P}.tar.gz"
485 pushd "${WORKDIR}/${P}/deps" > /dev/null || die