[pkg-opensc-commit] [opensc] 97/295: Add support for LibreSSL compatability as well as OpenSSL-1.1.0

Eric Dorland eric at moszumanska.debian.org
Sat Jun 24 21:11:20 UTC 2017


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository opensc.

commit c6dba96f559311576532578c4b274d50d710c225
Author: Doug Engert <deengert at gmail.com>
Date:   Mon Oct 3 20:10:21 2016 -0500

    Add support for LibreSSL compatability as well as OpenSSL-1.1.0
    
    This commit is based on input from https://github.com/lbschenkel
    LibreSSL is based on OpenSSL 1.0.1. API.
    
     Changes to be committed:
    	modified:   libopensc/sc-ossl-compat.h
    	modified:   tools/pkcs11-tool.c
    	modified:   tools/pkcs15-init.c
    	modified:   tools/sc-hsm-tool.c
---
 src/libopensc/sc-ossl-compat.h | 13 ++++++++++---
 src/tools/pkcs11-tool.c        |  6 +++---
 src/tools/pkcs15-init.c        |  4 ++--
 src/tools/sc-hsm-tool.c        |  2 +-
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/libopensc/sc-ossl-compat.h b/src/libopensc/sc-ossl-compat.h
index 42f0ca6..a97abe4 100644
--- a/src/libopensc/sc-ossl-compat.h
+++ b/src/libopensc/sc-ossl-compat.h
@@ -32,6 +32,13 @@ extern "C" {
 /*
  * Provide backward compatability to older versions of OpenSSL
  * while using most of OpenSSL 1.1  API
+ *
+ * LibreSSL is a fork of OpenSSL from 2014
+ * In its version of openssl/opensslv.h it defines:
+ * OPENSSL_VERSION_NUMBER  0x20000000L (Will not change)
+ * LIBRESSL_VERSION_NUMBER  0x2050000fL (changes with its versions.
+ * The LibreSSL appears to follow the OpenSSL-1.0.1 API
+ *
  */
 
 /*
@@ -81,7 +88,7 @@ extern "C" {
 #define EVP_PKEY_base_id(x)		(x->type)
 #endif
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
 #define RSA_PKCS1_OpenSSL		RSA_PKCS1_SSLeay
 #define OPENSSL_malloc_init		CRYPTO_malloc_init
 
@@ -101,7 +108,7 @@ extern "C" {
  * If that is not good enough, versions could be added to libopensc
  */
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
 /* based on OpenSSL-1.1.0 e_os2.h */
 /* sc_ossl_inline: portable inline definition usable in public headers */
 # if !defined(inline) && !defined(__cplusplus)
@@ -120,7 +127,7 @@ extern "C" {
 # endif
 #endif
 
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
 
 #define RSA_bits(R) (BN_num_bits(R->n))
 
diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c
index 2d9b610..7eb77a7 100644
--- a/src/tools/pkcs11-tool.c
+++ b/src/tools/pkcs11-tool.c
@@ -35,6 +35,7 @@
 
 #ifdef ENABLE_OPENSSL
 #include <openssl/opensslv.h>
+#include "libopensc/sc-ossl-compat.h"
 #if OPENSSL_VERSION_NUMBER >= 0x10000000L
 #include <openssl/opensslconf.h>
 #include <openssl/crypto.h>
@@ -56,7 +57,6 @@
 #include <openssl/err.h>
 #endif
 
-#include "libopensc/sc-ossl-compat.h"
 #include "pkcs11/pkcs11.h"
 #include "pkcs11/pkcs11-opensc.h"
 #include "libopensc/asn1.h"
@@ -460,10 +460,10 @@ int main(int argc, char * argv[])
 #endif
 
 #ifdef ENABLE_OPENSSL
-#if OPENSSL_VERSION_NUMBER >= 0x00907000L && OPENSSL_VERSION_NUMBER < 0x10100000L
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L && OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
 	OPENSSL_config(NULL);
 #endif
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
 	OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS
 		| OPENSSL_INIT_ADD_ALL_CIPHERS
 		| OPENSSL_INIT_ADD_ALL_DIGESTS
diff --git a/src/tools/pkcs15-init.c b/src/tools/pkcs15-init.c
index 3652f96..887fa98 100644
--- a/src/tools/pkcs15-init.c
+++ b/src/tools/pkcs15-init.c
@@ -39,6 +39,7 @@
 #include <string.h>
 #endif
 #include <openssl/opensslv.h>
+#include "libopensc/sc-ossl-compat.h"
 #if OPENSSL_VERSION_NUMBER >= 0x00907000L
 #include <openssl/conf.h>
 #endif
@@ -60,7 +61,6 @@
 #endif /* OPENSSL_VERSION_NUMBER >= 0x10000000L */
 
 #include "common/compat_strlcpy.h"
-#include "libopensc/sc-ossl-compat.h"
 #include "libopensc/cardctl.h"
 #include "libopensc/pkcs15.h"
 #include "libopensc/log.h"
@@ -439,7 +439,7 @@ main(int argc, char **argv)
 #if OPENSSL_VERSION_NUMBER >= 0x00907000L && OPENSSL_VERSION_NUMBER < 0x10100000L
 	OPENSSL_config(NULL);
 #endif
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !(defined LIBRESSL_VERSION_NUMBER)
 	/* Openssl 1.1.0 magic */
 	OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS
 		| OPENSSL_INIT_ADD_ALL_CIPHERS
diff --git a/src/tools/sc-hsm-tool.c b/src/tools/sc-hsm-tool.c
index 4efc1b1..cce855f 100644
--- a/src/tools/sc-hsm-tool.c
+++ b/src/tools/sc-hsm-tool.c
@@ -1745,7 +1745,7 @@ int main(int argc, char * const argv[])
 		}
 	}
 
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !(defined LIBRESSL_VERSION_NUMBER)
 	OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS
 		| OPENSSL_INIT_ADD_ALL_CIPHERS
 		| OPENSSL_INIT_ADD_ALL_DIGESTS,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/opensc.git



More information about the pkg-opensc-commit mailing list