- changes to signing verfifying: includes block expiration
authorMatthias Wachs <wachs@net.in.tum.de>
Fri, 9 Mar 2012 14:14:01 +0000 (14:14 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Fri, 9 Mar 2012 14:14:01 +0000 (14:14 +0000)
19 files changed:
src/gns/test_gns_dht_delegated_lookup.c
src/gns/test_gns_simple_shorten.c
src/include/gnunet_namestore_service.h
src/namestore/gnunet-service-namestore.c
src/namestore/namestore.h
src/namestore/namestore_api.c
src/namestore/namestore_common.c
src/namestore/test_namestore_api_create.c
src/namestore/test_namestore_api_create_update.c
src/namestore/test_namestore_api_lookup.c
src/namestore/test_namestore_api_lookup_specific_type.c
src/namestore/test_namestore_api_put.c
src/namestore/test_namestore_api_remove.c
src/namestore/test_namestore_api_remove_not_existing_record.c
src/namestore/test_namestore_api_sign_verify.c
src/namestore/test_namestore_api_zone_iteration.c
src/namestore/test_namestore_api_zone_iteration_specific_zone.c
src/namestore/test_namestore_api_zone_iteration_stop.c
src/namestore/test_namestore_api_zone_to_name.c

index 3b097a3d52c3b706042e720721dcd842e073a8d9..dc73c7b58691f8e01c01e292484f8f3657fb234f 100644 (file)
@@ -204,7 +204,8 @@ put_dht(void *cls, int32_t success, const char *emsg)
   rd.data_size = sizeof(struct in_addr);
   rd.data = web;
   rd.record_type = GNUNET_DNSPARSER_TYPE_A;
-  sig = GNUNET_NAMESTORE_create_signature(bob_key, TEST_RECORD_NAME,
+
+  sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_absolute_get_forever(), TEST_RECORD_NAME,
                                           &rd, 1);
   rd_payload_length = GNUNET_NAMESTORE_records_get_size (1, &rd);
   nrb = GNUNET_malloc(rd_payload_length + strlen(TEST_RECORD_NAME) + 1
index fc0c0f1f02615f8ab0d83814224cae12a48f48d8..4f8f57acbf87f77511d4eebadc225b13069b4a77 100644 (file)
@@ -254,7 +254,7 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
   /* put alice into bobs zone */
   GNUNET_CRYPTO_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash);
   rd.data = &alice_hash;
-  sig = GNUNET_NAMESTORE_create_signature(bob_key, TEST_AUTHORITY_ALICE,
+  sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_absolute_get_forever(), TEST_AUTHORITY_ALICE,
                                           &rd, 1);
 
   GNUNET_NAMESTORE_record_put (namestore_handle,
@@ -272,7 +272,7 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
   rd.data_size = sizeof(struct in_addr);
   rd.data = web;
   rd.record_type = GNUNET_DNSPARSER_TYPE_A;
-  sig = GNUNET_NAMESTORE_create_signature(alice_key, TEST_RECORD_NAME,
+  sig = GNUNET_NAMESTORE_create_signature(alice_key,GNUNET_TIME_absolute_get_forever(),  TEST_RECORD_NAME,
                                           &rd, 1);
 
   GNUNET_NAMESTORE_record_put (namestore_handle,
@@ -290,7 +290,7 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
   rd.record_type = GNUNET_GNS_RECORD_PSEU;
   GNUNET_free(sig);
 
-  sig = GNUNET_NAMESTORE_create_signature(alice_key, "",
+  sig = GNUNET_NAMESTORE_create_signature(alice_key,GNUNET_TIME_absolute_get_forever(),  "",
                                           &rd, 1);
 
   GNUNET_NAMESTORE_record_put (namestore_handle,
index 29c70a1795aa5fccf2261cb4f36236982ddcaa9a..fbc2a4b3c5982875cbec7331745e174af5f41b2a 100644 (file)
@@ -206,6 +206,7 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
  * to validate signatures received from the network.
  *
  * @param public_key public key of the zone
+ * @param expire block expiration
  * @param name name that is being mapped (at most 255 characters long)
  * @param rd_count number of entries in 'rd' array
  * @param rd array of records with data to store
@@ -214,10 +215,11 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
  */
 int
 GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
-                                  const char *name,
-                                  unsigned int rd_count,
-                                  const struct GNUNET_NAMESTORE_RecordData *rd,
-                                  const struct GNUNET_CRYPTO_RsaSignature *signature);
+                                   const struct GNUNET_TIME_Absolute expire,
+                                   const char *name,
+                                   unsigned int rd_count,
+                                   const struct GNUNET_NAMESTORE_RecordData *rd,
+                                   const struct GNUNET_CRYPTO_RsaSignature *signature);
 
 
 /**
index 87ecc9018cc0d1a5992c94cc49773a463a6acf74..57d2dd0072a17b71cfe6cf1239deca361f755459 100644 (file)
@@ -212,6 +212,21 @@ int zone_to_disk_it (void *cls,
 }
 
 
+struct GNUNET_TIME_Absolute
+get_block_expiration_time (unsigned int rd_count, const struct GNUNET_NAMESTORE_RecordData *rd)
+{
+  int c;
+  struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get_forever();
+  if (NULL == rd)
+    return GNUNET_TIME_absolute_get_zero();
+  for (c = 0; c < rd_count; c++)
+  {
+    if (rd[c].expiration.abs_value < expire.abs_value)
+      expire = rd[c].expiration;
+  }
+  return expire;
+}
+
 /**
  * Task run during shutdown.
  *
@@ -231,6 +246,7 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   snc = NULL;
 
   GNUNET_CONTAINER_multihashmap_iterate(zonekeys, &zone_to_disk_it, NULL);
+  GNUNET_CONTAINER_multihashmap_destroy(zonekeys);
 
   for (nc = client_head; nc != NULL; nc = next)
   {
@@ -364,6 +380,7 @@ handle_lookup_name_it (void *cls,
   struct GNUNET_NAMESTORE_RecordData *rd_selected = NULL;
   struct GNUNET_NAMESTORE_CryptoContainer *cc;
   struct GNUNET_CRYPTO_RsaSignature *signature_new = NULL;
+  struct GNUNET_TIME_Absolute e;
   GNUNET_HashCode zone_key_hash;
   char *rd_tmp;
   char *name_tmp;
@@ -435,7 +452,8 @@ handle_lookup_name_it (void *cls,
     if (GNUNET_CONTAINER_multihashmap_contains(zonekeys, &zone_key_hash))
     {
       cc = GNUNET_CONTAINER_multihashmap_get(zonekeys, &zone_key_hash);
-      signature_new = GNUNET_NAMESTORE_create_signature(cc->privkey, name, rd, rd_count);
+      e = get_block_expiration_time(rd_count, rd);
+      signature_new = GNUNET_NAMESTORE_create_signature(cc->privkey, e, name, rd, rd_count);
       GNUNET_assert (signature_new != NULL);
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating signature for name `%s' with %u records in zone `%s'\n",name, copied_elements, GNUNET_h2s(&zone_key_hash));
       authoritative = GNUNET_YES;
@@ -444,9 +462,6 @@ handle_lookup_name_it (void *cls,
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am not authoritative for name `%s' in zone `%s'\n",name, GNUNET_h2s(&zone_key_hash));
   }
 
-  if (rd_selected != rd)
-    GNUNET_free (rd_selected);
-
   r_size = sizeof (struct LookupNameResponseMessage) +
            sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) +
            name_len +
@@ -460,7 +475,10 @@ handle_lookup_name_it (void *cls,
   lnr_msg->rd_count = htons (copied_elements);
   lnr_msg->rd_len = htons (rd_ser_len);
   lnr_msg->name_len = htons (name_len);
-  lnr_msg->expire = GNUNET_TIME_absolute_hton(expire);
+  lnr_msg->expire = GNUNET_TIME_absolute_hton(get_block_expiration_time(copied_elements, rd_selected));
+
+  if (rd_selected != rd)
+    GNUNET_free (rd_selected);
 
   if (zone_key != NULL)
     lnr_msg->public_key = (*zone_key);
@@ -811,6 +829,7 @@ static void handle_record_create (void *cls,
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "NAMESTORE_RECORD_CREATE");
   struct GNUNET_NAMESTORE_Client *nc;
+  struct GNUNET_NAMESTORE_CryptoContainer *cc;
   struct CreateRecordContext crc;
   struct GNUNET_CRYPTO_RsaPrivateKey *pkey;
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
@@ -895,6 +914,19 @@ static void handle_record_create (void *cls,
   GNUNET_CRYPTO_rsa_key_get_public(pkey, &pub);
   GNUNET_CRYPTO_hash (&pub, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pubkey_hash);
 
+  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(zonekeys, &pubkey_hash))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received new private key for zone `%s'\n",GNUNET_h2s(&pubkey_hash));
+
+    cc = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_CryptoContainer));
+    cc->privkey = GNUNET_CRYPTO_rsa_decode_key((char *) pkey_tmp, key_len);
+    cc->pubkey = GNUNET_malloc(sizeof (pub));
+    memcpy (cc->pubkey, &pub, sizeof(pub));
+    cc->zone = pubkey_hash;
+
+    GNUNET_CONTAINER_multihashmap_put(zonekeys, &pubkey_hash, cc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+  }
+
   crc.expire = GNUNET_TIME_absolute_ntoh(rp_msg->expire);
   crc.res = GNUNET_SYSERR;
   crc.pkey = pkey;
@@ -909,6 +941,7 @@ static void handle_record_create (void *cls,
   if (res != GNUNET_SYSERR)
     res = GNUNET_OK;
   GNUNET_CRYPTO_rsa_key_free(pkey);
+  pkey = NULL;
 
   /* Send response */
 send:
@@ -1027,6 +1060,7 @@ static void handle_record_remove (void *cls,
   struct GNUNET_NAMESTORE_Client *nc;
   struct RecordRemoveResponseMessage rrr_msg;
   struct GNUNET_CRYPTO_RsaPrivateKey *pkey;
+  struct GNUNET_NAMESTORE_CryptoContainer *cc = NULL;
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
   GNUNET_HashCode pubkey_hash;
   char * pkey_tmp = NULL;
@@ -1120,6 +1154,18 @@ static void handle_record_remove (void *cls,
   GNUNET_CRYPTO_rsa_key_get_public(pkey, &pub);
   GNUNET_CRYPTO_hash (&pub, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pubkey_hash);
 
+  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(zonekeys, &pubkey_hash))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received new private key for zone `%s'\n",GNUNET_h2s(&pubkey_hash));
+    cc = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_CryptoContainer));
+    cc->privkey = GNUNET_CRYPTO_rsa_decode_key((char *) pkey_tmp, key_len);
+    cc->pubkey = GNUNET_malloc(sizeof (pub));
+    memcpy (cc->pubkey, &pub, sizeof(pub));
+    cc->zone = pubkey_hash;
+
+    GNUNET_CONTAINER_multihashmap_put(zonekeys, &pubkey_hash, cc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+  }
+
   struct GNUNET_NAMESTORE_RecordData rd[rd_count];
   res = GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_ser, rd_count, rd);
   if ((res != GNUNET_OK) || (rd_count != 1))
@@ -1334,6 +1380,7 @@ void zone_iteration_proc (void *cls,
   struct GNUNET_NAMESTORE_Client *nc = zi->client;
   struct GNUNET_NAMESTORE_CryptoContainer * cc;
   struct GNUNET_CRYPTO_RsaSignature *signature_new = NULL;
+  struct GNUNET_TIME_Absolute e;
   GNUNET_HashCode zone_key_hash;
   int authoritative = GNUNET_NO;
 
@@ -1393,9 +1440,11 @@ void zone_iteration_proc (void *cls,
     if (GNUNET_CONTAINER_multihashmap_contains(zonekeys, &zone_key_hash))
     {
       cc = GNUNET_CONTAINER_multihashmap_get(zonekeys, &zone_key_hash);
-      signature_new = GNUNET_NAMESTORE_create_signature(cc->privkey, name, rd, rd_count);
+      e = get_block_expiration_time(rd_count, rd);
+      expire = e;
+      signature_new = GNUNET_NAMESTORE_create_signature(cc->privkey, e, name, rd, rd_count);
       GNUNET_assert (signature_new != NULL);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating signature for name `%s' with %u records in zone `%s'\n",name, rd_count, GNUNET_h2s(&zone_key_hash));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating signature for `%s' in zone `%s' with %u records  and expiration %llu\n", name, GNUNET_h2s(&zone_key_hash), rd_count, e.abs_value);
       authoritative = GNUNET_YES;
     }
 
index e0550b499da6cd802ecda125da71c25a198d9ce8..48e021f6dc4e436432013294ede15ab90ed4373b 100644 (file)
 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 448
 
 /**
- * Create a signature based on name and records
+ * Sign name and records
  *
  * @param key the private key
+ * @param expire block expiration
  * @param name the name
  * @param rd record data
  * @param rd_count number of records
  */
 struct GNUNET_CRYPTO_RsaSignature *
 GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
-                                   const char *name,
-                                   const struct GNUNET_NAMESTORE_RecordData *rd,
-                                   unsigned int rd_count);
+    struct GNUNET_TIME_Absolute expire,
+    const char *name,
+    const struct GNUNET_NAMESTORE_RecordData *rd,
+    unsigned int rd_count);
 
 /**
  * Compares if two records are equal
index f1dfcc0aa5918ead18332ba777e05fbd162e98bf..f9125d325c2472ffa6805079447b4bca3a2c33ee 100644 (file)
@@ -1048,6 +1048,7 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
  * to validate signatures received from the network.
  *
  * @param public_key public key of the zone
+ * @param expire block expiration
  * @param name name that is being mapped (at most 255 characters long)
  * @param rd_count number of entries in 'rd' array
  * @param rd array of records with data to store
@@ -1056,6 +1057,7 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
  */
 int
 GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key,
+                                   const struct GNUNET_TIME_Absolute expire,
                                   const char *name,
                                   unsigned int rd_count,
                                   const struct GNUNET_NAMESTORE_RecordData *rd,
@@ -1067,6 +1069,8 @@ GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinary
   char * name_tmp;
   char * rd_tmp;
   struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose;
+  struct GNUNET_TIME_AbsoluteNBO *expire_tmp;
+  struct GNUNET_TIME_AbsoluteNBO expire_nbo = GNUNET_TIME_absolute_hton(expire);
 
   GNUNET_assert (public_key != NULL);
   GNUNET_assert (name != NULL);
@@ -1085,11 +1089,13 @@ GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinary
     return GNUNET_SYSERR;
   }
 
