From 8d3546bdb0e458da96092f76dc4d2735c747335d Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 1 Mar 2012 16:48:01 +0000 Subject: - added signature check --- src/namestore/test_namestore_api_create.c | 6 ++++++ src/namestore/test_namestore_api_remove.c | 9 ++++++-- ...test_namestore_api_remove_not_existing_record.c | 24 ++++++++++------------ 3 files changed, 24 insertions(+), 15 deletions(-) (limited to 'src/namestore') 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, } } + 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; 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, 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); } 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 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); -- cgit v1.2.3