diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-02-28 09:27:53 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-02-28 09:27:53 +0000 |
commit | a1276ebb880de3ab5cb711f69168468654937bf4 (patch) | |
tree | 9864dca47aa9ff85f76b75f369ab9f8dac2f4cbd /src/gns/plugin_block_gns.c | |
parent | 81d2c5dc7be45896aa7e2fe638611c032857b1e8 (diff) | |
download | gnunet-a1276ebb880de3ab5cb711f69168468654937bf4.tar.gz gnunet-a1276ebb880de3ab5cb711f69168468654937bf4.zip |
-fix xquery
Diffstat (limited to 'src/gns/plugin_block_gns.c')
-rw-r--r-- | src/gns/plugin_block_gns.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index 8a2cb0727..a4d6ad9c8 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c | |||
@@ -86,27 +86,17 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
86 | GNUNET_CRYPTO_hash(name, strlen(name), &name_hash); | 86 | GNUNET_CRYPTO_hash(name, strlen(name), &name_hash); |
87 | 87 | ||
88 | GNUNET_CRYPTO_hash_xor(&pkey_hash, &name_hash, &query_key); | 88 | GNUNET_CRYPTO_hash_xor(&pkey_hash, &name_hash, &query_key); |
89 | struct GNUNET_CRYPTO_HashAsciiEncoded hstr; | ||
90 | GNUNET_CRYPTO_hash_to_enc (query, &hstr); | ||
91 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Query key: %s\n", (char*)&hstr); | ||
92 | GNUNET_CRYPTO_hash_to_enc (&pkey_hash, &hstr); | ||
93 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Pub key: %s\n", (char*)&hstr); | ||
94 | GNUNET_CRYPTO_hash_to_enc (&name_hash, &hstr); | ||
95 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Name: %s\n", (char*)&hstr); | ||
96 | GNUNET_CRYPTO_hash_to_enc (&query_key, &hstr); | ||
97 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "XOR: %s\n", (char*)&hstr); | ||
98 | 89 | ||
99 | 90 | /* Check query key against public key */ | |
100 | //Check query key against public key | ||
101 | if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key)) | 91 | if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key)) |
102 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 92 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
103 | 93 | ||
104 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Checking payload\n"); | ||
105 | rd_count = ntohl(nrb->rd_count); | 94 | rd_count = ntohl(nrb->rd_count); |
106 | 95 | ||
107 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | 96 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; |
108 | int i = 0; | 97 | int i = 0; |
109 | int record_match = 0; | 98 | int record_match = 0; |
99 | uint32_t record_xquery = ntohl(*((uint32_t*)xquery)); | ||
110 | rb = (struct GNSRecordBlock*)(&name[strlen(name) + 1]); | 100 | rb = (struct GNSRecordBlock*)(&name[strlen(name) + 1]); |
111 | 101 | ||
112 | for (i=0; i<rd_count; i++) | 102 | for (i=0; i<rd_count; i++) |
@@ -118,10 +108,15 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
118 | rd[i].flags = ntohl(rb->flags); | 108 | rd[i].flags = ntohl(rb->flags); |
119 | rd[i].data = (char*)&rb[1]; | 109 | rd[i].data = (char*)&rb[1]; |
120 | rb = (struct GNSRecordBlock *)((char*)&rb[1] + rd[i].data_size); | 110 | rb = (struct GNSRecordBlock *)((char*)&rb[1] + rd[i].data_size); |
121 | if (xquery_size > 0 && (rd[i].record_type == *((uint32_t*)xquery))) | 111 | |
112 | if (xquery_size == 0) | ||
113 | continue; | ||
114 | |||
115 | if (rd[i].record_type == record_xquery) | ||
116 | { | ||
122 | record_match++; | 117 | record_match++; |
118 | } | ||
123 | } | 119 | } |
124 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "done\n"); | ||
125 | 120 | ||
126 | 121 | ||
127 | /*if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key, | 122 | /*if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key, |
@@ -133,10 +128,11 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
133 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Signature invalid\n"); | 128 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Signature invalid\n"); |
134 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; | 129 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; |
135 | }*/ | 130 | }*/ |
136 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "done\n"); | 131 | |
137 | //No record matches query | 132 | //No record matches query |
138 | if ((xquery_size > 0) && (record_match == 0)) | 133 | if ((xquery_size > 0) && (record_match == 0)) |
139 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | 134 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
135 | |||
140 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Records match\n"); | 136 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Records match\n"); |
141 | //FIXME do bf check before or after crypto?? | 137 | //FIXME do bf check before or after crypto?? |
142 | if (NULL != bf) | 138 | if (NULL != bf) |