Remove internal AES implementation and replace it with use of libcrypto#114
Remove internal AES implementation and replace it with use of libcrypto#114m6w6 merged 1 commit intoawesomized:v1.xfrom
Conversation
|
@TomasKorbar this break build with old openssl (such as 1.02k in RHEL-7) Proposal in Openssl 1.0
In Openssl 1.1 |
m6w6
left a comment
There was a problem hiding this comment.
Thank you!
Please see the inline comments.
CMakeLists.txt
Outdated
| if(NOT CRYPTO_LIB) | ||
| message(FATAL_ERROR "crypto library not found") | ||
| endif() | ||
|
|
There was a problem hiding this comment.
- This should be optional, and the build should use the bundled implementation when libcrypto was not found.
- It should use the cmake module FindOpenSSL and lbhashkit should link against
OpenSSL::Cryptoif found. - It should be located in
src/libhashkit/CMakeLists.txt
include/libhashkit-1.0/hashkit.h
Outdated
| #include <libhashkit-1.0/string.h> | ||
|
|
||
| #include <openssl/evp.h> | ||
|
|
There was a problem hiding this comment.
Should be #ifdef'd for optional support
| bool use_encryption; | ||
| EVP_CIPHER_CTX *encryption_context; | ||
| EVP_CIPHER_CTX *decryption_context; | ||
| }; |
There was a problem hiding this comment.
This breaks the ABI, so either allocate a private struct and reuse _key, or this may only be targeted at v2.0
include/libhashkit-1.0/hashkit.h
Outdated
|
|
||
| HASHKIT_API | ||
| bool hashkit_key(hashkit_st *, const char *key, const size_t key_length); | ||
| bool hashkit_initialize_encryption(hashkit_st *kit, const char *key, const size_t key_length); |
There was a problem hiding this comment.
We're way too far into the stability game, so changing the API for better names is not a good idea.
src/libhashkit/CMakeLists.txt
Outdated
| $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> | ||
| $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include> | ||
| $<INSTALL_INTERFACE:include>) | ||
| target_link_libraries(libhashkit PUBLIC -lcrypto) |
There was a problem hiding this comment.
See the FindOpenSSL and OpenSSL::Crypto comment above.
src/libmemcached/is.h
Outdated
| /* These are private */ | ||
| #define memcached_is_allocated(__object) ((__object)->options.is_allocated) | ||
| #define memcached_is_encrypted(__object) ((__object)->hashkit._key) | ||
| #define memcached_is_encrypted(__object) ((__object)->hashkit.use_encryption) |
There was a problem hiding this comment.
I think this should be (!!(__object)->hashkit._key) or alike.
| EVP_CIPHER_CTX_init(decryption_context) != 1 || | ||
| EVP_DecryptInit_ex(decryption_context, EVP_aes_256_cbc(), NULL, key, | ||
| aes_iv) != 1) { | ||
| return false; |
|
Hi @m6w6 , |
|
@m6w6 Any update on this? |
|
Yes, the update is, that I'm currently camping and there have been thunderstorms tonight. 😉 |
|
@m6w6 No pressure. Just wanted to keep this alive :) Enjoy your camping and i hope that the storms did not cause you any trouble. |
|
Merged, with a couple of fixes and simplifications, thank you! |
Hi,
As we are planning to replace original libmemcached in Fedora with awesomized libmemcached
i want to propose replacement of internal AES implementation with use of openssl.
In my opinion it is safer and more maintainable to use cryptographic library.
All tests are passing.
Feel free to propose any change.