Add an option to disable cryptographic operations
[bluesky.git] / bluesky / crypto.c
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");
     }