-  sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + rd_ser_len + name_len);
+  sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len);
   sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len);
   sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
-  name_tmp = (char *) &sig_purpose[1];
+  expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1];
+  name_tmp = (char *) &expire_tmp[1];
   rd_tmp = &name_tmp[name_len];
+  memcpy (expire_tmp, &expire_nbo, sizeof (struct GNUNET_TIME_AbsoluteNBO));
   memcpy (name_tmp, name, name_len);
   memcpy (rd_tmp, rd_ser, rd_ser_len);
 
index 311388b14c0a041d4a6eed482a71b954c7e705c0..b8236edf0b64bb7987c0c77cbcda4e613d8e00cf 100644 (file)
@@ -198,6 +198,7 @@ GNUNET_NAMESTORE_records_deserialize (size_t len,
  * Sign name and records
  *
  * @param key the private key
+ * @param expire block expiration
  * @param name the name
  * @param rd record data
  * @param rd_count number of records
@@ -206,14 +207,18 @@ GNUNET_NAMESTORE_records_deserialize (size_t len,
  */
 struct GNUNET_CRYPTO_RsaSignature *
 GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
+    struct GNUNET_TIME_Absolute expire,
     const char *name,
     const struct GNUNET_NAMESTORE_RecordData *rd,
     unsigned int rd_count)
 {
   struct GNUNET_CRYPTO_RsaSignature *sig = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignature));
   struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose;
