元 #if OPENSSL_VERSION_NUMBER < 0x10100000Lと言った書き換えだけでは不充分なものもあり、例えば MIT Kerberos ではダメ。
新 #if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
元 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
新 #if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
ということで、MIT Kerberos5 1.17 に対する LibreSSL 2.9.1 を使うためのパッチを作ってみました。
diff -ruN ../krb5-1.17.ORG/src/plugins/preauth/pkinit/asn1t_add.h ./src/plugins/preauth/pkinit/asn1t_add.hLibreSSL とは全く関係ないですが、他にもこの↓パッチもあてたほうが良い場合もあるかも。
--- ../krb5-1.17.ORG/src/plugins/preauth/pkinit/asn1t_add.h 1970-01-01 09:00:00.000000000 +0900
+++ ./src/plugins/preauth/pkinit/asn1t_add.h 2019-04-24 20:09:19.848554267 +0900
@@ -0,0 +1,23 @@
+#ifndef HEADER_ASN1T_ADD_H
+#define HEADER_ASN1T_ADD_H
+#include <openssl/asn1t.h>
+
+# define static_ASN1_ITEM_start(itname) \
+ static const ASN1_ITEM itname##_it = {
+
+# define ASN1_ITEM_end(itname) \
+ };
+
+# define static_ASN1_SEQUENCE_END_name(stname, tname) \
+ ;\
+ static_ASN1_ITEM_start(tname) \
+ ASN1_ITYPE_SEQUENCE,\
+ V_ASN1_SEQUENCE,\
+ tname##_seq_tt,\
+ sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
+ NULL,\
+ sizeof(stname),\
+ #stname \
+ ASN1_ITEM_end(tname)
+
+#endif /* HEADER_ASN1T_ADD_H */
diff -ruN ../krb5-1.17.ORG/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c ./src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
--- ../krb5-1.17.ORG/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c 2019-01-09 01:02:37.000000000 +0900
+++ ./src/plugins/preauth/pkinit/pkinit_crypto_openssl.c 2019-04-24 20:14:54.578620209 +0900
@@ -189,7 +189,7 @@
(*_x509_pp) = PKCS7_cert_from_signer_info(_p7,_si)
#endif
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
/* 1.1 standardizes constructor and destructor names, renaming
* EVP_MD_CTX_{create,destroy} and deprecating ASN1_STRING_data. */
@@ -3053,7 +3053,7 @@
return retval;
}
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#if ((OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)) || (LIBRESSL_VERSION_NUMBER >= 0x20900000L)
/*
* We need to decode DomainParameters from RFC 3279 section 2.3.3. We would
diff -ruN ../krb5-1.17.ORG/src/plugins/preauth/pkinit/pkinit_crypto_openssl.h ./src/plugins/preauth/pkinit/pkinit_crypto_openssl.h
--- ../krb5-1.17.ORG/src/plugins/preauth/pkinit/pkinit_crypto_openssl.h 2019-01-09 01:02:37.000000000 +0900
+++ ./src/plugins/preauth/pkinit/pkinit_crypto_openssl.h 2019-04-24 20:15:42.128629575 +0900
@@ -46,8 +46,11 @@
#include <openssl/asn1.h>
#include <openssl/pem.h>
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#if ((OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)) || (LIBRESSL_VERSION_NUMBER >= 0x20900000L)
#include <openssl/asn1t.h>
+# ifdef LIBRESSL_VERSION_NUMBER
+# include "asn1t_add.h"
+# endif
#else
#include <openssl/asn1_mac.h>
#endif
diff -ruN ../krb5-1.17.ORG/src/Makefile.in ./src/Makefile.in
--- ../krb5-1.17.ORG/src/Makefile.in 2019-01-09 01:02:37.000000000 +0900
+++ ./src/Makefile.in 2019-04-24 16:45:55.157416835 +0900
@@ -1,3 +1,4 @@
+localstatedir=@localstatedir@
datadir=@datadir@
mydir=.
MIT Kerberos5 1.18 で LibreSSL 3.0.2 を使うためのパッチ
http://yama-ga.seesaa.net/article/473628340.html