From 5e7de4cb5dbe62effdae7dab0cd9ad204f83a337 Mon Sep 17 00:00:00 2001 From: Christian Hohnstaedt Date: Thu, 30 Jan 2025 16:35:15 +0100 Subject: [PATCH] OPENSSL-3 Drop Openssl-1.x support --- CMakeLists.txt | 14 ++------------ lib/CMakeLists.txt | 2 +- lib/main.cpp | 20 ++++++++------------ lib/openssl_compat.h | 38 -------------------------------------- lib/pkcs11.cpp | 4 ---- lib/pki_evp.cpp | 5 ----- misc/dynamic.wxs.in | 2 +- test/main.cpp | 4 ---- 8 files changed, 12 insertions(+), 77 deletions(-) delete mode 100644 lib/openssl_compat.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c70765e..37db5e75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC_SEARCH_PATHS "${PROJECT_SOURCE_DIR}/ui") set(CMAKE_AUTOUIC ON) -add_compile_definitions(OPENSSL_SUPPRESS_DEPRECATED QT_MESSAGELOGCONTEXT) +add_compile_definitions(QT_MESSAGELOGCONTEXT) add_compile_options(-Wall -Wextra -Wno-unknown-pragmas) if (ADDRESS_SANITIZER) @@ -88,11 +88,6 @@ add_executable(xcaexport ${PROJECT_BINARY_DIR}/local.h) include_directories(${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}) -if (NOT OPENSSL_VERSION) - # Educated guess - set(OPENSSL_VERSION 3.0.0) -endif() - if (APPLE) execute_process(COMMAND brew --prefix OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE BREW_PREFIX ERROR_QUIET) @@ -104,11 +99,6 @@ elseif(WIN32) if (NOT CMAKE_PREFIX_PATH) set(CMAKE_PREFIX_PATH $ENV{UserProfile} $ENV{PROGRAMFILES}/OpenSSL-Win64) endif() - if (OPENSSL_VERSION VERSION_GREATER_EQUAL 3.0.0) - set(OPENSSL_LIBRARY_MAJOR "3") - else() - set(OPENSSL_LIBRARY_MAJOR "1_1") - endif() file(TO_CMAKE_PATH $ENV{WINDIR}/system32 SYSTEM32) endif() @@ -298,7 +288,7 @@ elseif(WIN32) ${CMAKE_BINARY_DIR}/libstdc++-6.dll ${CMAKE_BINARY_DIR}/libwinpthread-1.dll ${SYSTEM32}/vcruntime140.dll - ${OPENSSL_ROOT_DIR}/bin/libcrypto-${OPENSSL_LIBRARY_MAJOR}-x64.dll + ${OPENSSL_ROOT_DIR}/bin/libcrypto-3-x64.dll DESTINATION ${RUNTIME_DEST} ) install(CODE "execute_process(COMMAND cmake -E chdir \${CMAKE_INSTALL_PREFIX} tar cvf ${RUNTIME_DEST}.zip --format=zip -- ${RUNTIME_DEST})") diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 28807140..090303b7 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -19,7 +19,7 @@ builtin_curves.h pki_temp.h database_model.cpp oid.cpp pki_x509.cpp database_model.h oid.h pki_x509.h db_base.cpp opensc-pkcs11.h pki_x509req.cpp -db_base.h openssl_compat.h pki_x509req.h +db_base.h pki_x509req.h db_crl.cpp pass_info.cpp pki_x509super.cpp db_crl.h pass_info.h pki_x509super.h db_key.cpp pk11_attribute.cpp settings.cpp diff --git a/lib/main.cpp b/lib/main.cpp index 4c6a5d0a..9d9c0a2e 100644 --- a/lib/main.cpp +++ b/lib/main.cpp @@ -25,9 +25,7 @@ #include #endif -#if (OPENSSL_VERSION_NUMBER >= 0x30000000L) #include -#endif #include #include @@ -118,25 +116,23 @@ int main(int argc, char *argv[]) is_gui_app = true; } -#if (OPENSSL_VERSION_NUMBER >= 0x30000000L) - { - QString path; + QString path; #if defined(Q_OS_WIN32) - path = QCoreApplication::applicationDirPath(); + path = QCoreApplication::applicationDirPath(); #elif defined(Q_OS_MACOS) - path = QCoreApplication::applicationDirPath() + "/../PlugIns"; + path = QCoreApplication::applicationDirPath() + "/../PlugIns"; #endif - if (!path.isEmpty()) { - OSSL_PROVIDER_set_default_search_path(NULL, path.toUtf8().data()); - qDebug() << "OSSL_PROVIDER_set_default_search_path" << path; - } + if (!path.isEmpty()) { + OSSL_PROVIDER_set_default_search_path(NULL, path.toUtf8().data()); + qDebug() << "OSSL_PROVIDER_set_default_search_path" << path; } + MainWindow::legacy_loaded = OSSL_PROVIDER_try_load(0, "legacy", 1); if (MainWindow::legacy_loaded) qDebug() << "Legacy provider loaded"; else qWarning() << "Legacy provider NOT loaded"; -#endif + QSharedPointer uimeth( UI_create_method("xca-method"), UI_destroy_method); UI_method_set_writer(uimeth.data(), uiwriter); diff --git a/lib/openssl_compat.h b/lib/openssl_compat.h deleted file mode 100644 index 001d8e1d..00000000 --- a/lib/openssl_compat.h +++ /dev/null @@ -1,38 +0,0 @@ -/* vi: set sw=4 ts=4: - * - * Copyright (C) 2017 Christian Hohnstaedt. - * - * All rights reserved. - */ - -/* This header equalizes a lot of OpenSSL 1.1.0 vs. 1.1.1 - API clashes by defining some macros if OpenSSL < 1.1.1 - is used. This way the code is written with the new API - and have much less #ifdefs -*/ - -#ifndef __OPENSS_COMPAT_XCA_H -#define __OPENSS_COMPAT_XCA_H - -#include - -#if OPENSSL_VERSION_NUMBER < 0x10101000L - -static inline int -EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret, - size_t *siglen, const unsigned char *tbs, size_t tbslen) -{ - return EVP_DigestSignUpdate(ctx, tbs, tbslen) && - EVP_DigestSignFinal(ctx, sigret, siglen); -} - -static inline int -EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret, - size_t siglen, const unsigned char *tbs, size_t tbslen) -{ - return EVP_DigestVerifyUpdate(ctx, tbs, tbslen) && - EVP_DigestVerifyFinal(ctx, (unsigned char *)sigret, siglen); -} -#endif - -#endif diff --git a/lib/pkcs11.cpp b/lib/pkcs11.cpp index c4d4c9bb..1e5f6f48 100644 --- a/lib/pkcs11.cpp +++ b/lib/pkcs11.cpp @@ -661,11 +661,7 @@ static int eng_finish(ENGINE *e) return 1; } -#if (OPENSSL_VERSION_NUMBER >= 0x30000000L) static int eng_pmeth_copy(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src) -#else -static int eng_pmeth_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) -#endif { void *p = EVP_PKEY_CTX_get_app_data((EVP_PKEY_CTX *)src); EVP_PKEY_CTX_set_app_data(dst, p); diff --git a/lib/pki_evp.cpp b/lib/pki_evp.cpp index 2f0b3ee4..a3319734 100644 --- a/lib/pki_evp.cpp +++ b/lib/pki_evp.cpp @@ -13,7 +13,6 @@ #include "entropy.h" #include "BioByteArray.h" #include "XcaProgress.h" -#include "openssl_compat.h" #include "PwDialogCore.h" #include "XcaWarningCore.h" @@ -23,9 +22,7 @@ #include #include #include -#if (OPENSSL_VERSION_NUMBER >= 0x30000000L) #include -#endif Passwd pki_evp::passwd; @@ -225,9 +222,7 @@ bool pki_evp::openssl_pw_error() const case ERR_PACK(ERR_LIB_PEM, 0, PEM_R_BAD_DECRYPT): case ERR_PACK(ERR_LIB_PEM, 0, PEM_R_BAD_PASSWORD_READ): case ERR_PACK(ERR_LIB_EVP, 0, EVP_R_BAD_DECRYPT): -#if (OPENSSL_VERSION_NUMBER >= 0x30000000L) case ERR_PACK(ERR_LIB_PROV, 0, PROV_R_BAD_DECRYPT): -#endif case ERR_PACK(ERR_LIB_PKCS12, 0, PKCS12_R_PKCS12_CIPHERFINAL_ERROR): pki_ign_openssl_error(); return true; diff --git a/misc/dynamic.wxs.in b/misc/dynamic.wxs.in index bd3d6f03..cab0505c 100644 --- a/misc/dynamic.wxs.in +++ b/misc/dynamic.wxs.in @@ -4,7 +4,7 @@ - + diff --git a/test/main.cpp b/test/main.cpp index ecd09118..9e90185d 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -9,11 +9,7 @@ #include #include -#if (OPENSSL_VERSION_NUMBER >= 0x30000000L) #include -#else -#define OSSL_PROVIDER_try_load(a,b,c) do{}while(0) -#endif #include "widgets/MainWindow.h" #include "ui_MainWindow.h"