- usage of short hashes
authorMatthias Wachs <wachs@net.in.tum.de>
Mon, 19 Mar 2012 17:11:46 +0000 (17:11 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Mon, 19 Mar 2012 17:11:46 +0000 (17:11 +0000)
15 files changed:
src/namestore/gnunet-namestore.c
src/namestore/gnunet-service-namestore.c
src/namestore/namestore.h
src/namestore/namestore_api.c
src/namestore/namestore_common.c
src/namestore/plugin_namestore_sqlite.c
src/namestore/test_namestore_api.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_remove.c
src/namestore/test_namestore_api_zone_iteration_specific_zone.c
src/namestore/test_namestore_api_zone_to_name.c
src/namestore/test_plugin_namestore.c

index bd083470eef2afd42a84d2013f977afb6fae15da..eb77913cc50a1f4c953427b4282f88ace6bad637 100644 (file)
@@ -41,7 +41,7 @@ static struct GNUNET_NAMESTORE_Handle *ns;
 /**
  * Hash of the public key of our zone.
  */
-static GNUNET_HashCode zone;
+static struct GNUNET_CRYPTO_ShortHashCode zone;
 
 /**
  * Private key for the our zone.
@@ -292,7 +292,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   }
   GNUNET_CRYPTO_rsa_key_get_public (zone_pkey,
                                    &pub);
-  GNUNET_CRYPTO_hash (&pub, sizeof (pub), &zone);
+  GNUNET_CRYPTO_short_hash (&pub, sizeof (pub), &zone);
 
   ns = GNUNET_NAMESTORE_connect (cfg);
   if (NULL == ns)
index 6b4250d38b7fdb0e729df912815cc40ecde76d45..f45492fc8b6a91def75969787fdd5c01300cf6df 100644 (file)
@@ -45,7 +45,7 @@ struct GNUNET_NAMESTORE_ZoneIteration
 
   int has_zone;
 
-  GNUNET_HashCode zone;
+  struct GNUNET_CRYPTO_ShortHashCode zone;
 
   uint64_t request_id;
   uint32_t offset;
@@ -73,7 +73,7 @@ struct GNUNET_NAMESTORE_CryptoContainer
 {
   char * filename;
 
-  GNUNET_HashCode zone;
+  struct GNUNET_CRYPTO_ShortHashCode zone;
   struct GNUNET_CRYPTO_RsaPrivateKey *privkey;
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pubkey;
 };
@@ -125,7 +125,7 @@ write_key_to_file (const char *filename, struct GNUNET_NAMESTORE_CryptoContainer
 
   if (GNUNET_YES == GNUNET_DISK_file_test (filename))
   {
-    GNUNET_HashCode zone;
+    struct GNUNET_CRYPTO_ShortHashCode zone;
     struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
     struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
 
@@ -133,24 +133,24 @@ write_key_to_file (const char *filename, struct GNUNET_NAMESTORE_CryptoContainer
     if (privkey == NULL)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-           _("File zone `%s' but corrupt content already exists, failed to write! \n"), GNUNET_h2s (&zone));
+           _("File zone `%s' but corrupt content already exists, failed to write! \n"), GNUNET_short_h2s (&zone));
       return GNUNET_SYSERR;
     }
 
-    GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
-    GNUNET_CRYPTO_hash(&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone);
-    GNUNET_CRYPTO_rsa_key_free(privkey);
+    GNUNET_CRYPTO_rsa_key_get_public (privkey, &pubkey);
+    GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone);
+    GNUNET_CRYPTO_rsa_key_free (privkey);
 
     if (0 == memcmp (&zone, &c->zone, sizeof(zone)))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-           _("File zone `%s' containing this key already exists\n"), GNUNET_h2s (&zone));
+           _("File zone `%s' containing this key already exists\n"), GNUNET_short_h2s (&zone));
       return GNUNET_OK;
     }
     else
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-           _("File zone `%s' but different zone key already exists, failed to write! \n"), GNUNET_h2s (&zone));
+           _("File zone `%s' but different zone key already exists, failed to write! \n"), GNUNET_short_h2s (&zone));
       return GNUNET_OK;
     }
   }
@@ -185,12 +185,12 @@ write_key_to_file (const char *filename, struct GNUNET_NAMESTORE_CryptoContainer
   GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-       _("Stored zonekey for zone `%s' in file `%s'\n"), GNUNET_h2s(&c->zone), c->filename);
+       _("Stored zonekey for zone `%s' in file `%s'\n"), GNUNET_short_h2s(&c->zone), c->filename);
   return GNUNET_OK;
 }
 
 int zone_to_disk_it (void *cls,
-                     const GNUNET_HashCode * key,
+                     const GNUNET_HashCode *key,
                      void *value)
 {
   struct GNUNET_NAMESTORE_CryptoContainer * c = value;
@@ -199,11 +199,12 @@ int zone_to_disk_it (void *cls,
     write_key_to_file(c->filename, c);
   else
   {
-    GNUNET_asprintf(&c->filename, "%s/%s.zkey", zonefile_directory, GNUNET_h2s_full (&c->zone));
+    GNUNET_asprintf(&c->filename, "%s/%s.zkey", zonefile_directory, GNUNET_short_h2s (&c->zone));
     write_key_to_file(c->filename, c);
   }
 
-  GNUNET_CONTAINER_multihashmap_remove (zonekeys, key, value);;
+
+  GNUNET_CONTAINER_multihashmap_remove (zonekeys, key, value);
   GNUNET_CRYPTO_rsa_key_free(c->privkey);
   GNUNET_free (c->pubkey);
   GNUNET_free(c->filename);
@@ -340,7 +341,7 @@ struct LookupNameContext
   struct GNUNET_NAMESTORE_Client *nc;
   uint32_t request_id;
   uint32_t record_type;
-  GNUNET_HashCode *zone;
+  struct GNUNET_CRYPTO_ShortHashCode *zone;
   char * name;
 };
 
@@ -352,12 +353,12 @@ void drop_iterator (void *cls,
                    const struct GNUNET_NAMESTORE_RecordData *rd,
                    const struct GNUNET_CRYPTO_RsaSignature *signature)
 {
-  GNUNET_HashCode zone_hash;
+  struct GNUNET_CRYPTO_ShortHashCode zone_hash;
   int * stop = cls;
   if (NULL != zone_key)
   {
-    GNUNET_CRYPTO_hash(zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone_hash);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting zone `%s'\n", GNUNET_h2s (&zone_hash));
+    GNUNET_CRYPTO_short_hash(zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone_hash);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting zone `%s'\n", GNUNET_short_h2s (&zone_hash));
     GSN_database->delete_zone (GSN_database->cls, &zone_hash);
   }
   else
@@ -383,7 +384,8 @@ handle_lookup_name_it (void *cls,
   struct GNUNET_NAMESTORE_CryptoContainer *cc;
   struct GNUNET_CRYPTO_RsaSignature *signature_new = NULL;
   struct GNUNET_TIME_Absolute e;
-  GNUNET_HashCode zone_key_hash;
+  struct GNUNET_CRYPTO_ShortHashCode zone_key_hash;
+  GNUNET_HashCode long_hash;
   char *rd_tmp;
   char *name_tmp;
   size_t rd_ser_len;
@@ -408,7 +410,7 @@ handle_lookup_name_it (void *cls,
         if (rd[c].record_type == lnc->record_type)
           copied_elements++; /* found matching record */
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u records with type %u for name `%s' in zone `%s'\n",
-          copied_elements, lnc->record_type, lnc->name, GNUNET_h2s(lnc->zone));
+          copied_elements, lnc->record_type, lnc->name, GNUNET_short_h2s(lnc->zone));
       rd_selected = GNUNET_malloc (copied_elements * sizeof (struct GNUNET_NAMESTORE_RecordData));
       copied_elements = 0;
       for (c = 0; c < rd_count; c ++)
