Add an option to disable cryptographic operations
authorMichael Vrable <mvrable@cs.ucsd.edu>
Tue, 15 Mar 2011 04:24:25 +0000 (21:24 -0700)
committerMichael Vrable <mvrable@cs.ucsd.edu>
Tue, 15 Mar 2011 04:24:25 +0000 (21:24 -0700)
This is intended for benchmarking, to measure the overhead of just the
non-cryptographic operations.

bluesky/bluesky.h
bluesky/crypto.c
bluesky/init.c

index 874027f..674fa8b 100644 (file)
@@ -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;
index b79cfa3..2a5bf6e 100644 (file)
@@ -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");
     }
index 9ce20b9..666f6e8 100644 (file)
@@ -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}
 };