static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
struct GNUNET_CRYPTO_RsaSignature *s_signature;
static GNUNET_HashCode s_zone;
-struct GNUNET_NAMESTORE_RecordData *first_record;
+struct GNUNET_NAMESTORE_RecordData *s_rd;
static char *s_name;
int c;
for (c = 0; c < RECORDS; c++)
- GNUNET_free_non_null((void *) first_record[c].data);
- GNUNET_free (first_record);
+ GNUNET_free_non_null((void *) s_rd[c].data);
+ GNUNET_free (s_rd);
if (privkey != NULL)
GNUNET_CRYPTO_rsa_key_free (privkey);
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 == first_record[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, first_record[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, n, rd_count, rd, signature))
+ if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, n, rd_count, rd, signature))
{
GNUNET_break (0);
failed = GNUNET_YES;
res = 0;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing record for `%s'\n", name);
- GNUNET_NAMESTORE_record_remove (nsh, privkey, name, &first_record[0], &remove_cont, name);
+ GNUNET_NAMESTORE_record_remove (nsh, privkey, name, &s_rd[0], &remove_cont, name);
}
else
{
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);
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, "4UCICULTINKC87UO4326KEEDQ9MTEP2AJT88MJFVGTGNK12QNGMQI2S41VI07UUU6EO19BTB06PDL0HE6VP1OM50HOJEI75RHP4JP80.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);
/* create record */
s_name = "dummy.dummy.gnunet";
- first_record = create_record (RECORDS);
+ s_rd = create_record (RECORDS);
- rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, first_record);
+ rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, s_rd);
char rd_ser[rd_ser_len];
- GNUNET_NAMESTORE_records_serialize(RECORDS, first_record, rd_ser_len, rd_ser);
+ GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser);
/* sign */
- s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_name, first_record, RECORDS);
+ 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);
nsh = GNUNET_NAMESTORE_connect (cfg);
GNUNET_break (NULL != nsh);
- GNUNET_break (first_record != NULL);
+ GNUNET_break (s_rd != NULL);
GNUNET_break (s_name != NULL);
GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name,
GNUNET_TIME_absolute_get_forever(),
- RECORDS, first_record, s_signature, put_cont, s_name);
+ RECORDS, s_rd, s_signature, put_cont, s_name);