aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-03-09 12:03:29 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-03-09 12:03:29 +0000
commit3e25c4304d9da8b5dd236cae109194cd0e7db733 (patch)
treeeb5d31910e760e303cd96c6d519bf5fbc32bc6c4 /src/namestore
parentbc3e4df88fd50cfc0f4808201d5b6aedb6e4d55a (diff)
downloadgnunet-3e25c4304d9da8b5dd236cae109194cd0e7db733.tar.gz
gnunet-3e25c4304d9da8b5dd236cae109194cd0e7db733.zip
- signing during zone iteration
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/gnunet-service-namestore.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 727471f06..87ecc9018 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -424,9 +424,9 @@ handle_lookup_name_it (void *cls,
424 copied_elements, lnc->name, GNUNET_h2s(lnc->zone)); 424 copied_elements, lnc->name, GNUNET_h2s(lnc->zone));
425 425
426 if ((copied_elements == rd_count) && (NULL != signature)) 426 if ((copied_elements == rd_count) && (NULL != signature))
427 contains_signature = GNUNET_YES; 427 contains_signature = GNUNET_YES; /* returning all records, so include signature */
428 else 428 else
429 contains_signature = GNUNET_NO; 429 contains_signature = GNUNET_NO; /* returning not all records, so do not include signature */
430 430
431 431
432 if ((NULL != zone_key) && (copied_elements == rd_count)) 432 if ((NULL != zone_key) && (copied_elements == rd_count))
@@ -1332,7 +1332,10 @@ void zone_iteration_proc (void *cls,
1332{ 1332{
1333 struct GNUNET_NAMESTORE_ZoneIteration *zi = cls; 1333 struct GNUNET_NAMESTORE_ZoneIteration *zi = cls;
1334 struct GNUNET_NAMESTORE_Client *nc = zi->client; 1334 struct GNUNET_NAMESTORE_Client *nc = zi->client;
1335 //size_t len; 1335 struct GNUNET_NAMESTORE_CryptoContainer * cc;
1336 struct GNUNET_CRYPTO_RsaSignature *signature_new = NULL;
1337 GNUNET_HashCode zone_key_hash;
1338 int authoritative = GNUNET_NO;
1336 1339
1337 if ((zone_key == NULL) && (name == NULL)) 1340 if ((zone_key == NULL) && (name == NULL))
1338 { 1341 {
@@ -1386,6 +1389,17 @@ void zone_iteration_proc (void *cls,
1386 name_tmp = (char *) &zir_msg[1]; 1389 name_tmp = (char *) &zir_msg[1];
1387 rd_tmp = &name_tmp[name_len]; 1390 rd_tmp = &name_tmp[name_len];
1388 1391
1392 GNUNET_CRYPTO_hash(zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone_key_hash);
1393 if (GNUNET_CONTAINER_multihashmap_contains(zonekeys, &zone_key_hash))
1394 {
1395 cc = GNUNET_CONTAINER_multihashmap_get(zonekeys, &zone_key_hash);
1396 signature_new = GNUNET_NAMESTORE_create_signature(cc->privkey, name, rd, rd_count);
1397 GNUNET_assert (signature_new != NULL);
1398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating signature for name `%s' with %u records in zone `%s'\n",name, rd_count, GNUNET_h2s(&zone_key_hash));
1399 authoritative = GNUNET_YES;
1400 }
1401
1402
1389 zir_msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE); 1403 zir_msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_RESPONSE);
1390 zir_msg->gns_header.header.size = htons (msg_size); 1404 zir_msg->gns_header.header.size = htons (msg_size);
1391 zir_msg->gns_header.r_id = htonl(zi->request_id); 1405 zir_msg->gns_header.r_id = htonl(zi->request_id);
@@ -1394,7 +1408,13 @@ void zone_iteration_proc (void *cls,
1394 zir_msg->name_len = htons (name_len); 1408 zir_msg->name_len = htons (name_len);
1395 zir_msg->rd_count = htons (rd_count); 1409 zir_msg->rd_count = htons (rd_count);
1396 zir_msg->rd_len = htons (rd_ser_len); 1410 zir_msg->rd_len = htons (rd_ser_len);
1397 zir_msg->signature = *signature; 1411 if ((GNUNET_YES == authoritative) && (NULL != signature_new))
1412 {
1413 zir_msg->signature = *signature_new;
1414 GNUNET_free (signature_new);
1415 }
1416 else
1417 zir_msg->signature = *signature;
1398 GNUNET_assert (NULL != zone_key); 1418 GNUNET_assert (NULL != zone_key);
1399 if (zone_key != NULL) 1419 if (zone_key != NULL)
1400 zir_msg->public_key = *zone_key; 1420 zir_msg->public_key = *zone_key;