+  struct GNUNET_TIME_AbsoluteNBO expire_nbo = GNUNET_TIME_absolute_hton(expire);
   size_t rd_ser_len;
   size_t name_len;
+
+  struct GNUNET_TIME_AbsoluteNBO *expire_tmp;
   char * name_tmp;
   char * rd_tmp;
   int res;
@@ -230,12 +235,13 @@ GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key
   char rd_ser[rd_ser_len];
   GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
 
-  sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + rd_ser_len + name_len);
-
+  sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len);
   sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len);
   sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
-  name_tmp = (char *) &sig_purpose[1];
+  expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1];
+  name_tmp = (char *) &expire_tmp[1];
   rd_tmp = &name_tmp[name_len];
+  memcpy (expire_tmp, &expire_nbo, sizeof (struct GNUNET_TIME_AbsoluteNBO));
   memcpy (name_tmp, name, name_len);
   memcpy (rd_tmp, rd_ser, rd_ser_len);
 
index f42fee2061cadbd863fb9e8a0ce09a67c5722b89..82c2d2ab573aff6398fbaec94fe9d1f08e59196f 100644 (file)
@@ -176,14 +176,14 @@ void name_lookup_second_proc (void *cls,
       }
     }
 
-    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(zone_key, n, rd_count, rd, signature))
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(zone_key, expire, n, rd_count, rd, signature))
     {
       GNUNET_break (0);
       failed = GNUNET_YES;
     }
 
 
