From 97469f4f8b03fdb1bd03878482ae39fdfaf1941f Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Fri, 16 Oct 2026 09:37:59 +0900
Subject: Require openssl 1.1 or greater

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 ConfigureChecks.cmake | 11 ++++-------
 src/cardpincheck.c    | 11 -----------
 2 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 98d340a..64edf92 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -33,15 +33,12 @@ endif( NOT GNUTLS_FOUND )
 
 ##### check for OpenSSL
 
-pkg_search_module( SSL openssl )
+pkg_search_module( SSL openssl>=1.1.0 )
 if( NOT SSL_FOUND )
    check_include_file( openssl/ssl.h HAVE_OPENSSL_H )
    check_library_exists( ssl OPENSSL_init_ssl "" HAVE_LIBSSL_11 )
-   if( NOT HAVE_LIBSSL_11 )
-      check_library_exists( ssl SSL_library_init "" HAVE_LIBSSL )
-   endif( )
    check_library_exists( crypto EVP_EncryptInit_ex "" HAVE_LIBCRYPTO )
-   if( HAVE_OPENSSL_H AND (HAVE_LIBSSL_11 OR HAVEL_LIBSSL) AND HAVE_LIBCRYPTO )
+   if( HAVE_OPENSSL_H AND HAVE_LIBSSL_11 AND HAVE_LIBCRYPTO )
       set( SSL_FOUND 1 CACHE INTERNAL "" FORCE )
       find_file( OPENSSLV_H openssl/opensslv.h )
       file( STRINGS "${OPENSSLV_H}" SSL_VERSION REGEX "#[ \t]*define[ \t]*OPENSSL_VERSION_TEXT" )
@@ -49,10 +46,10 @@ if( NOT SSL_FOUND )
               SSL_VERSION "${SSL_VERSION}" )
       set( SSL_VERSION "${SSL_VERSION}" CACHE INTERNAL "" FORCE )
       message( STATUS "Found OpenSSL: version ${SSL_VERSION}" )
-   endif( HAVE_OPENSSL_H AND (HAVE_LIBSSL_11 OR HAVEL_LIBSSL) AND HAVE_LIBCRYPTO )
+   endif( HAVE_OPENSSL_H AND HAVE_LIBSSL_11 AND HAVE_LIBCRYPTO )
 endif( NOT SSL_FOUND )
 if( NOT SSL_FOUND )
-  tde_message_fatal( "SSL support is required but was not found on your system" )
+  tde_message_fatal( "OpenSSL 1.1 or newer is required but was not found on your system" )
 endif( NOT SSL_FOUND )
 
 
diff --git a/src/cardpincheck.c b/src/cardpincheck.c
index 18a7495..e12374b 100644
--- a/src/cardpincheck.c
+++ b/src/cardpincheck.c
@@ -141,13 +141,8 @@ char* tde_autopin(X509* x509_cert) {
 					int returnCode;
 					int index = 0;	// Search for the PIN field
 ;
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
 					const uint8_t* asnSeqValueString = ASN1_STRING_get0_data(asnValue->value.sequence);
 					asnSeqValueStack = d2i_ASN1_SEQUENCE_ANY(NULL, &asnSeqValueString, ASN1_STRING_length(asnValue->value.sequence));
-#else
-					uint8_t* asnSeqValueString = ASN1_STRING_data(asnValue->value.sequence);
-					asnSeqValueStack = ASN1_seq_unpack_ASN1_TYPE(asnSeqValueString, ASN1_STRING_length(asnValue->value.sequence), d2i_ASN1_TYPE, ASN1_TYPE_free);
-#endif
 					asnSeqValue = sk_ASN1_TYPE_value(asnSeqValueStack, index);
 					if (asnSeqValue) {
 						if (asnSeqValue->value.octet_string->data[0] == ((V_ASN1_CONSTRUCTED | V_ASN1_CONTEXT_SPECIFIC) + index)) {
@@ -156,19 +151,13 @@ char* tde_autopin(X509* x509_cert) {
 							if (!(returnCode & 0x80)) {
 								if (returnCode == (V_ASN1_CONSTRUCTED + index)) {
 									if (d2i_ASN1_GENERALSTRING(&asnGeneralString, &asn1SeqValueObjectData, asn1SeqValueObjectLength) != NULL) {
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
 										retString = strdup(ASN1_STRING_get0_data(asnGeneralString));
-#else
-										retString = strdup(ASN1_STRING_data(asnGeneralString));
-#endif
 									}
 								}
 							}
 						}
 					}
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
 					sk_ASN1_TYPE_pop_free(asnSeqValueStack, ASN1_TYPE_free);
-#endif
 				}
 			}
 		}
-- 
cgit v1.2.3

