endif()
option(ENABLE_MEMASLAP "enable memaslap client"
$ENV{ENABLE_MEMASLAP})
+option(ENABLE_OPENSSL_CRYPTO
+ "enable OpenSSL's libcrypto instead of bundled AES implementation"
+ $ENV{ENABLE_OPENSSL_CRYPTO})
if(BUILD_TESTING)
set(MEMCACHED_BINARY "$ENV{MEMCACHED_BINARY}"
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
-find_package(OpenSSL)
-if(NOT OPENSSL_FOUND)
- message(WARNING "crypto library not found")
-else()
- add_compile_definitions(WITH_OPENSSL)
- target_link_libraries(libhashkit PUBLIC OpenSSL::Crypto)
+if(ENABLE_OPENSSL_CRYPTO)
+ find_package(OpenSSL)
+ if(OPENSSL_FOUND)
+ if(OPENSSL_CRYPTO_LIBRARY)
+ target_compile_definitions(libhashkit PRIVATE HAVE_OPENSSL_CRYPTO)
+ target_link_libraries(libhashkit PUBLIC OpenSSL::Crypto)
+ else()
+ message(WARNING "Could not find OpenSSL::Crypto")
+ endif()
+ endif()
endif()
configure_file(hashkitcon.h.in hashkitcon.h @ONLY)
#include <cstring>
-#ifdef WITH_OPENSSL
+#ifdef HAVE_OPENSSL_CRYPTO
#include <openssl/evp.h>
return destination;
}
-#endif
\ No newline at end of file
+#endif
#pragma once
-#ifdef WITH_OPENSSL
+#ifdef HAVE_OPENSSL_CRYPTO
#include <openssl/evp.h>
aes_key_t *aes_create_key(const char *key, const size_t key_length);
aes_key_t *aes_clone_key(aes_key_t *_aes_key);
-#endif
\ No newline at end of file
+#endif
#include "libhashkit/common.h"
-#ifdef WITH_OPENSSL
+#ifdef HAVE_OPENSSL_CRYPTO
# include <openssl/evp.h>
#endif
hashkit_string_st *hashkit_encrypt(hashkit_st *kit, const char *source, size_t source_length) {
-#ifdef WITH_OPENSSL
+#ifdef HAVE_OPENSSL_CRYPTO
return aes_encrypt((encryption_context_t *) kit->_cryptographic_context,
(const unsigned char *) source, source_length);
#else
}
hashkit_string_st *hashkit_decrypt(hashkit_st *kit, const char *source, size_t source_length) {
-#ifdef WITH_OPENSSL
+#ifdef HAVE_OPENSSL_CRYPTO
return aes_decrypt((encryption_context_t *) kit->_cryptographic_context,
(const unsigned char *) source, source_length);
#else
#endif
}
-#ifdef WITH_OPENSSL
+#ifdef HAVE_OPENSSL_CRYPTO
bool hashkit_key(hashkit_st *kit, const char *key, const size_t key_length) {
kit->_cryptographic_context = (encryption_context_t *) malloc(sizeof(encryption_context_t));
((encryption_context_t *) kit->_cryptographic_context)->encryption_context = EVP_CIPHER_CTX_new();
return bool(kit->_cryptographic_context);
}
-#endif
\ No newline at end of file
+#endif
#include "libhashkit/common.h"
-#ifdef WITH_OPENSSL
+#ifdef HAVE_OPENSSL_CRYPTO
# include <openssl/evp.h>
#endif
return self;
}
-#ifdef WITH_OPENSSL
+#ifdef HAVE_OPENSSL_CRYPTO
static void cryptographic_context_free(encryption_context_t *context) {
EVP_CIPHER_CTX_free(context->encryption_context);
EVP_CIPHER_CTX_free(context->decryption_context);
#endif
void hashkit_free(hashkit_st *self) {
-#ifdef WITH_OPENSSL
+#ifdef HAVE_OPENSSL_CRYPTO
if (self and self->_cryptographic_context) {
cryptographic_context_free((encryption_context_t *)self->_cryptographic_context);
self->_cryptographic_context = NULL;
destination->base_hash = source->base_hash;
destination->distribution_hash = source->distribution_hash;
destination->flags = source->flags;
-#ifdef WITH_OPENSSL
+#ifdef HAVE_OPENSSL_CRYPTO
if (destination->_cryptographic_context) {
cryptographic_context_free((encryption_context_t *)destination->_cryptographic_context);
destination->_cryptographic_context = NULL;