diff --git a/crypto/mmohash.cpp b/crypto/mmohash.cpp index b8e13fe009..bbbdba2fe1 100644 --- a/crypto/mmohash.cpp +++ b/crypto/mmohash.cpp @@ -1,8 +1,19 @@ +/* + * Copyright (c) 2021-2024 dresden elektronik ingenieurtechnik gmbh. + * All rights reserved. + * + * The software in this package is published under the terms of the BSD + * style license a copy of which has been included with this distribution in + * the LICENSE.txt file. + * + */ + +#include "deconz/u_library_ex.h" +#include "deconz/u_memory.h" #include "crypto/mmohash.h" #ifdef HAS_OPENSSL -#include #include #define AES_BLOCK_SIZE 16 @@ -29,7 +40,7 @@ static bool aesMmoHash(unsigned char *result, unsigned char *data, unsigned data unsigned char block[AES_BLOCK_SIZE]; unsigned char encrypted_block[AES_BLOCK_SIZE * 2] = {0}; - memcpy(&block[0], &data[0], AES_BLOCK_SIZE); + U_memcpy(&block[0], &data[0], AES_BLOCK_SIZE); int outlen = 0; if (lib_EVP_EncryptUpdate(lib_ctx, &encrypted_block[0], &outlen, &block[0], AES_BLOCK_SIZE) != 1) @@ -98,20 +109,19 @@ static unsigned short ccit_crc16(unsigned char *data_p, unsigned short length) */ bool CRYPTO_GetMmoHashFromInstallCode(const std::string &hexString, std::vector &result) { -#ifdef Q_OS_WIN - QLibrary libCrypto(QLatin1String("libcrypto-1_1.dll")); -#elif defined (__APPLE__) - QLibrary libCrypto(QLatin1String("../Frameworks/libcrypto.3.dylib")); -#else - QLibrary libCrypto("crypto"); -#endif - - lib_EVP_CIPHER_CTX_new = (EVP_CIPHER_CTX *(*)(void))libCrypto.resolve("EVP_CIPHER_CTX_new"); - lib_EVP_EncryptInit = (void (*)(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, const unsigned char *key, const unsigned char *iv))libCrypto.resolve("EVP_EncryptInit"); - lib_EVP_EncryptUpdate = (int (*)(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl))libCrypto.resolve("EVP_EncryptUpdate"); - lib_EVP_EncryptFinal_ex = (int (*)(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl))libCrypto.resolve("EVP_EncryptFinal_ex"); - lib_EVP_CIPHER_CTX_free = (void (*)(EVP_CIPHER_CTX *ctx))libCrypto.resolve("EVP_CIPHER_CTX_free"); - lib_EVP_aes_128_ecb = (const EVP_CIPHER *(*)(void))libCrypto.resolve("EVP_aes_128_ecb"); + void *libCrypto = U_library_open_ex("libcrypto"); + + if (!libCrypto) + { + return false; + } + + lib_EVP_CIPHER_CTX_new = (EVP_CIPHER_CTX *(*)(void))U_library_symbol(libCrypto, "EVP_CIPHER_CTX_new"); + lib_EVP_EncryptInit = (void (*)(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, const unsigned char *key, const unsigned char *iv))U_library_symbol(libCrypto, "EVP_EncryptInit"); + lib_EVP_EncryptUpdate = (int (*)(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl))U_library_symbol(libCrypto, "EVP_EncryptUpdate"); + lib_EVP_EncryptFinal_ex = (int (*)(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl))U_library_symbol(libCrypto, "EVP_EncryptFinal_ex"); + lib_EVP_CIPHER_CTX_free = (void (*)(EVP_CIPHER_CTX *ctx))U_library_symbol(libCrypto, "EVP_CIPHER_CTX_free"); + lib_EVP_aes_128_ecb = (const EVP_CIPHER *(*)(void))U_library_symbol(libCrypto, "EVP_aes_128_ecb"); if (!lib_EVP_CIPHER_CTX_new || !lib_EVP_EncryptInit || !lib_EVP_EncryptUpdate || !lib_EVP_EncryptFinal_ex || !lib_EVP_CIPHER_CTX_free | !lib_EVP_aes_128_ecb) { @@ -195,7 +205,7 @@ bool CRYPTO_GetMmoHashFromInstallCode(const std::string &hexString, std::vector< if (AES_BLOCK_SIZE - moreDataLength < 3) { aesMmoHash(hashResult, &temp[0], AES_BLOCK_SIZE); - memset(&temp[0], 0x00, sizeof(temp)); + U_memset(&temp[0], 0x00, sizeof(temp)); } temp[AES_BLOCK_SIZE - 2] = (dataLength >> 5) & 0xFF; diff --git a/crypto/random.cpp b/crypto/random.cpp index f4201431bd..2b1d3ef938 100644 --- a/crypto/random.cpp +++ b/crypto/random.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 dresden elektronik ingenieurtechnik gmbh. + * Copyright (c) 2021-2024 dresden elektronik ingenieurtechnik gmbh. * All rights reserved. * * The software in this package is published under the terms of the BSD @@ -9,82 +9,13 @@ */ #include -#include #include "random.h" +#include "deconz/u_library_ex.h" // OpenSSL reference to RAND_bytes() typedef int (*RAND_bytes_t)(unsigned char *buf, int num); static RAND_bytes_t RAND_bytes = nullptr; -#ifdef __linux__ -#include - -/*! RAII helper to open/close OpenSSL. - */ -class RNGLib -{ -public: - RNGLib() - { - handle = dlopen("libcrypto.so", RTLD_LAZY); - - if (handle) - { - RAND_bytes = reinterpret_cast(dlsym(handle, "RAND_bytes")); - } - } - - ~RNGLib() - { - RAND_bytes = nullptr; - if (handle) - { - dlclose(handle); - } - } - -private: - void *handle = nullptr; -}; -#endif - -#ifdef __APPLE__ -class RNGLib -{ -}; -#endif - -#ifdef _WIN32 -#include -/*! RAII helper to open/close OpenSSL. - */ -class RNGLib -{ -public: - RNGLib() - { - handle = LoadLibraryA("libcrypto-1_1.dll"); - - if (handle) - { - RAND_bytes = reinterpret_cast(GetProcAddress(handle, "RAND_bytes")); - } - } - - ~RNGLib() - { - RAND_bytes = nullptr; - if (handle) - { - FreeLibrary(handle); - } - } - -private: - HMODULE handle = nullptr; -}; -#endif - /*! Fallback to C++ random number generator if OpenSSL isn't available. */ void fallbackRandom(unsigned char *buf, unsigned int size) @@ -103,7 +34,14 @@ void fallbackRandom(unsigned char *buf, unsigned int size) */ void CRYPTO_RandomBytes(unsigned char *buf, unsigned int size) { - RNGLib lib; + if (!RAND_bytes) + { + void *libCrypto = U_library_open_ex("libcrypto"); + if (libCrypto) + { + RAND_bytes = reinterpret_cast(U_library_symbol(libCrypto, "RAND_bytes")); + } + } if (RAND_bytes && RAND_bytes(buf, int(size)) == 1) { diff --git a/crypto/scrypt.cpp b/crypto/scrypt.cpp index 1133866952..c454d0a3bc 100644 --- a/crypto/scrypt.cpp +++ b/crypto/scrypt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 dresden elektronik ingenieurtechnik gmbh. + * Copyright (c) 2021-2024 dresden elektronik ingenieurtechnik gmbh. * All rights reserved. * * The software in this package is published under the terms of the BSD @@ -17,9 +17,11 @@ #endif #include -#include +#include +#include #include "random.h" #include "scrypt.h" +#include "deconz/u_library_ex.h" #ifdef HAS_OPENSSL @@ -63,35 +65,32 @@ static int wrap_EVP_PKEY_CTX_set_scrypt_p(EVP_PKEY_CTX *ctx, uint64_t p) */ static int scryptDerive(const char *input, size_t inputLength, std::array &out, int N, int r, int p, const unsigned char *salt, size_t saltlen) { -#ifdef Q_OS_WIN - QLibrary libCrypto(QLatin1String("libcrypto-1_1.dll")); - QLibrary libSsl(QLatin1String("libssl-1_1.dll")); -#elif defined (__APPLE__) - QLibrary libCrypto(QLatin1String("../Frameworks/libcrypto.3.dylib")); - QLibrary libSsl(QLatin1String("../Frameworks/libssl.3.dylib")); -#else - QLibrary libCrypto(QLatin1String("crypto")); - QLibrary libSsl(QLatin1String("ssl")); -#endif + void *libCrypto = U_library_open_ex("libcrypto"); + void *libSsl = U_library_open_ex("libssl"); + + if (!libCrypto || !libSsl) + { + return -1; + } unsigned long openSslVersion = 0; - auto _OpenSSL_version_num = reinterpret_cast(libCrypto.resolve("OpenSSL_version_num")); + auto _OpenSSL_version_num = reinterpret_cast(U_library_symbol(libCrypto, "OpenSSL_version_num")); - const auto lib_EVP_PKEY_CTX_new_id = reinterpret_cast(libCrypto.resolve("EVP_PKEY_CTX_new_id")); - const auto lib_EVP_PKEY_derive_init = reinterpret_cast(libCrypto.resolve("EVP_PKEY_derive_init")); - lib_EVP_PKEY_CTX_ctrl = reinterpret_cast(libCrypto.resolve("EVP_PKEY_CTX_ctrl")); - lib_EVP_PKEY_CTX_ctrl_uint64 = reinterpret_cast(libCrypto.resolve("EVP_PKEY_CTX_ctrl_uint64")); - const auto lib_EVP_PKEY_derive = reinterpret_cast(libCrypto.resolve("EVP_PKEY_derive")); - const auto lib_EVP_PKEY_CTX_free = reinterpret_cast(libCrypto.resolve("EVP_PKEY_CTX_free")); + const auto lib_EVP_PKEY_CTX_new_id = reinterpret_cast(U_library_symbol(libCrypto, "EVP_PKEY_CTX_new_id")); + const auto lib_EVP_PKEY_derive_init = reinterpret_cast(U_library_symbol(libCrypto, "EVP_PKEY_derive_init")); + lib_EVP_PKEY_CTX_ctrl = reinterpret_cast(U_library_symbol(libCrypto, "EVP_PKEY_CTX_ctrl")); + lib_EVP_PKEY_CTX_ctrl_uint64 = reinterpret_cast(U_library_symbol(libCrypto, "EVP_PKEY_CTX_ctrl_uint64")); + const auto lib_EVP_PKEY_derive = reinterpret_cast(U_library_symbol(libCrypto, "EVP_PKEY_derive")); + const auto lib_EVP_PKEY_CTX_free = reinterpret_cast(U_library_symbol(libCrypto, "EVP_PKEY_CTX_free")); - auto lib_EVP_PKEY_CTX_set1_pbe_pass = reinterpret_cast(libCrypto.resolve("EVP_PKEY_CTX_set1_pbe_pass")); + auto lib_EVP_PKEY_CTX_set1_pbe_pass = reinterpret_cast(U_library_symbol(libCrypto, "EVP_PKEY_CTX_set1_pbe_pass")); - auto lib_EVP_PKEY_CTX_set1_scrypt_salt = reinterpret_cast(libCrypto.resolve("EVP_PKEY_CTX_set1_scrypt_salt")); + auto lib_EVP_PKEY_CTX_set1_scrypt_salt = reinterpret_cast(U_library_symbol(libCrypto, "EVP_PKEY_CTX_set1_scrypt_salt")); - auto lib_EVP_PKEY_CTX_set_scrypt_N = reinterpret_cast(libCrypto.resolve("EVP_PKEY_CTX_set_scrypt_N")); - auto lib_EVP_PKEY_CTX_set_scrypt_r = reinterpret_cast(libCrypto.resolve("EVP_PKEY_CTX_set_scrypt_r")); - auto lib_EVP_PKEY_CTX_set_scrypt_p = reinterpret_cast(libCrypto.resolve("EVP_PKEY_CTX_set_scrypt_p")); + auto lib_EVP_PKEY_CTX_set_scrypt_N = reinterpret_cast(U_library_symbol(libCrypto, "EVP_PKEY_CTX_set_scrypt_N")); + auto lib_EVP_PKEY_CTX_set_scrypt_r = reinterpret_cast(U_library_symbol(libCrypto, "EVP_PKEY_CTX_set_scrypt_r")); + auto lib_EVP_PKEY_CTX_set_scrypt_p = reinterpret_cast(U_library_symbol(libCrypto, "EVP_PKEY_CTX_set_scrypt_p")); if (_OpenSSL_version_num) { diff --git a/de_web.pro b/de_web.pro deleted file mode 100644 index 1796862a4d..0000000000 --- a/de_web.pro +++ /dev/null @@ -1,321 +0,0 @@ -TARGET = de_rest_plugin - -# common configuration for deCONZ plugins - -TARGET = $$qtLibraryTarget($$TARGET) - -DEFINES += USE_ULIB_SHARED=1 - -# select Javascript engine -#DEFINES += USE_QT_JS_ENGINE -DEFINES += USE_DUKTAPE_JS_ENGINE - -QMAKE_CXXFLAGS += -Wno-attributes \ - -Wno-psabi \ - -Wall - -CONFIG(debug, debug|release) { - LIBS += -L../../debug - DEFINES += DECONZ_DEBUG_BUILD -} - -CONFIG(release, debug|release) { - LIBS += -L../../release -} - -equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 15) { - DEFINES += SKIP_EMPTY_PARTS=QString::SkipEmptyParts -} else { - DEFINES += SKIP_EMPTY_PARTS=Qt::SkipEmptyParts -} - -greaterThan(QT_MAJOR_VERSION, 4) { - QT += core gui widgets serialport - - greaterThan(QT_MINOR_VERSION, 2) { - DEFINES += USE_WEBSOCKETS - QT += websockets - } -} - -QMAKE_SPEC_T = $$[QMAKE_SPEC] - -contains(QMAKE_SPEC_T,.*linux.*) { - CONFIG += link_pkgconfig - packagesExist(sqlite3) { - DEFINES += HAS_SQLITE3 - PKGCONFIG += sqlite3 - } - - packagesExist(openssl) { - DEFINES += HAS_OPENSSL - #PKGCONFIG += openssl - } -} - -macx { - DEFINES += QT_NO_DEPRECATED_WARNINGS - CONFIG+=sdk_no_version_check - - LIBS += -lsqlite3 - DEFINES += HAS_SQLITE3 -} - -unix:LIBS += -L../.. -ldeCONZ - -unix:!macx { - LIBS += -lcrypt -} - -TEMPLATE = lib -CONFIG += plugin \ - += debug_and_release \ - += c++14 \ - -= qtquickcompiler - -QT += network -#QT += qml - -INCLUDEPATH += ../../lib - -# TAG is specified by auto build system -# this is needed since non head versions which are checkedout and build -# will have a revision different to HEAD -GIT_TAG=$$TAG - -isEmpty(GIT_TAG) { - GIT_TAG=HEAD # default -} - -GIT_COMMIT = $$system("git rev-list $$GIT_TAG --max-count=1") -GIT_COMMIT_DATE = $$system("git show -s --format=%ct $$GIT_TAG") - -# Version Major.Minor.Build -# Important: don't change the format of this line since it's parsed by scripts! -DEFINES += GW_SW_VERSION=\\\"2.26.03\\\" -DEFINES += GW_SW_DATE=$$GIT_COMMIT_DATE -DEFINES += GW_API_VERSION=\\\"1.16.0\\\" -DEFINES += GIT_COMMMIT=\\\"$$GIT_COMMIT\\\" - -# Minimum version of the RaspBee firmware -# which shall be used in order to support all features for this software release (case sensitive) -DEFINES += GW_AUTO_UPDATE_AVR_FW_VERSION=0x260b0500 -DEFINES += GW_AUTO_UPDATE_R21_FW_VERSION=0x26420700 -DEFINES += GW_MIN_AVR_FW_VERSION=0x26400500 -DEFINES += GW_MIN_R21_FW_VERSION=0x26720700 - -# Minimum version of the deRFusb23E0X firmware -# which shall be used in order to support all features for this software release -DEFINES += GW_MIN_DERFUSB23E0X_FW_VERSION=0x22030300 - -DEFINES += GW_DEFAULT_NAME=\\\"Phoscon-GW\\\" - -HEADERS = bindings.h \ - air_quality.h \ - alarm_system.h \ - alarm_system_device_table.h \ - alarm_system_event_handler.h \ - aps_controller_wrapper.h \ - backup.h \ - button_maps.h \ - colorspace.h \ - crypto/mmohash.h \ - crypto/password.h \ - crypto/random.h \ - crypto/scrypt.h \ - database.h \ - daylight.h \ - de_web_plugin.h \ - de_web_plugin_private.h \ - de_web_widget.h \ - device.h \ - device_access_fn.h \ - device_compat.h \ - device_ddf_init.h \ - device_descriptions.h \ - device_js/device_js.h \ - device_js/device_js_duktape.h \ - device_js/device_js_wrappers.h \ - device_tick.h \ - event.h \ - event_emitter.h \ - fan_control.h \ - gateway.h \ - gateway_scanner.h \ - green_power.h \ - group.h \ - group_info.h \ - json.h \ - ias_ace.h \ - ias_zone.h \ - light_node.h \ - poll_control.h \ - poll_manager.h \ - product_match.h \ - read_files.h \ - resource.h \ - resourcelinks.h \ - rest_alarmsystems.h \ - rest_devices.h \ - rest_node_base.h \ - rule.h \ - scene.h \ - sensor.h \ - state_change.h \ - simple_metering.h \ - thermostat.h \ - thermostat_ui_configuration.h \ - tuya.h \ - ui/ddf_bindingeditor.h \ - ui/ddf_editor.h \ - ui/ddf_itemeditor.h \ - ui/ddf_itemlist.h \ - ui/ddf_treeview.h \ - ui/device_widget.h \ - ui/text_lineedit.h \ - utils/bufstring.h \ - utils/stringcache.h \ - utils/utils.h \ - websocket_server.h \ - xiaomi.h \ - zcl/zcl.h \ - zdp/zdp.h \ - zdp/zdp_handlers.h - -SOURCES = air_quality.cpp \ - alarm_system.cpp \ - alarm_system_device_table.cpp \ - alarm_system_event_handler.cpp \ - aps_controller_wrapper.cpp \ - authorisation.cpp \ - backup.cpp \ - bindings.cpp \ - button_maps.cpp \ - change_channel.cpp \ - colorspace.cpp \ - crypto/mmohash.cpp \ - crypto/password.cpp \ - crypto/random.cpp \ - crypto/scrypt.cpp \ - database.cpp \ - daylight.cpp \ - device.cpp \ - device_access_fn.cpp \ - device_compat.cpp \ - device_ddf_init.cpp \ - device_descriptions.cpp \ - device_js/device_js.cpp \ - device_js/device_js_duktape.cpp \ - device_js/device_js_wrappers.cpp \ - device_js/duktape.c \ - device_tick.cpp \ - discovery.cpp \ - de_web_plugin.cpp \ - de_web_widget.cpp \ - de_otau.cpp \ - electrical_measurement.cpp \ - event.cpp \ - event_emitter.cpp \ - event_queue.cpp \ - fan_control.cpp \ - firmware_update.cpp \ - gateway.cpp \ - gateway_scanner.cpp \ - green_power.cpp \ - group.cpp \ - group_info.cpp \ - gw_uuid.cpp \ - hue.cpp \ - ias_ace.cpp \ - ias_zone.cpp \ - identify.cpp \ - json.cpp \ - light_node.cpp \ - occupancy_sensing.cpp \ - poll_control.cpp \ - poll_manager.cpp \ - power_configuration.cpp \ - product_match.cpp \ - read_files.cpp \ - resource.cpp \ - resourcelinks.cpp \ - rest_alarmsystems.cpp \ - rest_configuration.cpp \ - rest_devices.cpp \ - rest_gateways.cpp \ - rest_groups.cpp \ - rest_lights.cpp \ - rest_node_base.cpp \ - rest_resourcelinks.cpp \ - rest_rules.cpp \ - rest_sensors.cpp \ - rest_schedules.cpp \ - rest_touchlink.cpp \ - rest_scenes.cpp \ - rest_info.cpp \ - rest_capabilities.cpp \ - rule.cpp \ - state_change.cpp \ - thermostat_ui_configuration.cpp \ - ui/ddf_bindingeditor.cpp \ - ui/ddf_editor.cpp \ - ui/ddf_itemeditor.cpp \ - ui/ddf_itemlist.cpp \ - ui/ddf_treeview.cpp \ - ui/device_widget.cpp \ - ui/text_lineedit.cpp \ - upnp.cpp \ - permitJoin.cpp \ - scene.cpp \ - sensor.cpp \ - simple_metering.cpp \ - thermostat.cpp \ - time.cpp \ - tuya.cpp \ - basic.cpp \ - appliances.cpp \ - reset_device.cpp \ - rest_userparameter.cpp \ - utils/bufstring.cpp \ - utils/stringcache.cpp \ - utils/utils.cpp \ - xiaomi.cpp \ - window_covering.cpp \ - websocket_server.cpp \ - xmas.cpp \ - zcl/zcl.cpp \ - zcl_tasks.cpp \ - zdp/zdp.cpp \ - zdp/zdp_handlers.cpp - -win32 { - - OPENSSL_PATH = C:/Qt/Tools/OpenSSL/Win_x86 - - exists($$OPENSSL_PATH) { - message(OpenSLL detected $$OPENSSL_PATH) - - #LIBS += -L$$OPENSSL_PATH/bin \ - # -llibcrypto-1_1 \ - # -llibssl-1_1 - INCLUDEPATH += $$OPENSSL_PATH/include - DEFINES += HAS_OPENSSL - } - - LIBS += \ - -L../.. \ - -L$${PWD}/../../../lib/sqlite-dll-win32-x86-3270200 \ - -ldeCONZ1 \ - -lsqlite3 - - INCLUDEPATH += $${PWD}/../../../lib/sqlite-amalgamation-3270200 - CONFIG += dll -} - -win32:DESTDIR = ../../debug/plugins # TODO adjust -unix:DESTDIR = .. - -FORMS += \ - de_web_widget.ui \ - ui/ddf_editor.ui \ - ui/device_widget.ui diff --git a/green_power.cpp b/green_power.cpp index f98fad0704..5118d74dbe 100644 --- a/green_power.cpp +++ b/green_power.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021 dresden elektronik ingenieurtechnik gmbh. + * Copyright (c) 2020-2024 dresden elektronik ingenieurtechnik gmbh. * All rights reserved. * * The software in this package is published under the terms of the BSD @@ -8,7 +8,6 @@ * */ -#include #include #ifdef HAS_OPENSSL @@ -29,6 +28,7 @@ #include "deconz/dbg_trace.h" #include "deconz/green_power.h" #include "deconz/zcl.h" +#include "deconz/u_library_ex.h" #include "green_power.h" #include "resource.h" @@ -49,6 +49,8 @@ GpKey_t GP_DecryptSecurityKey(quint32 sourceID, const GpKey_t &securityKey) GpKey_t result = { 0 }; #ifdef HAS_RECENT_OPENSSL + void *libCrypto = nullptr; + void *libSsl = nullptr; const unsigned char defaultTCLinkKey[] = { 0x5A, 0x69, 0x67, 0x42, 0x65, 0x65, 0x41, 0x6C, 0x6C, 0x69, 0x61, 0x6E, 0x63, 0x65, 0x30, 0x39 }; unsigned char nonce[13]; // u8 source address, u32 frame counter, u8 security control @@ -69,18 +71,10 @@ GpKey_t GP_DecryptSecurityKey(quint32 sourceID, const GpKey_t &securityKey) nonce[12] = 0x05; -#ifdef Q_OS_WIN - QLibrary libCrypto(QLatin1String("libcrypto-1_1.dll")); - QLibrary libSsl(QLatin1String("libssl-1_1.dll")); -#elif defined (__APPLE__) - QLibrary libCrypto(QLatin1String("../Frameworks/libcrypto.3.dylib")); - QLibrary libSsl(QLatin1String("../Frameworks/libssl.3.dylib")); -#else - QLibrary libCrypto(QLatin1String("crypto")); - QLibrary libSsl(QLatin1String("ssl")); -#endif + libCrypto = U_library_open_ex("libcrypto"); + libSsl = U_library_open_ex("libssl"); - if (!libCrypto.load() || !libSsl.load()) + if (!libCrypto || !libSsl) { DBG_Printf(DBG_ZGP, "[ZGP] OpenSSl library for ZGP encryption not found\n"); return result; @@ -88,13 +82,13 @@ GpKey_t GP_DecryptSecurityKey(quint32 sourceID, const GpKey_t &securityKey) unsigned long openSslVersion = 0; - auto _OpenSSL_version_num = reinterpret_cast(libCrypto.resolve("OpenSSL_version_num")); - const auto _EVP_CIPHER_CTX_new = reinterpret_cast(libCrypto.resolve("EVP_CIPHER_CTX_new")); - const auto _EVP_EncryptInit_ex = reinterpret_cast(libCrypto.resolve("EVP_EncryptInit_ex")); - const auto _EVP_CIPHER_CTX_ctrl = reinterpret_cast(libCrypto.resolve("EVP_CIPHER_CTX_ctrl")); - const auto _EVP_EncryptUpdate = reinterpret_cast(libCrypto.resolve("EVP_EncryptUpdate")); - const auto _EVP_CIPHER_CTX_free = reinterpret_cast(libCrypto.resolve("EVP_CIPHER_CTX_free")); - const auto _EVP_aes_128_ccm = reinterpret_cast(libCrypto.resolve("EVP_aes_128_ccm")); + auto _OpenSSL_version_num = reinterpret_cast(U_library_symbol(libCrypto, "OpenSSL_version_num")); + const auto _EVP_CIPHER_CTX_new = reinterpret_cast(U_library_symbol(libCrypto, "EVP_CIPHER_CTX_new")); + const auto _EVP_EncryptInit_ex = reinterpret_cast(U_library_symbol(libCrypto, "EVP_EncryptInit_ex")); + const auto _EVP_CIPHER_CTX_ctrl = reinterpret_cast(U_library_symbol(libCrypto, "EVP_CIPHER_CTX_ctrl")); + const auto _EVP_EncryptUpdate = reinterpret_cast(U_library_symbol(libCrypto, "EVP_EncryptUpdate")); + const auto _EVP_CIPHER_CTX_free = reinterpret_cast(U_library_symbol(libCrypto, "EVP_CIPHER_CTX_free")); + const auto _EVP_aes_128_ccm = reinterpret_cast(U_library_symbol(libCrypto, "EVP_aes_128_ccm")); if (_OpenSSL_version_num) {