gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r28024 - gnunet/src/identity


From: gnunet
Subject: [GNUnet-SVN] r28024 - gnunet/src/identity
Date: Sun, 14 Jul 2013 22:37:08 +0200

Author: grothoff
Date: 2013-07-14 22:37:08 +0200 (Sun, 14 Jul 2013)
New Revision: 28024

Modified:
   gnunet/src/identity/identity.h
   gnunet/src/identity/identity_api.c
Log:
-addressing variable-size ECC private key len in IPC

Modified: gnunet/src/identity/identity.h
===================================================================
--- gnunet/src/identity/identity.h      2013-07-14 20:27:06 UTC (rev 28023)
+++ gnunet/src/identity/identity.h      2013-07-14 20:37:08 UTC (rev 28024)
@@ -74,14 +74,11 @@
   uint16_t name_len GNUNET_PACKED;
 
   /**
-   * Always zero.
+   * Number of bytes of private key data that follow, in NBO.
    */
-  uint16_t reserved GNUNET_PACKED;
+  uint16_t pk_len GNUNET_PACKED;
 
-  /**
-   * Public key of the identity that we provide an update about.
-   */
-  struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded private_key_FIXME;
+  /* followed by private key */
 
   /* followed by 0-terminated identity name */
 
@@ -133,14 +130,11 @@
   uint16_t name_len GNUNET_PACKED;
 
   /**
-   * Always zero.
+   * Number of bytes of private key data that follow, in NBO.
    */
-  uint16_t reserved GNUNET_PACKED;
+  uint16_t pk_len GNUNET_PACKED;
 
-  /**
-   * Public key of the identity to use.
-   */
-  struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded private_key_FIXME;
+  /* followed by private key */
 
   /* followed by 0-terminated service name */
 
@@ -164,14 +158,11 @@
   uint16_t name_len GNUNET_PACKED;
 
   /**
-   * Always zero.
+   * Number of bytes of private key data that follow, in NBO.
    */
-  uint16_t reserved GNUNET_PACKED;
+  uint16_t pk_len GNUNET_PACKED;
 
-  /**
-   * Public key of the identity to use.
-   */
-  struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded private_key_FIXME;
+  /* followed by private key */
 
   /* followed by 0-terminated identity name */
 

Modified: gnunet/src/identity/identity_api.c
===================================================================
--- gnunet/src/identity/identity_api.c  2013-07-14 20:27:06 UTC (rev 28023)
+++ gnunet/src/identity/identity_api.c  2013-07-14 20:37:08 UTC (rev 28024)
@@ -239,6 +239,8 @@
   struct GNUNET_HashCode id;
   const char *str;
   uint16_t size;
+  uint16_t pk_len;
+  uint16_t name_len;
 
   if (NULL == msg)
   {
@@ -285,19 +287,18 @@
       return;
     }
     um = (const struct GNUNET_IDENTITY_UpdateMessage *) msg;
+    pk_len = ntohs (um->pk_len);
+    name_len = ntohs (um->name_len);    
     str = (const char *) &um[1];
-    if ( (size > sizeof (struct GNUNET_IDENTITY_UpdateMessage)) &&
-        ('\0' != str[size - sizeof (struct GNUNET_IDENTITY_UpdateMessage) - 
1]) )
+    if ( (size != pk_len + name_len + sizeof (struct 
GNUNET_IDENTITY_UpdateMessage)) ||
+        ( (0 != name_len) &&
+          ('\0' != str[pk_len + name_len - 1])) )
     {
       GNUNET_break (0);
       reschedule_connect (h);
       return;
     }
-    if (size == sizeof (struct GNUNET_IDENTITY_UpdateMessage))
-      str = NULL;
-
-    // FIXME: um->pk does NOT work!
-    priv = GNUNET_CRYPTO_ecc_decode_key (NULL, 0, GNUNET_YES); // FIXME...
+    priv = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES); 
     if (NULL == priv)
     {
       GNUNET_break (0);
@@ -307,7 +308,10 @@
     GNUNET_CRYPTO_ecc_key_get_public (priv,
                                      &pub);
     GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
-
+    if (0 == name_len)
+      str = NULL;
+    else
+      str = &str[pk_len];
     ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
                                             &id);
     if (NULL == ego)
@@ -366,18 +370,18 @@
       return;
     }
     sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) msg;
+    pk_len = ntohs (sdm->pk_len);
+    name_len = ntohs (sdm->name_len);
     str = (const char *) &sdm[1];
-    if ( (size > sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) &&
-        ('\0' != str[size - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) 
- 1]) )
+    if ( (size != pk_len + name_len + sizeof (struct 
GNUNET_IDENTITY_SetDefaultMessage)) ||
+        ( (0 != name_len) &&
+          ('\0' != str[pk_len + name_len - 1]) ) )
     {
       GNUNET_break (0);
       reschedule_connect (h);
       return;
     }
-    if (size == sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
-      str = NULL;
-    // FIXME: sdr->pk does NOT work!
-    priv = GNUNET_CRYPTO_ecc_decode_key (NULL, 0, GNUNET_YES); // FIXME...
+    priv = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES); 
     if (NULL == priv)
     {
       GNUNET_break (0);
@@ -388,6 +392,10 @@
                                      &pub);
     GNUNET_CRYPTO_ecc_key_free (priv);
     GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
+    if (0 == name_len)
+      str = NULL;
+    else
+      str = &str[pk_len];
     ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
                                             &id);
     if (NULL == ego)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]