-fixing #3034
[oweals/gnunet.git] / src / fs / fs_search.c
index 3b0db042969435ea7c237e0e838d015595846eb5..09c260000e03b824d9ea04321a917536af79a02a 100644 (file)
@@ -342,7 +342,7 @@ GNUNET_FS_search_probe_progress_ (void *cls,
     {
       /* should only happen if the cancel task was already
         created on 'DOWNLOAD_INACTIVE' as we were out of time */
-      GNUNET_break (0 == sr->remaining_probe_time.rel_value);
+      GNUNET_break (0 == sr->remaining_probe_time.rel_value_us);
     }
     break;
   case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
@@ -354,7 +354,7 @@ GNUNET_FS_search_probe_progress_ (void *cls,
     dur = GNUNET_TIME_absolute_get_duration (sr->probe_active_time);
     sr->remaining_probe_time =
         GNUNET_TIME_relative_subtract (sr->remaining_probe_time, dur);
-    if (0 == sr->remaining_probe_time.rel_value)
+    if (0 == sr->remaining_probe_time.rel_value_us)
       sr->probe_cancel_task =
         GNUNET_SCHEDULER_add_now (&probe_failure_handler, sr);
     GNUNET_FS_search_result_sync_ (sr);
@@ -558,7 +558,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
   is_new = (NULL == sr) || (sr->mandatory_missing > 0);
   if (NULL == sr)
   {
-    sr = GNUNET_malloc (sizeof (struct GNUNET_FS_SearchResult));
+    sr = GNUNET_new (struct GNUNET_FS_SearchResult);
     sr->h = sc->h;
     sr->sc = sc;
     sr->anonymity = sc->anonymity;
@@ -639,7 +639,7 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc, const char *id_update,
                                                   &test_result_present,
                                                   (void *) uri))
     return;                     /* duplicate result */
-  sr = GNUNET_malloc (sizeof (struct GNUNET_FS_SearchResult));
+  sr = GNUNET_new (struct GNUNET_FS_SearchResult);
   sr->h = sc->h;
   sr->sc = sc;
   sr->anonymity = sc->anonymity;
@@ -679,20 +679,20 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc, const char *id_update,
  */
 static int
 decrypt_block_with_keyword (const struct GNUNET_FS_SearchContext *sc,
-                           const struct GNUNET_CRYPTO_EccPublicKey *dpub,
+                           const struct GNUNET_CRYPTO_EccPublicSignKey *dpub,
                            const void *edata,
                            size_t edata_size,
                            char *data)
 { 
   const struct GNUNET_CRYPTO_EccPrivateKey *anon;
-  struct GNUNET_CRYPTO_EccPublicKey anon_pub;
+  struct GNUNET_CRYPTO_EccPublicSignKey anon_pub;
   unsigned int i;
 
   /* find key */
   for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
     if (0 == memcmp (dpub,
                     &sc->requests[i].dpub,
-                    sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
+                    sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)))
       break;
   if (i == sc->uri->data.ksk.keywordCount)
   {
@@ -702,7 +702,7 @@ decrypt_block_with_keyword (const struct GNUNET_FS_SearchContext *sc,
   }
   /* decrypt */
   anon = GNUNET_CRYPTO_ecc_key_get_anonymous ();
-  GNUNET_CRYPTO_ecc_key_get_public (anon, &anon_pub);
+  GNUNET_CRYPTO_ecc_key_get_public_for_signature (anon, &anon_pub);
   GNUNET_FS_ublock_decrypt_ (edata, edata_size,
                             &anon_pub,
                             sc->requests[i].keyword,
@@ -721,7 +721,8 @@ decrypt_block_with_keyword (const struct GNUNET_FS_SearchContext *sc,
  * @param size size of nb
  */
 static void
-process_kblock (struct GNUNET_FS_SearchContext *sc, const struct UBlock *ub,
+process_kblock (struct GNUNET_FS_SearchContext *sc, 
+               const struct UBlock *ub,
                 size_t size)
 {
   size_t j;
@@ -793,7 +794,6 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
   size_t off;
   char *emsg;
 
-  /* decrypt */
   GNUNET_FS_ublock_decrypt_ (&ub[1], len,
                             &sc->uri->data.sks.ns,
                             sc->uri->data.sks.identifier,
@@ -837,12 +837,13 @@ process_sblock (struct GNUNET_FS_SearchContext *sc,
  * @param size size of data
  */
 static void
-process_result (struct GNUNET_FS_SearchContext *sc, enum GNUNET_BLOCK_Type type,
+process_result (struct GNUNET_FS_SearchContext *sc, 
+               enum GNUNET_BLOCK_Type type,
                 struct GNUNET_TIME_Absolute expiration, 
                const void *data,
                 size_t size)
 {
-  if (GNUNET_TIME_absolute_get_duration (expiration).rel_value > 0)
+  if (GNUNET_TIME_absolute_get_duration (expiration).rel_value_us > 0)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Result received has already expired.\n");
@@ -1034,7 +1035,7 @@ transmit_search_request (void *cls, size_t size, void *buf)
   struct MessageBuilderContext mbc;
   size_t msize;
   struct SearchMessage *sm;
-  struct GNUNET_CRYPTO_EccPublicKey dpub;
+  struct GNUNET_CRYPTO_EccPublicSignKey dpub;
   unsigned int sqms;
   uint32_t options;
 
@@ -1103,10 +1104,11 @@ transmit_search_request (void *cls, size_t size, void *buf)
     memset (&sm->target, 0, sizeof (struct GNUNET_HashCode));
     GNUNET_CRYPTO_ecc_public_key_derive (&sc->uri->data.sks.ns,
                                         sc->uri->data.sks.identifier,
+                                        "fs-ublock",
                                         &dpub);
     GNUNET_CRYPTO_hash (&dpub,
                        sizeof (dpub),
-                       &sm->query);
+                       &sm->query); 
     mbc.put_cnt = (size - msize) / sizeof (struct GNUNET_HashCode);
     sqms = GNUNET_CONTAINER_multihashmap_size (sc->master_result_map);
     mbc.put_cnt = GNUNET_MIN (mbc.put_cnt, sqms - mbc.skip_cnt);
@@ -1270,7 +1272,7 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc)
   unsigned int i;
   const char *keyword;
   const struct GNUNET_CRYPTO_EccPrivateKey *anon;
-  struct GNUNET_CRYPTO_EccPublicKey anon_pub;
+  struct GNUNET_CRYPTO_EccPublicSignKey anon_pub;
   struct SearchRequestEntry *sre;
 
   GNUNET_assert (NULL == sc->client);
@@ -1278,7 +1280,7 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc)
   {
     GNUNET_assert (0 != sc->uri->data.ksk.keywordCount);
     anon = GNUNET_CRYPTO_ecc_key_get_anonymous ();
-    GNUNET_CRYPTO_ecc_key_get_public (anon, &anon_pub);
+    GNUNET_CRYPTO_ecc_key_get_public_for_signature (anon, &anon_pub);
     sc->requests =
         GNUNET_malloc (sizeof (struct SearchRequestEntry) *
                        sc->uri->data.ksk.keywordCount);
@@ -1289,9 +1291,10 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc)
       sre->keyword = GNUNET_strdup (keyword);
       GNUNET_CRYPTO_ecc_public_key_derive (&anon_pub,
                                           keyword,
+                                          "fs-ublock",
                                           &sre->dpub);
       GNUNET_CRYPTO_hash (&sre->dpub, 
-                         sizeof (struct GNUNET_CRYPTO_EccPublicKey), 
+                         sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), 
                          &sre->uquery);
       sre->mandatory = (sc->uri->data.ksk.keywords[i][0] == '+');
       if (sre->mandatory)