-    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature))
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, n, rd_count, rd, signature))
     {
       GNUNET_break (0);
       failed = GNUNET_YES;
@@ -192,7 +192,7 @@ void name_lookup_second_proc (void *cls,
     struct GNUNET_NAMESTORE_RecordData rd_new[2];
     rd_new[0] = *s_first_record;
     rd_new[1] = *s_second_record;
-    s_signature_updated = GNUNET_NAMESTORE_create_signature(privkey, s_name, rd_new, 2);
+    s_signature_updated = GNUNET_NAMESTORE_create_signature(privkey, expire, s_name, rd_new, 2);
 
     if (0 != memcmp (s_signature_updated, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)))
     {
@@ -281,7 +281,7 @@ void name_lookup_initial_proc (void *cls,
       }
     }
 
-    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature))
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire,n, rd_count, rd, signature))
     {
       GNUNET_break (0);
       failed = GNUNET_YES;
@@ -423,7 +423,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   char rd_ser[rd_ser_len];
   GNUNET_NAMESTORE_records_serialize(1, s_first_record, rd_ser_len, rd_ser);
 
-  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, s_first_record, 1);
+  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_first_record->expiration, s_name, s_first_record, 1);
 
   /* create random zone hash */
   GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
index 4f8f6e05fde0c0e5420037863987b6e68e0fbd7a..9e8f9c4d4448a3ef43f1919acd02f6b0af81ea9c 100644 (file)
@@ -176,7 +176,7 @@ void name_lookup_second_proc (void *cls,
       }
     }
 
