Przeglądaj źródła

Pass error to decrypt function

Matthias Vogelgesang 7 lat temu
rodzic
commit
01bc873d49

+ 2 - 1
src/iridium-crypto.c

@@ -183,7 +183,8 @@ gchar *
 iridium_crypto_decrypt_item (const gchar *enc_content,
                              IridiumAuthParams *params,
                              const gchar *enc_item_key,
-                             const gchar *uuid)
+                             const gchar *uuid,
+                             GError **error)
 {
   gchar *enc_auth_key;
   const gchar *enc_key;

+ 2 - 1
src/iridium-crypto.h

@@ -51,7 +51,8 @@ void               iridium_crypto_derive_keys       (IridiumAuthParams  *params,
 gchar             *iridium_crypto_decrypt_item      (const gchar        *enc_content,
                                                      IridiumAuthParams  *params,
                                                      const gchar        *enc_item_key,
-                                                     const gchar        *uuid);
+                                                     const gchar        *uuid,
+                                                     GError            **error);
 gchar             *iridium_crypto_hexlify           (const guint8       *s,
                                                      gsize               length);
 guint8            *iridium_crypto_unhexlify         (const gchar        *s,

+ 1 - 1
src/iridium-standard-file.c

@@ -373,7 +373,7 @@ iridium_standard_file_get_items (JsonParser *parser,
       continue;
 
     enc_content = json_object_get_string_member (data, "content");
-    content = iridium_crypto_decrypt_item (enc_content, auth_params, enc_item_key, uuid);
+    content = iridium_crypto_decrypt_item (enc_content, auth_params, enc_item_key, uuid, error);
 
     if (content) {
       item = deserialize_item (data, content);

+ 6 - 1
src/iridium-storage.c

@@ -141,7 +141,7 @@ on_json_parsed (GObject *object,
       continue;
 
     enc_content = json_object_get_string_member (data, "content");
-    content = iridium_crypto_decrypt_item (enc_content, params, enc_item_key, uuid);
+    content = iridium_crypto_decrypt_item (enc_content, params, enc_item_key, uuid, &error);
 
     if (content) {
       item = deserialize_item (data, content);
@@ -149,6 +149,11 @@ on_json_parsed (GObject *object,
       if (item)
         items = g_list_append (items, item);
     }
+    else {
+      g_task_return_error (task, error);
+      iridium_crypto_auth_params_free (params);
+      return;
+    }
 
     g_free (content);
   }