aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-03-01 16:48:01 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-03-01 16:48:01 +0000
commit8d3546bdb0e458da96092f76dc4d2735c747335d (patch)
treeb595adcb8240dfa45cc32cf53fe120c3f15661a3 /src/namestore
parentc8ee017f28ce9c5f59bdae20bd2f9c0a6c4146a7 (diff)
downloadgnunet-8d3546bdb0e458da96092f76dc4d2735c747335d.tar.gz
gnunet-8d3546bdb0e458da96092f76dc4d2735c747335d.zip
- added signature check
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/test_namestore_api_create.c6
-rw-r--r--src/namestore/test_namestore_api_remove.c9
-rw-r--r--src/namestore/test_namestore_api_remove_not_existing_record.c24
3 files changed, 24 insertions, 15 deletions
diff --git a/src/namestore/test_namestore_api_create.c b/src/namestore/test_namestore_api_create.c
index 5d6cc510f..c74c80b03 100644
--- a/src/namestore/test_namestore_api_create.c
+++ b/src/namestore/test_namestore_api_create.c
@@ -198,6 +198,12 @@ void name_lookup_proc (void *cls,
198 } 198 }
199 } 199 }
200 200
201 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature))
202 {
203 GNUNET_break (0);
204 failed = GNUNET_YES;
205 }
206
201 found = GNUNET_YES; 207 found = GNUNET_YES;
202 if (failed == GNUNET_NO) 208 if (failed == GNUNET_NO)
203 res = 0; 209 res = 0;
diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c
index e9b13ccf5..31631da7d 100644
--- a/src/namestore/test_namestore_api_remove.c
+++ b/src/namestore/test_namestore_api_remove.c
@@ -174,7 +174,12 @@ void name_lookup_proc (void *cls,
174 GNUNET_break (0 == memcmp (rd[c].data, s_rd[c+1].data, TEST_RECORD_DATALEN)); 174 GNUNET_break (0 == memcmp (rd[c].data, s_rd[c+1].data, TEST_RECORD_DATALEN));
175 } 175 }
176 176
177 found = GNUNET_YES; 177 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, n, rd_count, rd, signature))
178 {
179 GNUNET_break (0);
180 failed = GNUNET_YES;
181 }
182
178 if (failed == GNUNET_NO) 183 if (failed == GNUNET_NO)
179 res = 0; 184 res = 0;
180 else 185 else
@@ -205,7 +210,7 @@ remove_cont (void *cls, int32_t success, const char *emsg)
205 else 210 else
206 { 211 {
207 res = 1; 212 res = 1;
208 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name); 213 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove record for name `%s'\n", name);
209 GNUNET_SCHEDULER_add_now(&end, NULL); 214 GNUNET_SCHEDULER_add_now(&end, NULL);
210 } 215 }
211 216
diff --git a/src/namestore/test_namestore_api_remove_not_existing_record.c b/src/namestore/test_namestore_api_remove_not_existing_record.c
index 6818e28f3..b202c9357 100644
--- a/src/namestore/test_namestore_api_remove_not_existing_record.c
+++ b/src/namestore/test_namestore_api_remove_not_existing_record.c
@@ -196,7 +196,7 @@ void
196remove_cont (void *cls, int32_t success, const char *emsg) 196remove_cont (void *cls, int32_t success, const char *emsg)
197{ 197{
198 char *name = cls; 198 char *name = cls;
199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Remove record for `%s': %s\n", name, (success == GNUNET_YES) ? "SUCCESS" : "FAIL", emsg); 199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Remove record for `%s': %s `%s'\n", name, (success == GNUNET_YES) ? "SUCCESS" : "FAIL", emsg);
200 if (success == GNUNET_OK) 200 if (success == GNUNET_OK)
201 { 201 {
202 res = 0; 202 res = 0;
@@ -219,9 +219,16 @@ put_cont (void *cls, int32_t success, const char *emsg)
219 if (success == GNUNET_OK) 219 if (success == GNUNET_OK)
220 { 220 {
221 res = 0; 221 res = 0;
222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing record for `%s'\n", name); 222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing non existing record for `%s'\n", name);
223 223
224 GNUNET_NAMESTORE_record_remove (nsh, privkey, name, &s_rd[0], &remove_cont, name); 224 struct GNUNET_NAMESTORE_RecordData rd;
225 char data[TEST_REMOVE_RECORD_DATALEN];
226 rd.expiration = GNUNET_TIME_absolute_get();
227 rd.record_type = TEST_REMOVE_RECORD_TYPE;
228 rd.data_size = TEST_REMOVE_RECORD_DATALEN;
229 rd.data = &data;
230
231 GNUNET_NAMESTORE_record_remove (nsh, privkey, name, &rd, &remove_cont, name);
225 } 232 }
226 else 233 else
227 { 234 {
@@ -238,14 +245,7 @@ create_record (int count)
238 struct GNUNET_NAMESTORE_RecordData * rd; 245 struct GNUNET_NAMESTORE_RecordData * rd;
239 rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData)); 246 rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData));
240 247
241 rd[0].expiration = GNUNET_TIME_absolute_get(); 248 for (c = 0; c < RECORDS; c++)
242 rd[0].record_type = 0;
243 rd[0].data_size = TEST_REMOVE_RECORD_DATALEN;
244 rd[0].data = GNUNET_malloc(TEST_RECORD_DATALEN);
245 memset ((char *) rd[0].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
246
247
248 for (c = 1; c < RECORDS; c++)
249 { 249 {
250 rd[c].expiration = GNUNET_TIME_absolute_get(); 250 rd[c].expiration = GNUNET_TIME_absolute_get();
251 rd[c].record_type = TEST_RECORD_TYPE; 251 rd[c].record_type = TEST_RECORD_TYPE;
@@ -293,8 +293,6 @@ run (void *cls, char *const *args, const char *cfgfile,
293 nsh = GNUNET_NAMESTORE_connect (cfg); 293 nsh = GNUNET_NAMESTORE_connect (cfg);
294 GNUNET_break (NULL != nsh); 294 GNUNET_break (NULL != nsh);
295 295
296
297
298 GNUNET_break (s_rd != NULL); 296 GNUNET_break (s_rd != NULL);
299 GNUNET_break (s_name != NULL); 297 GNUNET_break (s_name != NULL);
300 298