-    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature))
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, n, rd_count, rd, signature))
     {
       GNUNET_break (0);
       failed = GNUNET_YES;
@@ -185,7 +185,7 @@ void name_lookup_second_proc (void *cls,
     struct GNUNET_NAMESTORE_RecordData rd_new[2];
     rd_new[0] = *s_first_record;
     rd_new[1] = *s_second_record;
-    s_signature_updated = GNUNET_NAMESTORE_create_signature(privkey, s_name, rd_new, 2);
+    s_signature_updated = GNUNET_NAMESTORE_create_signature(privkey, expire, s_name, rd_new, 2);
 
     if (0 != memcmp (s_signature_updated, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)))
     {
@@ -274,7 +274,7 @@ void name_lookup_initial_proc (void *cls,
       }
     }
 
-    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature))
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, n, rd_count, rd, signature))
     {
       GNUNET_break (0);
       failed = GNUNET_YES;
@@ -462,7 +462,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   char rd_ser[rd_ser_len];
   GNUNET_NAMESTORE_records_serialize(1, s_first_record, rd_ser_len, rd_ser);
 
-  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, s_first_record, 1);
+  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_first_record->expiration, s_name, s_first_record, 1);
 
   /* create random zone hash */
   GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
index 47bc9b6723690770bc6b83cb5ac775e7642e7d64..4a33c6467cb88db3b7b8a7e538491b776a6672c0 100644 (file)
@@ -270,7 +270,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
 
   /* sign */
