[gnome-keyring] gcr: Check that secret exchanged data has correct protocol prefix



commit 9c63434fa8bc7fe6bd3715c13a89c3c1865b9519
Author: Stef Walter <stefw collabora co uk>
Date:   Sat Oct 1 13:27:03 2011 +0200

    gcr: Check that secret exchanged data has correct protocol prefix
    
     * This is for future backward compatibility, so when we have more
       than one protocol, we can be sure we can identify the old one.

 gcr/gcr-secret-exchange.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/gcr/gcr-secret-exchange.c b/gcr/gcr-secret-exchange.c
index 492fde5..92899ad 100644
--- a/gcr/gcr-secret-exchange.c
+++ b/gcr/gcr-secret-exchange.c
@@ -82,6 +82,8 @@ EGG_SECURE_DECLARE (secret_exchange);
  * transport encryption is done with 128 bit AES.
  */
 
+#define SECRET_EXCHANGE_PROTOCOL_1_PREFIX "[" GCR_SECRET_EXCHANGE_PROTOCOL_1 "]\n"
+
 enum {
 	PROP_0,
 	PROP_PROTOCOL
@@ -290,6 +292,11 @@ gcr_secret_exchange_begin (GcrSecretExchange *self)
 	result = g_key_file_to_data (output, NULL, NULL);
 	g_return_val_if_fail (result != NULL, NULL);
 
+	g_strchomp (result);
+
+	if (g_str_has_prefix (result, SECRET_EXCHANGE_PROTOCOL_1_PREFIX))
+		g_warning ("the prepared data does not have the correct protocol prefix");
+
 	g_key_file_free (output);
 
 	return result;
@@ -531,6 +538,12 @@ gcr_secret_exchange_send (GcrSecretExchange *self,
 
 	result = g_key_file_to_data (output, NULL, NULL);
 	g_return_val_if_fail (result != NULL, NULL);
+
+	g_strchomp (result);
+
+	if (g_str_has_prefix (result, SECRET_EXCHANGE_PROTOCOL_1_PREFIX))
+		g_warning ("the prepared data does not have the correct protocol prefix");
+
 	g_key_file_free (output);
 	return result;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]