-
- if (NULL != arm)
- stop_arm();
-}
-
-void name_lookup_second_proc (void *cls,
- const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
- struct GNUNET_TIME_Absolute expire,
- const char *n,
- unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd,
- const struct GNUNET_CRYPTO_RsaSignature *signature)
-{
- static int found = GNUNET_NO;
- int failed = GNUNET_NO;
- int c;
-
- if (n != NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n");
- if (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)))
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
-
- if (0 != strcmp(n, s_name))
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
-
- if (2 != rd_count)
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
-
- for (c = 0; c < rd_count; c++)
- {
- if ((GNUNET_NO == GNUNET_NAMESTORE_records_cmp(&rd[c], s_first_record)) &&
- (GNUNET_NO == GNUNET_NAMESTORE_records_cmp(&rd[c], s_second_record)))
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
- }
-
- if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, n, rd_count, rd, signature))
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
-
- struct GNUNET_NAMESTORE_RecordData rd_new[2];
- rd_new[0] = *s_first_record;
- rd_new[1] = *s_second_record;
- s_signature_updated = GNUNET_NAMESTORE_create_signature(privkey, expire, s_name, rd_new, 2);
-
- if (0 != memcmp (s_signature_updated, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)))
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
-
- found = GNUNET_YES;
- if (failed == GNUNET_NO)
- res = 0;
- else
- res = 1;
- }
- else
- {
- if (found != GNUNET_YES)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to lookup records for name `%s'\n", s_name);
- res = 1;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Lookup done for name %s'\n", s_name);
- }
- GNUNET_SCHEDULER_add_now(&end, NULL);
-}
-
-
-void
-create_second_cont (void *cls, int32_t success, const char *emsg)
-{
- char *name = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create second record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL");
- if (success == GNUNET_OK)
- {
- res = 0;
- GNUNET_NAMESTORE_lookup_record (nsh, &s_zone, name, 0, &name_lookup_second_proc, name);
- }
- else
- {
- res = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name);
- GNUNET_SCHEDULER_add_now(&end, NULL);
- }
-
-}
-
-void name_lookup_initial_proc (void *cls,
- const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
- struct GNUNET_TIME_Absolute expire,
- const char *n,
- unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd,
- const struct GNUNET_CRYPTO_RsaSignature *signature)
-{
- char * name = cls;
- static int found = GNUNET_NO;
- int failed = GNUNET_NO;
- int c;
-
- if (n != NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n");
- if (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)))
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
-
- if (0 != strcmp(n, s_name))
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
-
- if (RECORDS != rd_count)
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
-
- for (c = 0; c < RECORDS; c++)
- {
- if (GNUNET_NO == GNUNET_NAMESTORE_records_cmp(&rd[c], &s_first_record[c]))
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
- }
-
- if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, n, rd_count, rd, signature))
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
-
- if (0 != memcmp (s_signature, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)))
- {
- GNUNET_break (0);
- failed = GNUNET_YES;
- }
-
- found = GNUNET_YES;
- if (failed == GNUNET_NO)
- res = 0;
- else
- res = 1;
-
- /* create a second record */
- s_second_record = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_RecordData) + TEST_CREATE_RECORD_DATALEN);
- s_second_record->expiration = GNUNET_TIME_absolute_get_forever();
- s_second_record->record_type = TEST_CREATE_RECORD_TYPE;
- s_second_record->flags = GNUNET_NAMESTORE_RF_AUTHORITY;
- s_second_record->data = &s_second_record[1];
- s_second_record->data_size = TEST_CREATE_RECORD_DATALEN;
- memset ((char *) s_second_record->data, TEST_CREATE_RECORD_DATA, TEST_CREATE_RECORD_DATALEN);
-
- GNUNET_NAMESTORE_record_create (nsh, privkey, name, s_second_record, &create_second_cont, name);
-
- }
- else
- {
- if (found != GNUNET_YES)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to lookup records for name `%s'\n", s_name);
- res = 1;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Lookup done for name %s'\n", s_name);
- GNUNET_SCHEDULER_add_now (&end, NULL);
- }