In-progress commit of online cleaner.
[bluesky.git] / bluesky / crypto.c
index fd47491..b79cfa3 100644 (file)
@@ -185,7 +185,8 @@ void bluesky_crypt_block_encrypt(gchar *cloud_block, size_t len,
 }
 
 gboolean bluesky_crypt_block_decrypt(gchar *cloud_block, size_t len,
-                                     BlueSkyCryptKeys *keys)
+                                     BlueSkyCryptKeys *keys,
+                                     gboolean allow_unauth)
 {
     gcry_error_t status;
     uint8_t hmac_check[CRYPTO_HASH_SIZE];
@@ -209,8 +210,15 @@ gboolean bluesky_crypt_block_decrypt(gchar *cloud_block, size_t len,
                        keys->authentication_key,
                        hmac_check);
     if (memcmp(hmac_check, header->crypt_auth, CRYPTO_HASH_SIZE) != 0) {
-        g_warning("Cloud block HMAC does not match!\n");
-        return FALSE;
+        g_warning("Cloud block HMAC does not match!");
+        if (allow_unauth
+            && (header->type == LOGTYPE_INODE_MAP + '0'
+                || header->type == LOGTYPE_CHECKPOINT + '0'))
+        {
+            g_warning("Allowing unauthenticated data from cleaner");
+        } else {
+            return FALSE;
+        }
     }
 
     if (encrypted) {