From 39670859fe230805056e8128c7c0bf5d5c92665b Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Sun, 26 Feb 2012 14:34:56 +0000 Subject: [PATCH] -doxygen, more block plugin --- src/gns/gnunet-gns-lookup.c | 12 ++--- src/gns/gnunet-service-gns.c | 12 ++--- src/gns/plugin_block_gns.c | 80 +++++++++++++++++++++++++++++++- src/{gns => include}/block_gns.h | 0 src/include/gnunet_gns_service.h | 5 +- 5 files changed, 90 insertions(+), 19 deletions(-) rename src/{gns => include}/block_gns.h (100%) diff --git a/src/gns/gnunet-gns-lookup.c b/src/gns/gnunet-gns-lookup.c index 5adb4064e..f33264f61 100644 --- a/src/gns/gnunet-gns-lookup.c +++ b/src/gns/gnunet-gns-lookup.c @@ -104,15 +104,9 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * operation that expects a reply * * @param cls closure - * @param exp when will this value expire - * @param key key of the result - * @param get_path peers on reply path (or NULL if not recorded) - * @param get_path_length number of entries in get_path - * @param put_path peers on the PUT path (or NULL if not recorded) - * @param put_path_length number of entries in get_path - * @param type type of the result - * @param size number of bytes in data - * @param data pointer to the result data + * @param name name + * @param record a record + * @param num_records number of records */ static void lookup_result_iterator (void *cls, diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index e4e28c14b..d2cb477f6 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c @@ -303,7 +303,7 @@ process_authority_dht_result(void* cls, * Start DHT lookup for a name -> PKEY (compare NS) record in * query->authority's zone * - * @param query the pending gns query + * @param rh the pending gns query * @param name the name of the PKEY record */ void @@ -459,7 +459,7 @@ process_name_dht_result(void* cls, * Start DHT lookup for a (name -> query->record_type) record in * query->authority's zone * - * @param query the pending gns query + * @param rh the pending gns query context * @param name the name to query record */ void @@ -501,7 +501,7 @@ resolve_name(struct GNUNET_GNS_ResolverHandle *query, GNUNET_HashCode *zone); * @param expiration expiration date of the record data set in the namestore * @param name the name for which we need an authority * @param rd_count the number of records with 'name' - * @param data the record data + * @param rd the record data * @param signature the signature of the authority for the record data */ void @@ -697,7 +697,7 @@ reply_to_dns(struct GNUNET_GNS_ResolverHandle *rh, uint32_t rd_count, * @param expiration expiration date of the namestore entry * @param name the name for which we need an authority * @param rd_count the number of records with 'name' - * @param data the record data + * @param rd the record data * @param signature the signature of the authority for the record data */ static void @@ -854,7 +854,7 @@ char* pop_tld(char* name) * If it is then try to resolve directly. * If not then first have to resolve the authoritative entities. * - * @param query the pending lookup + * @param rh the pending lookup * @param zone the zone we are currently resolving in */ void @@ -889,7 +889,7 @@ resolve_name(struct GNUNET_GNS_ResolverHandle *rh, GNUNET_HashCode *zone) * * Setup a new query and try to resolve * - * @param rh the request handle of the DNS request from a client + * @param request the request handle of the DNS request from a client * @param p the DNS query packet we received * @param q the DNS query we received parsed from p */ diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index 33699a32c..1a33b2d1a 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c @@ -61,10 +61,86 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, size_t xquery_size, const void *reply_block, size_t reply_block_size) { - if (type != GNUNET_BLOCK_TYPE_GNS_RECORD) + if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; + + struct GNUNET_CRYPTO_RsaSignature *signature; + struct GNUNET_CRYPTO_RsaSignaturePurpose *purpose; + struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key; + char* name; + GNUNET_HashCode pkey_hash; + GNUNET_HashCode query_pkey; + GNUNET_HashCode name_hash; + + uint32_t rd_num; + uint32_t type; + struct GNUNET_TIME_AbsoluteNBO; + uint32_t data_length; + uint32_t flags; + + char* pos = (char*) reply_block; + signature = pos; + pos += sizeof(struct GNUNET_CRYPTO_RsaSignature); + pos += sizeof(struct GNUNET_CRYPTO_RsaSignaturePurpose); + + public_key = pos; + pos += sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded); + name = pos; + pos += namelen(name); //Off by 1? + + GNUNET_CRYPTO_hash(public_key, + sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), + &pkey_hash); + + GNUNET_CRYPTO_hash(name, strlen(name), &name_hash); + + GNUNET_CRYPTO_hash_xor(query, &name_hash, &query_pkey); - //FIXME check signatures here + //Check query key against public key + if (0 != GNUNET_CRYPTO_hash_cmp(&query_pkey, &pkey_hash)) + return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; + + rd_count = ntohl(*pos); + pos += sizeof(uint32_t); + + struct GNUNET_NAMESTORE_RecordData rd[rd_count]; + int i = 0; + + for (i=0; i