-  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, s_rd, RECORDS);
+  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_rd[0].expiration, s_name, s_rd, RECORDS);
 
   /* create random zone hash */
   GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
index 3facec50f7632ef345e62a025e9933c14374bb63..bd6a9f7d04d3238acea60026bf57baaedc4daaff 100644 (file)
@@ -279,7 +279,7 @@ create_record (int count)
 
   for (c = 0; c < RECORDS-1; c++)
   {
-  rd[c].expiration = GNUNET_TIME_absolute_get();
+  rd[c].expiration = GNUNET_TIME_absolute_get_zero();
   rd[c].record_type = 1;
   rd[c].data_size = TEST_RECORD_DATALEN;
   rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
@@ -342,7 +342,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
 
   /* sign */
-  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, s_rd, RECORDS);
+  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_rd[RECORDS -1].expiration, s_name, s_rd, RECORDS);
 
   /* create random zone hash */
   GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
index 310c9a33178a403e92759fff2c79fbc99e2d9186..190b5cec1f0114c9a807732f1d69e21c4160406a 100644 (file)
@@ -196,7 +196,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   char * s_name = "dummy.dummy.gnunet";
   s_rd = create_record (RECORDS);
 
-  signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, s_rd, RECORDS);
+  signature = GNUNET_NAMESTORE_create_signature(privkey, s_rd[0].expiration, s_name, s_rd, RECORDS);
 
   GNUNET_break (s_rd != NULL);
   GNUNET_break (s_name != NULL);
index 88c4771d14d73ca804ff77ba1f5739e6e991d311..3b05168c55b7877c200e2684900edc71c41ccb95 100644 (file)
@@ -174,7 +174,7 @@ void name_lookup_proc (void *cls,
       }
     }
 
-    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature))
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, n, rd_count, rd, signature))
     {
       GNUNET_break (0);
       failed = GNUNET_YES;
@@ -251,7 +251,7 @@ create_record (int count)
 
   for (c = 1; c < RECORDS; c++)
   {
-  rd[c].expiration = GNUNET_TIME_absolute_get();
+  rd[c].expiration = GNUNET_TIME_absolute_get_zero();
   rd[c].record_type = TEST_RECORD_TYPE;
   rd[c].data_size = TEST_RECORD_DATALEN;
   rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
@@ -306,7 +306,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
 
   /* sign */
-  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, s_rd, RECORDS);
+  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_rd[0].expiration, s_name, s_rd, RECORDS);
 
   /* create random zone hash */
   GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
index 431e7d1a552dd24dbfb7da3417967c3fc7adbdb7..bf50c6f175cdc7c2519c84ed988f46ab3a4b9e4a 100644 (file)
@@ -240,7 +240,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
 
   /* sign */
-  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, s_rd, RECORDS);
+  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_rd[0].expiration, s_name, s_rd, RECORDS);
 
   /* create random zone hash */
   GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
index 1fb4796110c0e4b29aef45748d052b536728856b..b9c9eec15912e721f760c7b5d52187ad67271ad5 100644 (file)
@@ -80,6 +80,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file);
   GNUNET_free (hostkey_file);
   GNUNET_assert (privkey != NULL);
+  struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get();
   /* get public key */
   GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
 
@@ -90,19 +91,19 @@ run (void *cls, char *const *args, const char *cfgfile,
   s_name = "dummy.dummy.gnunet";
   s_rd = create_record (RECORDS);
 
-  signature = GNUNET_NAMESTORE_create_signature (privkey, s_name, s_rd, RECORDS);
+  signature = GNUNET_NAMESTORE_create_signature (privkey, expire, s_name, s_rd, RECORDS);
   GNUNET_assert (signature != NULL);
 
-  res_c = GNUNET_NAMESTORE_verify_signature(&pubkey, s_name, RECORDS, s_rd, signature);
+  res_c = GNUNET_NAMESTORE_verify_signature(&pubkey, expire, s_name, RECORDS, s_rd, signature);
   GNUNET_break (res == GNUNET_OK);
 
   GNUNET_free (signature);
 
-  signature = GNUNET_NAMESTORE_create_signature (privkey, s_name, s_rd, RECORDS);
+  signature = GNUNET_NAMESTORE_create_signature (privkey, expire, s_name, s_rd, RECORDS);
   GNUNET_break (signature != NULL);
 
   GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "FYI: The next warning is intended!\n");
