- added signature check
authorMatthias Wachs <wachs@net.in.tum.de>
Thu, 1 Mar 2012 16:48:01 +0000 (16:48 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Thu, 1 Mar 2012 16:48:01 +0000 (16:48 +0000)
src/namestore/test_namestore_api_create.c
src/namestore/test_namestore_api_remove.c
src/namestore/test_namestore_api_remove_not_existing_record.c

index 5d6cc510f4289e2bbb687df22004d2bc857b39ec..c74c80b0301dad7168d34259fa518358d86415d5 100644 (file)
@@ -198,6 +198,12 @@ void name_lookup_proc (void *cls,
       }
     }
 
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature))
+    {
+      GNUNET_break (0);
+      failed = GNUNET_YES;
+    }
+
     found = GNUNET_YES;
     if (failed == GNUNET_NO)
       res = 0;
index e9b13ccf5b03a1c53da2b20df0e58df8c5bc05f8..31631da7d74c275b708a778a508d0ea096973aea 100644 (file)
@@ -174,7 +174,12 @@ void name_lookup_proc (void *cls,
       GNUNET_break (0 == memcmp (rd[c].data, s_rd[c+1].data, TEST_RECORD_DATALEN));
     }
 
-    found = GNUNET_YES;
+    if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature))
+    {
+      GNUNET_break (0);
+      failed = GNUNET_YES;
+    }
+
     if (failed == GNUNET_NO)
       res = 0;
     else
@@ -205,7 +210,7 @@ remove_cont (void *cls, int32_t success, const char *emsg)
   else
   {
     res = 1;
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove record for name `%s'\n", name);
     GNUNET_SCHEDULER_add_now(&end, NULL);
   }
 
index 6818e28f3ef9f84852ce3b9ffc86e50cbbfdeb6f..b202c9357900b3b9f3387e2b7cfb58fd9fffe566 100644 (file)
@@ -196,7 +196,7 @@ void
 remove_cont (void *cls, int32_t success, const char *emsg)
 {
   char *name = cls;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Remove record for `%s': %s\n", name, (success == GNUNET_YES) ? "SUCCESS" : "FAIL", emsg);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Remove record for `%s': %s `%s'\n", name, (success == GNUNET_YES) ? "SUCCESS" : "FAIL", emsg);
   if (success == GNUNET_OK)
   {
     res = 0;
@@ -219,9 +219,16 @@ put_cont (void *cls, int32_t success, const char *emsg)
   if (success == GNUNET_OK)
   {
     res = 0;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing record for `%s'\n", name);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing non existing record for `%s'\n", name);
 
-    GNUNET_NAMESTORE_record_remove (nsh, privkey, name, &s_rd[0], &remove_cont, name);
+    struct GNUNET_NAMESTORE_RecordData rd;
+    char data[TEST_REMOVE_RECORD_DATALEN];
+    rd.expiration = GNUNET_TIME_absolute_get();
+    rd.record_type = TEST_REMOVE_RECORD_TYPE;
+    rd.data_size = TEST_REMOVE_RECORD_DATALEN;
+    rd.data = &data;
+
+    GNUNET_NAMESTORE_record_remove (nsh, privkey, name, &rd, &remove_cont, name);
   }
   else
   {
@@ -238,14 +245,7 @@ create_record (int count)
   struct GNUNET_NAMESTORE_RecordData * rd;
   rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
 
-  rd[0].expiration = GNUNET_TIME_absolute_get();
-  rd[0].record_type = 0;
-  rd[0].data_size = TEST_REMOVE_RECORD_DATALEN;
-  rd[0].data = GNUNET_malloc(TEST_RECORD_DATALEN);
-  memset ((char *) rd[0].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
-
-
-  for (c = 1; c < RECORDS; c++)
+  for (c = 0; c < RECORDS; c++)
   {
   rd[c].expiration = GNUNET_TIME_absolute_get();
   rd[c].record_type = TEST_RECORD_TYPE;
@@ -293,8 +293,6 @@ run (void *cls, char *const *args, const char *cfgfile,
   nsh = GNUNET_NAMESTORE_connect (cfg);
   GNUNET_break (NULL != nsh);
 
-
-
   GNUNET_break (s_rd != NULL);
   GNUNET_break (s_name != NULL);