diff --git a/.ci/build-openssl.sh b/.ci/build-openssl.sh index e52943df..e483f778 100755 --- a/.ci/build-openssl.sh +++ b/.ci/build-openssl.sh @@ -12,7 +12,7 @@ build_openssl () { if [[ "$(cat ${OPENSSL_INSTALL_DIR}/.openssl-version)" != "${OPENSSL_VERSION}" ]]; then tar zxf "download-cache/openssl-${OPENSSL_VERSION}.tar.gz" cd "openssl-${OPENSSL_VERSION}/" - ./config shared --prefix="${OPENSSL_INSTALL_DIR}" --openssldir="${OPENSSL_INSTALL_DIR}" -DPURIFY + ./config shared no-deprecated --prefix="${OPENSSL_INSTALL_DIR}" --openssldir="${OPENSSL_INSTALL_DIR}" -DPURIFY make -j $(nproc || sysctl -n hw.ncpu || echo 4) all make install_sw echo "${OPENSSL_VERSION}" > "${OPENSSL_INSTALL_DIR}/.openssl-version" diff --git a/src/Mayaqua/Encrypt.c b/src/Mayaqua/Encrypt.c index 5901f0cc..de74c531 100644 --- a/src/Mayaqua/Encrypt.c +++ b/src/Mayaqua/Encrypt.c @@ -758,10 +758,18 @@ BUF *BigNumToBuf(const BIGNUM *bn) return b; } +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) +// Return the thread ID +static void OpenSSL_Id(CRYPTO_THREADID *id) +{ + CRYPTO_THREADID_set_numeric(id, (unsigned long)ThreadId()); +} +#endif + // Initialization of the lock of OpenSSL void OpenSSL_InitLock() { -#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) UINT i; // Initialization of the lock object @@ -774,14 +782,14 @@ void OpenSSL_InitLock() // Setting the lock function CRYPTO_set_locking_callback(OpenSSL_Lock); - CRYPTO_set_id_callback(OpenSSL_Id); + CRYPTO_THREADID_set_callback(OpenSSL_Id); #endif } // Release of the lock of OpenSSL void OpenSSL_FreeLock() { -#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) UINT i; for (i = 0;i < ssl_lock_num;i++) @@ -792,14 +800,14 @@ void OpenSSL_FreeLock() ssl_lock_obj = NULL; CRYPTO_set_locking_callback(NULL); - CRYPTO_set_id_callback(NULL); + CRYPTO_THREADID_set_callback(NULL); #endif } // Lock function for OpenSSL void OpenSSL_Lock(int mode, int n, const char *file, int line) { -#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) LOCK *lock = ssl_lock_obj[n]; if (mode & CRYPTO_LOCK) @@ -815,12 +823,6 @@ void OpenSSL_Lock(int mode, int n, const char *file, int line) #endif } -// Return the thread ID -unsigned long OpenSSL_Id(void) -{ - return (unsigned long)ThreadId(); -} - char *OpenSSL_Error() { return ERR_error_string(ERR_get_error(), NULL); @@ -3729,7 +3731,7 @@ void FreeCryptLibrary() openssl_lock = NULL; // RAND_Free_For_SoftEther(); OpenSSL_FreeLock(); -#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) #ifdef OPENSSL_FIPS FIPS_mode_set(0); #endif @@ -3754,7 +3756,7 @@ void InitCryptLibrary() { char tmp[16]; -#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) // RAND_Init_For_SoftEther() openssl_lock = NewLock(); SSL_library_init(); diff --git a/src/Mayaqua/Encrypt.h b/src/Mayaqua/Encrypt.h index 2cc05c29..dc82c562 100644 --- a/src/Mayaqua/Encrypt.h +++ b/src/Mayaqua/Encrypt.h @@ -416,7 +416,6 @@ bool IsAesNiSupported(); void OpenSSL_InitLock(); void OpenSSL_FreeLock(); void OpenSSL_Lock(int mode, int n, const char *file, int line); -unsigned long OpenSSL_Id(void); void FreeOpenSSLThreadState(); char *OpenSSL_Error();