projects
/
awesomized
/
libmemcached
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (from parent 1:
2aab181
)
libhashkit/aes: make using openssl configurable
author
Michael Wallner
<mike@php.net>
Mon, 12 Jul 2021 13:08:57 +0000
(15:08 +0200)
committer
Michael Wallner
<mike@php.net>
Mon, 12 Jul 2021 13:08:57 +0000
(15:08 +0200)
CMakeConfig.txt
patch
|
blob
|
history
src/libhashkit/CMakeLists.txt
patch
|
blob
|
history
src/libhashkit/aes.cc
patch
|
blob
|
history
src/libhashkit/aes.h
patch
|
blob
|
history
src/libhashkit/encrypt.cc
patch
|
blob
|
history
src/libhashkit/hashkit.cc
patch
|
blob
|
history
diff --git
a/CMakeConfig.txt
b/CMakeConfig.txt
index 973ff8244d2cb0ebca052a0afdbec135fa8f129e..d8afcaefc3ceae4cee6a09a0eacb45d0eb0b67e4 100644
(file)
--- a/
CMakeConfig.txt
+++ b/
CMakeConfig.txt
@@
-65,6
+65,9
@@
if(NOT DEFINED ENV{ENABLE_MEMASLAP})
endif()
option(ENABLE_MEMASLAP "enable memaslap client"
$ENV{ENABLE_MEMASLAP})
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}"
if(BUILD_TESTING)
set(MEMCACHED_BINARY "$ENV{MEMCACHED_BINARY}"
diff --git
a/src/libhashkit/CMakeLists.txt
b/src/libhashkit/CMakeLists.txt
index d0e03d15d4f3fe30de178b15669c29313b6fb99c..ed3f7f1d77caf79d7db960a07239ba735b7badf2 100644
(file)
--- a/
src/libhashkit/CMakeLists.txt
+++ b/
src/libhashkit/CMakeLists.txt
@@
-40,12
+40,16
@@
target_include_directories(libhashkit PUBLIC
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
$<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)
endif()
configure_file(hashkitcon.h.in hashkitcon.h @ONLY)
diff --git
a/src/libhashkit/aes.cc
b/src/libhashkit/aes.cc
index d4fdad5a0d7fe4387937639072344078d72a4983..d65a9d914666ef3adb4acfd24ea9c5ec2d56d527 100644
(file)
--- a/
src/libhashkit/aes.cc
+++ b/
src/libhashkit/aes.cc
@@
-17,7
+17,7
@@
#include <cstring>
#include <cstring>
-#ifdef
WITH_OPENSSL
+#ifdef
HAVE_OPENSSL_CRYPTO
#include <openssl/evp.h>
#include <openssl/evp.h>
@@
-250,4
+250,4
@@
hashkit_string_st *aes_decrypt(aes_key_t *_aes_key, const char *source, size_t s
return destination;
}
return destination;
}
-#endif
\ No newline at end of file
+#endif
diff --git
a/src/libhashkit/aes.h
b/src/libhashkit/aes.h
index e021c5f1dec7ad1fc045d8ce3b0ae6cf07dcdeab..243d501fef02049488bef501c0c14cbb56adf80c 100644
(file)
--- a/
src/libhashkit/aes.h
+++ b/
src/libhashkit/aes.h
@@
-15,7
+15,7
@@
#pragma once
#pragma once
-#ifdef
WITH_OPENSSL
+#ifdef
HAVE_OPENSSL_CRYPTO
#include <openssl/evp.h>
#include <openssl/evp.h>
@@
-45,4
+45,4
@@
hashkit_string_st *aes_decrypt(aes_key_t *_aes_key, const char *source, size_t s
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);
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
diff --git
a/src/libhashkit/encrypt.cc
b/src/libhashkit/encrypt.cc
index dbc051ae2d5e81c9f8b3f4d41763c274bf9adba2..e7898a6a3f6a08960ae4584c4e53a20f64b58e8f 100644
(file)
--- a/
src/libhashkit/encrypt.cc
+++ b/
src/libhashkit/encrypt.cc
@@
-15,12
+15,12
@@
#include "libhashkit/common.h"
#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) {
# 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
return aes_encrypt((encryption_context_t *) kit->_cryptographic_context,
(const unsigned char *) source, source_length);
#else
@@
-30,7
+30,7
@@
hashkit_string_st *hashkit_encrypt(hashkit_st *kit, const char *source, size_t s
}
hashkit_string_st *hashkit_decrypt(hashkit_st *kit, const char *source, size_t source_length) {
}
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
return aes_decrypt((encryption_context_t *) kit->_cryptographic_context,
(const unsigned char *) source, source_length);
#else
@@
-38,7
+38,7
@@
hashkit_string_st *hashkit_decrypt(hashkit_st *kit, const char *source, size_t s
#endif
}
#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();
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();
@@
-61,4
+61,4
@@
bool hashkit_key(hashkit_st *kit, const char *key, const size_t key_length) {
return bool(kit->_cryptographic_context);
}
return bool(kit->_cryptographic_context);
}
-#endif
\ No newline at end of file
+#endif
diff --git
a/src/libhashkit/hashkit.cc
b/src/libhashkit/hashkit.cc
index 46cf6368a0dc747d25f2ec4647c9da5f23b557c4..d15d73725d167aeaa6e1db74f15c138ef22c57e1 100644
(file)
--- a/
src/libhashkit/hashkit.cc
+++ b/
src/libhashkit/hashkit.cc
@@
-15,7
+15,7
@@
#include "libhashkit/common.h"
#include "libhashkit/common.h"
-#ifdef
WITH_OPENSSL
+#ifdef
HAVE_OPENSSL_CRYPTO
# include <openssl/evp.h>
#endif
# include <openssl/evp.h>
#endif
@@
-56,7
+56,7
@@
hashkit_st *hashkit_create(hashkit_st *self) {
return self;
}
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);
static void cryptographic_context_free(encryption_context_t *context) {
EVP_CIPHER_CTX_free(context->encryption_context);
EVP_CIPHER_CTX_free(context->decryption_context);
@@
-65,7
+65,7
@@
static void cryptographic_context_free(encryption_context_t *context) {
#endif
void hashkit_free(hashkit_st *self) {
#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;
if (self and self->_cryptographic_context) {
cryptographic_context_free((encryption_context_t *)self->_cryptographic_context);
self->_cryptographic_context = NULL;
@@
-98,7
+98,7
@@
hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *source) {
destination->base_hash = source->base_hash;
destination->distribution_hash = source->distribution_hash;
destination->flags = source->flags;
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;
if (destination->_cryptographic_context) {
cryptographic_context_free((encryption_context_t *)destination->_cryptographic_context);
destination->_cryptographic_context = NULL;