@@ -440,7 +442,7 @@ handle_lookup_name_it (void *cls,
   GNUNET_NAMESTORE_records_serialize(copied_elements, rd_selected, rd_ser_len, rd_ser);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u records for name `%s' in zone `%s'\n",
-      copied_elements, lnc->name, GNUNET_h2s(lnc->zone));
+      copied_elements, lnc->name, GNUNET_short_h2s(lnc->zone));
 
   if ((copied_elements == rd_count) && (NULL != signature))
     contains_signature = GNUNET_YES; /* returning all records, so include signature */
@@ -450,18 +452,19 @@ handle_lookup_name_it (void *cls,
 
   if ((NULL != zone_key) && (copied_elements == rd_count))
   {
-    GNUNET_CRYPTO_hash(zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone_key_hash);
-    if (GNUNET_CONTAINER_multihashmap_contains(zonekeys, &zone_key_hash))
+    GNUNET_CRYPTO_short_hash(zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone_key_hash);
+    GNUNET_CRYPTO_short_hash_double (&zone_key_hash, &long_hash);
+    if (GNUNET_CONTAINER_multihashmap_contains(zonekeys, &long_hash))
     {
-      cc = GNUNET_CONTAINER_multihashmap_get(zonekeys, &zone_key_hash);
+      cc = GNUNET_CONTAINER_multihashmap_get(zonekeys, &long_hash);
       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));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating signature for name `%s' with %u records in zone `%s'\n",name, copied_elements, GNUNET_short_h2s(&zone_key_hash));
       authoritative = GNUNET_YES;
     }
     else
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am not authoritative for name `%s' in zone `%s'\n",name, GNUNET_h2s(&zone_key_hash));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "I am not authoritative for name `%s' in zone `%s'\n",name, GNUNET_short_h2s(&zone_key_hash));
   }
 
   r_size = sizeof (struct LookupNameResponseMessage) +
@@ -565,9 +568,9 @@ static void handle_lookup_name (void *cls,
   }
 
   if (0 == type)
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up all records for name `%s' in zone `%s'\n", name, GNUNET_h2s(&ln_msg->zone));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up all records for name `%s' in zone `%s'\n", name, GNUNET_short_h2s(&ln_msg->zone));
   else
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up records with type %u for name `%s' in zone `%s'\n", type, name, GNUNET_h2s(&ln_msg->zone));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up records with type %u for name `%s' in zone `%s'\n", type, name, GNUNET_short_h2s(&ln_msg->zone));
 
   /* do the actual lookup */
   lnc.request_id = rid;
@@ -672,10 +675,10 @@ static void handle_record_put (void *cls,
     goto send;
   }
 
-  GNUNET_HashCode zone_hash;
-  GNUNET_CRYPTO_hash (&rp_msg->public_key, sizeof (rp_msg->public_key), &zone_hash);
+  struct GNUNET_CRYPTO_ShortHashCode zone_hash;
+  GNUNET_CRYPTO_short_hash (&rp_msg->public_key, sizeof (rp_msg->public_key), &zone_hash);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Putting %u record for name `%s' in zone `%s'\n", rd_count, name, GNUNET_h2s(&zone_hash));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Putting %u record for name `%s' in zone `%s'\n", rd_count, name, GNUNET_short_h2s(&zone_hash));
 
   /* Database operation */
   res = GSN_database->put_records(GSN_database->cls,
@@ -836,7 +839,8 @@ static void handle_record_create (void *cls,
   struct GNUNET_CRYPTO_RsaPrivateKey *pkey;
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
   struct RecordCreateResponseMessage rcr_msg;
-  GNUNET_HashCode pubkey_hash;
+  struct GNUNET_CRYPTO_ShortHashCode pubkey_hash;
+  GNUNET_HashCode long_hash;
   size_t name_len;
   size_t msg_size;
   size_t msg_size_exp;
@@ -914,19 +918,19 @@ static void handle_record_create (void *cls,
   pkey = GNUNET_CRYPTO_rsa_decode_key((char *) pkey_tmp, key_len);
   GNUNET_assert (pkey != NULL);
   GNUNET_CRYPTO_rsa_key_get_public(pkey, &pub);
-  GNUNET_CRYPTO_hash (&pub, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pubkey_hash);
+  GNUNET_CRYPTO_short_hash (&pub, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pubkey_hash);
+  GNUNET_CRYPTO_short_hash_double (&pubkey_hash, &long_hash);
 
-  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(zonekeys, &pubkey_hash))
+  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(zonekeys, &long_hash))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received new private key for zone `%s'\n",GNUNET_h2s(&pubkey_hash));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received new private key for zone `%s'\n",GNUNET_short_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);
+    GNUNET_CONTAINER_multihashmap_put(zonekeys, &long_hash, cc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
   }
 
   crc.expire = GNUNET_TIME_absolute_ntoh(rp_msg->expire);
@@ -936,7 +940,7 @@ static void handle_record_create (void *cls,
   crc.rd = rd;
   crc.name = name_tmp;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating record for name `%s' in zone `%s'\n", name_tmp, GNUNET_h2s(&pubkey_hash));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating record for name `%s' in zone `%s'\n", name_tmp, GNUNET_short_h2s(&pubkey_hash));
 
   /* Get existing records for name */
   res = GSN_database->iterate_records(GSN_database->cls, &pubkey_hash, name_tmp, 0, &handle_create_record_it, &crc);
@@ -1064,7 +1068,8 @@ static void handle_record_remove (void *cls,
   struct GNUNET_CRYPTO_RsaPrivateKey *pkey;
   struct GNUNET_NAMESTORE_CryptoContainer *cc = NULL;
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
-  GNUNET_HashCode pubkey_hash;
+  struct GNUNET_CRYPTO_ShortHashCode pubkey_hash;
+  GNUNET_HashCode long_hash;
   char * pkey_tmp = NULL;
   char * name_tmp = NULL;
   char * rd_ser = NULL;
@@ -1154,18 +1159,19 @@ static void handle_record_remove (void *cls,
   pkey = GNUNET_CRYPTO_rsa_decode_key((char *) pkey_tmp, key_len);
   GNUNET_assert (pkey != NULL);
   GNUNET_CRYPTO_rsa_key_get_public(pkey, &pub);
-  GNUNET_CRYPTO_hash (&pub, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pubkey_hash);
+  GNUNET_CRYPTO_short_hash (&pub, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pubkey_hash);
+  GNUNET_CRYPTO_short_hash_double (&pubkey_hash, &long_hash);
 
-  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(zonekeys, &pubkey_hash))
+  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(zonekeys, &long_hash))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received new private key for zone `%s'\n",GNUNET_h2s(&pubkey_hash));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received new private key for zone `%s'\n",GNUNET_short_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);
+    GNUNET_CONTAINER_multihashmap_put(zonekeys, &long_hash, cc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
   }
 
   struct GNUNET_NAMESTORE_RecordData rd[rd_count];
@@ -1180,7 +1186,7 @@ static void handle_record_remove (void *cls,
   rrc.rd = rd;
   rrc.pkey = pkey;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing record for name `%s' in zone `%s'\n", name_tmp, GNUNET_h2s(&pubkey_hash));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing record for name `%s' in zone `%s'\n", name_tmp, GNUNET_short_h2s(&pubkey_hash));
 
   /* Database operation */
   res = GSN_database->iterate_records (GSN_database->cls,
@@ -1342,10 +1348,10 @@ static void handle_zone_to_name (void *cls,
   ztn_ctx.rid = rid;
   ztn_ctx.nc = nc;
 
-  char * z_tmp = strdup (GNUNET_h2s (&ztn_msg->zone));
+  char * z_tmp = strdup (GNUNET_short_h2s (&ztn_msg->zone));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up name for zone `%s' in zone `%s'\n",
       z_tmp,
-      GNUNET_h2s (&ztn_msg->value_zone));
+      GNUNET_short_h2s (&ztn_msg->value_zone));
   GNUNET_free (z_tmp);
 
   GSN_database->zone_to_name (GSN_database->cls, &ztn_msg->zone, &ztn_msg->value_zone, &handle_zone_to_name_it, &ztn_ctx);
@@ -1383,14 +1389,15 @@ void zone_iteration_proc (void *cls,
   struct GNUNET_NAMESTORE_CryptoContainer * cc;
   struct GNUNET_CRYPTO_RsaSignature *signature_new = NULL;
   struct GNUNET_TIME_Absolute e;
-  GNUNET_HashCode zone_key_hash;
+  struct GNUNET_CRYPTO_ShortHashCode zone_key_hash;
+  GNUNET_HashCode long_hash;
   int authoritative = GNUNET_NO;
 
   if ((zone_key == NULL) && (name == NULL))
   {
     struct ZoneIterationResponseMessage zir_msg;
     if (zi->has_zone == GNUNET_YES)
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No more results for zone `%s'\n", GNUNET_h2s(&zi->zone));
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No more results for zone `%s'\n", GNUNET_short_h2s(&zi->zone));
     else
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No more results for all zones\n");
 
@@ -1417,7 +1424,7 @@ void zone_iteration_proc (void *cls,
     struct ZoneIterationResponseMessage *zir_msg;
     if (zi->has_zone == GNUNET_YES)
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending name `%s' for iteration over zone `%s'\n",
-          name, GNUNET_h2s(&zi->zone));
+          name, GNUNET_short_h2s(&zi->zone));
     if (zi->has_zone == GNUNET_NO)
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending name `%s' for iteration over all zones\n",
           name);
@@ -1438,15 +1445,16 @@ void zone_iteration_proc (void *cls,
     name_tmp = (char *) &zir_msg[1];
     rd_tmp = &name_tmp[name_len];
 
-    GNUNET_CRYPTO_hash(zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone_key_hash);
-    if (GNUNET_CONTAINER_multihashmap_contains(zonekeys, &zone_key_hash))
+    GNUNET_CRYPTO_short_hash(zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone_key_hash);
+    GNUNET_CRYPTO_short_hash_double(&zone_key_hash, &long_hash);
+    if (GNUNET_CONTAINER_multihashmap_contains(zonekeys, &long_hash))
     {
-      cc = GNUNET_CONTAINER_multihashmap_get(zonekeys, &zone_key_hash);
+      cc = GNUNET_CONTAINER_multihashmap_get(zonekeys, &long_hash);
       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 `%s' in zone `%s' with %u records  and expiration %llu\n", name, GNUNET_h2s(&zone_key_hash), rd_count, e.abs_value);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating signature for `%s' in zone `%s' with %u records  and expiration %llu\n", name, GNUNET_short_h2s(&zone_key_hash), rd_count, e.abs_value);
       authoritative = GNUNET_YES;
     }
 
