diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-04-05 13:07:27 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-04-05 13:07:27 +0000 |
commit | acd08b65a860450488d5e6b5403e43bed3748dc9 (patch) | |
tree | 20fc809a1d307b07993c4b2d80f14594e53938e1 /src | |
parent | 4a8a0bbb94a087d697092bad031261c0ee51a8cc (diff) | |
download | gnunet-acd08b65a860450488d5e6b5403e43bed3748dc9.tar.gz gnunet-acd08b65a860450488d5e6b5403e43bed3748dc9.zip |
nblock support done
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/fs.h | 21 | ||||
-rw-r--r-- | src/fs/fs_namespace.c | 179 | ||||
-rw-r--r-- | src/fs/fs_search.c | 99 | ||||
-rw-r--r-- | src/fs/gnunet-pseudonym.c | 25 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs.c | 75 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 2 | ||||
-rw-r--r-- | src/include/gnunet_signatures.h | 7 |
7 files changed, 338 insertions, 70 deletions
diff --git a/src/fs/fs.h b/src/fs/fs.h index 3a42fee2d..a9a585a15 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h | |||
@@ -1218,20 +1218,37 @@ struct NBlock | |||
1218 | { | 1218 | { |
1219 | 1219 | ||
1220 | /** | 1220 | /** |
1221 | * GNUNET_RSA_Signature using RSA-key generated from search keyword. | ||
1222 | */ | ||
1223 | struct GNUNET_CRYPTO_RsaSignature ksk_signature; | ||
1224 | |||
1225 | /** | ||
1226 | * What is being signed and why? | ||
1227 | */ | ||
1228 | struct GNUNET_CRYPTO_RsaSignaturePurpose ksk_purpose; | ||
1229 | |||
1230 | /** | ||
1231 | * Key generated (!) from the H(keyword) as the seed! | ||
1232 | */ | ||
1233 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace; | ||
1234 | |||
1235 | /** | ||
1221 | * GNUNET_RSA_Signature using RSA-key of the namespace | 1236 | * GNUNET_RSA_Signature using RSA-key of the namespace |
1222 | */ | 1237 | */ |
1223 | struct GNUNET_CRYPTO_RsaSignature signature; | 1238 | struct GNUNET_CRYPTO_RsaSignature ns_signature; |
1224 | 1239 | ||
1225 | /** | 1240 | /** |
1226 | * What is being signed and why? | 1241 | * What is being signed and why? |
1227 | */ | 1242 | */ |
1228 | struct GNUNET_CRYPTO_RsaSignaturePurpose purpose; | 1243 | struct GNUNET_CRYPTO_RsaSignaturePurpose ns_purpose; |
1229 | 1244 | ||
1230 | /** | 1245 | /** |
1231 | * Public key of the namespace. | 1246 | * Public key of the namespace. |
1232 | */ | 1247 | */ |
1233 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace; | 1248 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace; |
1234 | 1249 | ||
1250 | /* from here on, data is encrypted with H(keyword) */ | ||
1251 | |||
1235 | /* 0-terminated root identifier here */ | 1252 | /* 0-terminated root identifier here */ |
1236 | 1253 | ||
1237 | /* variable-size Meta-Data follows here */ | 1254 | /* variable-size Meta-Data follows here */ |
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c index 873494c4f..96e1f4f3f 100644 --- a/src/fs/fs_namespace.c +++ b/src/fs/fs_namespace.c | |||
@@ -79,9 +79,49 @@ struct AdvertisementContext | |||
79 | struct GNUNET_DATASTORE_Handle *dsh; | 79 | struct GNUNET_DATASTORE_Handle *dsh; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * URI that was created. | 82 | * Our KSK URI. |
83 | */ | 83 | */ |
84 | struct GNUNET_FS_Uri *uri; | 84 | struct GNUNET_FS_Uri *ksk_uri; |
85 | |||
86 | /** | ||
87 | * Plaintext. | ||
88 | */ | ||
89 | char *pt; | ||
90 | |||
91 | /** | ||
92 | * NBlock to sign and store. | ||
93 | */ | ||
94 | struct NBlock *nb; | ||
95 | |||
96 | /** | ||
97 | * The namespace. | ||
98 | */ | ||
99 | struct GNUNET_FS_Namespace *ns; | ||
100 | |||
101 | /** | ||
102 | * Expiration time. | ||
103 | */ | ||
104 | struct GNUNET_TIME_Absolute expiration; | ||
105 | |||
106 | /** | ||
107 | * Number of bytes of plaintext. | ||
108 | */ | ||
109 | size_t pt_size; | ||
110 | |||
111 | /** | ||
112 | * Anonymity level. | ||
113 | */ | ||
114 | uint32_t anonymity; | ||
115 | |||
116 | /** | ||
117 | * Content priority. | ||
118 | */ | ||
119 | uint32_t priority; | ||
120 | |||
121 | /** | ||
122 | * Current keyword offset. | ||
123 | */ | ||
124 | unsigned int pos; | ||
85 | }; | 125 | }; |
86 | 126 | ||
87 | 127 | ||
@@ -99,14 +139,74 @@ advertisement_cont (void *cls, | |||
99 | const char *msg) | 139 | const char *msg) |
100 | { | 140 | { |
101 | struct AdvertisementContext *ac = cls; | 141 | struct AdvertisementContext *ac = cls; |
142 | const char *keyword; | ||
143 | GNUNET_HashCode key; | ||
144 | GNUNET_HashCode query; | ||
145 | struct GNUNET_CRYPTO_AesSessionKey skey; | ||
146 | struct GNUNET_CRYPTO_AesInitializationVector iv; | ||
147 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; | ||
102 | 148 | ||
103 | if (GNUNET_OK != success) | 149 | if (GNUNET_OK != success) |
104 | ac->cont (ac->cont_cls, NULL, msg); | 150 | { |
105 | else | 151 | /* error! */ |
106 | ac->cont (ac->cont_cls, ac->uri, NULL); | 152 | GNUNET_DATASTORE_disconnect (ac->dsh, GNUNET_NO); |
107 | GNUNET_DATASTORE_disconnect (ac->dsh, GNUNET_NO); | 153 | ac->cont (ac->cont_cls, NULL, msg); |
108 | GNUNET_FS_uri_destroy (ac->uri); | 154 | GNUNET_FS_uri_destroy (ac->ksk_uri); |
109 | GNUNET_free (ac); | 155 | GNUNET_free (ac->pt); |
156 | GNUNET_free (ac->nb); | ||
157 | GNUNET_FS_namespace_delete (ac->ns, GNUNET_NO); | ||
158 | GNUNET_free (ac); | ||
159 | return; | ||
160 | } | ||
161 | if (ac->pos == ac->ksk_uri->data.ksk.keywordCount) | ||
162 | { | ||
163 | /* done! */ | ||
164 | GNUNET_DATASTORE_disconnect (ac->dsh, GNUNET_NO); | ||
165 | ac->cont (ac->cont_cls, ac->ksk_uri, NULL); | ||
166 | GNUNET_FS_uri_destroy (ac->ksk_uri); | ||
167 | GNUNET_free (ac->pt); | ||
168 | GNUNET_free (ac->nb); | ||
169 | GNUNET_FS_namespace_delete (ac->ns, GNUNET_NO); | ||
170 | GNUNET_free (ac); | ||
171 | return; | ||
172 | } | ||
173 | |||
174 | keyword = ac->ksk_uri->data.ksk.keywords[ac->pos++]; | ||
175 | /* first character of keyword indicates if it is | ||
176 | mandatory or not -- ignore for hashing */ | ||
177 | GNUNET_CRYPTO_hash (&keyword[1], strlen (&keyword[1]), &key); | ||
178 | GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv); | ||
179 | GNUNET_CRYPTO_aes_encrypt (ac->pt, | ||
180 | ac->pt_size, | ||
181 | &skey, | ||
182 | &iv, | ||
183 | &ac->nb[1]); | ||
184 | GNUNET_break (GNUNET_OK == | ||
185 | GNUNET_CRYPTO_rsa_sign (ac->ns->key, | ||
186 | &ac->nb->ns_purpose, | ||
187 | &ac->nb->ns_signature)); | ||
188 | pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key); | ||
189 | GNUNET_CRYPTO_rsa_key_get_public (pk, &ac->nb->keyspace); | ||
190 | GNUNET_CRYPTO_hash (&ac->nb->keyspace, | ||
191 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
192 | &query); | ||
193 | GNUNET_break (GNUNET_OK == | ||
194 | GNUNET_CRYPTO_rsa_sign (pk, | ||
195 | &ac->nb->ksk_purpose, | ||
196 | &ac->nb->ksk_signature)); | ||
197 | GNUNET_CRYPTO_rsa_key_free (pk); | ||
198 | GNUNET_DATASTORE_put (ac->dsh, | ||
199 | 0 /* no reservation */, | ||
200 | &query, | ||
201 | ac->pt_size + sizeof (struct NBlock), | ||
202 | ac->nb, | ||
203 | GNUNET_DATASTORE_BLOCKTYPE_NBLOCK, | ||
204 | ac->priority, | ||
205 | ac->anonymity, | ||
206 | ac->expiration, | ||
207 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | ||
208 | &advertisement_cont, | ||
209 | ac); | ||
110 | } | 210 | } |
111 | 211 | ||
112 | 212 | ||
@@ -114,6 +214,7 @@ advertisement_cont (void *cls, | |||
114 | * Publish an advertismement for a namespace. | 214 | * Publish an advertismement for a namespace. |
115 | * | 215 | * |
116 | * @param h handle to the file sharing subsystem | 216 | * @param h handle to the file sharing subsystem |
217 | * @param ksk_uri keywords to use for advertisment | ||
117 | * @param namespace handle for the namespace that should be advertised | 218 | * @param namespace handle for the namespace that should be advertised |
118 | * @param meta meta-data for the namespace advertisement | 219 | * @param meta meta-data for the namespace advertisement |
119 | * @param anonymity for the namespace advertismement | 220 | * @param anonymity for the namespace advertismement |
@@ -125,6 +226,7 @@ advertisement_cont (void *cls, | |||
125 | */ | 226 | */ |
126 | void | 227 | void |
127 | GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, | 228 | GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, |
229 | struct GNUNET_FS_Uri *ksk_uri, | ||
128 | struct GNUNET_FS_Namespace *namespace, | 230 | struct GNUNET_FS_Namespace *namespace, |
129 | const struct GNUNET_CONTAINER_MetaData *meta, | 231 | const struct GNUNET_CONTAINER_MetaData *meta, |
130 | uint32_t anonymity, | 232 | uint32_t anonymity, |
@@ -138,10 +240,10 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, | |||
138 | size_t size; | 240 | size_t size; |
139 | ssize_t mdsize; | 241 | ssize_t mdsize; |
140 | struct NBlock *nb; | 242 | struct NBlock *nb; |
141 | char *rtgt; | ||
142 | char *mdst; | 243 | char *mdst; |
143 | struct GNUNET_DATASTORE_Handle *dsh; | 244 | struct GNUNET_DATASTORE_Handle *dsh; |
144 | struct AdvertisementContext *ctx; | 245 | struct AdvertisementContext *ctx; |
246 | char *pt; | ||
145 | 247 | ||
146 | /* create advertisements */ | 248 | /* create advertisements */ |
147 | mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); | 249 | mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta); |
@@ -157,11 +259,10 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, | |||
157 | size = MAX_NBLOCK_SIZE; | 259 | size = MAX_NBLOCK_SIZE; |
158 | mdsize = size - sizeof (struct NBlock) - reslen; | 260 | mdsize = size - sizeof (struct NBlock) - reslen; |
159 | } | 261 | } |
160 | nb = GNUNET_malloc (size); | 262 | |
161 | GNUNET_CRYPTO_rsa_key_get_public (namespace->key, &nb->subspace); | 263 | pt = GNUNET_malloc (mdsize + reslen); |
162 | rtgt = (char *) &nb[1]; | 264 | memcpy (pt, rootEntry, reslen); |
163 | memcpy (rtgt, rootEntry, reslen); | 265 | mdst = &pt[reslen]; |
164 | mdst = &rtgt[reslen]; | ||
165 | mdsize = GNUNET_CONTAINER_meta_data_serialize (meta, | 266 | mdsize = GNUNET_CONTAINER_meta_data_serialize (meta, |
166 | &mdst, | 267 | &mdst, |
167 | mdsize, | 268 | mdsize, |
@@ -169,46 +270,42 @@ GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, | |||
169 | if (mdsize == -1) | 270 | if (mdsize == -1) |
170 | { | 271 | { |
171 | GNUNET_break (0); | 272 | GNUNET_break (0); |
172 | GNUNET_free (nb); | 273 | GNUNET_free (pt); |
173 | cont (cont_cls, NULL, _("Failed to serialize meta data")); | 274 | cont (cont_cls, NULL, _("Failed to serialize meta data")); |
174 | return; | 275 | return; |
175 | } | 276 | } |
176 | size = mdsize + sizeof (struct NBlock) + reslen; | 277 | size = mdsize + sizeof (struct NBlock) + reslen; |
177 | nb->purpose.size = htonl (size - sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 278 | nb = GNUNET_malloc (size); |
178 | nb->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK); | 279 | GNUNET_CRYPTO_rsa_key_get_public (namespace->key, |
179 | GNUNET_break (GNUNET_OK == | 280 | &nb->subspace); |
180 | GNUNET_CRYPTO_rsa_sign (namespace->key, | 281 | nb->ns_purpose.size = htonl (mdsize + reslen + |
181 | &nb->purpose, | 282 | sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + |
182 | &nb->signature)); | 283 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); |
284 | nb->ns_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK); | ||
285 | nb->ksk_purpose.size = htonl (size - sizeof (struct GNUNET_CRYPTO_RsaSignature)); | ||
286 | nb->ksk_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG); | ||
183 | dsh = GNUNET_DATASTORE_connect (h->cfg, h->sched); | 287 | dsh = GNUNET_DATASTORE_connect (h->cfg, h->sched); |
184 | if (NULL == dsh) | 288 | if (NULL == dsh) |
185 | { | 289 | { |
186 | GNUNET_free (nb); | 290 | GNUNET_free (nb); |
291 | GNUNET_free (pt); | ||
187 | cont (cont_cls, NULL, _("Failed to connect to datastore service")); | 292 | cont (cont_cls, NULL, _("Failed to connect to datastore service")); |
188 | return; | 293 | return; |
189 | } | 294 | } |
190 | ctx = GNUNET_malloc (sizeof (struct AdvertisementContext)); | 295 | ctx = GNUNET_malloc (sizeof (struct AdvertisementContext)); |
191 | ctx->cont = cont; | 296 | ctx->cont = cont; |
192 | ctx->cont_cls = cont_cls; | 297 | ctx->cont_cls = cont_cls; |
193 | ctx->dsh = dsh; | 298 | ctx->dsh = dsh; |
194 | ctx->uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 299 | ctx->ksk_uri = GNUNET_FS_uri_dup (ksk_uri); |
195 | ctx->uri->type = sks; | 300 | ctx->nb = nb; |
196 | ctx->uri->data.sks.identifier = GNUNET_strdup (""); | 301 | ctx->pt = pt; |
197 | GNUNET_CRYPTO_hash (&nb->subspace, | 302 | ctx->pt_size = mdsize + reslen; |
198 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 303 | ctx->ns = namespace; |
199 | &ctx->uri->data.sks.namespace); | 304 | ctx->ns->rc++; |
200 | GNUNET_DATASTORE_put (dsh, | 305 | ctx->anonymity = anonymity; |
201 | 0, | 306 | ctx->priority = priority; |
202 | &ctx->uri->data.sks.namespace, | 307 | ctx->expiration = expiration; |
203 | size, | 308 | advertisement_cont (ctx, GNUNET_OK, NULL); |
204 | nb, | ||
205 | GNUNET_DATASTORE_BLOCKTYPE_NBLOCK, | ||
206 | priority, | ||
207 | anonymity, | ||
208 | expiration, | ||
209 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | ||
210 | &advertisement_cont, | ||
211 | ctx); | ||
212 | } | 309 | } |
213 | 310 | ||
214 | 311 | ||
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index ce4af43fc..8674f824c 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c | |||
@@ -24,9 +24,6 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * | 25 | * |
26 | * TODO: | 26 | * TODO: |
27 | * - handle namespace advertisements (NBlocks, see FIXME; | ||
28 | * note that we currently use KBLOCK instead of ANY when | ||
29 | * searching => NBLOCKS would not fit! FIX this as well!) | ||
30 | * - add support for pushing "already seen" information | 27 | * - add support for pushing "already seen" information |
31 | * to FS service for bloomfilter (can wait) | 28 | * to FS service for bloomfilter (can wait) |
32 | * - handle availability probes (can wait) | 29 | * - handle availability probes (can wait) |
@@ -412,6 +409,88 @@ process_kblock (struct GNUNET_FS_SearchContext *sc, | |||
412 | 409 | ||
413 | 410 | ||
414 | /** | 411 | /** |
412 | * Process a keyword-search result with a namespace advertisment. | ||
413 | * | ||
414 | * @param sc our search context | ||
415 | * @param nb the nblock | ||
416 | * @param size size of nb | ||
417 | */ | ||
418 | static void | ||
419 | process_nblock (struct GNUNET_FS_SearchContext *sc, | ||
420 | const struct NBlock *nb, | ||
421 | size_t size) | ||
422 | { | ||
423 | unsigned int i; | ||
424 | size_t j; | ||
425 | GNUNET_HashCode q; | ||
426 | char pt[size - sizeof (struct NBlock)]; | ||
427 | struct GNUNET_CRYPTO_AesSessionKey skey; | ||
428 | struct GNUNET_CRYPTO_AesInitializationVector iv; | ||
429 | const char *eos; | ||
430 | struct GNUNET_CONTAINER_MetaData *meta; | ||
431 | struct GNUNET_FS_Uri *uri; | ||
432 | |||
433 | GNUNET_CRYPTO_hash (&nb->keyspace, | ||
434 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
435 | &q); | ||
436 | /* find key */ | ||
437 | for (i=0;i<sc->uri->data.ksk.keywordCount;i++) | ||
438 | if (0 == memcmp (&q, | ||
439 | &sc->requests[i].query, | ||
440 | sizeof (GNUNET_HashCode))) | ||
441 | break; | ||
442 | if (i == sc->uri->data.ksk.keywordCount) | ||
443 | { | ||
444 | /* oops, does not match any of our keywords!? */ | ||
445 | GNUNET_break (0); | ||
446 | return; | ||
447 | } | ||
448 | /* decrypt */ | ||
449 | GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv); | ||
450 | GNUNET_CRYPTO_aes_decrypt (&nb[1], | ||
451 | size - sizeof (struct NBlock), | ||
452 | &skey, | ||
453 | &iv, | ||
454 | pt); | ||
455 | /* parse */ | ||
456 | eos = memchr (pt, 0, sizeof (pt)); | ||
457 | if (NULL == eos) | ||
458 | { | ||
459 | GNUNET_break_op (0); | ||
460 | return; | ||
461 | } | ||
462 | j = eos - pt + 1; | ||
463 | if (sizeof (pt) == j) | ||
464 | meta = GNUNET_CONTAINER_meta_data_create (); | ||
465 | else | ||
466 | meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[j], | ||
467 | sizeof (pt) - j); | ||
468 | if (meta == NULL) | ||
469 | { | ||
470 | GNUNET_break_op (0); /* nblock malformed */ | ||
471 | return; | ||
472 | } | ||
473 | |||
474 | uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | ||
475 | uri->type = sks; | ||
476 | uri->data.sks.identifier = GNUNET_strdup (pt); | ||
477 | GNUNET_CRYPTO_hash (&nb->subspace, | ||
478 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
479 | &uri->data.sks.namespace); | ||
480 | /* FIXME: should store 'root' in meta? */ | ||
481 | GNUNET_PSEUDONYM_add (sc->h->cfg, | ||
482 | &uri->data.sks.namespace, | ||
483 | meta); | ||
484 | /* process */ | ||
485 | process_ksk_result (sc, &sc->requests[i], uri, meta); | ||
486 | |||
487 | /* clean up */ | ||
488 | GNUNET_CONTAINER_meta_data_destroy (meta); | ||
489 | GNUNET_FS_uri_destroy (uri); | ||
490 | } | ||
491 | |||
492 | |||
493 | /** | ||
415 | * Process a namespace-search result. | 494 | * Process a namespace-search result. |
416 | * | 495 | * |
417 | * @param sc our search context | 496 | * @param sc our search context |
@@ -535,7 +614,17 @@ process_result (struct GNUNET_FS_SearchContext *sc, | |||
535 | process_sblock (sc, data, size); | 614 | process_sblock (sc, data, size); |
536 | break; | 615 | break; |
537 | case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK: | 616 | case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK: |
538 | GNUNET_break (0); // FIXME: not implemented! | 617 | if (! GNUNET_FS_uri_test_ksk (sc->uri)) |
618 | { | ||
619 | GNUNET_break (0); | ||
620 | return; | ||
621 | } | ||
622 | if (sizeof (struct NBlock) > size) | ||
623 | { | ||
624 | GNUNET_break_op (0); | ||
625 | return; | ||
626 | } | ||
627 | process_nblock (sc, data, size); | ||
539 | break; | 628 | break; |
540 | case GNUNET_DATASTORE_BLOCKTYPE_ANY: | 629 | case GNUNET_DATASTORE_BLOCKTYPE_ANY: |
541 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | 630 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: |
@@ -640,7 +729,7 @@ transmit_search_request (void *cls, | |||
640 | { | 729 | { |
641 | sm[i].header.size = htons (sizeof (struct SearchMessage)); | 730 | sm[i].header.size = htons (sizeof (struct SearchMessage)); |
642 | sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); | 731 | sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); |
643 | sm[i].type = htonl (GNUNET_DATASTORE_BLOCKTYPE_KBLOCK); | 732 | sm[i].type = htonl (GNUNET_DATASTORE_BLOCKTYPE_ANY); |
644 | sm[i].anonymity_level = htonl (sc->anonymity); | 733 | sm[i].anonymity_level = htonl (sc->anonymity); |
645 | sm[i].query = sc->requests[i].query; | 734 | sm[i].query = sc->requests[i].query; |
646 | } | 735 | } |
diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c index e7b2bb8dd..93b51817d 100644 --- a/src/fs/gnunet-pseudonym.c +++ b/src/fs/gnunet-pseudonym.c | |||
@@ -251,7 +251,6 @@ run (void *cls, | |||
251 | const char *cfgfile, | 251 | const char *cfgfile, |
252 | const struct GNUNET_CONFIGURATION_Handle *c) | 252 | const struct GNUNET_CONFIGURATION_Handle *c) |
253 | { | 253 | { |
254 | struct GNUNET_FS_Uri *ns_uri; | ||
255 | struct GNUNET_TIME_Absolute expiration; | 254 | struct GNUNET_TIME_Absolute expiration; |
256 | char *emsg; | 255 | char *emsg; |
257 | 256 | ||
@@ -289,9 +288,6 @@ run (void *cls, | |||
289 | { | 288 | { |
290 | if (NULL != root_identifier) | 289 | if (NULL != root_identifier) |
291 | { | 290 | { |
292 | emsg = NULL; | ||
293 | ns_uri = GNUNET_FS_uri_sks_create (ns, root_identifier, &emsg); | ||
294 | GNUNET_assert (emsg == NULL); | ||
295 | expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS); | 291 | expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS); |
296 | if (ksk_uri == NULL) | 292 | if (ksk_uri == NULL) |
297 | { | 293 | { |
@@ -299,17 +295,16 @@ run (void *cls, | |||
299 | ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg); | 295 | ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg); |
300 | GNUNET_assert (NULL == emsg); | 296 | GNUNET_assert (NULL == emsg); |
301 | } | 297 | } |
302 | GNUNET_FS_publish_ksk (h, | 298 | GNUNET_FS_namespace_advertise (h, |
303 | ksk_uri, | 299 | ksk_uri, |
304 | adv_metadata, | 300 | ns, |
305 | ns_uri, | 301 | adv_metadata, |
306 | expiration, | 302 | anonymity, |
307 | anonymity, | 303 | priority, |
308 | priority, | 304 | expiration, |
309 | GNUNET_FS_PUBLISH_OPTION_NONE, | 305 | root_identifier, |
310 | &post_advertising, | 306 | &post_advertising, |
311 | NULL); | 307 | NULL); |
312 | GNUNET_FS_uri_destroy (ns_uri); | ||
313 | return; | 308 | return; |
314 | } | 309 | } |
315 | } | 310 | } |
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 22e826536..13f1c727c 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -1641,6 +1641,64 @@ check_kblock (const struct KBlock *kb, | |||
1641 | 1641 | ||
1642 | 1642 | ||
1643 | /** | 1643 | /** |
1644 | * Check if the given NBlock is well-formed. | ||
1645 | * | ||
1646 | * @param nb the nblock data (or at least "dsize" bytes claiming to be one) | ||
1647 | * @param dsize size of "nb" in bytes; check for < sizeof(struct NBlock)! | ||
1648 | * @param query where to store the query that this block answers | ||
1649 | * @return GNUNET_OK if this is actually a well-formed NBlock | ||
1650 | */ | ||
1651 | static int | ||
1652 | check_nblock (const struct NBlock *nb, | ||
1653 | size_t dsize, | ||
1654 | GNUNET_HashCode *query) | ||
1655 | { | ||
1656 | if (dsize < sizeof (struct NBlock)) | ||
1657 | { | ||
1658 | GNUNET_break_op (0); | ||
1659 | return GNUNET_SYSERR; | ||
1660 | } | ||
1661 | if (dsize - sizeof (struct NBlock) != | ||
1662 | ntohl (nb->ns_purpose.size) | ||
1663 | - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) | ||
1664 | - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) ) | ||
1665 | { | ||
1666 | GNUNET_break_op (0); | ||
1667 | return GNUNET_SYSERR; | ||
1668 | } | ||
1669 | if (dsize != | ||
1670 | ntohl (nb->ksk_purpose.size) + sizeof (struct GNUNET_CRYPTO_RsaSignature)) | ||
1671 | { | ||
1672 | GNUNET_break_op (0); | ||
1673 | return GNUNET_SYSERR; | ||
1674 | } | ||
1675 | if (GNUNET_OK != | ||
1676 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG, | ||
1677 | &nb->ksk_purpose, | ||
1678 | &nb->ksk_signature, | ||
1679 | &nb->keyspace)) | ||
1680 | { | ||
1681 | GNUNET_break_op (0); | ||
1682 | return GNUNET_SYSERR; | ||
1683 | } | ||
1684 | if (GNUNET_OK != | ||
1685 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK, | ||
1686 | &nb->ns_purpose, | ||
1687 | &nb->ns_signature, | ||
1688 | &nb->subspace)) | ||
1689 | { | ||
1690 | GNUNET_break_op (0); | ||
1691 | return GNUNET_SYSERR; | ||
1692 | } | ||
1693 | if (query != NULL) | ||
1694 | GNUNET_CRYPTO_hash (&nb->keyspace, | ||
1695 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
1696 | query); | ||
1697 | return GNUNET_OK; | ||
1698 | } | ||
1699 | |||
1700 | |||
1701 | /** | ||
1644 | * Check if the given SBlock is well-formed. | 1702 | * Check if the given SBlock is well-formed. |
1645 | * | 1703 | * |
1646 | * @param sb the sblock data (or at least "dsize" bytes claiming to be one) | 1704 | * @param sb the sblock data (or at least "dsize" bytes claiming to be one) |
@@ -1855,6 +1913,7 @@ process_reply (void *cls, | |||
1855 | } | 1913 | } |
1856 | /* then: fall-through! */ | 1914 | /* then: fall-through! */ |
1857 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: | 1915 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: |
1916 | case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK: | ||
1858 | if (pr->bf != NULL) | 1917 | if (pr->bf != NULL) |
1859 | { | 1918 | { |
1860 | mingle_hash (&chash, pr->mingle, &mhash); | 1919 | mingle_hash (&chash, pr->mingle, &mhash); |
@@ -1897,9 +1956,6 @@ process_reply (void *cls, | |||
1897 | pr->replies_seen[pr->replies_seen_off++] = chash; | 1956 | pr->replies_seen[pr->replies_seen_off++] = chash; |
1898 | } | 1957 | } |
1899 | break; | 1958 | break; |
1900 | case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK: | ||
1901 | // FIXME: any checks against duplicates for NBlocks? | ||
1902 | break; | ||
1903 | default: | 1959 | default: |
1904 | GNUNET_break (0); | 1960 | GNUNET_break (0); |
1905 | return GNUNET_YES; | 1961 | return GNUNET_YES; |
@@ -2054,8 +2110,11 @@ handle_p2p_put (void *cls, | |||
2054 | return GNUNET_SYSERR; | 2110 | return GNUNET_SYSERR; |
2055 | break; | 2111 | break; |
2056 | case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK: | 2112 | case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK: |
2057 | // FIXME -- validate NBLOCK! | 2113 | if (GNUNET_OK != |
2058 | GNUNET_break (0); | 2114 | check_nblock ((const struct NBlock*) &put[1], |
2115 | dsize, | ||
2116 | &query)) | ||
2117 | return GNUNET_SYSERR; | ||
2059 | return GNUNET_OK; | 2118 | return GNUNET_OK; |
2060 | default: | 2119 | default: |
2061 | /* unknown block type */ | 2120 | /* unknown block type */ |
@@ -2744,10 +2803,12 @@ handle_start_search (void *cls, | |||
2744 | #endif | 2803 | #endif |
2745 | switch (type) | 2804 | switch (type) |
2746 | { | 2805 | { |
2806 | case GNUNET_DATASTORE_BLOCKTYPE_ANY: | ||
2747 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: | 2807 | case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK: |
2748 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: | 2808 | case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK: |
2749 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: | 2809 | case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK: |
2750 | case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: | 2810 | case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK: |
2811 | case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK: | ||
2751 | break; | 2812 | break; |
2752 | default: | 2813 | default: |
2753 | GNUNET_break (0); | 2814 | GNUNET_break (0); |
@@ -2757,7 +2818,9 @@ handle_start_search (void *cls, | |||
2757 | } | 2818 | } |
2758 | 2819 | ||
2759 | /* detect duplicate KBLOCK requests */ | 2820 | /* detect duplicate KBLOCK requests */ |
2760 | if (type == GNUNET_DATASTORE_BLOCKTYPE_KBLOCK) | 2821 | if ( (type == GNUNET_DATASTORE_BLOCKTYPE_KBLOCK) || |
2822 | (type == GNUNET_DATASTORE_BLOCKTYPE_NBLOCK) || | ||
2823 | (type == GNUNET_DATASTORE_BLOCKTYPE_ANY) ) | ||
2761 | { | 2824 | { |
2762 | crl = cl->rl_head; | 2825 | crl = cl->rl_head; |
2763 | while ( (crl != NULL) && | 2826 | while ( (crl != NULL) && |
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index e26d6b000..f24b3d8b7 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -2053,6 +2053,7 @@ GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc); | |||
2053 | * Publish an advertismement for a namespace. | 2053 | * Publish an advertismement for a namespace. |
2054 | * | 2054 | * |
2055 | * @param h handle to the file sharing subsystem | 2055 | * @param h handle to the file sharing subsystem |
2056 | * @param ksk_uri keywords to use for advertisment | ||
2056 | * @param namespace handle for the namespace that should be advertised | 2057 | * @param namespace handle for the namespace that should be advertised |
2057 | * @param meta meta-data for the namespace advertisement | 2058 | * @param meta meta-data for the namespace advertisement |
2058 | * @param anonymity for the namespace advertismement | 2059 | * @param anonymity for the namespace advertismement |
@@ -2064,6 +2065,7 @@ GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc); | |||
2064 | */ | 2065 | */ |
2065 | void | 2066 | void |
2066 | GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, | 2067 | GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, |
2068 | struct GNUNET_FS_Uri *ksk_uri, | ||
2067 | struct GNUNET_FS_Namespace *namespace, | 2069 | struct GNUNET_FS_Namespace *namespace, |
2068 | const struct GNUNET_CONTAINER_MetaData *meta, | 2070 | const struct GNUNET_CONTAINER_MetaData *meta, |
2069 | uint32_t anonymity, | 2071 | uint32_t anonymity, |
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h index 8b71bb616..29da16b42 100644 --- a/src/include/gnunet_signatures.h +++ b/src/include/gnunet_signatures.h | |||
@@ -82,9 +82,14 @@ extern "C" | |||
82 | #define GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK 7 | 82 | #define GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK 7 |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Keyword-based signature of advertisment for a namespace. | ||
86 | */ | ||
87 | #define GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG 8 | ||
88 | |||
89 | /** | ||
85 | * | 90 | * |
86 | */ | 91 | */ |
87 | #define GNUNET_SIGNATURE_PURPOSE_RESOLVER_RESPONSE 8 | 92 | #define GNUNET_SIGNATURE_PURPOSE_RESOLVER_RESPONSE 9 |
88 | 93 | ||
89 | 94 | ||
90 | #if 0 /* keep Emacsens' auto-indent happy */ | 95 | #if 0 /* keep Emacsens' auto-indent happy */ |