-  res_w = GNUNET_NAMESTORE_verify_signature(&pubkey, s_name, RECORDS - 1, s_rd, signature);
+  res_w = GNUNET_NAMESTORE_verify_signature(&pubkey, expire, s_name, RECORDS - 1, s_rd, signature);
   GNUNET_break (res_w == GNUNET_SYSERR);
 
   GNUNET_free (signature);
index ffc482e0d0bfbb76a770f1df76c9751df2c38f00..7433b95b03fb2180476dac3654161150c6f91c2b 100644 (file)
@@ -220,8 +220,12 @@ void zone_proc (void *cls,
   else
   {
     /* verify signature returned from name store */
-    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(zone_key, name, rd_count, rd, signature))
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (zone_key, expire, name, rd_count, rd, signature))
     {
+      GNUNET_HashCode zone_key_hash;
+      GNUNET_CRYPTO_hash (zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone_key_hash);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Verifying signature for `%s' in zone `%s' with %u records  and expiration %llu failed\n", name, GNUNET_h2s(&zone_key_hash), rd_count, expire.abs_value);
+
       failed = GNUNET_YES;
       GNUNET_break (0);
     }
@@ -284,7 +288,7 @@ void zone_proc (void *cls,
         failed = GNUNET_YES;
         GNUNET_break (0);
       }
-      if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(zone_key, name, rd_count, rd, signature))
+      if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(zone_key, expire, name, rd_count, rd, signature))
       {
         failed = GNUNET_YES;
         GNUNET_break (0);
@@ -430,7 +434,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 
   GNUNET_asprintf(&s_name_1, "dummy1");
   s_rd_1 = create_record(1);
-  sig_1 = GNUNET_NAMESTORE_create_signature(privkey, s_name_1, s_rd_1, 1);
+  sig_1 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_1->expiration, s_name_1, s_rd_1, 1);
   GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_1, s_rd_1, &put_cont, NULL);
 
 
@@ -438,14 +442,14 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_asprintf(&s_name_2, "dummy2");
   s_rd_2 = create_record(1);
 
-  sig_2 = GNUNET_NAMESTORE_create_signature(privkey, s_name_2, s_rd_2, 1);
+  sig_2 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_2->expiration, s_name_2, s_rd_2, 1);
   GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_2, s_rd_2, &put_cont, NULL);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n");
   /* name in different zone */
   GNUNET_asprintf(&s_name_3, "dummy3");
   s_rd_3 = create_record(1);
-  sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, s_name_3, s_rd_3, 1);
+  sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, s_rd_3->expiration, s_name_3, s_rd_3, 1);
   GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_absolute_get_forever(), 1, s_rd_3, sig_3, &put_cont, NULL);
 }
 
index 4b0ce817fa2bb00b542bbeed78ab3fe1bed44695..ae8e2da5c1e56024874fe013c37ddc6fad040194 100644 (file)
@@ -396,7 +396,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 
   GNUNET_asprintf(&s_name_1, "dummy1");
   s_rd_1 = create_record(1);
-  sig_1 = GNUNET_NAMESTORE_create_signature(privkey, s_name_1, s_rd_1, 1);
+  sig_1 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_1[0].expiration ,s_name_1, s_rd_1, 1);
   GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_1, s_rd_1, &put_cont, NULL);
 
 
@@ -404,14 +404,14 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_asprintf(&s_name_2, "dummy2");
   s_rd_2 = create_record(1);
 