@@ -1502,8 +1510,8 @@ static void handle_iteration_start (void *cls,
   zi->client = nc;
   zi->zone = zis_msg->zone;
 
-  GNUNET_HashCode dummy;
-  GNUNET_HashCode *zone_tmp;
+  struct GNUNET_CRYPTO_ShortHashCode dummy;
+  struct GNUNET_CRYPTO_ShortHashCode *zone_tmp;
   memset (&dummy, '\0', sizeof (dummy));
   if (0 == memcmp (&dummy, &zis_msg->zone, sizeof (dummy)))
   {
@@ -1513,7 +1521,7 @@ static void handle_iteration_start (void *cls,
   }
   else
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting to iterate over zone  `%s'\n", GNUNET_h2s (&zis_msg->zone));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting to iterate over zone  `%s'\n", GNUNET_short_h2s (&zis_msg->zone));
     zi->has_zone = GNUNET_YES;
     zone_tmp = &zis_msg->zone;
   }
@@ -1558,7 +1566,7 @@ static void handle_iteration_stop (void *cls,
 
   GNUNET_CONTAINER_DLL_remove(nc->op_head, nc->op_tail, zi);
   if (GNUNET_YES == zi->has_zone)
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopped zone iteration for zone `%s'\n", GNUNET_h2s (&zi->zone));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopped zone iteration for zone `%s'\n", GNUNET_short_h2s (&zi->zone));
   else
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopped zone iteration all zones\n");
   GNUNET_free (zi);
@@ -1574,7 +1582,7 @@ static void handle_iteration_next (void *cls,
 
   struct GNUNET_NAMESTORE_Client *nc;
   struct GNUNET_NAMESTORE_ZoneIteration *zi;
-  GNUNET_HashCode *zone_tmp;
+  struct GNUNET_CRYPTO_ShortHashCode *zone_tmp;
   struct ZoneIterationStopMessage * zis_msg = (struct ZoneIterationStopMessage *) message;
   uint32_t rid;
 
@@ -1611,6 +1619,7 @@ static void handle_iteration_next (void *cls,
 
 int zonekey_file_it (void *cls, const char *filename)
 {
+  GNUNET_HashCode long_hash;
   int *counter = cls;
    if ((filename != NULL) && (NULL != strstr(filename, ".zkey")))
    {
@@ -1624,11 +1633,12 @@ int zonekey_file_it (void *cls, const char *filename)
      c->pubkey = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
      c->privkey = privkey;
      GNUNET_CRYPTO_rsa_key_get_public(privkey, c->pubkey);
-     GNUNET_CRYPTO_hash(c->pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &c->zone);
-
-     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found zonefile for zone `%s'\n", GNUNET_h2s (&c->zone));
+     GNUNET_CRYPTO_short_hash(c->pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &c->zone);
 
-     GNUNET_CONTAINER_multihashmap_put(zonekeys, &c->zone, c, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+     //GNUNET_CRYPTO_short_hash_to_enc (&name_hase, &name_enc);
+     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found zonefile for zone `%s'\n", GNUNET_short_h2s (&c->zone));
+     GNUNET_CRYPTO_short_hash_double (&c->zone, &long_hash);
+     GNUNET_CONTAINER_multihashmap_put(zonekeys, &long_hash, c, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
      (*counter) ++;
    }
    return GNUNET_OK;
index 48e021f6dc4e436432013294ede15ab90ed4373b..c7af82dc3c876c60fb06efed39911b0efb570e5c 100644 (file)
 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT 447
 #define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 448
 
+/**
+ * Convert a short hash to a string (for printing debug messages).
+ * This is one of the very few calls in the entire API that is
+ * NOT reentrant!
+ *
+ * @param hc the short hash code
+ * @return string form; will be overwritten by next call to GNUNET_h2s.
+ */
+const char *
+GNUNET_short_h2s (const struct GNUNET_CRYPTO_ShortHashCode * hc);
+
 /**
  * Sign name and records
  *
@@ -150,7 +161,7 @@ struct LookupNameMessage
   /**
    * The zone 
    */
-  GNUNET_HashCode zone;
+  struct GNUNET_CRYPTO_ShortHashCode zone;
 
   /**
    * Requested record type 
@@ -419,12 +430,12 @@ struct ZoneToNameMessage
   /**
    * The hash of public key of the zone to look up in 
    */
-  GNUNET_HashCode zone;
+  struct GNUNET_CRYPTO_ShortHashCode zone;
 
   /**
    * The  hash of the public key of the target zone  
    */
-  GNUNET_HashCode value_zone;
+  struct GNUNET_CRYPTO_ShortHashCode value_zone;
 };
 
 /**
@@ -487,7 +498,7 @@ struct ZoneIterationStartMessage
   /**
    * Zone hash
    */
-  GNUNET_HashCode zone;
+  struct GNUNET_CRYPTO_ShortHashCode zone;
 
   /**
    * Which flags must be included
index 4abad4d1c7745cafaa142c5b65e1300a03112612..be80e2091da4468787e015a816b0e4e62d021edd 100644 (file)
@@ -90,7 +90,7 @@ struct GNUNET_NAMESTORE_ZoneIterator
   struct GNUNET_NAMESTORE_Handle *h;
   GNUNET_NAMESTORE_RecordProcessor proc;
   void* proc_cls;
-  GNUNET_HashCode zone;
+  struct GNUNET_CRYPTO_ShortHashCode zone;
   uint32_t no_flags;
   uint32_t flags;
   int has_zone;
@@ -193,7 +193,7 @@ struct GNUNET_NAMESTORE_SimpleRecord
   struct GNUNET_NAMESTORE_SimpleRecord *prev;
   
   const char *name;
-  const GNUNET_HashCode *zone;
+  const struct GNUNET_CRYPTO_ShortHashCode *zone;
   uint32_t record_type;
   struct GNUNET_TIME_Absolute expiration;
   enum GNUNET_NAMESTORE_RecordFlags flags;
@@ -1316,7 +1316,7 @@ GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h,
  */
 struct GNUNET_NAMESTORE_QueueEntry *
 GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h, 
-                             const GNUNET_HashCode *zone,
+                             const struct GNUNET_CRYPTO_ShortHashCode *zone,
                              const char *name,
                              uint32_t record_type,
                              GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
@@ -1388,8 +1388,8 @@ GNUNET_NAMESTORE_lookup_record (struct GNUNET_NAMESTORE_Handle *h,
  */
 struct GNUNET_NAMESTORE_QueueEntry *
 GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
-                               const GNUNET_HashCode *zone,
-                               const GNUNET_HashCode *value_zone,
+                               const struct GNUNET_CRYPTO_ShortHashCode *zone,
+                               const struct GNUNET_CRYPTO_ShortHashCode *value_zone,
                                GNUNET_NAMESTORE_RecordProcessor proc, void *proc_cls)
 {
   struct GNUNET_NAMESTORE_QueueEntry *qe;
@@ -1424,11 +1424,11 @@ GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
   msg->zone = *zone;
   msg->value_zone = *value_zone;
 
-  char * z_tmp = strdup (GNUNET_h2s (zone));
+  char * z_tmp = strdup (GNUNET_short_h2s (zone));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s' in zone `%s'\n",
       "NAMESTORE_ZONE_TO_NAME",
       z_tmp,
-      GNUNET_h2s (value_zone));
+      GNUNET_short_h2s (value_zone));
   GNUNET_free (z_tmp);
 
   /* transmit message */
@@ -1460,7 +1460,7 @@ GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h,
  */
 struct GNUNET_NAMESTORE_ZoneIterator *
 GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
-                                      const GNUNET_HashCode *zone,
+                                      const struct GNUNET_CRYPTO_ShortHashCode *zone,
                                       enum GNUNET_NAMESTORE_RecordFlags must_have_flags,
                                       enum GNUNET_NAMESTORE_RecordFlags must_not_have_flags,
                                       GNUNET_NAMESTORE_RecordProcessor proc,
@@ -1507,7 +1507,7 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h,
   msg->gns_header.r_id = htonl (rid);
   if (NULL != zone)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_START", GNUNET_h2s(zone));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_START", GNUNET_short_h2s(zone));
     msg->zone = *zone;
   }
   else
@@ -1610,7 +1610,7 @@ GNUNET_NAMESTORE_zone_iteration_stop (struct GNUNET_NAMESTORE_ZoneIterator *it)
   msg->gns_header.r_id = htonl (it->op_id);
 
   if (GNUNET_YES == it->has_zone)
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_STOP", GNUNET_h2s(&it->zone));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for zone `%s'\n", "ZONE_ITERATION_STOP", GNUNET_short_h2s(&it->zone));
   else
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for all zones\n", "ZONE_ITERATION_STOP");
 
index 45fccbb186e16aea65dc1aa5c33dc0b77e5de256..403f75ea8c5a53b6eaf52a65c58c3597b1c9bfea 100644 (file)
@@ -66,6 +66,25 @@ struct NetworkRecord
   
 };
 
