[epiphany/wip/sync] sync-crypto: Change signature of _key_bundle_new()
- From: Gabriel Ivașcu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/sync] sync-crypto: Change signature of _key_bundle_new()
- Date: Wed, 14 Jun 2017 13:03:06 +0000 (UTC)
commit 94341bfc9fe4a6e0478cb0bd447d297a63db9001
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date: Wed Jun 14 16:02:45 2017 +0300
sync-crypto: Change signature of _key_bundle_new()
lib/sync/debug/ephy-sync-debug.c | 3 ++-
lib/sync/ephy-sync-crypto.c | 27 +++++++++++++--------------
lib/sync/ephy-sync-crypto.h | 4 ++--
lib/sync/ephy-sync-service.c | 3 ++-
lib/sync/ephy-synchronizable.h | 1 +
5 files changed, 20 insertions(+), 18 deletions(-)
---
diff --git a/lib/sync/debug/ephy-sync-debug.c b/lib/sync/debug/ephy-sync-debug.c
index a19093f..edabcef 100644
--- a/lib/sync/debug/ephy-sync-debug.c
+++ b/lib/sync/debug/ephy-sync-debug.c
@@ -114,7 +114,8 @@ ephy_sync_debug_get_bundle_for_collection (const char *collection)
array = json_object_has_member (collections, collection) ?
json_object_get_array_member (collections, collection) :
json_object_get_array_member (json, "default");
- bundle = ephy_sync_crypto_key_bundle_new (array);
+ bundle = ephy_sync_crypto_key_bundle_new (json_array_get_string_element (array, 0),
+ json_array_get_string_element (array, 1));
json_node_unref (node);
free_secrets:
diff --git a/lib/sync/ephy-sync-crypto.c b/lib/sync/ephy-sync-crypto.c
index fad1084..7ea7ebe 100644
--- a/lib/sync/ephy-sync-crypto.c
+++ b/lib/sync/ephy-sync-crypto.c
@@ -26,6 +26,7 @@
#include <glib/gstdio.h>
#include <inttypes.h>
+#include <json-glib/json-glib.h>
#include <libsoup/soup.h>
#include <nettle/cbc.h>
#include <nettle/aes.h>
@@ -443,31 +444,29 @@ ephy_sync_crypto_rsa_key_pair_free (SyncCryptoRSAKeyPair *key_pair)
}
SyncCryptoKeyBundle *
-ephy_sync_crypto_key_bundle_new (JsonArray *array)
+ephy_sync_crypto_key_bundle_new (const char *aes_key_b64,
+ const char *hmac_key_b64)
{
SyncCryptoKeyBundle *bundle;
- char *aes_key_hex;
- char *hmac_key_hex;
guint8 *aes_key;
guint8 *hmac_key;
- gsize len;
+ gsize aes_key_len;
+ gsize hmac_key_len;
- g_return_val_if_fail (array, NULL);
- g_return_val_if_fail (json_array_get_length (array) == 2, NULL);
+ g_return_val_if_fail (aes_key_b64, NULL);
+ g_return_val_if_fail (hmac_key_b64, NULL);
- aes_key = g_base64_decode (json_array_get_string_element (array, 0), &len);
- hmac_key = g_base64_decode (json_array_get_string_element (array, 1), &len);
- aes_key_hex = ephy_sync_utils_encode_hex (aes_key, 32);
- hmac_key_hex = ephy_sync_utils_encode_hex (hmac_key, 32);
+ aes_key = g_base64_decode (aes_key_b64, &aes_key_len);
+ g_return_val_if_fail (aes_key_len == 32, NULL);
+ hmac_key = g_base64_decode (hmac_key_b64, &hmac_key_len);
+ g_return_val_if_fail (hmac_key_len == 32, NULL);
bundle = g_slice_new (SyncCryptoKeyBundle);
- bundle->aes_key_hex = g_strdup (aes_key_hex);
- bundle->hmac_key_hex = g_strdup (hmac_key_hex);
+ bundle->aes_key_hex = ephy_sync_utils_encode_hex (aes_key, aes_key_len);
+ bundle->hmac_key_hex = ephy_sync_utils_encode_hex (hmac_key, hmac_key_len);
g_free (aes_key);
g_free (hmac_key);
- g_free (aes_key_hex);
- g_free (hmac_key_hex);
return bundle;
}
diff --git a/lib/sync/ephy-sync-crypto.h b/lib/sync/ephy-sync-crypto.h
index be52d6f..57b77b9 100644
--- a/lib/sync/ephy-sync-crypto.h
+++ b/lib/sync/ephy-sync-crypto.h
@@ -21,7 +21,6 @@
#pragma once
#include <glib-object.h>
-#include <json-glib/json-glib.h>
#include <nettle/rsa.h>
G_BEGIN_DECLS
@@ -88,7 +87,8 @@ void ephy_sync_crypto_hawk_header_free (SyncCryptoHawkH
SyncCryptoRSAKeyPair *ephy_sync_crypto_rsa_key_pair_new (void);
void ephy_sync_crypto_rsa_key_pair_free (SyncCryptoRSAKeyPair *key_pair);
-SyncCryptoKeyBundle *ephy_sync_crypto_key_bundle_new (JsonArray *array);
+SyncCryptoKeyBundle *ephy_sync_crypto_key_bundle_new (const char *aes_key_b64,
+ const char *hmac_key_b64);
void ephy_sync_crypto_key_bundle_free (SyncCryptoKeyBundle *bundle);
void ephy_sync_crypto_derive_session_token (const char *session_token,
diff --git a/lib/sync/ephy-sync-service.c b/lib/sync/ephy-sync-service.c
index 9ec8938..62e2d35 100644
--- a/lib/sync/ephy-sync-service.c
+++ b/lib/sync/ephy-sync-service.c
@@ -347,7 +347,8 @@ ephy_sync_service_get_key_bundle (EphySyncService *self,
array = json_object_has_member (collections, collection) ?
json_object_get_array_member (collections, collection) :
json_object_get_array_member (json, "default");
- bundle = ephy_sync_crypto_key_bundle_new (array);
+ bundle = ephy_sync_crypto_key_bundle_new (json_array_get_string_element (array, 0),
+ json_array_get_string_element (array, 1));
json_node_unref (node);
diff --git a/lib/sync/ephy-synchronizable.h b/lib/sync/ephy-synchronizable.h
index 84f77da..2dca634 100644
--- a/lib/sync/ephy-synchronizable.h
+++ b/lib/sync/ephy-synchronizable.h
@@ -23,6 +23,7 @@
#include "ephy-sync-crypto.h"
#include <glib-object.h>
+#include <json-glib/json-glib.h>
G_BEGIN_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]