Skip to content

Commit

Permalink
requires openssl minimum version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenml committed Oct 28, 2024
1 parent f257eef commit e527e57
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 47 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2.1.0 not released

* requires OpenSSL minimum version 1.1.0 with SNI support
* try harder to bind TCP and UDP sockets to the same port
* made disk_interface's status_t type a flags type
* optimize resume data format to use less space
Expand Down
8 changes: 0 additions & 8 deletions src/ed25519/hasher512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ namespace libtorrent::aux {
#elif TORRENT_USE_CNG
#elif TORRENT_USE_CRYPTOAPI_SHA_512
#elif defined TORRENT_USE_LIBCRYPTO
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
m_context = EVP_MD_CTX_new();
#else
m_context = EVP_MD_CTX_create();
#endif
EVP_DigestInit_ex(m_context, EVP_sha512(), nullptr);
#else
SHA512_init(&m_context);
Expand Down Expand Up @@ -176,11 +172,7 @@ namespace libtorrent::aux {
#if defined TORRENT_USE_LIBGCRYPT
gcry_md_close(m_context);
#elif defined TORRENT_USE_LIBCRYPTO
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
if (m_context) EVP_MD_CTX_free(m_context);
#else
if (m_context) EVP_MD_CTX_destroy(m_context);
#endif
#endif
}

Expand Down
16 changes: 0 additions & 16 deletions src/hasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ TORRENT_CRYPTO_NAMESPACE
#elif TORRENT_USE_CNG
#elif TORRENT_USE_CRYPTOAPI
#elif defined TORRENT_USE_LIBCRYPTO
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
m_context = EVP_MD_CTX_new();
#else
m_context = EVP_MD_CTX_create();
#endif
EVP_DigestInit_ex(m_context, EVP_sha1(), nullptr);
#else
aux::SHA1_init(&m_context);
Expand Down Expand Up @@ -173,11 +169,7 @@ TORRENT_CRYPTO_NAMESPACE
#if defined TORRENT_USE_LIBGCRYPT
gcry_md_close(m_context);
#elif defined TORRENT_USE_LIBCRYPTO
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
if (m_context) EVP_MD_CTX_free(m_context);
#else
if (m_context) EVP_MD_CTX_destroy(m_context);
#endif
#endif
}

Expand All @@ -190,11 +182,7 @@ TORRENT_CRYPTO_NAMESPACE
#elif TORRENT_USE_CNG
#elif TORRENT_USE_CRYPTOAPI_SHA_512
#elif defined TORRENT_USE_LIBCRYPTO
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
m_context = EVP_MD_CTX_new();
#else
m_context = EVP_MD_CTX_create();
#endif
EVP_DigestInit_ex(m_context, EVP_sha256(), nullptr);
#else
aux::SHA256_init(m_context);
Expand Down Expand Up @@ -330,11 +318,7 @@ TORRENT_CRYPTO_NAMESPACE
#if defined TORRENT_USE_LIBGCRYPT
gcry_md_close(m_context);
#elif defined TORRENT_USE_LIBCRYPTO
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
if (m_context) EVP_MD_CTX_free(m_context);
#else
if (m_context) EVP_MD_CTX_destroy(m_context);
#endif
#endif
}

Expand Down
25 changes: 2 additions & 23 deletions src/ssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,32 +155,11 @@ namespace {
{
lifecycle()
{
// this is needed for openssl < 1.0 to decrypt keys created by openssl 1.0+
#if !defined(OPENSSL_API_COMPAT) || (OPENSSL_API_COMPAT < 0x10100000L)
OpenSSL_add_all_algorithms();
#else
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS, nullptr);
#endif
}

~lifecycle()
{
// by openssl changelog at https://www.openssl.org/news/changelog.html
// Changes between 1.0.2h and 1.1.0 [25 Aug 2016]
// - Most global cleanup functions are no longer required because they are handled
// via auto-deinit. Affected function CRYPTO_cleanup_all_ex_data()
#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < 0x10100000L
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
// openssl requires this to clean up internal structures it allocates
CRYPTO_cleanup_all_ex_data();
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic pop
#endif
#endif
}
// put openssl cleanup code here if necessary
~lifecycle() = default;
} global;
}
#endif
Expand Down

0 comments on commit e527e57

Please sign in to comment.