-  sig_2 = GNUNET_NAMESTORE_create_signature(privkey, s_name_2, s_rd_2, 1);
+  sig_2 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_2[0].expiration, s_name_2, s_rd_2, 1);
   GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_2, s_rd_2, &put_cont, NULL);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n");
   /* name in different zone */
   GNUNET_asprintf(&s_name_3, "dummy3");
   s_rd_3 = create_record(1);
-  sig_3 = GNUNET_NAMESTORE_create_signature(privkey, s_name_3, s_rd_3, 1);
+  sig_3 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_3[0].expiration, s_name_3, s_rd_3, 1);
   GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_absolute_get_forever(), 1, s_rd_3, sig_3, &put_cont, NULL);
 }
 
index 419a058fad3d064eaa9640761f9e3195bf84eea0..47b09a00ca2d5ca3942ff843948ecf1ed154671f 100644 (file)
@@ -226,7 +226,7 @@ void zone_proc (void *cls,
   {
 
     /* verify signature returned from name store */
-    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(zone_key, name, rd_count, rd, signature))
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(zone_key, expire, name, rd_count, rd, signature))
     {
       failed = GNUNET_YES;
       GNUNET_break (0);
@@ -249,7 +249,7 @@ void zone_proc (void *cls,
         failed = GNUNET_YES;
         GNUNET_break (0);
       }
-      if (0 != memcmp (signature, sig_1, sizeof (struct GNUNET_CRYPTO_RsaSignature)))
+      if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, s_name_1, 1, s_rd_1, signature))
       {
         failed = GNUNET_YES;
         GNUNET_break (0);
@@ -271,7 +271,7 @@ void zone_proc (void *cls,
         GNUNET_break (0);
       }
 
-      if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey2, s_name_2, 1, s_rd_2, signature))
+      if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, s_name_2, 1, s_rd_2, signature))
       {
         failed = GNUNET_YES;
         GNUNET_break (0);
@@ -292,7 +292,7 @@ void zone_proc (void *cls,
         failed = GNUNET_YES;
         GNUNET_break (0);
       }
-      if (0 != memcmp (signature, sig_3, sizeof (struct GNUNET_CRYPTO_RsaSignature)))
+      if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey2, expire, s_name_3, 1, s_rd_3, signature))
       {
         failed = GNUNET_YES;
         GNUNET_break (0);
@@ -446,7 +446,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 
   GNUNET_asprintf(&s_name_1, "dummy1");
   s_rd_1 = create_record(1);
-  sig_1 = GNUNET_NAMESTORE_create_signature(privkey, s_name_1, s_rd_1, 1);
+  sig_1 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_1[0].expiration, s_name_1, s_rd_1, 1);
   GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_1, s_rd_1, &put_cont, NULL);
 
 
@@ -454,14 +454,14 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_asprintf(&s_name_2, "dummy2");
   s_rd_2 = create_record(1);
 
-  sig_2 = GNUNET_NAMESTORE_create_signature(privkey, s_name_2, s_rd_2, 1);
+  sig_2 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_2[0].expiration, s_name_2, s_rd_2, 1);
   GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_2, s_rd_2, &put_cont, NULL);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n");
   /* name in different zone */
   GNUNET_asprintf(&s_name_3, "dummy3");
   s_rd_3 = create_record(1);
-  sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, s_name_3, s_rd_3, 1);
+  sig_3 = GNUNET_NAMESTORE_create_signature(privkey2, s_rd_3[0].expiration, s_name_3, s_rd_3, 1);
   GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_absolute_get_forever(), 1, s_rd_3, sig_3, &put_cont, NULL);
 }
 
index 498b1197da6c5b4c13bc989615c9125d3077022e..ba15389f06ae8cb487c797c2829e26330f977bf9 100644 (file)
@@ -247,7 +247,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_break (NULL != nsh);
 
   expire = GNUNET_TIME_absolute_get ();
-  s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, &rd, 1);
+  s_signature = GNUNET_NAMESTORE_create_signature(privkey, rd.expiration, s_name, &rd, 1);
   GNUNET_NAMESTORE_record_put(nsh, &pubkey, s_name, expire, 1, &rd, s_signature, put_cont, NULL);
 
   GNUNET_free ((void *) rd.data);