diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c2dcd8e1..1549e78f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -75,9 +75,7 @@ if (RDMACM_LIBRARIES) endif (RDMACM_LIBRARIES) find_package(OpenSSL REQUIRED) -if (OPENSSL_FOUND) - add_definitions(-DWITH_OPENSSL) -endif (OPENSSL_FOUND) +add_definitions(-DWITH_OPENSSL) pkg_check_modules(CARES REQUIRED libcares) include_directories(${CARES_INCLUDE_DIRS}) diff --git a/src/client/messenger.cpp b/src/client/messenger.cpp index 8610fa5e..5b644bc5 100644 --- a/src/client/messenger.cpp +++ b/src/client/messenger.cpp @@ -16,12 +16,10 @@ #include "msgr_rdma.h" #endif #include "http_client.h" -#ifdef WITH_OPENSSL #include #include #include #include -#endif #include @@ -128,11 +126,6 @@ void osd_messenger_t::init() if (!tls_cert.empty() || !tls_key.empty() || !osd_tls_ca.empty() || !client_tls_ca.empty()) { // Initialize TLS context - // FIXME: require OpenSSL -#ifndef WITH_OPENSSL - fprintf(stderr, "Vitastor is built without OpenSSL support\n"); - exit(1); -#else if (tls_cert.empty() || tls_key.empty() || osd_tls_ca.empty() || osd_num && client_tls_ca.empty()) { if (osd_num) @@ -167,7 +160,6 @@ init_err: goto init_err; } } -#endif } #ifdef WITH_RDMACM if (use_rdmacm) @@ -355,7 +347,6 @@ osd_messenger_t::~osd_messenger_t() { destroy_aes_xts_decrypt(decrypt_ctx); } -#ifdef WITH_OPENSSL for (EVP_CIPHER_CTX *ctx: encrypt_gcm_pool) { EVP_CIPHER_CTX_free(ctx); @@ -369,7 +360,6 @@ osd_messenger_t::~osd_messenger_t() SSL_CTX_free(ssl_ctx); ssl_ctx = NULL; } -#endif } void osd_messenger_t::parse_config(const json11::Json & config) diff --git a/src/client/messenger.h b/src/client/messenger.h index 54fdce5a..a847d06d 100644 --- a/src/client/messenger.h +++ b/src/client/messenger.h @@ -12,9 +12,7 @@ #include #include -#ifdef WITH_OPENSSL #include -#endif #include "../util/xxh_x86dispatch.h" #include "../util/robin_hood.h" @@ -90,7 +88,6 @@ struct osd_client_t msgr_rdma_connection_t *rdma_conn = NULL; #endif -#ifdef WITH_OPENSSL SSL *ssl_cli = NULL; BIO *write_to_ssl = NULL; // FIXME: use custom bio to avoid 1 more memory copy? @@ -109,7 +106,6 @@ struct osd_client_t EVP_CIPHER_CTX *dec_ctx = NULL; uint8_t dec_tag[16]; size_t dec_tag_size = 0; -#endif // Read state bool io_error = false; @@ -279,13 +275,11 @@ protected: robin_hood::unordered_flat_map rdmacm_connecting; #endif -#ifdef WITH_OPENSSL SSL_CTX *ssl_ctx = NULL; std::string tls_cn; void ssl_init(osd_client_t *cl, bool server_mode); bool ssl_do_handshake(osd_client_t *cl); -#endif std::vector iothreads; std::vector read_ready_clients; diff --git a/src/client/msgr_encrypt.cpp b/src/client/msgr_encrypt.cpp index 3a7b0297..c87088ca 100644 --- a/src/client/msgr_encrypt.cpp +++ b/src/client/msgr_encrypt.cpp @@ -9,7 +9,6 @@ op_aes_xts_encrypt_t::op_aes_xts_encrypt_t() { -#ifdef WITH_OPENSSL if (!(ctx = EVP_CIPHER_CTX_new())) { ERR_print_errors_fp(stderr); @@ -21,18 +20,12 @@ op_aes_xts_encrypt_t::op_aes_xts_encrypt_t() ERR_print_errors_fp(stderr); abort(); } -#else - fprintf(stderr, "Error: Vitastor is built without encryption support\n"); - abort(); -#endif } op_aes_xts_encrypt_t::~op_aes_xts_encrypt_t() { assert(!encrypted); -#ifdef WITH_OPENSSL EVP_CIPHER_CTX_free(ctx); -#endif if (tmp) free(tmp); } @@ -52,18 +45,15 @@ void op_aes_xts_encrypt_t::start(uint8_t *key, uint64_t start_offset, size_t blo tmp = NULL; tmp_size = 0; } -#ifdef WITH_OPENSSL if (EVP_EncryptInit_ex(ctx, NULL, NULL, key, NULL) != 1) { ERR_print_errors_fp(stderr); abort(); } -#endif } void op_aes_xts_encrypt_t::encrypt_block(uint8_t *in, uint8_t *out) { -#ifdef WITH_OPENSSL uint8_t iv[16] = { 0 }; *((uint64_t*)iv) = start_offset + offset - offset%block_size; if (EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv) != 1) @@ -78,7 +68,6 @@ void op_aes_xts_encrypt_t::encrypt_block(uint8_t *in, uint8_t *out) abort(); } assert(actual_out == block_size); -#endif } void op_aes_xts_encrypt_t::update(uint8_t *in, size_t max_in, uint8_t *out, size_t max_out, size_t & done_in, size_t & done_out) @@ -158,7 +147,6 @@ void destroy_aes_xts_encrypt(op_aes_xts_encrypt_t *encrypt_ctx) op_aes_xts_decrypt_t::op_aes_xts_decrypt_t() { -#ifdef WITH_OPENSSL if (!(ctx = EVP_CIPHER_CTX_new())) { ERR_print_errors_fp(stderr); @@ -170,18 +158,12 @@ op_aes_xts_decrypt_t::op_aes_xts_decrypt_t() ERR_print_errors_fp(stderr); abort(); } -#else - fprintf(stderr, "Error: Vitastor is built without encryption support\n"); - abort(); -#endif } op_aes_xts_decrypt_t::~op_aes_xts_decrypt_t() { assert(!decrypted); -#ifdef WITH_OPENSSL EVP_CIPHER_CTX_free(ctx); -#endif if (tmp) free(tmp); } @@ -204,13 +186,11 @@ void op_aes_xts_decrypt_t::start(uint8_t **key_chain, size_t chain_size, void *k tmp = NULL; tmp_size = 0; } -#ifdef WITH_OPENSSL if (chain_size == 1 && key_chain[0] && EVP_DecryptInit_ex(ctx, NULL, NULL, key_chain[0], NULL) != 1) { ERR_print_errors_fp(stderr); abort(); } -#endif } void op_aes_xts_decrypt_t::decrypt_block(uint8_t *in, uint8_t *out) @@ -234,7 +214,6 @@ void op_aes_xts_decrypt_t::decrypt_block(uint8_t *in, uint8_t *out) return; } } -#ifdef WITH_OPENSSL uint8_t iv[16] = { 0 }; *((uint64_t*)iv) = start_offset + offset - offset%block_size; if (EVP_DecryptInit_ex(ctx, NULL, NULL, key, iv) != 1) @@ -249,7 +228,6 @@ void op_aes_xts_decrypt_t::decrypt_block(uint8_t *in, uint8_t *out) abort(); } assert(actual_out == block_size); -#endif } // out may be NULL, in this case all input is still decrypted to calculate checksums, diff --git a/src/client/msgr_encrypt.h b/src/client/msgr_encrypt.h index f7d95e4c..957212df 100644 --- a/src/client/msgr_encrypt.h +++ b/src/client/msgr_encrypt.h @@ -4,18 +4,13 @@ #include #include "../util/xxh_x86dispatch.h" -// WITH_OPENSSL is left to possibly support other crypto libraries -#ifdef WITH_OPENSSL #include #include #include -#endif class op_aes_xts_encrypt_t { -#ifdef WITH_OPENSSL EVP_CIPHER_CTX *ctx = NULL; -#endif uint64_t start_offset = 0; uint8_t *key = NULL; size_t offset = 0; @@ -40,9 +35,7 @@ void destroy_aes_xts_encrypt(op_aes_xts_encrypt_t *encrypt_ctx); class op_aes_xts_decrypt_t { -#ifdef WITH_OPENSSL EVP_CIPHER_CTX *ctx = NULL; -#endif uint64_t start_offset = 0; uint8_t **key_chain = NULL; size_t chain_size = 0; diff --git a/src/client/msgr_receive.cpp b/src/client/msgr_receive.cpp index c943b792..5e3122f7 100644 --- a/src/client/msgr_receive.cpp +++ b/src/client/msgr_receive.cpp @@ -5,12 +5,10 @@ #include #include "messenger.h" -#ifdef WITH_OPENSSL #include #include #include #include -#endif #define RDR_TLS 1 #define RDR_XTS 2 diff --git a/src/client/msgr_send.cpp b/src/client/msgr_send.cpp index 0b2308a0..f9d89ef2 100644 --- a/src/client/msgr_send.cpp +++ b/src/client/msgr_send.cpp @@ -7,12 +7,10 @@ #include "messenger.h" -#ifdef WITH_OPENSSL #include #include #include #include -#endif #define WR_TLS 1 #define WR_XTS 2 diff --git a/src/client/msgr_stop.cpp b/src/client/msgr_stop.cpp index 096e5aa8..a2843771 100644 --- a/src/client/msgr_stop.cpp +++ b/src/client/msgr_stop.cpp @@ -9,12 +9,10 @@ #ifdef WITH_RDMA #include "msgr_rdma.h" #endif -#ifdef WITH_OPENSSL #include #include #include #include -#endif void osd_client_t::cancel_ops() { @@ -248,7 +246,6 @@ osd_client_t::~osd_client_t() XXH3_freeState(write_csum_state); write_csum_state = NULL; } -#ifdef WITH_OPENSSL if (enc_ctx) { EVP_CIPHER_CTX_free(enc_ctx); @@ -271,5 +268,4 @@ osd_client_t::~osd_client_t() free(ssl_out_buf); ssl_out_buf = NULL; } -#endif } diff --git a/src/cmd/cli_create.cpp b/src/cmd/cli_create.cpp index d3531c7d..6e96a1a1 100644 --- a/src/cmd/cli_create.cpp +++ b/src/cmd/cli_create.cpp @@ -1,9 +1,7 @@ // Copyright (c) Vitaliy Filippov, 2019+ // License: VNPL-1.1 (see README.md for details) -#ifdef WITH_OPENSSL #include -#endif #include #include "cli.h" @@ -628,14 +626,12 @@ std::function cli_tool_t::start_create(json11::Json cfg) if (!cfg["enc_key"].is_null()) { image_creator->set_key = true; -#ifdef WITH_OPENSSL if (image_creator->enc_key == "random") { uint8_t newkey[64]; RAND_bytes(newkey, 64); image_creator->enc_key = tohexstr(newkey, 64); } -#endif else { image_creator->enc_key = cfg["enc_key"].string_value(); diff --git a/src/test/test_cluster_client.cpp b/src/test/test_cluster_client.cpp index 289a7a40..1aef5e32 100644 --- a/src/test/test_cluster_client.cpp +++ b/src/test/test_cluster_client.cpp @@ -1,9 +1,7 @@ // Copyright (c) Vitaliy Filippov, 2019+ // License: VNPL-1.1 (see README.md for details) -#ifdef WITH_OPENSSL #include -#endif #include #include @@ -556,7 +554,6 @@ void test_writeback_merge() printf("[ok] writeback merge test\n"); } -#ifdef WITH_OPENSSL void test_msgr_encrypt() { const size_t sz = 1048576; @@ -725,7 +722,6 @@ void test_msgr_decrypt_chain() free(src); printf("[ok] msgr aes-xts chained decrypt\n"); } -#endif void test_vault() { @@ -794,10 +790,8 @@ int main(int narg, char *args[]) test2(); test_writeback(); test_writeback_merge(); -#ifdef WITH_OPENSSL test_msgr_encrypt(); test_msgr_decrypt_chain(); -#endif test_vault(); return 0; }