Remove WITH_OPENSSL from all files except http_client, always require OpenSSL
This commit is contained in:
+1
-3
@@ -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})
|
||||
|
||||
@@ -16,12 +16,10 @@
|
||||
#include "msgr_rdma.h"
|
||||
#endif
|
||||
#include "http_client.h"
|
||||
#ifdef WITH_OPENSSL
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/ssl.h>
|
||||
#endif
|
||||
|
||||
#include <sys/poll.h>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
#include <openssl/types.h>
|
||||
#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<rdma_cm_id*, rdmacm_connecting_t*> 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<msgr_iothread_t*> iothreads;
|
||||
std::vector<uint64_t> read_ready_clients;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -4,18 +4,13 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../util/xxh_x86dispatch.h"
|
||||
// WITH_OPENSSL is left to possibly support other crypto libraries
|
||||
#ifdef WITH_OPENSSL
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/err.h>
|
||||
#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;
|
||||
|
||||
@@ -5,12 +5,10 @@
|
||||
#include <limits.h>
|
||||
#include "messenger.h"
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/ssl.h>
|
||||
#endif
|
||||
|
||||
#define RDR_TLS 1
|
||||
#define RDR_XTS 2
|
||||
|
||||
@@ -7,12 +7,10 @@
|
||||
|
||||
#include "messenger.h"
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/ssl.h>
|
||||
#endif
|
||||
|
||||
#define WR_TLS 1
|
||||
#define WR_XTS 2
|
||||
|
||||
@@ -9,12 +9,10 @@
|
||||
#ifdef WITH_RDMA
|
||||
#include "msgr_rdma.h"
|
||||
#endif
|
||||
#ifdef WITH_OPENSSL
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/ssl.h>
|
||||
#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
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// Copyright (c) Vitaliy Filippov, 2019+
|
||||
// License: VNPL-1.1 (see README.md for details)
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
#include <openssl/rand.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include "cli.h"
|
||||
@@ -628,14 +626,12 @@ std::function<bool(cli_result_t &)> 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();
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// Copyright (c) Vitaliy Filippov, 2019+
|
||||
// License: VNPL-1.1 (see README.md for details)
|
||||
|
||||
#ifdef WITH_OPENSSL
|
||||
#include <openssl/rand.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user