static struct GNUNET_CRYPTO_RsaPrivateKey * privkey;
static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
-struct GNUNET_CRYPTO_RsaSignature s_signature;
-static GNUNET_HashCode s_zone;
+struct GNUNET_CRYPTO_RsaSignature *s_signature;
+static struct GNUNET_CRYPTO_ShortHashCode s_zone;
struct GNUNET_NAMESTORE_RecordData *s_rd;
static char *s_name;
for (c = 0; c < rd_count; c++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Record [%u]: type: %u, size %u\n", c, rd[c].record_type, rd[c].data_size);
- GNUNET_break (rd[c].expiration.abs_value == s_rd[c+1].expiration.abs_value);
- GNUNET_break (rd[c].record_type == TEST_RECORD_TYPE);
- GNUNET_break (rd[c].data_size == TEST_RECORD_DATALEN);
- GNUNET_break (0 == memcmp (rd[c].data, s_rd[c+1].data, TEST_RECORD_DATALEN));
+ if (GNUNET_NO == GNUNET_NAMESTORE_records_cmp (&rd[c], &s_rd[c+1]))
+ {
+ 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;
}
- found = GNUNET_YES;
if (failed == GNUNET_NO)
res = 0;
else
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);
}
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);
+ rd[0].data = GNUNET_malloc(TEST_REMOVE_RECORD_DATALEN);
memset ((char *) rd[0].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
-
for (c = 1; c < RECORDS; c++)
{
- rd[c].expiration = GNUNET_TIME_absolute_get();
+ rd[c].expiration = GNUNET_TIME_absolute_get_zero();
rd[c].record_type = TEST_RECORD_TYPE;
rd[c].data_size = TEST_RECORD_DATALEN;
rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
return rd;
}
+void
+delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ char *afsdir;
+
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite",
+ "FILENAME", &afsdir))
+ {
+ if (GNUNET_OK == GNUNET_DISK_file_test (afsdir))
+ if (GNUNET_OK == GNUNET_DISK_file_test (afsdir))
+ if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir);
+ GNUNET_free (afsdir);
+ }
+
+}
+
static void
run (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
+ delete_existing_db(cfg);
endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL);
size_t rd_ser_len;
/* load privat key */
- privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey");
+ char *hostkey_file;
+ GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
+ "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
+ privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file);
+ GNUNET_free (hostkey_file);
GNUNET_assert (privkey != NULL);
/* get public key */
GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
/* sign */
- struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + rd_ser_len);
- sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len);
- sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
- memcpy (&sig_purpose[1], rd_ser, rd_ser_len);
- GNUNET_CRYPTO_rsa_sign (privkey, sig_purpose, &s_signature);
- GNUNET_free (sig_purpose);
+ s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_rd[0].expiration, s_name, s_rd, RECORDS);
/* create random zone hash */
- GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
+ GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_h2s_full(&s_zone));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_short_h2s (&s_zone));
start_arm (cfgfile);
nsh = GNUNET_NAMESTORE_connect (cfg);
GNUNET_break (NULL != nsh);
-
-
GNUNET_break (s_rd != NULL);
GNUNET_break (s_name != NULL);
GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name,
GNUNET_TIME_absolute_get_forever(),
- RECORDS, s_rd, &s_signature, put_cont, s_name);
+ RECORDS, s_rd, s_signature, put_cont, s_name);
+
+
}
int ret;
ret = check ();
-
+ GNUNET_free (s_signature);
return ret;
}