From fed8d93caec822aded82cdd96c783a9ccf156f7b Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Mon, 14 Mar 2011 21:24:25 -0700 Subject: [PATCH] Add an option to disable cryptographic operations This is intended for benchmarking, to measure the overhead of just the non-cryptographic operations. --- bluesky/bluesky.h | 3 +++ bluesky/crypto.c | 8 ++++++++ bluesky/init.c | 1 + 3 files changed, 12 insertions(+) diff --git a/bluesky/bluesky.h b/bluesky/bluesky.h index 874027f..674fa8b 100644 --- a/bluesky/bluesky.h +++ b/bluesky/bluesky.h @@ -45,6 +45,9 @@ typedef struct { /* Disable aggregating of data into log segments. Each object will be * stored in a separate segment. */ int disable_aggregation; + + /* Disable cryptography. This is for benchmarking purposes. */ + int disable_crypto; } BlueSkyOptions; extern BlueSkyOptions bluesky_options; diff --git a/bluesky/crypto.c b/bluesky/crypto.c index b79cfa3..2a5bf6e 100644 --- a/bluesky/crypto.c +++ b/bluesky/crypto.c @@ -132,6 +132,9 @@ gboolean bluesky_crypt_block_needs_encryption(uint8_t type) void bluesky_crypt_block_encrypt(gchar *cloud_block, size_t len, BlueSkyCryptKeys *keys) { + if (bluesky_options.disable_crypto) + return; + gcry_error_t status; gcry_cipher_hd_t handle; @@ -201,6 +204,11 @@ gboolean bluesky_crypt_block_decrypt(gchar *cloud_block, size_t len, g_assert(memcmp(header->magic, CLOUDLOG_MAGIC_ENCRYPTED, sizeof(header->magic)) == 0); + if (bluesky_options.disable_crypto) { + g_assert(encrypted == FALSE); + return TRUE; + } + if (encrypted != bluesky_crypt_block_needs_encryption(header->type)) { g_warning("Encrypted status of item does not match expected!\n"); } diff --git a/bluesky/init.c b/bluesky/init.c index 9ce20b9..666f6e8 100644 --- a/bluesky/init.c +++ b/bluesky/init.c @@ -53,6 +53,7 @@ static struct { {"BLUESKY_CACHE_SIZE", &bluesky_options.cache_size}, {"BLUESKY_OPT_FULL_SEGMENTS", &bluesky_options.full_segment_fetches}, {"BLUESKY_OPT_NO_AGGREGATION", &bluesky_options.disable_aggregation}, + {"BLUESKY_OPT_NO_CRYPTO", &bluesky_options.disable_crypto}, {NULL, NULL} }; -- 2.20.1