+
+/**
+ * Convert a short hash to a string (for printing debug messages).
+ * This is one of the very few calls in the entire API that is
+ * NOT reentrant!
+ *
+ * @param hc the short hash code
+ * @return string form; will be overwritten by next call to GNUNET_h2s.
+ */
+const char *
+GNUNET_short_h2s (const struct GNUNET_CRYPTO_ShortHashCode * hc)
+{
+  static struct GNUNET_CRYPTO_ShortHashAsciiEncoded ret;
+
+  GNUNET_CRYPTO_short_hash_to_enc (hc, &ret);
+  return (const char *) &ret;
+}
+
+
 /**
  * Calculate how many bytes we will need to serialize the given
  * records.
index 39cd185fce051d48341e93c43eb5a5eb4e2db4a9..45fad545cddc547b3cd1ba0fea05c6e75d524b10 100644 (file)
@@ -397,19 +397,18 @@ database_shutdown (struct Plugin *plugin)
  */
 static int 
 namestore_sqlite_remove_records (void *cls, 
-                                const GNUNET_HashCode *zone,
+                                const struct GNUNET_CRYPTO_ShortHashCode *zone,
                                 const char *name)
 {
   struct Plugin *plugin = cls;
-  GNUNET_HashCode nh;
+  struct GNUNET_CRYPTO_ShortHashCode nh;
   size_t name_len;
   int n;
-
   name_len = strlen (name);
-  GNUNET_CRYPTO_hash (name, name_len, &nh);
+  GNUNET_CRYPTO_short_hash (name, name_len, &nh);
 
-  if ((SQLITE_OK != sqlite3_bind_blob (plugin->remove_records, 1, zone, sizeof (GNUNET_HashCode), SQLITE_STATIC)) ||
-      (SQLITE_OK != sqlite3_bind_blob (plugin->remove_records, 2, &nh, sizeof (GNUNET_HashCode), SQLITE_STATIC)))
+  if ((SQLITE_OK != sqlite3_bind_blob (plugin->remove_records, 1, zone, sizeof (struct GNUNET_CRYPTO_ShortHashCode), SQLITE_STATIC)) ||
+      (SQLITE_OK != sqlite3_bind_blob (plugin->remove_records, 2, &nh, sizeof (struct GNUNET_CRYPTO_ShortHashCode), SQLITE_STATIC)))
   {
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_bind_XXXX");
@@ -466,26 +465,26 @@ namestore_sqlite_put_records (void *cls,
 {
   struct Plugin *plugin = cls;
   int n;
-  GNUNET_HashCode zone;
-  GNUNET_HashCode zone_delegation;
-  GNUNET_HashCode nh;
+  struct GNUNET_CRYPTO_ShortHashCode zone;
+  struct GNUNET_CRYPTO_ShortHashCode zone_delegation;
+  struct GNUNET_CRYPTO_ShortHashCode nh;
   size_t name_len;
   uint64_t rvalue;
   size_t data_size;
   unsigned int i;
 
-  GNUNET_CRYPTO_hash (zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone);
+  GNUNET_CRYPTO_short_hash (zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone);
   (void) namestore_sqlite_remove_records (plugin, &zone, name);
   name_len = strlen (name);
-  GNUNET_CRYPTO_hash (name, name_len, &nh);
+  GNUNET_CRYPTO_short_hash (name, name_len, &nh);
   memset (&zone_delegation, 0, sizeof (zone_delegation));
   for (i=0;i<rd_count;i++)
     if (rd[i].record_type == GNUNET_NAMESTORE_TYPE_PKEY)
     {
-      GNUNET_assert (sizeof (GNUNET_HashCode) == rd[i].data_size);
+      GNUNET_assert (sizeof (struct GNUNET_CRYPTO_ShortHashCode) == rd[i].data_size);
       memcpy (&zone_delegation,
              rd[i].data,
-             sizeof (GNUNET_HashCode));
+             sizeof (struct GNUNET_CRYPTO_ShortHashCode));
       break;
     }
   rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
@@ -510,9 +509,9 @@ namestore_sqlite_put_records (void *cls,
        (SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 4, data, data_size, SQLITE_STATIC)) ||
        (SQLITE_OK != sqlite3_bind_int64 (plugin->put_records, 5, expire.abs_value)) ||
        (SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 6, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature), SQLITE_STATIC)) ||
-       (SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 7, &zone_delegation, sizeof (GNUNET_HashCode), SQLITE_STATIC)) ||
-       (SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 8, &zone, sizeof (GNUNET_HashCode), SQLITE_STATIC)) ||
-       (SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 9, &nh, sizeof (GNUNET_HashCode), SQLITE_STATIC)) ||
+       (SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 7, &zone_delegation, sizeof (struct GNUNET_CRYPTO_ShortHashCode), SQLITE_STATIC)) ||
+       (SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 8, &zone, sizeof (struct GNUNET_CRYPTO_ShortHashCode), SQLITE_STATIC)) ||
+       (SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 9, &nh, sizeof (struct GNUNET_CRYPTO_ShortHashCode), SQLITE_STATIC)) ||
        (SQLITE_OK != sqlite3_bind_int64 (plugin->put_records, 10, rvalue)) )
     {
       LOG_SQLITE (plugin, 
@@ -638,14 +637,14 @@ get_record_and_call_iterator (struct Plugin *plugin,
  */
 static int 
 namestore_sqlite_iterate_records (void *cls, 
-                                 const GNUNET_HashCode *zone,
+                                 const struct GNUNET_CRYPTO_ShortHashCode *zone,
                                  const char *name,
                                  uint64_t offset,
                                  GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
 {
   struct Plugin *plugin = cls;
   sqlite3_stmt *stmt;
-  GNUNET_HashCode name_hase;
+  struct GNUNET_CRYPTO_ShortHashCode name_hase;
   unsigned int boff;
 
   if (NULL == zone)
@@ -653,7 +652,7 @@ namestore_sqlite_iterate_records (void *cls,
       stmt = plugin->iterate_all;
     else
     {
-      GNUNET_CRYPTO_hash (name, strlen(name), &name_hase);
+      GNUNET_CRYPTO_short_hash (name, strlen(name), &name_hase);
       stmt = plugin->iterate_by_name;
     }
   else
@@ -661,14 +660,14 @@ namestore_sqlite_iterate_records (void *cls,
       stmt = plugin->iterate_by_zone;
     else
     {
-      GNUNET_CRYPTO_hash (name, strlen(name), &name_hase);
+      GNUNET_CRYPTO_short_hash (name, strlen(name), &name_hase);
       stmt = plugin->iterate_records;
     }
 
   boff = 0;
   if ( (NULL != zone) &&
        (SQLITE_OK != sqlite3_bind_blob (stmt, ++boff, 
-                                       zone, sizeof (GNUNET_HashCode), 
+                                       zone, sizeof (struct GNUNET_CRYPTO_ShortHashCode),
                                        SQLITE_STATIC)) )
   {
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
@@ -681,10 +680,10 @@ namestore_sqlite_iterate_records (void *cls,
   }      
   if ( (NULL != name) &&
        (SQLITE_OK != sqlite3_bind_blob (stmt, ++boff, 
-                                       &name_hase, sizeof (GNUNET_HashCode),
+                                       &name_hase, sizeof (struct GNUNET_CRYPTO_ShortHashCode),
                                        SQLITE_STATIC)) )
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ITERATE NAME HASH: `%s'", GNUNET_h2s_full(&name_hase));
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ITERATE NAME HASH: `%8s'", GNUNET_short_h2s(&name_hase));
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                "sqlite3_bind_XXXX");
     if (SQLITE_OK != sqlite3_reset (stmt))
@@ -723,8 +722,8 @@ namestore_sqlite_iterate_records (void *cls,
  */
 static int
 namestore_sqlite_zone_to_name (void *cls, 
-                              const GNUNET_HashCode *zone,
-                              const GNUNET_HashCode *value_zone,
+                              const struct GNUNET_CRYPTO_ShortHashCode *zone,
+                              const struct GNUNET_CRYPTO_ShortHashCode *value_zone,
                               GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
 {
   struct Plugin *plugin = cls;
@@ -732,10 +731,10 @@ namestore_sqlite_zone_to_name (void *cls,
 
   stmt = plugin->zone_to_name;
   if ( (SQLITE_OK != sqlite3_bind_blob (stmt, 1, 
-                                       zone, sizeof (GNUNET_HashCode), 
+                                       zone, sizeof (struct GNUNET_CRYPTO_ShortHashCode),
                                        SQLITE_STATIC)) ||
        (SQLITE_OK != sqlite3_bind_blob (stmt, 2, 
-                                       value_zone, sizeof (GNUNET_HashCode), 
+                                       value_zone, sizeof (struct GNUNET_CRYPTO_ShortHashCode),
                                        SQLITE_STATIC)) )
   {
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
@@ -759,13 +758,13 @@ namestore_sqlite_zone_to_name (void *cls,
  */
 static void 
 namestore_sqlite_delete_zone (void *cls,
-                             const GNUNET_HashCode *zone)
+                             const struct GNUNET_CRYPTO_ShortHashCode *zone)
 {
   struct Plugin *plugin = cls;
   sqlite3_stmt *stmt = plugin->delete_zone;
   int n;
 
-  if (SQLITE_OK != sqlite3_bind_blob (stmt, 1, zone, sizeof (GNUNET_HashCode), SQLITE_STATIC))
+  if (SQLITE_OK != sqlite3_bind_blob (stmt, 1, zone, sizeof (struct GNUNET_CRYPTO_ShortHashCode), SQLITE_STATIC))
   {
     LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
                 "sqlite3_bind_XXXX");
index 74c344c0a83a1a25551dd1243fd7e0a44e229e47..4c654ecf4c9ccd4baae36e5ee38b3bc5a05421c1 100644 (file)
@@ -36,7 +36,7 @@ static struct GNUNET_OS_Process *arm;
 
 static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
-static GNUNET_HashCode zone;
+static struct GNUNET_CRYPTO_ShortHashCode zone;
 
 static int res;
 
@@ -175,7 +175,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_assert (privkey != NULL);
   GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
 
-  GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &zone);
+  GNUNET_CRYPTO_short_hash (&pubkey, sizeof (pubkey), &zone);
 
 
   struct GNUNET_CRYPTO_RsaSignature signature;
index 5117ba9e8bd06327c53b178e8aed3f783cfec638..4490b85c61ac156e9c53477cfe9a3074a9a83643 100644 (file)
@@ -49,7 +49,7 @@ static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
 struct GNUNET_CRYPTO_RsaSignature *s_signature;
 struct GNUNET_CRYPTO_RsaSignature *s_signature_updated;
-static GNUNET_HashCode s_zone;
+static struct GNUNET_CRYPTO_ShortHashCode s_zone;
 struct GNUNET_NAMESTORE_RecordData *s_first_record;
 struct GNUNET_NAMESTORE_RecordData *s_second_record;
 static char *s_name;
@@ -426,9 +426,9 @@ run (void *cls, char *const *args, const char *cfgfile,
   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);
+  GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_h2s_full(&s_zone));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_short_h2s (&s_zone));
 
   start_arm (cfgfile);
   GNUNET_assert (arm != NULL);
index 2eb078d5a9fefd2c8298fe2426c4bcd39a5aad80..6deb03bf08bfef6b73a076370114d8eb1281c04c 100644 (file)
@@ -49,7 +49,7 @@ static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
 struct GNUNET_CRYPTO_RsaSignature *s_signature;
 struct GNUNET_CRYPTO_RsaSignature *s_signature_updated;
-static GNUNET_HashCode s_zone;
+static struct GNUNET_CRYPTO_ShortHashCode s_zone;
 struct GNUNET_NAMESTORE_RecordData *s_first_record;
 struct GNUNET_NAMESTORE_RecordData *s_second_record;
 static char *s_name;
@@ -465,9 +465,9 @@ run (void *cls, char *const *args, const char *cfgfile,
   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);
+  GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_h2s_full(&s_zone));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_short_h2s (&s_zone));
 
   start_arm (cfgfile);
   GNUNET_assert (arm != NULL);
index 4a33c6467cb88db3b7b8a7e538491b776a6672c0..5be939a89c780c78f50487878dd66d061ca0c0f1 100644 (file)
@@ -44,7 +44,7 @@ static struct GNUNET_OS_Process *arm;
 static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
 struct GNUNET_CRYPTO_RsaSignature *s_signature;
-static GNUNET_HashCode s_zone;
+static struct GNUNET_CRYPTO_ShortHashCode s_zone;
 struct GNUNET_NAMESTORE_RecordData *s_rd;
 static char *s_name;
 
@@ -273,7 +273,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   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);
+  GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
 
   start_arm (cfgfile);
   GNUNET_assert (arm != NULL);
index 1a1dca2ff6bd1a361af77c5f4e6e0c21a68c350a..ec5ca8b78ad8534933f5398fd2738a218b15e86e 100644 (file)
@@ -47,7 +47,7 @@ static struct GNUNET_OS_Process *arm;
 static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
 struct GNUNET_CRYPTO_RsaSignature *s_signature;
-static GNUNET_HashCode s_zone;
+static struct GNUNET_CRYPTO_ShortHashCode s_zone;
 struct GNUNET_NAMESTORE_RecordData *s_rd;
 static char *s_name;
 
@@ -345,7 +345,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   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);
+  GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
 
   start_arm (cfgfile);
   GNUNET_assert (arm != NULL);
index 398f21ba6082b669d68ca42a5eb59c14873a4e42..83e6529b87ac15394eef2a3f8b87fb8efc90464d 100644 (file)
@@ -48,7 +48,7 @@ static struct GNUNET_OS_Process *arm;
 static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
 struct GNUNET_CRYPTO_RsaSignature *s_signature;
-static GNUNET_HashCode s_zone;
+static struct GNUNET_CRYPTO_ShortHashCode s_zone;
 struct GNUNET_NAMESTORE_RecordData *s_rd;
 static char *s_name;
 
@@ -309,9 +309,9 @@ run (void *cls, char *const *args, const char *cfgfile,
   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);
+  GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_h2s_full(&s_zone));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_short_h2s (&s_zone));
 
 
   start_arm (cfgfile);
index 2c03c82d66dc86a54d9c5f0d6a5abfce03b54990..550662e1f58a9ee9016a1796082dbc73025be586 100644 (file)
@@ -38,11 +38,11 @@ static struct GNUNET_OS_Process *arm;
 
 static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
-static GNUNET_HashCode zone;
+static struct GNUNET_CRYPTO_ShortHashCode zone;
 
 static struct GNUNET_CRYPTO_RsaPrivateKey * privkey2;
 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey2;
-static GNUNET_HashCode zone2;
+static struct GNUNET_CRYPTO_ShortHashCode zone2;
 
 static struct GNUNET_NAMESTORE_ZoneIterator *zi;
 static int res;
@@ -206,7 +206,7 @@ void zone_proc (void *cls,
                 const struct GNUNET_CRYPTO_RsaSignature *signature)
 {
   int failed = GNUNET_NO;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for zone `%s'\n", GNUNET_h2s (&zone));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for zone `%s'\n", GNUNET_short_h2s (&zone));
   if ((zone_key == NULL) &&  (name == NULL))
   {
     GNUNET_break (2 == returned_records);
@@ -326,7 +326,7 @@ put_cont (void *cls, int32_t success, const char *emsg)
     res = 1;
     returned_records = 0;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over zone `%s'\n",
-        GNUNET_h2s(&zone));
+        GNUNET_short_h2s(&zone));
     zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
                                         &zone,
                                         GNUNET_NAMESTORE_RF_NONE,
@@ -375,7 +375,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_free (hostkey_file);
   GNUNET_assert (privkey != NULL);
   GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
-  GNUNET_CRYPTO_hash(&pubkey, sizeof (pubkey), &zone);
+  GNUNET_CRYPTO_short_hash (&pubkey, sizeof (pubkey), &zone);
 
   GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, "KJI3AL00K91EDPFJF58DAJM7H61D189TLP70N56JL8SVDCJE1SJ3SNNBOQPPONTL37FMHPS39SMK2NMVC0GQMGA6QCMHITT78O8GF80.zkey");
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
@@ -383,7 +383,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_free (hostkey_file);
   GNUNET_assert (privkey2 != NULL);
   GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2);
-  GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2);
+  GNUNET_CRYPTO_short_hash (&pubkey2, sizeof (pubkey), &zone2);
 
 
   start_arm (cfgfile);
index ad9acc89055a48fadb2786c0ae2bd6bd5ef92b98..5fb984dc16ec710cc3f05b029757a944664bfb8e 100644 (file)
@@ -46,8 +46,8 @@ static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
 
 struct GNUNET_TIME_Absolute expire;
 
-static GNUNET_HashCode s_zone;
-static GNUNET_HashCode s_zone_value;
+static struct GNUNET_CRYPTO_ShortHashCode s_zone;
+static struct GNUNET_CRYPTO_ShortHashCode s_zone_value;
 
 char * s_name;
 
@@ -230,8 +230,8 @@ run (void *cls, char *const *args, const char *cfgfile,
   GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
 
   /* zone hash */
-  GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
-  GNUNET_CRYPTO_hash (s_name, strlen (s_name) + 1, &s_zone_value);
+  GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
+  GNUNET_CRYPTO_short_hash (s_name, strlen (s_name) + 1, &s_zone_value);
 
   struct GNUNET_NAMESTORE_RecordData rd;
   rd.expiration = GNUNET_TIME_absolute_get();
index dcf3505c39a75b1c089bc322a78c75e9163c93da..3e93d73b24e8d028a0d23914a99239c1219fba94 100644 (file)
@@ -176,7 +176,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 {
   struct GNUNET_NAMESTORE_PluginFunctions *nsp;  
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
-  GNUNET_HashCode zone;
+  struct GNUNET_CRYPTO_ShortHashCode zone;
   
   ok = 0;
   nsp = load_plugin (cfg);
@@ -187,13 +187,16 @@ run (void *cls, char *const *args, const char *cfgfile,
             "Failed to initialize namestore.  Database likely not setup, skipping test.\n");
     return;
   }
+
   put_record (nsp, 1);
+
   get_record (nsp, 1);
 
   memset (&zone_key, 1, sizeof (zone_key));
-  GNUNET_CRYPTO_hash (&zone_key, sizeof (zone_key), &zone);  
+  GNUNET_CRYPTO_short_hash (&zone_key, sizeof (zone_key), &zone);
   nsp->delete_zone (nsp->cls, &zone);
   unload_plugin (nsp);
+
 }