mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 21:12:28 +00:00
Fixed compilation for older (pre-3.0.0) OpenSSL versions
This commit is contained in:
parent
7cc4118dab
commit
bdaa012239
@ -7,6 +7,18 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
void CipherDeleter(const EVP_CIPHER * cipher [[maybe_unused]])
|
||||||
|
{
|
||||||
|
#if OPENSSL_VERSION_NUMBER >= 0x03 << 28
|
||||||
|
// Used to free EVP_CIPHER poniter obtained with EVP_CIPHER_fetch,
|
||||||
|
// available only since OpenSSL ver 3.0.0.
|
||||||
|
EVP_CIPHER_free(const_cast<EVP_CIPHER*>(cipher));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
namespace ErrorCodes
|
namespace ErrorCodes
|
||||||
@ -49,10 +61,14 @@ CipherPtr getCipherByName(const StringRef & cipher_name)
|
|||||||
evp_cipher = EVP_aes_256_cfb128();
|
evp_cipher = EVP_aes_256_cfb128();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OPENSSL_VERSION_NUMBER < 0x03 << 28
|
||||||
|
return CipherPtr{evp_cipher, CipherDeleter};
|
||||||
|
#else
|
||||||
// HACK: To speed up context initialization with EVP_EncryptInit_ex (which is called at least once per row)
|
// HACK: To speed up context initialization with EVP_EncryptInit_ex (which is called at least once per row)
|
||||||
// Apparently cipher from EVP_get_cipherbyname may require additional initialization of context,
|
// Apparently cipher from EVP_get_cipherbyname may require additional initialization of context,
|
||||||
// while cipher from EVP_CIPHER_fetch causes less operations => faster context initialization.
|
// while cipher from EVP_CIPHER_fetch causes less operations => faster context initialization.
|
||||||
return CipherPtr{EVP_CIPHER_fetch(nullptr, EVP_CIPHER_name(evp_cipher), nullptr), &EVP_CIPHER_free};
|
return CipherPtr{EVP_CIPHER_fetch(nullptr, EVP_CIPHER_name(evp_cipher), nullptr), &CipherDeleter};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,8 @@ namespace OpenSSLDetails
|
|||||||
[[noreturn]] void onError(std::string error_message);
|
[[noreturn]] void onError(std::string error_message);
|
||||||
StringRef foldEncryptionKeyInMySQLCompatitableMode(size_t cipher_key_size, const StringRef & key, std::array<char, EVP_MAX_KEY_LENGTH> & folded_key);
|
StringRef foldEncryptionKeyInMySQLCompatitableMode(size_t cipher_key_size, const StringRef & key, std::array<char, EVP_MAX_KEY_LENGTH> & folded_key);
|
||||||
|
|
||||||
using CipherPtr = std::unique_ptr<EVP_CIPHER, decltype(&::EVP_CIPHER_free)>;
|
using CipherDeleterType = void (*) (const EVP_CIPHER *cipher);
|
||||||
|
using CipherPtr = std::unique_ptr<const EVP_CIPHER, CipherDeleterType>;
|
||||||
CipherPtr getCipherByName(const StringRef & name);
|
CipherPtr getCipherByName(const StringRef & name);
|
||||||
|
|
||||||
enum class CompatibilityMode
|
enum class CompatibilityMode
|
||||||
|
Loading…
Reference in New Issue
Block a user