aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-03-05 16:10:55 +0000
committerChristian Grothoff <christian@grothoff.org>2013-03-05 16:10:55 +0000
commit2a23e57e4216593e83e7235e23988564825e4229 (patch)
tree89cdee0dd816e722214f76f4b9762140416ade20 /src/fs
parentdfeb2b787f31255761a808007779c6e992c47591 (diff)
downloadgnunet-2a23e57e4216593e83e7235e23988564825e4229.tar.gz
gnunet-2a23e57e4216593e83e7235e23988564825e4229.zip
starting major change towards implementing #2564, this breaks some FS tests and FS APIs
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/Makefile.am1
-rw-r--r--src/fs/fs.h15
-rw-r--r--src/fs/fs_api.h18
-rw-r--r--src/fs/fs_namespace.c288
-rw-r--r--src/fs/fs_namespace_advertise.c363
-rw-r--r--src/fs/fs_publish_ksk.c89
-rw-r--r--src/fs/fs_search.c249
-rw-r--r--src/fs/fs_unindex.c84
-rw-r--r--src/fs/fs_uri.c71
-rw-r--r--src/fs/gnunet-pseudonym.c41
-rw-r--r--src/fs/gnunet-service-fs.c4
-rw-r--r--src/fs/gnunet-service-fs.h6
-rw-r--r--src/fs/gnunet-service-fs_cp.c18
-rw-r--r--src/fs/gnunet-service-fs_lc.c12
-rw-r--r--src/fs/gnunet-service-fs_pr.c36
-rw-r--r--src/fs/gnunet-service-fs_pr.h8
-rw-r--r--src/fs/gnunet-service-fs_put.c4
-rw-r--r--src/fs/plugin_block_fs.c181
-rw-r--r--src/fs/test_fs_namespace.c182
-rw-r--r--src/fs/test_fs_uri.c23
20 files changed, 457 insertions, 1236 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am
index 84c0a61d9..54267c57c 100644
--- a/src/fs/Makefile.am
+++ b/src/fs/Makefile.am
@@ -38,7 +38,6 @@ libgnunetfs_la_SOURCES = \
38 fs_publish_ksk.c \ 38 fs_publish_ksk.c \
39 fs_misc.c \ 39 fs_misc.c \
40 fs_namespace.c \ 40 fs_namespace.c \
41 fs_namespace_advertise.c \
42 fs_search.c \ 41 fs_search.c \
43 fs_sharetree.c \ 42 fs_sharetree.c \
44 fs_tree.c fs_tree.h \ 43 fs_tree.c fs_tree.h \
diff --git a/src/fs/fs.h b/src/fs/fs.h
index ffd448d2b..9a987303b 100644
--- a/src/fs/fs.h
+++ b/src/fs/fs.h
@@ -240,26 +240,21 @@ struct SearchMessage
240 * nevertheless, we should probably not use it for a DHT-lookup 240 * nevertheless, we should probably not use it for a DHT-lookup
241 * or similar blunt actions in order to avoid exposing ourselves). 241 * or similar blunt actions in order to avoid exposing ourselves).
242 * <p> 242 * <p>
243 * If the request is for an SBLOCK, this is the identity of the 243 * Otherwise, "target" must be all zeros.
244 * pseudonym to which the SBLOCK belongs.
245 * <p>
246 * If the request is for a KBLOCK, "target" must be all zeros.
247 */ 244 */
248 struct GNUNET_HashCode target; 245 struct GNUNET_HashCode target;
249 246
250 /** 247 /**
251 * Hash of the keyword (aka query) for KBLOCKs; Hash of 248 * Hash of the public key for UBLOCKs; Hash of
252 * the CHK-encoded block for DBLOCKS and IBLOCKS (aka query) 249 * the CHK-encoded block for DBLOCKS and IBLOCKS.
253 * and hash of the identifier XORed with the target for
254 * SBLOCKS (aka query).
255 */ 250 */
256 struct GNUNET_HashCode query; 251 struct GNUNET_HashCode query;
257 252
258 /* this is followed by the hash codes of already-known 253 /* this is followed by the hash codes of already-known
259 * results (which should hence be excluded from what 254 * results (which should hence be excluded from what
260 * the service returns); naturally, this only applies 255 * the service returns); naturally, this only applies
261 * to queries that can have multiple results, such as 256 * to queries that can have multiple results (UBLOCKS).
262 * those for KBLOCKS (KSK) and SBLOCKS (SKS) */ 257 */
263}; 258};
264 259
265 260
diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h
index 61a568fa0..b2744237e 100644
--- a/src/fs/fs_api.h
+++ b/src/fs/fs_api.h
@@ -204,9 +204,9 @@ struct GNUNET_FS_Uri
204 struct 204 struct
205 { 205 {
206 /** 206 /**
207 * Hash of the public key for the namespace. 207 * Identifier of the namespace.
208 */ 208 */
209 struct GNUNET_HashCode ns; 209 struct GNUNET_PseudonymIdentifier ns;
210 210
211 /** 211 /**
212 * Human-readable identifier chosen for this 212 * Human-readable identifier chosen for this
@@ -1390,14 +1390,14 @@ struct GNUNET_FS_UnindexContext
1390 struct GNUNET_DATASTORE_QueueEntry *dqe; 1390 struct GNUNET_DATASTORE_QueueEntry *dqe;
1391 1391
1392 /** 1392 /**
1393 * Current key for decrypting KBLocks from 'get_key' operation. 1393 * Current key for decrypting UBLocks from 'get_key' operation.
1394 */ 1394 */
1395 struct GNUNET_HashCode key; 1395 struct GNUNET_HashCode ukey;
1396 1396
1397 /** 1397 /**
1398 * Current query of 'get_key' operation. 1398 * Current query of 'get_key' operation.
1399 */ 1399 */
1400 struct GNUNET_HashCode query; 1400 struct GNUNET_HashCode uquery;
1401 1401
1402 /** 1402 /**
1403 * First content UID, 0 for none. 1403 * First content UID, 0 for none.
@@ -1449,15 +1449,15 @@ struct GNUNET_FS_UnindexContext
1449struct SearchRequestEntry 1449struct SearchRequestEntry
1450{ 1450{
1451 /** 1451 /**
1452 * Hash of the original keyword, also known as the 1452 * Hash of the original keyword, used to derive the
1453 * key (for decrypting the KBlock). 1453 * key (for decrypting the KBlock).
1454 */ 1454 */
1455 struct GNUNET_HashCode key; 1455 struct GNUNET_HashCode ukey;
1456 1456
1457 /** 1457 /**
1458 * Hash of the public key, also known as the query. 1458 * Hash of the public key, also known as the query.
1459 */ 1459 */
1460 struct GNUNET_HashCode query; 1460 struct GNUNET_HashCode uquery;
1461 1461
1462 /** 1462 /**
1463 * Map that contains a "struct GNUNET_FS_SearchResult" for each result that 1463 * Map that contains a "struct GNUNET_FS_SearchResult" for each result that
@@ -2008,7 +2008,7 @@ struct GNUNET_FS_Namespace
2008 /** 2008 /**
2009 * Private key for the namespace. 2009 * Private key for the namespace.
2010 */ 2010 */
2011 struct GNUNET_CRYPTO_RsaPrivateKey *key; 2011 struct GNUNET_PseudonymHandle *key;
2012 2012
2013 /** 2013 /**
2014 * Hash map mapping identifiers of update nodes 2014 * Hash map mapping identifiers of update nodes
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index 3cc3ca299..87ddb667f 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -32,49 +32,6 @@
32 32
33 33
34/** 34/**
35 * Maximum legal size for an sblock.
36 */
37#define MAX_SBLOCK_SIZE (60 * 1024)
38
39
40/**
41 * Context for creating a namespace asynchronously.
42 */
43struct GNUNET_FS_NamespaceCreationContext
44{
45 /**
46 * Context for asynchronous key creation.
47 */
48 struct GNUNET_CRYPTO_RsaKeyGenerationContext *keycreator;
49
50 /**
51 * Name of the file to store key in / read key from.
52 */
53 char *filename;
54
55 /**
56 * Name of the namespace.
57 */
58 char *name;
59
60 /**
61 * Global fs handle
62 */
63 struct GNUNET_FS_Handle *h;
64
65 /**
66 * Function to call when generation ends (successfully or not)
67 */
68 GNUNET_FS_NamespaceCreationCallback cont;
69
70 /**
71 * Client value to pass to continuation function.
72 */
73 void *cont_cls;
74};
75
76
77/**
78 * Return the name of the directory in which we store 35 * Return the name of the directory in which we store
79 * our local namespaces (or rather, their public keys). 36 * our local namespaces (or rather, their public keys).
80 * 37 *
@@ -288,7 +245,7 @@ GNUNET_FS_namespace_create (struct GNUNET_FS_Handle *h, const char *name)
288 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Namespace)); 245 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Namespace));
289 ret->h = h; 246 ret->h = h;
290 ret->rc = 1; 247 ret->rc = 1;
291 ret->key = GNUNET_CRYPTO_rsa_key_create_from_file (fn); 248 ret->key = GNUNET_PSEUDONYM_create (fn);
292 if (NULL == ret->key) 249 if (NULL == ret->key)
293 { 250 {
294 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 251 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -332,7 +289,7 @@ GNUNET_FS_namespace_open_existing (struct GNUNET_FS_Handle *h, const char *name)
332 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Namespace)); 289 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Namespace));
333 ret->h = h; 290 ret->h = h;
334 ret->rc = 1; 291 ret->rc = 1;
335 ret->key = GNUNET_CRYPTO_rsa_key_create_from_existing_file (fn); 292 ret->key = GNUNET_PSEUDONYM_create_from_existing_file (fn);
336 if (NULL == ret->key) 293 if (NULL == ret->key)
337 { 294 {
338 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 295 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -348,118 +305,6 @@ GNUNET_FS_namespace_open_existing (struct GNUNET_FS_Handle *h, const char *name)
348 305
349 306
350/** 307/**
351 * Function called upon completion of 'GNUNET_CRYPTO_rsa_key_create_start'.
352 *
353 * @param cls closure
354 * @param pk NULL on error, otherwise the private key (which must be free'd by the callee)
355 * @param emsg NULL on success, otherwise an error message
356 */
357static void
358ns_key_created (void *cls, struct GNUNET_CRYPTO_RsaPrivateKey *pk,
359 const char *emsg)
360{
361 struct GNUNET_FS_NamespaceCreationContext *ncc = cls;
362
363 ncc->keycreator = NULL;
364
365 if (pk)
366 {
367 struct GNUNET_FS_Namespace *ret;
368 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Namespace));
369 ret->rc = 1;
370 ret->key = pk;
371 ret->h = ncc->h;
372 ret->name = ncc->name;
373 ret->filename = ncc->filename;
374 ncc->cont (ncc->cont_cls, ret, NULL);
375 }
376 else
377 {
378 GNUNET_free (ncc->filename);
379 GNUNET_free (ncc->name);
380 ncc->cont (ncc->cont_cls, NULL, emsg);
381 }
382 GNUNET_free (ncc);
383}
384
385
386/**
387 * Create a namespace with the given name.
388 * If one already exists, the continuation will be called with a handle to
389 * the existing namespace.
390 * Otherwise creates a new namespace.
391 *
392 * @param h handle to the file sharing subsystem
393 * @param name name to use for the namespace
394 * @return namespace creation context, NULL on error (i.e. invalid filename)
395 */
396struct GNUNET_FS_NamespaceCreationContext *
397GNUNET_FS_namespace_create_start (struct GNUNET_FS_Handle *h, const char *name,
398 GNUNET_FS_NamespaceCreationCallback cont, void *cont_cls)
399{
400 char *dn;
401 char *fn;
402 struct GNUNET_FS_NamespaceCreationContext *ret;
403
404 dn = get_namespace_directory (h);
405 if (NULL == dn)
406 {
407 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
408 _("Can't determine where namespace directory is\n"));
409 return NULL;
410 }
411 GNUNET_asprintf (&fn, "%s%s%s", dn, DIR_SEPARATOR_STR, name);
412 GNUNET_free (dn);
413
414 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_NamespaceCreationContext));
415 ret->filename = fn;
416 ret->h = h;
417 ret->name = GNUNET_strdup (name);
418 ret->cont = cont;
419 ret->cont_cls = cont_cls;
420
421 ret->keycreator = GNUNET_CRYPTO_rsa_key_create_start (fn,
422 ns_key_created, ret);
423
424 if (NULL == ret->keycreator)
425 {
426 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
427 _("Failed to start creating or reading private key for namespace `%s'\n"),
428 name);
429 GNUNET_free (fn);
430 GNUNET_free (ret->name);
431 GNUNET_free (ret);
432 return NULL;
433 }
434 return ret;
435}
436
437
438/**
439 * Abort namespace creation.
440 *
441 * @param ncc namespace creation context to abort
442 */
443void
444GNUNET_FS_namespace_create_stop (struct GNUNET_FS_NamespaceCreationContext *ncc)
445{
446 if (NULL != ncc->keycreator)
447 {
448 GNUNET_CRYPTO_rsa_key_create_stop (ncc->keycreator);
449 ncc->keycreator = NULL;
450 }
451 if (NULL != ncc->filename)
452 {
453 if (0 != UNLINK (ncc->filename))
454 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", ncc->filename);
455 GNUNET_free (ncc->filename);
456 }
457 GNUNET_free_non_null (ncc->name);
458 GNUNET_free (ncc);
459}
460
461
462/**
463 * Rename a local namespace. 308 * Rename a local namespace.
464 * 309 *
465 * @param h handle to the file sharing subsystem 310 * @param h handle to the file sharing subsystem
@@ -468,7 +313,9 @@ GNUNET_FS_namespace_create_stop (struct GNUNET_FS_NamespaceCreationContext *ncc)
468 * @return GNUNET_OK on success, GNUNET_SYSERR on error (see errno for details) 313 * @return GNUNET_OK on success, GNUNET_SYSERR on error (see errno for details)
469 */ 314 */
470int 315int
471GNUNET_FS_namespace_rename (struct GNUNET_FS_Handle *h, const char *old_name, const char *new_name) 316GNUNET_FS_namespace_rename (struct GNUNET_FS_Handle *h,
317 const char *old_name,
318 const char *new_name)
472{ 319{
473 char *dn; 320 char *dn;
474 char *fn_old; 321 char *fn_old;
@@ -496,6 +343,7 @@ GNUNET_FS_namespace_rename (struct GNUNET_FS_Handle *h, const char *old_name, co
496 return GNUNET_SYSERR; 343 return GNUNET_SYSERR;
497} 344}
498 345
346
499/** 347/**
500 * Duplicate a namespace handle. 348 * Duplicate a namespace handle.
501 * 349 *
@@ -536,7 +384,7 @@ GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *ns, int freeze)
536 } 384 }
537 if (0 != ns->rc) 385 if (0 != ns->rc)
538 return GNUNET_OK; 386 return GNUNET_OK;
539 GNUNET_CRYPTO_rsa_key_free (ns->key); 387 GNUNET_PSEUDONYM_destroy (ns->key);
540 GNUNET_free (ns->filename); 388 GNUNET_free (ns->filename);
541 GNUNET_free (ns->name); 389 GNUNET_free (ns->name);
542 for (i = 0; i < ns->update_node_count; i++) 390 for (i = 0; i < ns->update_node_count; i++)
@@ -584,12 +432,12 @@ struct ProcessNamespaceContext
584 * GNUNET_SYSERR on failure (contents of id remain intact) 432 * GNUNET_SYSERR on failure (contents of id remain intact)
585 */ 433 */
586int 434int
587GNUNET_FS_namespace_get_public_key_hash (struct GNUNET_FS_Namespace *ns, 435GNUNET_FS_namespace_get_public_identifier (struct GNUNET_FS_Namespace *ns,
588 struct GNUNET_HashCode *id) 436 struct GNUNET_PseudonymIdentifier *id)
589{ 437{
590 if ((NULL == ns) || (NULL == id)) 438 if ((NULL == ns) || (NULL == id))
591 return GNUNET_SYSERR; 439 return GNUNET_SYSERR;
592 GNUNET_CRYPTO_rsa_get_public_key_hash (ns->key, id); 440 GNUNET_PSEUDONYM_get_identifier (ns->key, id);
593 return GNUNET_OK; 441 return GNUNET_OK;
594} 442}
595 443
@@ -607,13 +455,12 @@ static int
607process_namespace (void *cls, const char *filename) 455process_namespace (void *cls, const char *filename)
608{ 456{
609 struct ProcessNamespaceContext *pnc = cls; 457 struct ProcessNamespaceContext *pnc = cls;
610 struct GNUNET_CRYPTO_RsaPrivateKey *key; 458 struct GNUNET_PseudonymHandle *ph;
611 struct GNUNET_HashCode id; 459 struct GNUNET_PseudonymIdentifier id;
612 const char *name; 460 const char *name;
613 const char *t; 461 const char *t;
614 462
615 key = GNUNET_CRYPTO_rsa_key_create_from_file (filename); 463 if (NULL == (ph = GNUNET_PSEUDONYM_create (filename)))
616 if (NULL == key)
617 { 464 {
618 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 465 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
619 _ 466 _
@@ -623,8 +470,8 @@ process_namespace (void *cls, const char *filename)
623 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename); 470 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", filename);
624 return GNUNET_OK; 471 return GNUNET_OK;
625 } 472 }
626 GNUNET_CRYPTO_rsa_get_public_key_hash (key, &id); 473 GNUNET_PSEUDONYM_get_identifier (ph, &id);
627 GNUNET_CRYPTO_rsa_key_free (key); 474 GNUNET_PSEUDONYM_destroy (ph);
628 name = filename; 475 name = filename;
629 while (NULL != (t = strstr (name, DIR_SEPARATOR_STR))) 476 while (NULL != (t = strstr (name, DIR_SEPARATOR_STR)))
630 name = t + 1; 477 name = t + 1;
@@ -705,7 +552,7 @@ struct GNUNET_FS_PublishSksContext
705 552
706/** 553/**
707 * Function called by the datastore API with 554 * Function called by the datastore API with
708 * the result from the PUT (SBlock) request. 555 * the result from the PUT (UBlock) request.
709 * 556 *
710 * @param cls closure of type "struct GNUNET_FS_PublishSksContext*" 557 * @param cls closure of type "struct GNUNET_FS_PublishSksContext*"
711 * @param success GNUNET_OK on success 558 * @param success GNUNET_OK on success
@@ -737,7 +584,7 @@ sb_put_cont (void *cls, int success,
737 read_update_information_graph (psc->ns); 584 read_update_information_graph (psc->ns);
738 GNUNET_array_append (psc->ns->update_nodes, 585 GNUNET_array_append (psc->ns->update_nodes,
739 psc->ns->update_node_count, psc->nsn); 586 psc->ns->update_node_count, psc->nsn);
740 if (psc->ns->update_map != NULL) 587 if (NULL != psc->ns->update_map)
741 { 588 {
742 GNUNET_CRYPTO_hash (psc->nsn->id, strlen (psc->nsn->id), &hc); 589 GNUNET_CRYPTO_hash (psc->nsn->id, strlen (psc->nsn->id), &hc);
743 GNUNET_CONTAINER_multihashmap_put (psc->ns->update_map, &hc, 590 GNUNET_CONTAINER_multihashmap_put (psc->ns->update_map, &hc,
@@ -788,13 +635,15 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
788 size_t nidlen; 635 size_t nidlen;
789 size_t idlen; 636 size_t idlen;
790 ssize_t mdsize; 637 ssize_t mdsize;
791 struct SBlock *sb; 638 struct UBlock *ub;
792 struct SBlock *sb_enc; 639 struct UBlock *ub_enc;
793 char *dest; 640 char *dest;
794 struct GNUNET_CONTAINER_MetaData *mmeta; 641 struct GNUNET_CONTAINER_MetaData *mmeta;
795 struct GNUNET_HashCode key; /* hash of thisId = key */ 642 struct GNUNET_HashCode id_hash; /* hash of thisId */
796 struct GNUNET_HashCode id; /* hash of hc = identifier */ 643 struct GNUNET_HashCode ns_hash; /* hash of namespace public key */
797 struct GNUNET_HashCode query; /* id ^ nsid = DB query */ 644 struct GNUNET_HashCode key; /* id_hash ^ ns_hash, for AES key */
645 struct GNUNET_HashCode signing_key; /* H(key) = input for public key */
646 struct GNUNET_HashCode query; /* H(verification_key) = query */
798 647
799 idlen = strlen (identifier); 648 idlen = strlen (identifier);
800 if (NULL != update) 649 if (NULL != update)
@@ -803,11 +652,11 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
803 nidlen = 1; 652 nidlen = 1;
804 uris = GNUNET_FS_uri_to_string (uri); 653 uris = GNUNET_FS_uri_to_string (uri);
805 slen = strlen (uris) + 1; 654 slen = strlen (uris) + 1;
806 if ( (slen >= MAX_SBLOCK_SIZE - sizeof (struct SBlock)) || 655 if ( (slen >= MAX_UBLOCK_SIZE - sizeof (struct UBlock)) ||
807 (nidlen >= MAX_SBLOCK_SIZE - sizeof (struct SBlock) - slen) ) 656 (nidlen >= MAX_UBLOCK_SIZE - sizeof (struct UBlock) - slen) )
808 { 657 {
809 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 658 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
810 _("Identifiers or URI too long to create SBlock")); 659 _("Identifiers or URI too long to create UBlock"));
811 GNUNET_free (uris); 660 GNUNET_free (uris);
812 return NULL; 661 return NULL;
813 } 662 }
@@ -816,15 +665,15 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
816 else 665 else
817 mmeta = GNUNET_CONTAINER_meta_data_duplicate (meta); 666 mmeta = GNUNET_CONTAINER_meta_data_duplicate (meta);
818 mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (mmeta); 667 mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (mmeta);
819 size = sizeof (struct SBlock) + slen + nidlen + mdsize; 668 size = sizeof (struct UBlock) + slen + nidlen + mdsize;
820 if ( (size > MAX_SBLOCK_SIZE) || 669 if ( (size > MAX_UBLOCK_SIZE) ||
821 (size < sizeof (struct SBlock) + slen + nidlen) ) 670 (size < sizeof (struct UBlock) + slen + nidlen) )
822 { 671 {
823 size = MAX_SBLOCK_SIZE; 672 size = MAX_UBLOCK_SIZE;
824 mdsize = MAX_SBLOCK_SIZE - (sizeof (struct SBlock) + slen + nidlen); 673 mdsize = MAX_UBLOCK_SIZE - (sizeof (struct UBlock) + slen + nidlen);
825 } 674 }
826 sb = GNUNET_malloc (sizeof (struct SBlock) + size); 675 ub = GNUNET_malloc (sizeof (struct UBlock) + size);
827 dest = (char *) &sb[1]; 676 dest = (char *) &ub[1];
828 if (NULL != update) 677 if (NULL != update)
829 memcpy (dest, update, nidlen); 678 memcpy (dest, update, nidlen);
830 else 679 else
@@ -840,34 +689,44 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
840 if (-1 == mdsize) 689 if (-1 == mdsize)
841 { 690 {
842 GNUNET_break (0); 691 GNUNET_break (0);
843 GNUNET_free (sb); 692 GNUNET_free (ub);
844 if (NULL != cont) 693 if (NULL != cont)
845 cont (cont_cls, NULL, _("Internal error.")); 694 cont (cont_cls, NULL, _("Internal error."));
846 return NULL; 695 return NULL;
847 } 696 }
848 size = sizeof (struct SBlock) + mdsize + slen + nidlen;
849 sb_enc = GNUNET_malloc (size);
850 GNUNET_CRYPTO_hash (identifier, idlen, &key);
851 GNUNET_CRYPTO_hash (&key, sizeof (struct GNUNET_HashCode), &id);
852 sks_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); 697 sks_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
853 sks_uri->type = GNUNET_FS_URI_SKS; 698 sks_uri->type = GNUNET_FS_URI_SKS;
854 GNUNET_CRYPTO_rsa_key_get_public (ns->key, &sb_enc->subspace);
855 GNUNET_CRYPTO_hash (&sb_enc->subspace,
856 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
857 &sks_uri->data.sks.ns);
858 sks_uri->data.sks.identifier = GNUNET_strdup (identifier); 699 sks_uri->data.sks.identifier = GNUNET_strdup (identifier);
859 GNUNET_CRYPTO_hash_xor (&id, &sks_uri->data.sks.ns, 700 GNUNET_FS_namespace_get_public_identifier (ns,
860 &sb_enc->identifier); 701 &sks_uri->data.sks.ns);
702
703 size = sizeof (struct UBlock) + mdsize + slen + nidlen;
704 ub_enc = GNUNET_malloc (size);
705 GNUNET_CRYPTO_hash (identifier, idlen, &id_hash);
706 GNUNET_CRYPTO_hash (&sks_uri->data.sks.ns,
707 sizeof (sks_uri->data.sks.ns), &ns_hash);
708 GNUNET_CRYPTO_hash_xor (&id_hash, &ns_hash, &key);
861 GNUNET_CRYPTO_hash_to_aes_key (&key, &sk, &iv); 709 GNUNET_CRYPTO_hash_to_aes_key (&key, &sk, &iv);
862 GNUNET_CRYPTO_aes_encrypt (&sb[1], size - sizeof (struct SBlock), &sk, &iv, 710 GNUNET_CRYPTO_hash (&key, sizeof (struct GNUNET_HashCode), &signing_key);
863 &sb_enc[1]); 711
864 sb_enc->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK); 712 GNUNET_CRYPTO_aes_encrypt (&ub[1],
865 sb_enc->purpose.size = 713 size - sizeof (struct UBlock),
866 htonl (slen + mdsize + nidlen + sizeof (struct SBlock) - 714 &sk, &iv,
867 sizeof (struct GNUNET_CRYPTO_RsaSignature)); 715 &ub_enc[1]);
868 GNUNET_assert (GNUNET_OK == 716 ub_enc->purpose.size = htonl (nidlen + slen + mdsize + sizeof (struct UBlock)
869 GNUNET_CRYPTO_rsa_sign (ns->key, &sb_enc->purpose, 717 - sizeof (struct GNUNET_PseudonymSignature));
870 &sb_enc->signature)); 718 ub_enc->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK);
719 GNUNET_PSEUDONYM_sign (ns->key,
720 &ub_enc->purpose,
721 NULL,
722 &signing_key,
723 &ub_enc->signature);
724 GNUNET_PSEUDONYM_derive_verification_key (&sks_uri->data.sks.ns,
725 &signing_key,
726 &ub_enc->verification_key);
727 GNUNET_CRYPTO_hash (&ub_enc->verification_key,
728 sizeof (ub_enc->verification_key),
729 &query);
871 psc = GNUNET_malloc (sizeof (struct GNUNET_FS_PublishSksContext)); 730 psc = GNUNET_malloc (sizeof (struct GNUNET_FS_PublishSksContext));
872 psc->uri = sks_uri; 731 psc->uri = sks_uri;
873 psc->cont = cont; 732 psc->cont = cont;
@@ -875,20 +734,20 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
875 psc->cont_cls = cont_cls; 734 psc->cont_cls = cont_cls;
876 if (0 != (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY)) 735 if (0 != (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
877 { 736 {
878 GNUNET_free (sb_enc); 737 GNUNET_free (ub_enc);
879 GNUNET_free (sb); 738 GNUNET_free (ub);
880 sb_put_cont (psc, GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, NULL); 739 sb_put_cont (psc, GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, NULL);
881 return NULL; 740 return NULL;
882 } 741 }
883 psc->dsh = GNUNET_DATASTORE_connect (h->cfg); 742 psc->dsh = GNUNET_DATASTORE_connect (h->cfg);
884 if (NULL == psc->dsh) 743 if (NULL == psc->dsh)
885 { 744 {
886 GNUNET_free (sb_enc); 745 GNUNET_free (ub_enc);
887 GNUNET_free (sb); 746 GNUNET_free (ub);
888 sb_put_cont (psc, GNUNET_NO, GNUNET_TIME_UNIT_ZERO_ABS, _("Failed to connect to datastore.")); 747 sb_put_cont (psc, GNUNET_NO, GNUNET_TIME_UNIT_ZERO_ABS, _("Failed to connect to datastore."));
889 return NULL; 748 return NULL;
890 } 749 }
891 GNUNET_CRYPTO_hash_xor (&sks_uri->data.sks.ns, &id, &query); 750
892 if (NULL != update) 751 if (NULL != update)
893 { 752 {
894 psc->nsn = GNUNET_malloc (sizeof (struct NamespaceUpdateNode)); 753 psc->nsn = GNUNET_malloc (sizeof (struct NamespaceUpdateNode));
@@ -897,13 +756,14 @@ GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h,
897 psc->nsn->md = GNUNET_CONTAINER_meta_data_duplicate (meta); 756 psc->nsn->md = GNUNET_CONTAINER_meta_data_duplicate (meta);
898 psc->nsn->uri = GNUNET_FS_uri_dup (uri); 757 psc->nsn->uri = GNUNET_FS_uri_dup (uri);
899 } 758 }
900 psc->dqe = GNUNET_DATASTORE_put (psc->dsh, 0, &sb_enc->identifier, size, sb_enc, 759
901 GNUNET_BLOCK_TYPE_FS_SBLOCK, bo->content_priority, 760 psc->dqe = GNUNET_DATASTORE_put (psc->dsh, 0, &query, size, ub_enc,
761 GNUNET_BLOCK_TYPE_FS_UBLOCK, bo->content_priority,
902 bo->anonymity_level, bo->replication_level, 762 bo->anonymity_level, bo->replication_level,
903 bo->expiration_time, -2, 1, 763 bo->expiration_time, -2, 1,
904 GNUNET_CONSTANTS_SERVICE_TIMEOUT, &sb_put_cont, psc); 764 GNUNET_CONSTANTS_SERVICE_TIMEOUT, &sb_put_cont, psc);
905 GNUNET_free (sb); 765 GNUNET_free (ub);
906 GNUNET_free (sb_enc); 766 GNUNET_free (ub_enc);
907 return psc; 767 return psc;
908} 768}
909 769
diff --git a/src/fs/fs_namespace_advertise.c b/src/fs/fs_namespace_advertise.c
deleted file mode 100644
index 554f61657..000000000
--- a/src/fs/fs_namespace_advertise.c
+++ /dev/null
@@ -1,363 +0,0 @@
1/*
2 This file is part of GNUnet
3 (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file fs/fs_namespace_advertise.c
23 * @brief advertise namespaces (creating NBlocks)
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_constants.h"
28#include "gnunet_signatures.h"
29#include "gnunet_util_lib.h"
30#include "gnunet_fs_service.h"
31#include "fs_api.h"
32
33
34/**
35 * Maximum legal size for an nblock.
36 */
37#define MAX_NBLOCK_SIZE (60 * 1024)
38
39
40/**
41 * Context for advertising a namespace.
42 */
43struct GNUNET_FS_AdvertisementContext
44{
45 /**
46 * Function to call with the result.
47 */
48 GNUNET_FS_PublishContinuation cont;
49
50 /**
51 * Closure for cont.
52 */
53 void *cont_cls;
54
55 /**
56 * Datastore handle.
57 */
58 struct GNUNET_DATASTORE_Handle *dsh;
59
60 /**
61 * Our KSK URI.
62 */
63 struct GNUNET_FS_Uri *ksk_uri;
64
65 /**
66 * Plaintext.
67 */
68 char *pt;
69
70 /**
71 * NBlock to sign and store.
72 */
73 struct NBlock *nb;
74
75 /**
76 * The namespace.
77 */
78 struct GNUNET_FS_Namespace *ns;
79
80 /**
81 * Current datastore queue entry for advertising.
82 */
83 struct GNUNET_DATASTORE_QueueEntry *dqe;
84
85 /**
86 * Block options.
87 */
88 struct GNUNET_FS_BlockOptions bo;
89
90 /**
91 * Number of bytes of plaintext.
92 */
93 size_t pt_size;
94
95 /**
96 * Current keyword offset.
97 */
98 unsigned int pos;
99};
100
101
102// FIXME: I see no good reason why this should need to be done
103// in a new task (anymore). Integrate with 'cancel' function below?
104/**
105 * Disconnect from the datastore.
106 *
107 * @param cls datastore handle
108 * @param tc scheduler context
109 */
110static void
111do_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
112{
113 struct GNUNET_DATASTORE_Handle *dsh = cls;
114
115 GNUNET_DATASTORE_disconnect (dsh, GNUNET_NO);
116}
117
118
119/**
120 * Continuation called to notify client about result of the
121 * operation.
122 *
123 * @param cls closure (our struct GNUNET_FS_AdvertismentContext)
124 * @param success GNUNET_SYSERR on failure
125 * @param min_expiration minimum expiration time required for content to be stored
126 * @param msg NULL on success, otherwise an error message
127 */
128static void
129advertisement_cont (void *cls, int success,
130 struct GNUNET_TIME_Absolute min_expiration,
131 const char *msg)
132{
133 struct GNUNET_FS_AdvertisementContext *ac = cls;
134 const char *keyword;
135 struct GNUNET_HashCode key;
136 struct GNUNET_HashCode query;
137 struct GNUNET_CRYPTO_AesSessionKey skey;
138 struct GNUNET_CRYPTO_AesInitializationVector iv;
139 struct GNUNET_CRYPTO_RsaPrivateKey *pk;
140
141 ac->dqe = NULL;
142 if (GNUNET_SYSERR == success)
143 {
144 /* error! */
145 (void) GNUNET_SCHEDULER_add_now (&do_disconnect, ac->dsh);
146 ac->dsh = NULL;
147 if (msg == NULL)
148 {
149 GNUNET_break (0);
150 msg = _("Unknown error");
151 }
152 if (ac->cont != NULL)
153 {
154 ac->cont (ac->cont_cls, NULL, msg);
155 ac->cont = NULL;
156 }
157 GNUNET_FS_namespace_advertise_cancel (ac);
158 return;
159 }
160 if (ac->pos == ac->ksk_uri->data.ksk.keywordCount)
161 {
162 /* done! */
163 (void) GNUNET_SCHEDULER_add_now (&do_disconnect, ac->dsh);
164 ac->dsh = NULL;
165 if (ac->cont != NULL)
166 {
167 ac->cont (ac->cont_cls, ac->ksk_uri, NULL);
168 ac->cont = NULL;
169 }
170 GNUNET_FS_namespace_advertise_cancel (ac);
171 return;
172 }
173 keyword = ac->ksk_uri->data.ksk.keywords[ac->pos++];
174 /* first character of keyword indicates if it is
175 * mandatory or not -- ignore for hashing */
176 GNUNET_CRYPTO_hash (&keyword[1], strlen (&keyword[1]), &key);
177 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
178 GNUNET_CRYPTO_aes_encrypt (ac->pt, ac->pt_size, &skey, &iv, &ac->nb[1]);
179 GNUNET_break (GNUNET_OK ==
180 GNUNET_CRYPTO_rsa_sign (ac->ns->key, &ac->nb->ns_purpose,
181 &ac->nb->ns_signature));
182 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key);
183 GNUNET_assert (pk != NULL);
184 GNUNET_CRYPTO_rsa_key_get_public (pk, &ac->nb->keyspace);
185 GNUNET_CRYPTO_hash (&ac->nb->keyspace,
186 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
187 &query);
188 GNUNET_break (GNUNET_OK ==
189 GNUNET_CRYPTO_rsa_sign (pk, &ac->nb->ksk_purpose,
190 &ac->nb->ksk_signature));
191 GNUNET_CRYPTO_rsa_key_free (pk);
192 ac->dqe = GNUNET_DATASTORE_put (ac->dsh, 0 /* no reservation */ ,
193 &query, ac->pt_size + sizeof (struct NBlock), ac->nb,
194 GNUNET_BLOCK_TYPE_FS_NBLOCK, ac->bo.content_priority,
195 ac->bo.anonymity_level, ac->bo.replication_level,
196 ac->bo.expiration_time, -2, 1,
197 GNUNET_CONSTANTS_SERVICE_TIMEOUT, &advertisement_cont,
198 ac);
199}
200
201
202/**
203 * Create an SKS uri that points to the root entry of the namespace,
204 * then insert that SKS uri into metadata.
205 *
206 * @param ns handle for the namespace that should be advertised
207 * @param meta meta-data into which namespace advertisement should be inserted
208 * @param rootEntry name of the root of the namespace (use NULL to use default)
209 * @return GNUNET_OK on success, GNUNET_SYSERR on error
210 */
211int
212GNUNET_FS_namespace_insert_advertisement_into_metadata (
213 struct GNUNET_FS_Namespace *ns, struct GNUNET_CONTAINER_MetaData *meta,
214 const char *rootEntry)
215{
216 struct GNUNET_FS_Uri *sks_uri;
217 char *emsg;
218 char *sks_uri_string;
219 int md_insert;
220
221 if (NULL == rootEntry)
222 rootEntry = "/";
223
224 emsg = NULL;
225 sks_uri = GNUNET_FS_uri_sks_create (ns, rootEntry, &emsg);
226 GNUNET_free_non_null (emsg);
227 if (NULL == sks_uri)
228 return GNUNET_SYSERR;
229
230 sks_uri_string = GNUNET_FS_uri_to_string (sks_uri);
231 GNUNET_FS_uri_destroy (sks_uri);
232 if (NULL == sks_uri_string)
233 return GNUNET_SYSERR;
234
235 md_insert = GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>",
236 EXTRACTOR_METATYPE_URI, EXTRACTOR_METAFORMAT_UTF8,
237 "text/plain", sks_uri_string, strlen (sks_uri_string) + 1);
238 GNUNET_free (sks_uri_string);
239 return md_insert;
240}
241
242/**
243 * Publish an advertismement for a namespace.
244 *
245 * @param h handle to the file sharing subsystem
246 * @param ksk_uri keywords to use for advertisment
247 * @param ns handle for the namespace that should be advertised
248 * @param meta meta-data for the namespace advertisement
249 * @param bo block options
250 * @param rootEntry name of the root of the namespace
251 * @param cont continuation
252 * @param cont_cls closure for cont
253 * @return NULL on error ('cont' is still called)
254 */
255struct GNUNET_FS_AdvertisementContext *
256GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h,
257 struct GNUNET_FS_Uri *ksk_uri,
258 struct GNUNET_FS_Namespace *ns,
259 const struct GNUNET_CONTAINER_MetaData *meta,
260 const struct GNUNET_FS_BlockOptions *bo,
261 const char *rootEntry,
262 GNUNET_FS_PublishContinuation cont,
263 void *cont_cls)
264{
265 size_t reslen;
266 size_t size;
267 ssize_t mdsize;
268 struct NBlock *nb;
269 char *mdst;
270 struct GNUNET_DATASTORE_Handle *dsh;
271 struct GNUNET_FS_AdvertisementContext *ctx;
272 char *pt;
273
274 /* create advertisements */
275 mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta);
276 if (-1 == mdsize)
277 {
278 cont (cont_cls, NULL, _("Failed to serialize meta data"));
279 return NULL;
280 }
281 reslen = strlen (rootEntry) + 1;
282 size = mdsize + sizeof (struct NBlock) + reslen;
283 if (size > MAX_NBLOCK_SIZE)
284 {
285 size = MAX_NBLOCK_SIZE;
286 mdsize = size - sizeof (struct NBlock) - reslen;
287 }
288
289 pt = GNUNET_malloc (mdsize + reslen);
290 memcpy (pt, rootEntry, reslen);
291 mdst = &pt[reslen];
292 mdsize =
293 GNUNET_CONTAINER_meta_data_serialize (meta, &mdst, mdsize,
294 GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
295 if (-1 == mdsize)
296 {
297 GNUNET_break (0);
298 GNUNET_free (pt);
299 cont (cont_cls, NULL, _("Failed to serialize meta data"));
300 return NULL;
301 }
302 size = mdsize + sizeof (struct NBlock) + reslen;
303 nb = GNUNET_malloc (size);
304 GNUNET_CRYPTO_rsa_key_get_public (ns->key, &nb->subspace);
305 nb->ns_purpose.size =
306 htonl (mdsize + reslen +
307 sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) +
308 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
309 nb->ns_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK);
310 nb->ksk_purpose.size =
311 htonl (size - sizeof (struct GNUNET_CRYPTO_RsaSignature));
312 nb->ksk_purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG);
313 dsh = GNUNET_DATASTORE_connect (h->cfg);
314 if (NULL == dsh)
315 {
316 GNUNET_free (nb);
317 GNUNET_free (pt);
318 cont (cont_cls, NULL, _("Failed to connect to datastore service"));
319 return NULL;
320 }
321 ctx = GNUNET_malloc (sizeof (struct GNUNET_FS_AdvertisementContext));
322 ctx->cont = cont;
323 ctx->cont_cls = cont_cls;
324 ctx->dsh = dsh;
325 ctx->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
326 ctx->nb = nb;
327 ctx->pt = pt;
328 ctx->pt_size = mdsize + reslen;
329 ctx->ns = ns;
330 ctx->ns->rc++;
331 ctx->bo = *bo;
332 advertisement_cont (ctx, GNUNET_OK, GNUNET_TIME_UNIT_ZERO_ABS, NULL);
333 return ctx;
334}
335
336
337/**
338 * Abort the namespace advertisement operation.
339 *
340 * @param ac context of the operation to abort.
341 */
342void
343GNUNET_FS_namespace_advertise_cancel (struct GNUNET_FS_AdvertisementContext *ac)
344{
345 if (NULL != ac->dqe)
346 {
347 GNUNET_DATASTORE_cancel (ac->dqe);
348 ac->dqe = NULL;
349 }
350 if (NULL != ac->dsh)
351 {
352 GNUNET_DATASTORE_disconnect (ac->dsh, GNUNET_NO);
353 ac->dsh = NULL;
354 }
355 GNUNET_FS_uri_destroy (ac->ksk_uri);
356 GNUNET_free (ac->pt);
357 GNUNET_free (ac->nb);
358 GNUNET_FS_namespace_delete (ac->ns, GNUNET_NO);
359 GNUNET_free (ac);
360}
361
362
363/* end of fs_namespace_advertise.c */
diff --git a/src/fs/fs_publish_ksk.c b/src/fs/fs_publish_ksk.c
index 5511fb93d..bbbbdc1d6 100644
--- a/src/fs/fs_publish_ksk.c
+++ b/src/fs/fs_publish_ksk.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009, 2010, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2009, 2010, 2012, 2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -21,7 +21,7 @@
21/** 21/**
22 * @file fs/fs_publish_ksk.c 22 * @file fs/fs_publish_ksk.c
23 * @brief publish a URI under a keyword in GNUnet 23 * @brief publish a URI under a keyword in GNUnet
24 * @see https://gnunet.org/encoding 24 * @see https://gnunet.org/encoding and #2564
25 * @author Krista Bennett 25 * @author Krista Bennett
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 */ 27 */
@@ -36,12 +36,6 @@
36 36
37 37
38/** 38/**
39 * Maximum legal size for a kblock.
40 */
41#define MAX_KBLOCK_SIZE (60 * 1024)
42
43
44/**
45 * Context for the KSK publication. 39 * Context for the KSK publication.
46 */ 40 */
47struct GNUNET_FS_PublishKskContext 41struct GNUNET_FS_PublishKskContext
@@ -62,13 +56,13 @@ struct GNUNET_FS_PublishKskContext
62 * (in plaintext), has "mdsize+slen" more 56 * (in plaintext), has "mdsize+slen" more
63 * bytes than the struct would suggest. 57 * bytes than the struct would suggest.
64 */ 58 */
65 struct KBlock *kb; 59 struct UBlock *ub;
66 60
67 /** 61 /**
68 * Buffer of the same size as "kb" for 62 * Buffer of the same size as "kb" for
69 * the encrypted version. 63 * the encrypted version.
70 */ 64 */
71 struct KBlock *cpy; 65 struct UBlock *cpy;
72 66
73 /** 67 /**
74 * Handle to the datastore, NULL if we are just 68 * Handle to the datastore, NULL if we are just
@@ -173,10 +167,13 @@ publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
173 struct GNUNET_FS_PublishKskContext *pkc = cls; 167 struct GNUNET_FS_PublishKskContext *pkc = cls;
174 const char *keyword; 168 const char *keyword;
175 struct GNUNET_HashCode key; 169 struct GNUNET_HashCode key;
170 struct GNUNET_HashCode seed;
171 struct GNUNET_HashCode signing_key;
176 struct GNUNET_HashCode query; 172 struct GNUNET_HashCode query;
177 struct GNUNET_CRYPTO_AesSessionKey skey; 173 struct GNUNET_CRYPTO_AesSessionKey skey;
178 struct GNUNET_CRYPTO_AesInitializationVector iv; 174 struct GNUNET_CRYPTO_AesInitializationVector iv;
179 struct GNUNET_CRYPTO_RsaPrivateKey *pk; 175 struct GNUNET_PseudonymHandle *ph;
176 struct GNUNET_PseudonymIdentifier pseudonym;
180 177
181 pkc->ksk_task = GNUNET_SCHEDULER_NO_TASK; 178 pkc->ksk_task = GNUNET_SCHEDULER_NO_TASK;
182 if ((pkc->i == pkc->ksk_uri->data.ksk.keywordCount) || (NULL == pkc->dsh)) 179 if ((pkc->i == pkc->ksk_uri->data.ksk.keywordCount) || (NULL == pkc->dsh))
@@ -186,29 +183,43 @@ publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
186 GNUNET_FS_publish_ksk_cancel (pkc); 183 GNUNET_FS_publish_ksk_cancel (pkc);
187 return; 184 return;
188 } 185 }
186 /* derive signing seed from plaintext */
187 GNUNET_CRYPTO_hash (&pkc->ub[1],
188 1 + pkc->slen + pkc->mdsize,
189 &seed);
189 keyword = pkc->ksk_uri->data.ksk.keywords[pkc->i++]; 190 keyword = pkc->ksk_uri->data.ksk.keywords[pkc->i++];
190 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing under keyword `%s'\n", 191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing under keyword `%s'\n",
191 &keyword[1]); 192 &keyword[1]);
192 /* first character of keyword indicates if it is 193 /* first character of keyword indicates if it is
193 * mandatory or not -- ignore for hashing */ 194 * mandatory or not -- ignore for hashing */
194 GNUNET_CRYPTO_hash (&keyword[1], strlen (&keyword[1]), &key); 195 GNUNET_CRYPTO_hash (&keyword[1], strlen (&keyword[1]), &key);
195 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv); 196 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
196 GNUNET_CRYPTO_aes_encrypt (&pkc->kb[1], pkc->slen + pkc->mdsize, &skey, &iv, 197 GNUNET_CRYPTO_aes_encrypt (&pkc->ub[1],
198 1 + pkc->slen + pkc->mdsize,
199 &skey, &iv,
197 &pkc->cpy[1]); 200 &pkc->cpy[1]);
198 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key); 201 ph = GNUNET_PSEUDONYM_get_anonymous_pseudonym_handle ();
199 GNUNET_assert (NULL != pk); 202 GNUNET_CRYPTO_hash (&key, sizeof (key), &signing_key);
200 GNUNET_CRYPTO_rsa_key_get_public (pk, &pkc->cpy->keyspace); 203 pkc->cpy->purpose.size = htonl (1 + pkc->slen + pkc->mdsize + sizeof (struct UBlock)
201 GNUNET_CRYPTO_hash (&pkc->cpy->keyspace, 204 - sizeof (struct GNUNET_PseudonymSignature));
202 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 205 pkc->cpy->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK);
203 &query); 206 GNUNET_PSEUDONYM_sign (ph,
204 GNUNET_assert (GNUNET_OK == 207 &pkc->cpy->purpose,
205 GNUNET_CRYPTO_rsa_sign (pk, &pkc->cpy->purpose, 208 &seed,
206 &pkc->cpy->signature)); 209 &signing_key,
207 GNUNET_CRYPTO_rsa_key_free (pk); 210 &pkc->cpy->signature);
211 GNUNET_PSEUDONYM_get_identifier (ph, &pseudonym);
212 GNUNET_PSEUDONYM_derive_verification_key (&pseudonym,
213 &signing_key,
214 &pkc->cpy->verification_key);
215 GNUNET_CRYPTO_hash (&pkc->cpy->verification_key,
216 sizeof (pkc->cpy->verification_key),
217 &query);
218 GNUNET_PSEUDONYM_destroy (ph);
208 pkc->qre = 219 pkc->qre =
209 GNUNET_DATASTORE_put (pkc->dsh, 0, &query, 220 GNUNET_DATASTORE_put (pkc->dsh, 0, &query,
210 pkc->mdsize + sizeof (struct KBlock) + pkc->slen, 221 1 + pkc->slen + pkc->mdsize + sizeof (struct UBlock),
211 pkc->cpy, GNUNET_BLOCK_TYPE_FS_KBLOCK, 222 pkc->cpy, GNUNET_BLOCK_TYPE_FS_UBLOCK,
212 pkc->bo.content_priority, pkc->bo.anonymity_level, 223 pkc->bo.content_priority, pkc->bo.anonymity_level,
213 pkc->bo.replication_level, pkc->bo.expiration_time, 224 pkc->bo.replication_level, pkc->bo.expiration_time,
214 -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, 225 -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT,
@@ -267,14 +278,15 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
267 GNUNET_assert (pkc->mdsize >= 0); 278 GNUNET_assert (pkc->mdsize >= 0);
268 uris = GNUNET_FS_uri_to_string (uri); 279 uris = GNUNET_FS_uri_to_string (uri);
269 pkc->slen = strlen (uris) + 1; 280 pkc->slen = strlen (uris) + 1;
270 size = pkc->mdsize + sizeof (struct KBlock) + pkc->slen; 281 size = pkc->mdsize + sizeof (struct UBlock) + pkc->slen + 1;
271 if (size > MAX_KBLOCK_SIZE) 282 if (size > MAX_UBLOCK_SIZE)
272 { 283 {
273 size = MAX_KBLOCK_SIZE; 284 size = MAX_UBLOCK_SIZE;
274 pkc->mdsize = size - sizeof (struct KBlock) - pkc->slen; 285 pkc->mdsize = size - sizeof (struct UBlock) - pkc->slen + 1;
275 } 286 }
276 pkc->kb = GNUNET_malloc (size); 287 pkc->ub = GNUNET_malloc (size);
277 kbe = (char *) &pkc->kb[1]; 288 kbe = (char *) &pkc->ub[1];
289 kbe++; /* leave one '\0' for the update identifier */
278 memcpy (kbe, uris, pkc->slen); 290 memcpy (kbe, uris, pkc->slen);
279 GNUNET_free (uris); 291 GNUNET_free (uris);
280 sptr = &kbe[pkc->slen]; 292 sptr = &kbe[pkc->slen];
@@ -285,8 +297,8 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
285 if (-1 == pkc->mdsize) 297 if (-1 == pkc->mdsize)
286 { 298 {
287 GNUNET_break (0); 299 GNUNET_break (0);
288 GNUNET_free (pkc->kb); 300 GNUNET_free (pkc->ub);
289 if (pkc->dsh != NULL) 301 if (NULL != pkc->dsh)
290 { 302 {
291 GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO); 303 GNUNET_DATASTORE_disconnect (pkc->dsh, GNUNET_NO);
292 pkc->dsh = NULL; 304 pkc->dsh = NULL;
@@ -295,14 +307,13 @@ GNUNET_FS_publish_ksk (struct GNUNET_FS_Handle *h,
295 cont (cont_cls, NULL, _("Internal error.")); 307 cont (cont_cls, NULL, _("Internal error."));
296 return NULL; 308 return NULL;
297 } 309 }
298 size = sizeof (struct KBlock) + pkc->slen + pkc->mdsize; 310 size = sizeof (struct UBlock) + pkc->slen + pkc->mdsize + 1;
299 311
300 pkc->cpy = GNUNET_malloc (size); 312 pkc->cpy = GNUNET_malloc (size);
301 pkc->cpy->purpose.size = 313 pkc->cpy->purpose.size =
302 htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + 314 htonl (sizeof (struct GNUNET_PseudonymSignaturePurpose) +
303 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + 315 pkc->mdsize + pkc->slen + 1);
304 pkc->mdsize + pkc->slen); 316 pkc->cpy->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK);
305 pkc->cpy->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK);
306 pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri); 317 pkc->ksk_uri = GNUNET_FS_uri_dup (ksk_uri);
307 pkc->ksk_task = GNUNET_SCHEDULER_add_now (&publish_ksk_cont, pkc); 318 pkc->ksk_task = GNUNET_SCHEDULER_add_now (&publish_ksk_cont, pkc);
308 return pkc; 319 return pkc;
@@ -333,7 +344,7 @@ GNUNET_FS_publish_ksk_cancel (struct GNUNET_FS_PublishKskContext *pkc)
333 pkc->dsh = NULL; 344 pkc->dsh = NULL;
334 } 345 }
335 GNUNET_free (pkc->cpy); 346 GNUNET_free (pkc->cpy);
336 GNUNET_free (pkc->kb); 347 GNUNET_free (pkc->ub);
337 GNUNET_FS_uri_destroy (pkc->ksk_uri); 348 GNUNET_FS_uri_destroy (pkc->ksk_uri);
338 GNUNET_free (pkc); 349 GNUNET_free (pkc);
339} 350}
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index fc05498cc..eaf26f73f 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001-2006, 2008-2012 Christian Grothoff (and other contributing authors) 3 (C) 2001-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -22,7 +22,6 @@
22 * @brief Helper functions for searching. 22 * @brief Helper functions for searching.
23 * @author Christian Grothoff 23 * @author Christian Grothoff
24 */ 24 */
25
26#include "platform.h" 25#include "platform.h"
27#include "gnunet_constants.h" 26#include "gnunet_constants.h"
28#include "gnunet_fs_service.h" 27#include "gnunet_fs_service.h"
@@ -575,22 +574,22 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc, const char *id_update,
575 574
576 575
577/** 576/**
578 * Decrypt a block using a 'keyword' as the passphrase. Given the 577 * Decrypt a ublock using a 'keyword' as the passphrase. Given the
579 * KSK public key derived from the keyword, this function looks up 578 * KSK public key derived from the keyword, this function looks up
580 * the original keyword in the search context and decrypts the 579 * the original keyword in the search context and decrypts the
581 * given ciphertext block. 580 * given ciphertext block.
582 * 581 *
583 * @param sc search context with the keywords 582 * @param sc search context with the keywords
584 * @param public_key public key to use to lookup the keyword 583 * @param verification_key public key to use to lookup the keyword
585 * @param edata encrypted data 584 * @param edata encrypted data
586 * @param edata_size number of bytes in 'edata' (and 'data') 585 * @param edata_size number of bytes in 'edata' (and 'data')
587 * @param data where to store the plaintext 586 * @param data where to store the plaintext
588 * @return keyword index on success, GNUNET_SYSERR on error (no such 587 * @return keyword index on success, GNUNET_SYSERR on error (no such
589 * keyword, internal error) 588 * keyword, internal error)
590 */ 589 */
591static int 590static int
592decrypt_block_with_keyword (const struct GNUNET_FS_SearchContext *sc, 591decrypt_block_with_keyword (const struct GNUNET_FS_SearchContext *sc,
593 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key, 592 const struct GNUNET_PseudonymIdentifier *verification_key,
594 const void *edata, 593 const void *edata,
595 size_t edata_size, 594 size_t edata_size,
596 char *data) 595 char *data)
@@ -600,12 +599,12 @@ decrypt_block_with_keyword (const struct GNUNET_FS_SearchContext *sc,
600 struct GNUNET_CRYPTO_AesInitializationVector iv; 599 struct GNUNET_CRYPTO_AesInitializationVector iv;
601 int i; 600 int i;
602 601
603 GNUNET_CRYPTO_hash (public_key, 602 GNUNET_CRYPTO_hash (verification_key,
604 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 603 sizeof (struct GNUNET_PseudonymIdentifier),
605 &q); 604 &q);
606 /* find key */ 605 /* find key */
607 for (i = 0; i < sc->uri->data.ksk.keywordCount; i++) 606 for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
608 if (0 == memcmp (&q, &sc->requests[i].query, sizeof (struct GNUNET_HashCode))) 607 if (0 == memcmp (&q, &sc->requests[i].uquery, sizeof (struct GNUNET_HashCode)))
609 break; 608 break;
610 if (i == sc->uri->data.ksk.keywordCount) 609 if (i == sc->uri->data.ksk.keywordCount)
611 { 610 {
@@ -614,7 +613,7 @@ decrypt_block_with_keyword (const struct GNUNET_FS_SearchContext *sc,
614 return GNUNET_SYSERR; 613 return GNUNET_SYSERR;
615 } 614 }
616 /* decrypt */ 615 /* decrypt */
617 GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].key, &skey, &iv); 616 GNUNET_CRYPTO_hash_to_aes_key (&sc->requests[i].ukey, &skey, &iv);
618 if (-1 == 617 if (-1 ==
619 GNUNET_CRYPTO_aes_decrypt (edata, edata_size, &skey, 618 GNUNET_CRYPTO_aes_decrypt (edata, edata_size, &skey,
620 &iv, data)) 619 &iv, data))
@@ -627,18 +626,20 @@ decrypt_block_with_keyword (const struct GNUNET_FS_SearchContext *sc,
627 626
628 627
629/** 628/**
630 * Process a keyword-search result. 629 * Process a keyword search result. The actual type of block is
630 * a UBlock; we know it is a keyword search result because that's
631 * what we were searching for.
631 * 632 *
632 * @param sc our search context 633 * @param sc our search context
633 * @param kb the kblock 634 * @param ub the ublock with the keyword search result
634 * @param size size of kb 635 * @param size size of nb
635 */ 636 */
636static void 637static void
637process_kblock (struct GNUNET_FS_SearchContext *sc, const struct KBlock *kb, 638process_kblock (struct GNUNET_FS_SearchContext *sc, const struct UBlock *ub,
638 size_t size) 639 size_t size)
639{ 640{
640 size_t j; 641 size_t j;
641 char pt[size - sizeof (struct KBlock)]; 642 char pt[size - sizeof (struct UBlock)];
642 const char *eos; 643 const char *eos;
643 struct GNUNET_CONTAINER_MetaData *meta; 644 struct GNUNET_CONTAINER_MetaData *meta;
644 struct GNUNET_FS_Uri *uri; 645 struct GNUNET_FS_Uri *uri;
@@ -646,75 +647,22 @@ process_kblock (struct GNUNET_FS_SearchContext *sc, const struct KBlock *kb,
646 int i; 647 int i;
647 648
648 if (-1 == (i = decrypt_block_with_keyword (sc, 649 if (-1 == (i = decrypt_block_with_keyword (sc,
649 &kb->keyspace, 650 &ub->verification_key,
650 &kb[1], 651 &ub[1],
651 size - sizeof (struct KBlock), 652 size - sizeof (struct UBlock),
652 pt))) 653 pt)))
653 return; 654 return;
654 /* parse */ 655 /* parse; pt[0] is just '\0', so we skip over that */
655 eos = memchr (pt, 0, sizeof (pt)); 656 eos = memchr (&pt[1], '\0', sizeof (pt) - 1);
656 if (NULL == eos) 657 if (NULL == eos)
657 { 658 {
658 GNUNET_break_op (0); 659 GNUNET_break_op (0);
659 return; 660 return;
660 } 661 }
661 j = eos - pt + 1; 662 if (NULL == (uri = GNUNET_FS_uri_parse (&pt[1], &emsg)))
662 if (sizeof (pt) == j)
663 meta = GNUNET_CONTAINER_meta_data_create ();
664 else
665 meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[j], sizeof (pt) - j);
666 if (NULL == meta)
667 { 663 {
668 GNUNET_break_op (0); /* kblock malformed */ 664 GNUNET_break_op (0); /* ublock malformed */
669 return; 665 GNUNET_free_non_null (emsg);
670 }
671 uri = GNUNET_FS_uri_parse (pt, &emsg);
672 if (NULL == uri)
673 {
674 GNUNET_break_op (0); /* kblock malformed */
675 GNUNET_free_non_null (emsg);
676 GNUNET_CONTAINER_meta_data_destroy (meta);
677 return;
678 }
679 /* process */
680 process_ksk_result (sc, &sc->requests[i], uri, meta);
681
682 /* clean up */
683 GNUNET_CONTAINER_meta_data_destroy (meta);
684 GNUNET_FS_uri_destroy (uri);
685}
686
687
688/**
689 * Process a keyword-search result with a namespace advertisment.
690 *
691 * @param sc our search context
692 * @param nb the nblock
693 * @param size size of nb
694 */
695static void
696process_nblock (struct GNUNET_FS_SearchContext *sc, const struct NBlock *nb,
697 size_t size)
698{
699 size_t j;
700 char pt[size - sizeof (struct NBlock)];
701 const char *eos;
702 struct GNUNET_CONTAINER_MetaData *meta;
703 struct GNUNET_FS_Uri *uri;
704 char *uris;
705 int i;
706
707 if (-1 == (i = decrypt_block_with_keyword (sc,
708 &nb->keyspace,
709 &nb[1],
710 size - sizeof (struct NBlock),
711 pt)))
712 return;
713 /* parse */
714 eos = memchr (pt, 0, sizeof (pt));
715 if (NULL == eos)
716 {
717 GNUNET_break_op (0);
718 return; 666 return;
719 } 667 }
720 j = eos - pt + 1; 668 j = eos - pt + 1;
@@ -724,23 +672,10 @@ process_nblock (struct GNUNET_FS_SearchContext *sc, const struct NBlock *nb,
724 meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[j], sizeof (pt) - j); 672 meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[j], sizeof (pt) - j);
725 if (NULL == meta) 673 if (NULL == meta)
726 { 674 {
727 GNUNET_break_op (0); /* nblock malformed */ 675 GNUNET_break_op (0); /* ublock malformed */
676 GNUNET_FS_uri_destroy (uri);
728 return; 677 return;
729 } 678 }
730
731 uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
732 uri->type = GNUNET_FS_URI_SKS;
733 uri->data.sks.identifier = GNUNET_strdup (pt);
734 GNUNET_CRYPTO_hash (&nb->subspace,
735 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
736 &uri->data.sks.ns);
737 uris = GNUNET_FS_uri_to_string (uri);
738 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", EXTRACTOR_METATYPE_URI,
739 EXTRACTOR_METAFORMAT_UTF8, "text/plain",
740 uris, strlen (uris) + 1);
741 GNUNET_free (uris);
742 GNUNET_PSEUDONYM_add (sc->h->cfg, &uri->data.sks.ns, meta);
743 /* process */
744 process_ksk_result (sc, &sc->requests[i], uri, meta); 679 process_ksk_result (sc, &sc->requests[i], uri, meta);
745 680
746 /* clean up */ 681 /* clean up */
@@ -750,17 +685,20 @@ process_nblock (struct GNUNET_FS_SearchContext *sc, const struct NBlock *nb,
750 685
751 686
752/** 687/**
753 * Process a namespace-search result. 688 * Process a namespace-search result. The actual type of block is
689 * a UBlock; we know it is a namespace search result because that's
690 * what we were searching for.
754 * 691 *
755 * @param sc our search context 692 * @param sc our search context
756 * @param sb the sblock 693 * @param ub the ublock with a namespace result
757 * @param size size of sb 694 * @param size size of sb
758 */ 695 */
759static void 696static void
760process_sblock (struct GNUNET_FS_SearchContext *sc, const struct SBlock *sb, 697process_sblock (struct GNUNET_FS_SearchContext *sc,
698 const struct UBlock *ub,
761 size_t size) 699 size_t size)
762{ 700{
763 size_t len = size - sizeof (struct SBlock); 701 size_t len = size - sizeof (struct UBlock);
764 char pt[len]; 702 char pt[len];
765 struct GNUNET_CRYPTO_AesSessionKey skey; 703 struct GNUNET_CRYPTO_AesSessionKey skey;
766 struct GNUNET_CRYPTO_AesInitializationVector iv; 704 struct GNUNET_CRYPTO_AesInitializationVector iv;
@@ -771,36 +709,39 @@ process_sblock (struct GNUNET_FS_SearchContext *sc, const struct SBlock *sb,
771 size_t off; 709 size_t off;
772 char *emsg; 710 char *emsg;
773 struct GNUNET_HashCode key; 711 struct GNUNET_HashCode key;
712 struct GNUNET_HashCode id_hash;
713 struct GNUNET_HashCode ns_hash;
774 char *identifier; 714 char *identifier;
775 715
776 /* decrypt */ 716 /* decrypt */
777 identifier = sc->uri->data.sks.identifier; 717 identifier = sc->uri->data.sks.identifier;
778 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &key); 718 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &id_hash);
719 GNUNET_CRYPTO_hash (&sc->uri->data.sks.ns,
720 sizeof (sc->uri->data.sks.ns), &ns_hash);
721 GNUNET_CRYPTO_hash_xor (&id_hash, &ns_hash, &key);
779 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv); 722 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
780 if (-1 == GNUNET_CRYPTO_aes_decrypt (&sb[1], len, &skey, &iv, pt)) 723 if (-1 == GNUNET_CRYPTO_aes_decrypt (&ub[1], len, &skey, &iv, pt))
781 { 724 {
782 GNUNET_break (0); 725 GNUNET_break (0);
783 return; 726 return;
784 } 727 }
785 /* parse */ 728 /* parse */
786 off = GNUNET_STRINGS_buffer_tokenize (pt, len, 2, &id, &uris); 729 if (0 == (off = GNUNET_STRINGS_buffer_tokenize (pt, len, 2, &id, &uris)))
787 if (0 == off)
788 { 730 {
789 GNUNET_break_op (0); /* sblock malformed */ 731 GNUNET_break_op (0); /* ublock malformed */
790 return; 732 return;
791 } 733 }
792 meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[off], len - off); 734 if (NULL == (meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[off], len - off)))
793 if (meta == NULL)
794 { 735 {
795 GNUNET_break_op (0); /* sblock malformed */ 736 GNUNET_break_op (0); /* ublock malformed */
796 return; 737 return;
797 } 738 }
798 uri = GNUNET_FS_uri_parse (uris, &emsg); 739 if (NULL == (uri = GNUNET_FS_uri_parse (uris, &emsg)))
799 if (NULL == uri)
800 { 740 {
801 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to parse URI `%s': %s\n", uris, 741 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
802 emsg); 742 _("Failed to parse URI `%s': %s\n"),
803 GNUNET_break_op (0); /* sblock malformed */ 743 uris, emsg);
744 GNUNET_break_op (0); /* ublock malformed */
804 GNUNET_free_non_null (emsg); 745 GNUNET_free_non_null (emsg);
805 GNUNET_CONTAINER_meta_data_destroy (meta); 746 GNUNET_CONTAINER_meta_data_destroy (meta);
806 return; 747 return;
@@ -836,44 +777,11 @@ process_result (struct GNUNET_FS_SearchContext *sc, enum GNUNET_BLOCK_Type type,
836 } 777 }
837 switch (type) 778 switch (type)
838 { 779 {
839 case GNUNET_BLOCK_TYPE_FS_KBLOCK: 780 case GNUNET_BLOCK_TYPE_FS_UBLOCK:
840 if (!GNUNET_FS_uri_test_ksk (sc->uri)) 781 if (GNUNET_FS_URI_SKS == sc->uri->type)
841 { 782 process_sblock (sc, data, size);
842 GNUNET_break (0); 783 else
843 return; 784 process_kblock (sc, data, size);
844 }
845 if (sizeof (struct KBlock) > size)
846 {
847 GNUNET_break_op (0);
848 return;
849 }
850 process_kblock (sc, data, size);
851 break;
852 case GNUNET_BLOCK_TYPE_FS_SBLOCK:
853 if (!GNUNET_FS_uri_test_sks (sc->uri))
854 {
855 GNUNET_break (0);
856 return;
857 }
858 if (sizeof (struct SBlock) > size)
859 {
860 GNUNET_break_op (0);
861 return;
862 }
863 process_sblock (sc, data, size);
864 break;
865 case GNUNET_BLOCK_TYPE_FS_NBLOCK:
866 if (!GNUNET_FS_uri_test_ksk (sc->uri))
867 {
868 GNUNET_break (0);
869 return;
870 }
871 if (sizeof (struct NBlock) > size)
872 {
873 GNUNET_break_op (0);
874 return;
875 }
876 process_nblock (sc, data, size);
877 break; 785 break;
878 case GNUNET_BLOCK_TYPE_ANY: 786 case GNUNET_BLOCK_TYPE_ANY:
879 GNUNET_break (0); 787 GNUNET_break (0);
@@ -1054,7 +962,10 @@ transmit_search_request (void *cls, size_t size, void *buf)
1054 struct SearchMessage *sm; 962 struct SearchMessage *sm;
1055 const char *identifier; 963 const char *identifier;
1056 struct GNUNET_HashCode key; 964 struct GNUNET_HashCode key;
1057 struct GNUNET_HashCode idh; 965 struct GNUNET_HashCode signing_key;
966 struct GNUNET_HashCode ns_hash;
967 struct GNUNET_HashCode id_hash;
968 struct GNUNET_PseudonymIdentifier verification_key;
1058 unsigned int sqms; 969 unsigned int sqms;
1059 uint32_t options; 970 uint32_t options;
1060 971
@@ -1090,10 +1001,10 @@ transmit_search_request (void *cls, size_t size, void *buf)
1090 /* now build message */ 1001 /* now build message */
1091 msize += sizeof (struct GNUNET_HashCode) * mbc.put_cnt; 1002 msize += sizeof (struct GNUNET_HashCode) * mbc.put_cnt;
1092 sm->header.size = htons (msize); 1003 sm->header.size = htons (msize);
1093 sm->type = htonl (GNUNET_BLOCK_TYPE_ANY); 1004 sm->type = htonl (GNUNET_BLOCK_TYPE_FS_UBLOCK);
1094 sm->anonymity_level = htonl (sc->anonymity); 1005 sm->anonymity_level = htonl (sc->anonymity);
1095 memset (&sm->target, 0, sizeof (struct GNUNET_HashCode)); 1006 memset (&sm->target, 0, sizeof (struct GNUNET_HashCode));
1096 sm->query = sc->requests[sc->keyword_offset].query; 1007 sm->query = sc->requests[sc->keyword_offset].uquery;
1097 GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map, 1008 GNUNET_CONTAINER_multihashmap_iterate (sc->master_result_map,
1098 &build_result_set, &mbc); 1009 &build_result_set, &mbc);
1099 GNUNET_assert (sqms >= sc->search_request_map_offset); 1010 GNUNET_assert (sqms >= sc->search_request_map_offset);
@@ -1118,13 +1029,22 @@ transmit_search_request (void *cls, size_t size, void *buf)
1118 GNUNET_assert (GNUNET_FS_uri_test_sks (sc->uri)); 1029 GNUNET_assert (GNUNET_FS_uri_test_sks (sc->uri));
1119 msize = sizeof (struct SearchMessage); 1030 msize = sizeof (struct SearchMessage);
1120 GNUNET_assert (size >= msize); 1031 GNUNET_assert (size >= msize);
1121 sm->type = htonl (GNUNET_BLOCK_TYPE_FS_SBLOCK); 1032 sm->type = htonl (GNUNET_BLOCK_TYPE_FS_UBLOCK);
1122 sm->anonymity_level = htonl (sc->anonymity); 1033 sm->anonymity_level = htonl (sc->anonymity);
1123 sm->target = sc->uri->data.sks.ns; 1034 memset (&sm->target, 0, sizeof (struct GNUNET_HashCode));
1035
1124 identifier = sc->uri->data.sks.identifier; 1036 identifier = sc->uri->data.sks.identifier;
1125 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &key); 1037 GNUNET_CRYPTO_hash (identifier, strlen (identifier), &id_hash);
1126 GNUNET_CRYPTO_hash (&key, sizeof (struct GNUNET_HashCode), &idh); 1038 GNUNET_CRYPTO_hash (&sc->uri->data.sks.ns,
1127 GNUNET_CRYPTO_hash_xor (&idh, &sm->target, &sm->query); 1039 sizeof (sc->uri->data.sks.ns), &ns_hash);
1040 GNUNET_CRYPTO_hash_xor (&id_hash, &ns_hash, &key);
1041 GNUNET_CRYPTO_hash (&key, sizeof (struct GNUNET_HashCode), &signing_key);
1042 GNUNET_PSEUDONYM_derive_verification_key (&sc->uri->data.sks.ns,
1043 &signing_key,
1044 &verification_key);
1045 GNUNET_CRYPTO_hash (&verification_key,
1046 sizeof (verification_key),
1047 &sm->query);
1128 mbc.put_cnt = (size - msize) / sizeof (struct GNUNET_HashCode); 1048 mbc.put_cnt = (size - msize) / sizeof (struct GNUNET_HashCode);
1129 sqms = GNUNET_CONTAINER_multihashmap_size (sc->master_result_map); 1049 sqms = GNUNET_CONTAINER_multihashmap_size (sc->master_result_map);
1130 mbc.put_cnt = GNUNET_MIN (mbc.put_cnt, sqms - mbc.skip_cnt); 1050 mbc.put_cnt = GNUNET_MIN (mbc.put_cnt, sqms - mbc.skip_cnt);
@@ -1287,28 +1207,35 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc)
1287{ 1207{
1288 unsigned int i; 1208 unsigned int i;
1289 const char *keyword; 1209 const char *keyword;
1290 struct GNUNET_HashCode hc; 1210 struct GNUNET_HashCode signing_key;
1291 struct GNUNET_CRYPTO_RsaPrivateKey *pk; 1211 struct GNUNET_PseudonymHandle *ph;
1212 struct GNUNET_PseudonymIdentifier anon;
1213 struct GNUNET_PseudonymIdentifier verification_key;
1292 1214
1293 GNUNET_assert (NULL == sc->client); 1215 GNUNET_assert (NULL == sc->client);
1294 if (GNUNET_FS_uri_test_ksk (sc->uri)) 1216 if (GNUNET_FS_uri_test_ksk (sc->uri))
1295 { 1217 {
1296 GNUNET_assert (0 != sc->uri->data.ksk.keywordCount); 1218 GNUNET_assert (0 != sc->uri->data.ksk.keywordCount);
1219 ph = GNUNET_PSEUDONYM_get_anonymous_pseudonym_handle ();
1220 GNUNET_PSEUDONYM_get_identifier (ph, &anon);
1221 GNUNET_PSEUDONYM_destroy (ph);
1297 sc->requests = 1222 sc->requests =
1298 GNUNET_malloc (sizeof (struct SearchRequestEntry) * 1223 GNUNET_malloc (sizeof (struct SearchRequestEntry) *
1299 sc->uri->data.ksk.keywordCount); 1224 sc->uri->data.ksk.keywordCount);
1300 for (i = 0; i < sc->uri->data.ksk.keywordCount; i++) 1225 for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
1301 { 1226 {
1302 keyword = &sc->uri->data.ksk.keywords[i][1]; 1227 keyword = &sc->uri->data.ksk.keywords[i][1];
1303 GNUNET_CRYPTO_hash (keyword, strlen (keyword), &hc); 1228 GNUNET_CRYPTO_hash (keyword, strlen (keyword), &sc->requests[i].ukey);
1304 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&hc); 1229 GNUNET_CRYPTO_hash (&sc->requests[i].ukey, sizeof (struct GNUNET_HashCode), &signing_key);
1305 GNUNET_assert (NULL != pk); 1230 GNUNET_PSEUDONYM_derive_verification_key (&anon,
1306 GNUNET_CRYPTO_rsa_get_public_key_hash (pk, &sc->requests[i].query); 1231 &signing_key,
1232 &verification_key);
1233 GNUNET_CRYPTO_hash (&verification_key, sizeof (struct GNUNET_PseudonymIdentifier),
1234 &sc->requests[i].uquery);
1307 sc->requests[i].mandatory = (sc->uri->data.ksk.keywords[i][0] == '+'); 1235 sc->requests[i].mandatory = (sc->uri->data.ksk.keywords[i][0] == '+');
1308 if (sc->requests[i].mandatory) 1236 if (sc->requests[i].mandatory)
1309 sc->mandatory_count++; 1237 sc->mandatory_count++;
1310 sc->requests[i].results = GNUNET_CONTAINER_multihashmap_create (4, GNUNET_NO); 1238 sc->requests[i].results = GNUNET_CONTAINER_multihashmap_create (4, GNUNET_NO);
1311 GNUNET_CRYPTO_hash (keyword, strlen (keyword), &sc->requests[i].key);
1312 } 1239 }
1313 } 1240 }
1314 sc->client = GNUNET_CLIENT_connect ("fs", sc->h->cfg); 1241 sc->client = GNUNET_CLIENT_connect ("fs", sc->h->cfg);
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c
index 49518a3df..17c3731fe 100644
--- a/src/fs/fs_unindex.c
+++ b/src/fs/fs_unindex.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2003, 2004, 2006, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2003--2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -260,7 +260,7 @@ process_fs_response (void *cls, const struct GNUNET_MessageHeader *msg)
260 260
261 261
262/** 262/**
263 * Function called when we are done with removing KBlocks. 263 * Function called when we are done with removing UBlocks.
264 * Disconnect from datastore and notify FS service about 264 * Disconnect from datastore and notify FS service about
265 * the unindex event. 265 * the unindex event.
266 * 266 *
@@ -314,7 +314,7 @@ unindex_finish (struct GNUNET_FS_UnindexContext *uc)
314 314
315/** 315/**
316 * Function called by the directory scanner as we extract keywords 316 * Function called by the directory scanner as we extract keywords
317 * that we will need to remove KBlocks. 317 * that we will need to remove UBlocks.
318 * 318 *
319 * @param cls the 'struct GNUNET_FS_UnindexContext *' 319 * @param cls the 'struct GNUNET_FS_UnindexContext *'
320 * @param filename which file we are making progress on 320 * @param filename which file we are making progress on
@@ -369,7 +369,7 @@ unindex_directory_scan_cb (void *cls,
369 369
370 370
371/** 371/**
372 * If necessary, connect to the datastore and remove the KBlocks. 372 * If necessary, connect to the datastore and remove the UBlocks.
373 * 373 *
374 * @param uc context for the unindex operation. 374 * @param uc context for the unindex operation.
375 */ 375 */
@@ -391,7 +391,7 @@ GNUNET_FS_unindex_do_extract_keywords_ (struct GNUNET_FS_UnindexContext *uc)
391 391
392/** 392/**
393 * Continuation called to notify client about result of the remove 393 * Continuation called to notify client about result of the remove
394 * operation for the KBlock. 394 * operation for the UBlock.
395 * 395 *
396 * @param cls the 'struct GNUNET_FS_UnindexContext *' 396 * @param cls the 'struct GNUNET_FS_UnindexContext *'
397 * @param success GNUNET_SYSERR on failure (including timeout/queue drop) 397 * @param success GNUNET_SYSERR on failure (including timeout/queue drop)
@@ -413,7 +413,7 @@ continue_after_remove (void *cls,
413 uc->dqe = NULL; 413 uc->dqe = NULL;
414 if (success != GNUNET_YES) 414 if (success != GNUNET_YES)
415 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 415 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
416 _("Failed to remove KBlock: %s\n"), 416 _("Failed to remove UBlock: %s\n"),
417 msg); 417 msg);
418 uc->ksk_offset++; 418 uc->ksk_offset++;
419 GNUNET_FS_unindex_do_remove_kblocks_ (uc); 419 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
@@ -422,11 +422,11 @@ continue_after_remove (void *cls,
422 422
423/** 423/**
424 * Function called from datastore with result from us looking for 424 * Function called from datastore with result from us looking for
425 * a KBlock. There are four cases: 425 * a UBlock. There are four cases:
426 * 1) no result, means we move on to the next keyword 426 * 1) no result, means we move on to the next keyword
427 * 2) UID is the same as the first UID, means we move on to next keyword 427 * 2) UID is the same as the first UID, means we move on to next keyword
428 * 3) KBlock for a different CHK, means we keep looking for more 428 * 3) UBlock for a different CHK, means we keep looking for more
429 * 4) KBlock is for our CHK, means we remove the block and then move 429 * 4) UBlock is for our CHK, means we remove the block and then move
430 * on to the next keyword 430 * on to the next keyword
431 * 431 *
432 * @param cls the 'struct GNUNET_FS_UnindexContext *' 432 * @param cls the 'struct GNUNET_FS_UnindexContext *'
@@ -442,7 +442,7 @@ continue_after_remove (void *cls,
442 */ 442 */
443static void 443static void
444process_kblock_for_unindex (void *cls, 444process_kblock_for_unindex (void *cls,
445 const struct GNUNET_HashCode * key, 445 const struct GNUNET_HashCode *key,
446 size_t size, const void *data, 446 size_t size, const void *data,
447 enum GNUNET_BLOCK_Type type, 447 enum GNUNET_BLOCK_Type type,
448 uint32_t priority, 448 uint32_t priority,
@@ -451,8 +451,9 @@ process_kblock_for_unindex (void *cls,
451 expiration, uint64_t uid) 451 expiration, uint64_t uid)
452{ 452{
453 struct GNUNET_FS_UnindexContext *uc = cls; 453 struct GNUNET_FS_UnindexContext *uc = cls;
454 const struct KBlock *kb; 454 const struct UBlock *ub;
455 struct GNUNET_FS_Uri *chk_uri; 455 struct GNUNET_FS_Uri *chk_uri;
456 struct GNUNET_HashCode query;
456 457
457 uc->dqe = NULL; 458 uc->dqe = NULL;
458 if (NULL == data) 459 if (NULL == data)
@@ -474,38 +475,43 @@ process_kblock_for_unindex (void *cls,
474 GNUNET_FS_unindex_do_remove_kblocks_ (uc); 475 GNUNET_FS_unindex_do_remove_kblocks_ (uc);
475 return; 476 return;
476 } 477 }
477 GNUNET_assert (GNUNET_BLOCK_TYPE_FS_KBLOCK == type); 478 GNUNET_assert (GNUNET_BLOCK_TYPE_FS_UBLOCK == type);
478 if (size < sizeof (struct KBlock)) 479 if (size < sizeof (struct UBlock))
479 { 480 {
480 GNUNET_break (0); 481 GNUNET_break (0);
481 goto get_next; 482 goto get_next;
482 } 483 }
483 kb = data; 484 ub = data;
485 GNUNET_CRYPTO_hash (&ub->verification_key,
486 sizeof (ub->verification_key),
487 &query);
488 if (0 != memcmp (&query, key, sizeof (struct GNUNET_HashCode)))
489 {
490 /* result does not match our keyword, skip */
491 goto get_next;
492 }
484 { 493 {
485 char pt[size - sizeof (struct KBlock)]; 494 char pt[size - sizeof (struct UBlock)];
486 struct GNUNET_CRYPTO_AesSessionKey skey; 495 struct GNUNET_CRYPTO_AesSessionKey skey;
487 struct GNUNET_CRYPTO_AesInitializationVector iv; 496 struct GNUNET_CRYPTO_AesInitializationVector iv;
488 497
489 GNUNET_CRYPTO_hash_to_aes_key (&uc->key, &skey, &iv); 498 GNUNET_CRYPTO_hash_to_aes_key (&uc->ukey, &skey, &iv);
490 if (-1 == 499 if (-1 ==
491 GNUNET_CRYPTO_aes_decrypt (&kb[1], size - sizeof (struct KBlock), &skey, 500 GNUNET_CRYPTO_aes_decrypt (&ub[1], size - sizeof (struct UBlock), &skey,
492 &iv, pt)) 501 &iv, pt))
493 { 502 {
494 GNUNET_break (0); 503 GNUNET_break (0);
495 goto get_next; 504 goto get_next;
496 } 505 }
497 if (NULL == memchr (pt, 0, sizeof (pt))) 506 if (NULL == memchr (&pt[1], 0, sizeof (pt) - 1))
498 { 507 {
499 GNUNET_break (0); 508 GNUNET_break_op (0); /* malformed UBlock */
500 goto get_next; 509 goto get_next;
501 } 510 }
502 chk_uri = GNUNET_FS_uri_parse (pt, NULL); 511 chk_uri = GNUNET_FS_uri_parse (&pt[1], NULL);
503 if (NULL == chk_uri) 512 if (NULL == chk_uri)
504 { 513 {
505 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 514 GNUNET_break_op (0); /* malformed UBlock */
506 _("Failed to parse URI `%s' from KBlock!\n"),
507 pt);
508 GNUNET_break (0);
509 goto get_next; 515 goto get_next;
510 } 516 }
511 } 517 }
@@ -529,8 +535,8 @@ process_kblock_for_unindex (void *cls,
529 get_next: 535 get_next:
530 uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, 536 uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh,
531 uc->roff++, 537 uc->roff++,
532 &uc->query, 538 &uc->uquery,
533 GNUNET_BLOCK_TYPE_FS_KBLOCK, 539 GNUNET_BLOCK_TYPE_FS_UBLOCK,
534 0 /* priority */, 1 /* queue size */, 540 0 /* priority */, 1 /* queue size */,
535 GNUNET_TIME_UNIT_FOREVER_REL, 541 GNUNET_TIME_UNIT_FOREVER_REL,
536 &process_kblock_for_unindex, 542 &process_kblock_for_unindex,
@@ -547,7 +553,10 @@ void
547GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc) 553GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc)
548{ 554{
549 const char *keyword; 555 const char *keyword;
550 struct GNUNET_CRYPTO_RsaPrivateKey *pk; 556 struct GNUNET_PseudonymHandle *ph;
557 struct GNUNET_PseudonymIdentifier anon;
558 struct GNUNET_PseudonymIdentifier verification_key;
559 struct GNUNET_HashCode signing_key;
551 560
552 if (NULL == uc->dsh) 561 if (NULL == uc->dsh)
553 uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg); 562 uc->dsh = GNUNET_DATASTORE_connect (uc->h->cfg);
@@ -566,16 +575,23 @@ GNUNET_FS_unindex_do_remove_kblocks_ (struct GNUNET_FS_UnindexContext *uc)
566 return; 575 return;
567 } 576 }
568 /* FIXME: code duplication with fs_search.c here... */ 577 /* FIXME: code duplication with fs_search.c here... */
578 ph = GNUNET_PSEUDONYM_get_anonymous_pseudonym_handle ();
579 GNUNET_PSEUDONYM_get_identifier (ph, &anon);
580 GNUNET_PSEUDONYM_destroy (ph);
569 keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1]; 581 keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
570 GNUNET_CRYPTO_hash (keyword, strlen (keyword), &uc->key); 582 GNUNET_CRYPTO_hash (keyword, strlen (keyword), &uc->ukey);
571 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&uc->key); 583 GNUNET_CRYPTO_hash (&uc->ukey, sizeof (struct GNUNET_HashCode), &signing_key);
572 GNUNET_assert (pk != NULL); 584 GNUNET_PSEUDONYM_derive_verification_key (&anon,
573 GNUNET_CRYPTO_rsa_get_public_key_hash (pk, &uc->query); 585 &signing_key,
586 &verification_key);
587 GNUNET_CRYPTO_hash (&verification_key,
588 sizeof (struct GNUNET_PseudonymIdentifier),
589 &uc->uquery);
574 uc->first_uid = 0; 590 uc->first_uid = 0;
575 uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh, 591 uc->dqe = GNUNET_DATASTORE_get_key (uc->dsh,
576 uc->roff++, 592 uc->roff++,
577 &uc->query, 593 &uc->uquery,
578 GNUNET_BLOCK_TYPE_FS_KBLOCK, 594 GNUNET_BLOCK_TYPE_FS_UBLOCK,
579 0 /* priority */, 1 /* queue size */, 595 0 /* priority */, 1 /* queue size */,
580 GNUNET_TIME_UNIT_FOREVER_REL, 596 GNUNET_TIME_UNIT_FOREVER_REL,
581 &process_kblock_for_unindex, 597 &process_kblock_for_unindex,
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index e76693521..2b7af3c9e 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2003--2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -356,36 +356,30 @@ static struct GNUNET_FS_Uri *
356uri_sks_parse (const char *s, char **emsg) 356uri_sks_parse (const char *s, char **emsg)
357{ 357{
358 struct GNUNET_FS_Uri *ret; 358 struct GNUNET_FS_Uri *ret;
359 struct GNUNET_HashCode ns; 359 struct GNUNET_PseudonymIdentifier id;
360 char *identifier; 360 size_t pos;
361 unsigned int pos; 361 char *end;
362 size_t slen;
363 char enc[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)];
364 362
365 GNUNET_assert (s != NULL); 363 GNUNET_assert (s != NULL);
366 slen = strlen (s);
367 pos = strlen (GNUNET_FS_URI_SKS_PREFIX); 364 pos = strlen (GNUNET_FS_URI_SKS_PREFIX);
368 if ((slen <= pos) || (0 != strncmp (s, GNUNET_FS_URI_SKS_PREFIX, pos))) 365 if ((strlen (s) <= pos) || (0 != strncmp (s, GNUNET_FS_URI_SKS_PREFIX, pos)))
369 return NULL; /* not an SKS URI */ 366 return NULL; /* not an SKS URI */
370 if ((slen < pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) || 367 end = strchr (&s[pos], '/');
371 (s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] != '/')) 368 if ( (NULL == end) ||
372 { 369 (GNUNET_OK !=
373 *emsg = GNUNET_strdup (_("Malformed SKS URI")); 370 GNUNET_STRINGS_string_to_data (&s[pos],
374 return NULL; 371 end - &s[pos],
375 } 372 &id,
376 memcpy (enc, &s[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); 373 sizeof (id))) )
377 enc[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1] = '\0';
378 if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (enc, &ns))
379 { 374 {
380 *emsg = GNUNET_strdup (_("Malformed SKS URI")); 375 *emsg = GNUNET_strdup (_("Malformed SKS URI"));
381 return NULL; 376 return NULL; /* malformed */
382 } 377 }
383 identifier = 378 end++; /* skip over '/' */
384 GNUNET_strdup (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)]);
385 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); 379 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
386 ret->type = GNUNET_FS_URI_SKS; 380 ret->type = GNUNET_FS_URI_SKS;
387 ret->data.sks.ns = ns; 381 ret->data.sks.ns = id;
388 ret->data.sks.identifier = identifier; 382 ret->data.sks.identifier = GNUNET_strdup (end);
389 return ret; 383 return ret;
390} 384}
391 385
@@ -957,7 +951,7 @@ GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, const char *id,
957 } 951 }
958 ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); 952 ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
959 ns_uri->type = GNUNET_FS_URI_SKS; 953 ns_uri->type = GNUNET_FS_URI_SKS;
960 GNUNET_FS_namespace_get_public_key_hash (ns, &ns_uri->data.sks.ns); 954 GNUNET_FS_namespace_get_public_identifier (ns, &ns_uri->data.sks.ns);
961 ns_uri->data.sks.identifier = GNUNET_strdup (id); 955 ns_uri->data.sks.identifier = GNUNET_strdup (id);
962 return ns_uri; 956 return ns_uri;
963} 957}
@@ -966,18 +960,19 @@ GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, const char *id,
966/** 960/**
967 * Create an SKS URI from a namespace ID and an identifier. 961 * Create an SKS URI from a namespace ID and an identifier.
968 * 962 *
969 * @param nsid namespace ID 963 * @param pseudonym namespace ID
970 * @param id identifier 964 * @param id identifier
971 * @return an FS URI for the given namespace and identifier 965 * @return an FS URI for the given namespace and identifier
972 */ 966 */
973struct GNUNET_FS_Uri * 967struct GNUNET_FS_Uri *
974GNUNET_FS_uri_sks_create_from_nsid (struct GNUNET_HashCode * nsid, const char *id) 968GNUNET_FS_uri_sks_create_from_nsid (struct GNUNET_PseudonymIdentifier *pseudonym,
969 const char *id)
975{ 970{
976 struct GNUNET_FS_Uri *ns_uri; 971 struct GNUNET_FS_Uri *ns_uri;
977 972
978 ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); 973 ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
979 ns_uri->type = GNUNET_FS_URI_SKS; 974 ns_uri->type = GNUNET_FS_URI_SKS;
980 ns_uri->data.sks.ns = *nsid; 975 ns_uri->data.sks.ns = *pseudonym;
981 ns_uri->data.sks.identifier = GNUNET_strdup (id); 976 ns_uri->data.sks.identifier = GNUNET_strdup (id);
982 return ns_uri; 977 return ns_uri;
983} 978}
@@ -1337,19 +1332,19 @@ GNUNET_FS_uri_test_sks (const struct GNUNET_FS_Uri *uri)
1337 * namespace URI. 1332 * namespace URI.
1338 * 1333 *
1339 * @param uri the uri to get the namespace ID from 1334 * @param uri the uri to get the namespace ID from
1340 * @param nsid where to store the ID of the namespace 1335 * @param pseudonym where to store the ID of the namespace
1341 * @return GNUNET_OK on success 1336 * @return GNUNET_OK on success
1342 */ 1337 */
1343int 1338int
1344GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri, 1339GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri,
1345 struct GNUNET_HashCode * nsid) 1340 struct GNUNET_PseudonymIdentifier *pseudonym)
1346{ 1341{
1347 if (!GNUNET_FS_uri_test_sks (uri)) 1342 if (!GNUNET_FS_uri_test_sks (uri))
1348 { 1343 {
1349 GNUNET_break (0); 1344 GNUNET_break (0);
1350 return GNUNET_SYSERR; 1345 return GNUNET_SYSERR;
1351 } 1346 }
1352 *nsid = uri->data.sks.ns; 1347 *pseudonym = uri->data.sks.ns;
1353 return GNUNET_OK; 1348 return GNUNET_OK;
1354} 1349}
1355 1350
@@ -1939,18 +1934,20 @@ uri_ksk_to_string (const struct GNUNET_FS_Uri *uri)
1939static char * 1934static char *
1940uri_sks_to_string (const struct GNUNET_FS_Uri *uri) 1935uri_sks_to_string (const struct GNUNET_FS_Uri *uri)
1941{ 1936{
1942 const struct GNUNET_HashCode *ns;
1943 const char *identifier;
1944 char *ret; 1937 char *ret;
1945 struct GNUNET_CRYPTO_HashAsciiEncoded nsasc; 1938 char buf[1024];
1946 1939
1947 if (uri->type != GNUNET_FS_URI_SKS) 1940 if (GNUNET_FS_URI_SKS != uri->type)
1948 return NULL; 1941 return NULL;
1949 ns = &uri->data.sks.ns; 1942 ret = GNUNET_STRINGS_data_to_string (&uri->data.sks.ns,
1950 identifier = uri->data.sks.identifier; 1943 sizeof (struct GNUNET_PseudonymIdentifier),
1951 GNUNET_CRYPTO_hash_to_enc (ns, &nsasc); 1944 buf,
1945 sizeof (buf));
1946 GNUNET_assert (NULL != ret);
1947 ret[0] = '\0';
1952 GNUNET_asprintf (&ret, "%s%s%s/%s", GNUNET_FS_URI_PREFIX, 1948 GNUNET_asprintf (&ret, "%s%s%s/%s", GNUNET_FS_URI_PREFIX,
1953 GNUNET_FS_URI_SKS_INFIX, (const char *) &nsasc, identifier); 1949 GNUNET_FS_URI_SKS_INFIX, buf,
1950 uri->data.sks.identifier);
1954 return ret; 1951 return ret;
1955} 1952}
1956 1953
diff --git a/src/fs/gnunet-pseudonym.c b/src/fs/gnunet-pseudonym.c
index a692917da..dd3c9d4a2 100644
--- a/src/fs/gnunet-pseudonym.c
+++ b/src/fs/gnunet-pseudonym.c
@@ -95,19 +95,37 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
95 95
96 96
97static void 97static void
98ns_printer (void *cls, const char *name, const struct GNUNET_HashCode * id) 98ns_printer (void *cls, const char *name, const struct GNUNET_PseudonymIdentifier *pseudonym)
99{ 99{
100 struct GNUNET_CRYPTO_HashAsciiEncoded enc; 100 struct GNUNET_CRYPTO_HashAsciiEncoded enc;
101 struct GNUNET_HashCode hc;
101 102
102 GNUNET_CRYPTO_hash_to_enc (id, &enc); 103 GNUNET_CRYPTO_hash (pseudonym,
104 sizeof (struct GNUNET_PseudonymIdentifier),
105 &hc);
106 GNUNET_CRYPTO_hash_to_enc (&hc, &enc);
103 FPRINTF (stdout, "%s (%s)\n", name, (const char *) &enc); 107 FPRINTF (stdout, "%s (%s)\n", name, (const char *) &enc);
104} 108}
105 109
106 110
111/**
112 * Output information about a pseudonym.
113 *
114 * @param cls closure
115 * @param pseudonym hash code of public key of pseudonym
116 * @param name name of the pseudonym (might be NULL)
117 * @param unique_name unique name of the pseudonym (might be NULL)
118 * @param md meta data known about the pseudonym
119 * @param rating the local rating of the pseudonym
120 * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
121 */
107static int 122static int
108pseudo_printer (void *cls, const struct GNUNET_HashCode * pseudonym, 123pseudo_printer (void *cls,
109 const char *name, const char *unique_name, 124 const struct GNUNET_PseudonymIdentifier *pseudonym,
110 const struct GNUNET_CONTAINER_MetaData *md, int rating) 125 const char *name,
126 const char *unique_name,
127 const struct GNUNET_CONTAINER_MetaData *md,
128 int32_t rating)
111{ 129{
112 char *id; 130 char *id;
113 char *unique_id; 131 char *unique_id;
@@ -136,7 +154,7 @@ pseudo_printer (void *cls, const struct GNUNET_HashCode * pseudonym,
136static void 154static void
137post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) 155post_advertising (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
138{ 156{
139 struct GNUNET_HashCode nsid; 157 struct GNUNET_PseudonymIdentifier nsid;
140 char *set; 158 char *set;
141 int delta; 159 int delta;
142 160
@@ -203,6 +221,7 @@ static void
203run (void *cls, char *const *args, const char *cfgfile, 221run (void *cls, char *const *args, const char *cfgfile,
204 const struct GNUNET_CONFIGURATION_Handle *c) 222 const struct GNUNET_CONFIGURATION_Handle *c)
205{ 223{
224 struct GNUNET_FS_Uri *sks_uri;
206 char *emsg; 225 char *emsg;
207 226
208 cfg = c; 227 cfg = c;
@@ -239,9 +258,13 @@ run (void *cls, char *const *args, const char *cfgfile,
239 ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg); 258 ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/namespace", &emsg);
240 GNUNET_assert (NULL == emsg); 259 GNUNET_assert (NULL == emsg);
241 } 260 }
242 GNUNET_FS_namespace_advertise (h, ksk_uri, ns, adv_metadata, &bo, 261 sks_uri = GNUNET_FS_uri_sks_create (ns, root_identifier, &emsg);
243 root_identifier, &post_advertising, 262 GNUNET_assert (NULL == emsg);
244 NULL); 263 GNUNET_FS_publish_ksk (h, ksk_uri, adv_metadata, sks_uri,
264 &bo,
265 GNUNET_FS_PUBLISH_OPTION_NONE,
266 &post_advertising, NULL);
267 GNUNET_FS_uri_destroy (sks_uri);
245 return; 268 return;
246 } 269 }
247 else 270 else
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 0f4d513ff..4364265a8 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -405,9 +405,7 @@ start_p2p_processing (void *cls, struct GSF_PendingRequest *pr,
405 "Considering stream-based download for block\n"); 405 "Considering stream-based download for block\n");
406 GSF_stream_lookup_ (pr); 406 GSF_stream_lookup_ (pr);
407 break; 407 break;
408 case GNUNET_BLOCK_TYPE_FS_KBLOCK: 408 case GNUNET_BLOCK_TYPE_FS_UBLOCK:
409 case GNUNET_BLOCK_TYPE_FS_SBLOCK:
410 case GNUNET_BLOCK_TYPE_FS_NBLOCK:
411 /* the above block types are in the DHT */ 409 /* the above block types are in the DHT */
412 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
413 "Considering DHT-based search for block\n"); 411 "Considering DHT-based search for block\n");
diff --git a/src/fs/gnunet-service-fs.h b/src/fs/gnunet-service-fs.h
index 3213712c8..60075e097 100644
--- a/src/fs/gnunet-service-fs.h
+++ b/src/fs/gnunet-service-fs.h
@@ -63,12 +63,6 @@
63#define GET_MESSAGE_BIT_RETURN_TO 1 63#define GET_MESSAGE_BIT_RETURN_TO 1
64 64
65/** 65/**
66 * The hash of the public key of the target
67 * namespace is included (for SKS queries).
68 */
69#define GET_MESSAGE_BIT_SKS_NAMESPACE 2
70
71/**
72 * The peer identity of a peer that had claimed to have the content 66 * The peer identity of a peer that had claimed to have the content
73 * previously is included (can be used if responder-anonymity is not 67 * previously is included (can be used if responder-anonymity is not
74 * desired; note that the precursor presumably lacked a direct 68 * desired; note that the precursor presumably lacked a direct
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index e389a24b2..f38a32c81 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -1143,7 +1143,6 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1143 struct GSF_PendingRequestData *prd; 1143 struct GSF_PendingRequestData *prd;
1144 struct GSF_ConnectedPeer *cp; 1144 struct GSF_ConnectedPeer *cp;
1145 struct GSF_ConnectedPeer *cps; 1145 struct GSF_ConnectedPeer *cps;
1146 const struct GNUNET_HashCode *namespace;
1147 const struct GNUNET_PeerIdentity *target; 1146 const struct GNUNET_PeerIdentity *target;
1148 enum GSF_PendingRequestOptions options; 1147 enum GSF_PendingRequestOptions options;
1149 uint16_t msize; 1148 uint16_t msize;
@@ -1244,17 +1243,6 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1244 "Received request for `%s' of type %u from peer `%4s' with flags %u\n", 1243 "Received request for `%s' of type %u from peer `%4s' with flags %u\n",
1245 GNUNET_h2s (&gm->query), (unsigned int) type, GNUNET_i2s (other), 1244 GNUNET_h2s (&gm->query), (unsigned int) type, GNUNET_i2s (other),
1246 (unsigned int) bm); 1245 (unsigned int) bm);
1247 namespace = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) ? &opt[bits++] : NULL;
1248 if ((GNUNET_BLOCK_TYPE_FS_SBLOCK == type) && (NULL == namespace))
1249 {
1250 GNUNET_break_op (0);
1251 return NULL;
1252 }
1253 if ((GNUNET_BLOCK_TYPE_FS_SBLOCK != type) && (NULL != namespace))
1254 {
1255 GNUNET_break_op (0);
1256 return NULL;
1257 }
1258 target = 1246 target =
1259 (0 != 1247 (0 !=
1260 (bm & GET_MESSAGE_BIT_TRANSMIT_TO)) ? ((const struct GNUNET_PeerIdentity 1248 (bm & GET_MESSAGE_BIT_TRANSMIT_TO)) ? ((const struct GNUNET_PeerIdentity
@@ -1298,9 +1286,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1298 { 1286 {
1299 pr = peerreq->pr; 1287 pr = peerreq->pr;
1300 prd = GSF_pending_request_get_data_ (pr); 1288 prd = GSF_pending_request_get_data_ (pr);
1301 if ((prd->type == type) && 1289 if (prd->type == type)
1302 ((type != GNUNET_BLOCK_TYPE_FS_SBLOCK) ||
1303 (0 == memcmp (&prd->namespace, namespace, sizeof (struct GNUNET_HashCode)))))
1304 { 1290 {
1305 if (prd->ttl.abs_value >= GNUNET_TIME_absolute_get ().abs_value + ttl) 1291 if (prd->ttl.abs_value >= GNUNET_TIME_absolute_get ().abs_value + ttl)
1306 { 1292 {
@@ -1324,7 +1310,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1324 1310
1325 peerreq = GNUNET_malloc (sizeof (struct PeerRequest)); 1311 peerreq = GNUNET_malloc (sizeof (struct PeerRequest));
1326 peerreq->cp = cp; 1312 peerreq->cp = cp;
1327 pr = GSF_pending_request_create_ (options, type, &gm->query, namespace, 1313 pr = GSF_pending_request_create_ (options, type, &gm->query,
1328 target, 1314 target,
1329 (bfsize > 1315 (bfsize >
1330 0) ? (const char *) &opt[bits] : NULL, 1316 0) ? (const char *) &opt[bits] : NULL,
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c
index c3b6f40b0..f90131815 100644
--- a/src/fs/gnunet-service-fs_lc.c
+++ b/src/fs/gnunet-service-fs_lc.c
@@ -335,9 +335,9 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
335 GNUNET_h2s (&sm->query), (unsigned int) type); 335 GNUNET_h2s (&sm->query), (unsigned int) type);
336 lc = GSF_local_client_lookup_ (client); 336 lc = GSF_local_client_lookup_ (client);
337 cr = NULL; 337 cr = NULL;
338 /* detect duplicate KBLOCK requests */ 338 /* detect duplicate UBLOCK requests */
339 if ((type == GNUNET_BLOCK_TYPE_FS_KBLOCK) || 339 if ((type == GNUNET_BLOCK_TYPE_FS_UBLOCK) ||
340 (type == GNUNET_BLOCK_TYPE_FS_NBLOCK) || (type == GNUNET_BLOCK_TYPE_ANY)) 340 (type == GNUNET_BLOCK_TYPE_ANY))
341 { 341 {
342 cr = lc->cr_head; 342 cr = lc->cr_head;
343 while (cr != NULL) 343 while (cr != NULL)
@@ -353,7 +353,7 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
353 cr = cr->next; 353 cr = cr->next;
354 } 354 }
355 } 355 }
356 if (cr != NULL) 356 if (NULL != cr)
357 { 357 {
358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
359 "Have existing request, merging content-seen lists.\n"); 359 "Have existing request, merging content-seen lists.\n");
@@ -374,8 +374,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
374 options = GSF_PRO_LOCAL_REQUEST; 374 options = GSF_PRO_LOCAL_REQUEST;
375 if (0 != (SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY & ntohl (sm->options))) 375 if (0 != (SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY & ntohl (sm->options)))
376 options |= GSF_PRO_LOCAL_ONLY; 376 options |= GSF_PRO_LOCAL_ONLY;
377 cr->pr = GSF_pending_request_create_ (options, type, &sm->query, (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target /* namespace */ 377 cr->pr = GSF_pending_request_create_ (options, type,
378 : NULL, 378 &sm->query,
379 (0 != 379 (0 !=
380 memcmp (&sm->target, &all_zeros, 380 memcmp (&sm->target, &all_zeros,
381 sizeof (struct GNUNET_HashCode))) 381 sizeof (struct GNUNET_HashCode)))
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index 76e04f57c..2ab4771b5 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -268,7 +268,6 @@ refresh_bloomfilter (struct GSF_PendingRequest *pr)
268 * @param options request options 268 * @param options request options
269 * @param type type of the block that is being requested 269 * @param type type of the block that is being requested
270 * @param query key for the lookup 270 * @param query key for the lookup
271 * @param namespace namespace to lookup, NULL for no namespace
272 * @param target preferred target for the request, NULL for none 271 * @param target preferred target for the request, NULL for none
273 * @param bf_data raw data for bloom filter for known replies, can be NULL 272 * @param bf_data raw data for bloom filter for known replies, can be NULL
274 * @param bf_size number of bytes in bf_data 273 * @param bf_size number of bytes in bf_data
@@ -288,7 +287,6 @@ struct GSF_PendingRequest *
288GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, 287GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
289 enum GNUNET_BLOCK_Type type, 288 enum GNUNET_BLOCK_Type type,
290 const struct GNUNET_HashCode *query, 289 const struct GNUNET_HashCode *query,
291 const struct GNUNET_HashCode *namespace,
292 const struct GNUNET_PeerIdentity *target, 290 const struct GNUNET_PeerIdentity *target,
293 const char *bf_data, size_t bf_size, 291 const char *bf_data, size_t bf_size,
294 uint32_t mingle, uint32_t anonymity_level, 292 uint32_t mingle, uint32_t anonymity_level,
@@ -313,8 +311,6 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
313 GNUNET_NO); 311 GNUNET_NO);
314#endif 312#endif
315 extra = 0; 313 extra = 0;
316 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == type)
317 extra += sizeof (struct GNUNET_HashCode);
318 if (NULL != target) 314 if (NULL != target)
319 extra += sizeof (struct GNUNET_PeerIdentity); 315 extra += sizeof (struct GNUNET_PeerIdentity);
320 pr = GNUNET_malloc (sizeof (struct GSF_PendingRequest) + extra); 316 pr = GNUNET_malloc (sizeof (struct GSF_PendingRequest) + extra);
@@ -322,13 +318,6 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
322 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); 318 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
323 pr->public_data.query = *query; 319 pr->public_data.query = *query;
324 eptr = (struct GNUNET_HashCode *) &pr[1]; 320 eptr = (struct GNUNET_HashCode *) &pr[1];
325 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == type)
326 {
327 GNUNET_assert (NULL != namespace);
328 pr->public_data.namespace = eptr;
329 memcpy (eptr, namespace, sizeof (struct GNUNET_HashCode));
330 eptr++;
331 }
332 if (NULL != target) 321 if (NULL != target)
333 { 322 {
334 pr->public_data.target = (struct GNUNET_PeerIdentity *) eptr; 323 pr->public_data.target = (struct GNUNET_PeerIdentity *) eptr;
@@ -435,12 +424,7 @@ GSF_pending_request_is_compatible_ (struct GSF_PendingRequest *pra,
435 if ((pra->public_data.type != prb->public_data.type) || 424 if ((pra->public_data.type != prb->public_data.type) ||
436 (0 != 425 (0 !=
437 memcmp (&pra->public_data.query, &prb->public_data.query, 426 memcmp (&pra->public_data.query, &prb->public_data.query,
438 sizeof (struct GNUNET_HashCode))) || 427 sizeof (struct GNUNET_HashCode))))
439 ((pra->public_data.type == GNUNET_BLOCK_TYPE_FS_SBLOCK) &&
440 (0 !=
441 memcmp (pra->public_data.namespace,
442 prb->public_data.namespace,
443 sizeof (struct GNUNET_HashCode)))))
444 return GNUNET_NO; 428 return GNUNET_NO;
445 return GNUNET_OK; 429 return GNUNET_OK;
446} 430}
@@ -546,11 +530,6 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
546 bm |= GET_MESSAGE_BIT_RETURN_TO; 530 bm |= GET_MESSAGE_BIT_RETURN_TO;
547 k++; 531 k++;
548 } 532 }
549 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == pr->public_data.type)
550 {
551 bm |= GET_MESSAGE_BIT_SKS_NAMESPACE;
552 k++;
553 }
554 if (NULL != pr->public_data.target) 533 if (NULL != pr->public_data.target)
555 { 534 {
556 bm |= GET_MESSAGE_BIT_TRANSMIT_TO; 535 bm |= GET_MESSAGE_BIT_TRANSMIT_TO;
@@ -586,8 +565,6 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr,
586 if (!do_route) 565 if (!do_route)
587 GNUNET_PEER_resolve (pr->sender_pid, 566 GNUNET_PEER_resolve (pr->sender_pid,
588 (struct GNUNET_PeerIdentity *) &ext[k++]); 567 (struct GNUNET_PeerIdentity *) &ext[k++]);
589 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == pr->public_data.type)
590 memcpy (&ext[k++], pr->public_data.namespace, sizeof (struct GNUNET_HashCode));
591 if (NULL != pr->public_data.target) 568 if (NULL != pr->public_data.target)
592 memcpy (&ext[k++], 569 memcpy (&ext[k++],
593 pr->public_data.target, 570 pr->public_data.target,
@@ -836,10 +813,7 @@ process_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
836 GNUNET_NO); 813 GNUNET_NO);
837 prq->eval = 814 prq->eval =
838 GNUNET_BLOCK_evaluate (GSF_block_ctx, prq->type, key, &pr->bf, pr->mingle, 815 GNUNET_BLOCK_evaluate (GSF_block_ctx, prq->type, key, &pr->bf, pr->mingle,
839 pr->public_data.namespace, 816 NULL, 0, prq->data,
840 (prq->type ==
841 GNUNET_BLOCK_TYPE_FS_SBLOCK) ?
842 sizeof (struct GNUNET_HashCode) : 0, prq->data,
843 prq->size); 817 prq->size);
844 switch (prq->eval) 818 switch (prq->eval)
845 { 819 {
@@ -1140,12 +1114,6 @@ GSF_dht_lookup_ (struct GSF_PendingRequest *pr)
1140 } 1114 }
1141 xquery = NULL; 1115 xquery = NULL;
1142 xquery_size = 0; 1116 xquery_size = 0;
1143 if (GNUNET_BLOCK_TYPE_FS_SBLOCK == pr->public_data.type)
1144 {
1145 xquery = buf;
1146 memcpy (buf, pr->public_data.namespace, sizeof (struct GNUNET_HashCode));
1147 xquery_size = sizeof (struct GNUNET_HashCode);
1148 }
1149 if (0 != (pr->public_data.options & GSF_PRO_FORWARD_ONLY)) 1117 if (0 != (pr->public_data.options & GSF_PRO_FORWARD_ONLY))
1150 { 1118 {
1151 GNUNET_assert (0 != pr->sender_pid); 1119 GNUNET_assert (0 != pr->sender_pid);
diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h
index 371aa660b..66488f79c 100644
--- a/src/fs/gnunet-service-fs_pr.h
+++ b/src/fs/gnunet-service-fs_pr.h
@@ -87,12 +87,6 @@ struct GSF_PendingRequestData
87 struct GNUNET_HashCode query; 87 struct GNUNET_HashCode query;
88 88
89 /** 89 /**
90 * Namespace to query, only set if the type is SBLOCK.
91 * Allocated after struct only if needed. Do not free!
92 */
93 const struct GNUNET_HashCode *namespace;
94
95 /**
96 * Identity of a peer hosting the content, otherwise NULl. 90 * Identity of a peer hosting the content, otherwise NULl.
97 * Allocated after struct only if needed. Do not free! 91 * Allocated after struct only if needed. Do not free!
98 */ 92 */
@@ -212,7 +206,6 @@ typedef void (*GSF_PendingRequestReplyHandler) (void *cls,
212 * @param options request options 206 * @param options request options
213 * @param type type of the block that is being requested 207 * @param type type of the block that is being requested
214 * @param query key for the lookup 208 * @param query key for the lookup
215 * @param namespace namespace to lookup, NULL for no namespace
216 * @param target preferred target for the request, NULL for none 209 * @param target preferred target for the request, NULL for none
217 * @param bf_data raw data for bloom filter for known replies, can be NULL 210 * @param bf_data raw data for bloom filter for known replies, can be NULL
218 * @param bf_size number of bytes in bf_data 211 * @param bf_size number of bytes in bf_data
@@ -233,7 +226,6 @@ struct GSF_PendingRequest *
233GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, 226GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
234 enum GNUNET_BLOCK_Type type, 227 enum GNUNET_BLOCK_Type type,
235 const struct GNUNET_HashCode * query, 228 const struct GNUNET_HashCode * query,
236 const struct GNUNET_HashCode * namespace,
237 const struct GNUNET_PeerIdentity *target, 229 const struct GNUNET_PeerIdentity *target,
238 const char *bf_data, size_t bf_size, 230 const char *bf_data, size_t bf_size,
239 uint32_t mingle, uint32_t anonymity_level, 231 uint32_t mingle, uint32_t anonymity_level,
diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c
index 49962d314..ef796f559 100644
--- a/src/fs/gnunet-service-fs_put.c
+++ b/src/fs/gnunet-service-fs_put.c
@@ -83,9 +83,7 @@ struct PutOperator
83 * of block that we're putting into the DHT). 83 * of block that we're putting into the DHT).
84 */ 84 */
85static struct PutOperator operators[] = { 85static struct PutOperator operators[] = {
86 {NULL, GNUNET_BLOCK_TYPE_FS_KBLOCK, 0, 0, 0}, 86 {NULL, GNUNET_BLOCK_TYPE_FS_UBLOCK, 0, 0, 0},
87 {NULL, GNUNET_BLOCK_TYPE_FS_SBLOCK, 0, 0, 0},
88 {NULL, GNUNET_BLOCK_TYPE_FS_NBLOCK, 0, 0, 0},
89 {NULL, GNUNET_BLOCK_TYPE_ANY, 0, 0, 0} 87 {NULL, GNUNET_BLOCK_TYPE_ANY, 0, 0, 0}
90}; 88};
91 89
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c
index 8e90589cf..468dd96a3 100644
--- a/src/fs/plugin_block_fs.c
+++ b/src/fs/plugin_block_fs.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2010 Christian Grothoff (and other contributing authors) 3 (C) 2010, 2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -56,75 +56,67 @@
56 */ 56 */
57static enum GNUNET_BLOCK_EvaluationResult 57static enum GNUNET_BLOCK_EvaluationResult
58block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type, 58block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
59 const struct GNUNET_HashCode * query, 59 const struct GNUNET_HashCode *query,
60 struct GNUNET_CONTAINER_BloomFilter **bf, 60 struct GNUNET_CONTAINER_BloomFilter **bf,
61 int32_t bf_mutator, const void *xquery, 61 int32_t bf_mutator, const void *xquery,
62 size_t xquery_size, const void *reply_block, 62 size_t xquery_size, const void *reply_block,
63 size_t reply_block_size) 63 size_t reply_block_size)
64{ 64{
65 const struct SBlock *sb; 65 const struct UBlock *ub;
66 struct GNUNET_HashCode hc;
66 struct GNUNET_HashCode chash; 67 struct GNUNET_HashCode chash;
67 struct GNUNET_HashCode mhash; 68 struct GNUNET_HashCode mhash;
68 const struct GNUNET_HashCode *nsid;
69 struct GNUNET_HashCode sh;
70 69
71 switch (type) 70 switch (type)
72 { 71 {
73 case GNUNET_BLOCK_TYPE_FS_DBLOCK: 72 case GNUNET_BLOCK_TYPE_FS_DBLOCK:
74 case GNUNET_BLOCK_TYPE_FS_IBLOCK: 73 case GNUNET_BLOCK_TYPE_FS_IBLOCK:
75 if (xquery_size != 0) 74 if (0 != xquery_size)
76 { 75 {
77 GNUNET_break_op (0); 76 GNUNET_break_op (0);
78 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; 77 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
79 } 78 }
80 if (reply_block == NULL) 79 if (NULL == reply_block)
81 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; 80 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
82 return GNUNET_BLOCK_EVALUATION_OK_LAST; 81 return GNUNET_BLOCK_EVALUATION_OK_LAST;
83 case GNUNET_BLOCK_TYPE_FS_KBLOCK: 82 case GNUNET_BLOCK_TYPE_FS_UBLOCK:
84 case GNUNET_BLOCK_TYPE_FS_NBLOCK: 83 if (0 != xquery_size)
85 if (xquery_size != 0)
86 { 84 {
87 GNUNET_break_op (0); 85 GNUNET_break_op (0);
88 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; 86 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
89 } 87 }
90 if (reply_block == NULL) 88 if (NULL == reply_block)
91 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; 89 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
92 if (NULL != bf) 90
91 if (reply_block_size < sizeof (struct UBlock))
93 { 92 {
94 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); 93 GNUNET_break_op (0);
95 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); 94 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
96 if (NULL != *bf)
97 {
98 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
99 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
100 }
101 else
102 {
103 *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
104 }
105 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
106 } 95 }
107 return GNUNET_BLOCK_EVALUATION_OK_MORE; 96 ub = reply_block;
108 case GNUNET_BLOCK_TYPE_FS_SBLOCK: 97 GNUNET_CRYPTO_hash (&ub->verification_key,
109 if (xquery_size != sizeof (struct GNUNET_HashCode)) 98 sizeof (ub->verification_key),
99 &hc);
100 if (0 != memcmp (&hc,
101 query,
102 sizeof (struct GNUNET_HashCode)))
110 { 103 {
111 GNUNET_break_op (0); 104 GNUNET_break_op (0);
112 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; 105 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
113 } 106 }
114 if (reply_block == NULL) 107 if (reply_block_size != ntohl (ub->purpose.size) + sizeof (struct GNUNET_PseudonymSignature))
115 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; 108 {
116 nsid = xquery; 109 GNUNET_break_op (0);
117 if (reply_block_size < sizeof (struct SBlock)) 110 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
111 }
112 if (GNUNET_OK !=
113 GNUNET_PSEUDONYM_verify (&ub->purpose,
114 &ub->signature,
115 &ub->verification_key))
118 { 116 {
119 GNUNET_break_op (0); 117 GNUNET_break_op (0);
120 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 118 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
121 } 119 }
122 sb = reply_block;
123 GNUNET_CRYPTO_hash (&sb->subspace,
124 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
125 &sh);
126 if (0 != memcmp (nsid, &sh, sizeof (struct GNUNET_HashCode)))
127 return GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT;
128 if (NULL != bf) 120 if (NULL != bf)
129 { 121 {
130 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); 122 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
@@ -161,11 +153,9 @@ block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
161static int 153static int
162block_plugin_fs_get_key (void *cls, enum GNUNET_BLOCK_Type type, 154block_plugin_fs_get_key (void *cls, enum GNUNET_BLOCK_Type type,
163 const void *block, size_t block_size, 155 const void *block, size_t block_size,
164 struct GNUNET_HashCode * key) 156 struct GNUNET_HashCode *key)
165{ 157{
166 const struct KBlock *kb; 158 const struct UBlock *ub;
167 const struct SBlock *sb;
168 const struct NBlock *nb;
169 159
170 switch (type) 160 switch (type)
171 { 161 {
@@ -173,104 +163,19 @@ block_plugin_fs_get_key (void *cls, enum GNUNET_BLOCK_Type type,
173 case GNUNET_BLOCK_TYPE_FS_IBLOCK: 163 case GNUNET_BLOCK_TYPE_FS_IBLOCK:
174 GNUNET_CRYPTO_hash (block, block_size, key); 164 GNUNET_CRYPTO_hash (block, block_size, key);
175 return GNUNET_OK; 165 return GNUNET_OK;
176 case GNUNET_BLOCK_TYPE_FS_KBLOCK: 166 case GNUNET_BLOCK_TYPE_FS_UBLOCK:
177 if (block_size < sizeof (struct KBlock)) 167 if (block_size < sizeof (struct UBlock))
178 {
179 GNUNET_break_op (0);
180 return GNUNET_NO;
181 }
182 kb = block;
183 if (block_size - sizeof (struct KBlock) !=
184 ntohl (kb->purpose.size) -
185 sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) -
186 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))
187 {
188 GNUNET_break_op (0);
189 return GNUNET_NO;
190 }
191 if (GNUNET_OK !=
192 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK,
193 &kb->purpose, &kb->signature, &kb->keyspace))
194 {
195 GNUNET_break_op (0);
196 return GNUNET_NO;
197 }
198 if (key != NULL)
199 GNUNET_CRYPTO_hash (&kb->keyspace,
200 sizeof (struct
201 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
202 key);
203 return GNUNET_OK;
204 case GNUNET_BLOCK_TYPE_FS_SBLOCK:
205 if (block_size < sizeof (struct SBlock))
206 {
207 GNUNET_break_op (0);
208 return GNUNET_NO;
209 }
210 sb = block;
211 if (block_size !=
212 ntohl (sb->purpose.size) + sizeof (struct GNUNET_CRYPTO_RsaSignature))
213 {
214 GNUNET_break_op (0);
215 return GNUNET_NO;
216 }
217 if (GNUNET_OK !=
218 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK,
219 &sb->purpose, &sb->signature, &sb->subspace))
220 {
221 GNUNET_break_op (0);
222 return GNUNET_NO;
223 }
224 if (key != NULL)
225 *key = sb->identifier;
226 return GNUNET_OK;
227 case GNUNET_BLOCK_TYPE_FS_NBLOCK:
228 if (block_size < sizeof (struct NBlock))
229 { 168 {
230 GNUNET_break_op (0); 169 GNUNET_break (0);
231 return GNUNET_NO; 170 return GNUNET_SYSERR;
232 }
233 nb = block;
234 if (block_size - sizeof (struct NBlock) !=
235 ntohl (nb->ns_purpose.size) -
236 sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) -
237 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))
238 {
239 GNUNET_break_op (0);
240 return GNUNET_NO;
241 }
242 if (block_size !=
243 ntohl (nb->ksk_purpose.size) +
244 sizeof (struct GNUNET_CRYPTO_RsaSignature))
245 {
246 GNUNET_break_op (0);
247 return GNUNET_NO;
248 }
249 if (GNUNET_OK !=
250 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG,
251 &nb->ksk_purpose, &nb->ksk_signature,
252 &nb->keyspace))
253 {
254 GNUNET_break_op (0);
255 return GNUNET_NO;
256 }
257 if (GNUNET_OK !=
258 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK,
259 &nb->ns_purpose, &nb->ns_signature,
260 &nb->subspace))
261 {
262 GNUNET_break_op (0);
263 return GNUNET_NO;
264 } 171 }
265 /* FIXME: we used to xor ID with NSID, 172 ub = block;
266 * why not here? */ 173 GNUNET_CRYPTO_hash (&ub->verification_key,
267 if (key != NULL) 174 sizeof (ub->verification_key),
268 GNUNET_CRYPTO_hash (&nb->keyspace, 175 key);
269 sizeof (struct
270 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
271 key);
272 return GNUNET_OK; 176 return GNUNET_OK;
273 default: 177 default:
178 GNUNET_break (0);
274 return GNUNET_SYSERR; 179 return GNUNET_SYSERR;
275 } 180 }
276} 181}
@@ -286,9 +191,7 @@ libgnunet_plugin_block_fs_init (void *cls)
286 { 191 {
287 GNUNET_BLOCK_TYPE_FS_DBLOCK, 192 GNUNET_BLOCK_TYPE_FS_DBLOCK,
288 GNUNET_BLOCK_TYPE_FS_IBLOCK, 193 GNUNET_BLOCK_TYPE_FS_IBLOCK,
289 GNUNET_BLOCK_TYPE_FS_KBLOCK, 194 GNUNET_BLOCK_TYPE_FS_UBLOCK,
290 GNUNET_BLOCK_TYPE_FS_SBLOCK,
291 GNUNET_BLOCK_TYPE_FS_NBLOCK,
292 GNUNET_BLOCK_TYPE_ANY /* end of list */ 195 GNUNET_BLOCK_TYPE_ANY /* end of list */
293 }; 196 };
294 struct GNUNET_BLOCK_PluginFunctions *api; 197 struct GNUNET_BLOCK_PluginFunctions *api;
diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c
index 5d7eb841c..a72197e10 100644
--- a/src/fs/test_fs_namespace.c
+++ b/src/fs/test_fs_namespace.c
@@ -29,7 +29,7 @@
29#include "gnunet_fs_service.h" 29#include "gnunet_fs_service.h"
30 30
31 31
32static struct GNUNET_HashCode nsid; 32static struct GNUNET_PseudonymIdentifier nsid;
33 33
34static struct GNUNET_FS_Uri *sks_expect_uri; 34static struct GNUNET_FS_Uri *sks_expect_uri;
35 35
@@ -43,64 +43,27 @@ static struct GNUNET_FS_SearchContext *ksk_search;
43 43
44static GNUNET_SCHEDULER_TaskIdentifier kill_task; 44static GNUNET_SCHEDULER_TaskIdentifier kill_task;
45 45
46static GNUNET_SCHEDULER_TaskIdentifier kill_ncc_task;
47
48struct GNUNET_FS_NamespaceCreationContext *ncc;
49
50static int update_started; 46static int update_started;
51 47
52static int err; 48static int err;
53 49
54static int phase;
55
56const struct GNUNET_CONFIGURATION_Handle *config;
57
58static void ns_created (void *cls, struct GNUNET_FS_Namespace *ns, const char *emsg);
59
60static void do_ncc_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
61
62 50
63static void 51static void
64next_phase () 52abort_ksk_search_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
65{ 53{
66 switch (phase) 54 if (ksk_search != NULL)
67 { 55 {
68 case 0: 56 GNUNET_FS_search_stop (ksk_search);
69 phase += 1; 57 ksk_search = NULL;
70 FPRINTF (stderr, "%s", "Testing asynchronous namespace creation\n"); 58 if (sks_search == NULL)
71 ncc = GNUNET_FS_namespace_create_start (fs, "testNamespace", ns_created, NULL);
72 if (NULL == ncc)
73 { 59 {
74 FPRINTF (stderr, "%s", "Failed to start asynchronous namespace creation\n"); 60 GNUNET_FS_stop (fs);
75 err = 1; 61 if (GNUNET_SCHEDULER_NO_TASK != kill_task)
76 next_phase (); 62 GNUNET_SCHEDULER_cancel (kill_task);
77 return;
78 } 63 }
79 kill_ncc_task =
80 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &do_ncc_timeout,
81 NULL);
82 break;
83 case 1:
84 FPRINTF (stderr, "%s", "Shutting down FS\n");
85 GNUNET_FS_stop (fs);
86 if (GNUNET_SCHEDULER_NO_TASK != kill_task)
87 GNUNET_SCHEDULER_cancel (kill_task);
88 kill_task = GNUNET_SCHEDULER_NO_TASK;
89 } 64 }
90} 65}
91 66
92static void
93abort_ksk_search_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
94{
95 if (NULL == ksk_search)
96 return;
97 FPRINTF (stderr, "%s", "Stopping KSK search\n");
98 GNUNET_FS_search_stop (ksk_search);
99 ksk_search = NULL;
100 if (sks_search == NULL)
101 next_phase ();
102}
103
104 67
105static void 68static void
106abort_sks_search_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 69abort_sks_search_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -109,14 +72,17 @@ abort_sks_search_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
109 72
110 if (sks_search == NULL) 73 if (sks_search == NULL)
111 return; 74 return;
112 FPRINTF (stderr, "%s", "Stopping SKS search\n");
113 GNUNET_FS_search_stop (sks_search); 75 GNUNET_FS_search_stop (sks_search);
114 sks_search = NULL; 76 sks_search = NULL;
115 ns = GNUNET_FS_namespace_create (fs, "testNamespace"); 77 ns = GNUNET_FS_namespace_create (fs, "testNamespace");
116 GNUNET_assert (NULL != ns); 78 GNUNET_assert (NULL != ns);
117 GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_YES)); 79 GNUNET_assert (GNUNET_OK == GNUNET_FS_namespace_delete (ns, GNUNET_YES));
118 if (ksk_search == NULL) 80 if (ksk_search == NULL)
119 next_phase (); 81 {
82 GNUNET_FS_stop (fs);
83 if (GNUNET_SCHEDULER_NO_TASK != kill_task)
84 GNUNET_SCHEDULER_cancel (kill_task);
85 }
120} 86}
121 87
122 88
@@ -133,25 +99,18 @@ do_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
133static void * 99static void *
134progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) 100progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
135{ 101{
136 char *got;
137 switch (event->status) 102 switch (event->status)
138 { 103 {
139 case GNUNET_FS_STATUS_SEARCH_RESULT: 104 case GNUNET_FS_STATUS_SEARCH_RESULT:
140 got = GNUNET_FS_uri_to_string (event->value.search.specifics.result.uri);
141 FPRINTF (stderr, "Got a search result `%s'\n", got);
142 if (sks_search == event->value.search.sc) 105 if (sks_search == event->value.search.sc)
143 { 106 {
144 if (!GNUNET_FS_uri_test_equal 107 if (!GNUNET_FS_uri_test_equal
145 (sks_expect_uri, event->value.search.specifics.result.uri)) 108 (sks_expect_uri, event->value.search.specifics.result.uri))
146 { 109 {
147 char *expected; 110 FPRINTF (stderr, "%s", "Wrong result for sks search!\n");
148 expected = GNUNET_FS_uri_to_string (sks_expect_uri);
149 FPRINTF (stderr, "Wrong result for sks search! Expected:\n%s\nGot:\n%s\n", expected, got);
150 GNUNET_free (expected);
151 err = 1; 111 err = 1;
152 } 112 }
153 /* give system 1ms to initiate update search! */ 113 /* give system 1ms to initiate update search! */
154 FPRINTF (stderr, "scheduling `%s'\n", "abort_sks_search_task");
155 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, 114 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
156 &abort_sks_search_task, NULL); 115 &abort_sks_search_task, NULL);
157 } 116 }
@@ -160,22 +119,17 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
160 if (!GNUNET_FS_uri_test_equal 119 if (!GNUNET_FS_uri_test_equal
161 (ksk_expect_uri, event->value.search.specifics.result.uri)) 120 (ksk_expect_uri, event->value.search.specifics.result.uri))
162 { 121 {
163 char *expected; 122 FPRINTF (stderr, "%s", "Wrong result for ksk search!\n");
164 expected = GNUNET_FS_uri_to_string (ksk_expect_uri);
165 FPRINTF (stderr, "Wrong result for ksk search! Expected:\n%s\nGot:\n%s\n", expected, got);
166 GNUNET_free (expected);
167 err = 1; 123 err = 1;
168 } 124 }
169 FPRINTF (stderr, "scheduling `%s'\n", "abort_ksk_search_task");
170 GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL, 125 GNUNET_SCHEDULER_add_continuation (&abort_ksk_search_task, NULL,
171 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 126 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
172 } 127 }
173 else 128 else
174 { 129 {
175 FPRINTF (stderr, "Unexpected search result `%s' received!\n", got); 130 FPRINTF (stderr, "%s", "Unexpected search result received!\n");
176 GNUNET_break (0); 131 GNUNET_break (0);
177 } 132 }
178 GNUNET_free (got);
179 break; 133 break;
180 case GNUNET_FS_STATUS_SEARCH_ERROR: 134 case GNUNET_FS_STATUS_SEARCH_ERROR:
181 FPRINTF (stderr, "Error searching file: %s\n", 135 FPRINTF (stderr, "Error searching file: %s\n",
@@ -190,7 +144,6 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
190 GNUNET_break (0); 144 GNUNET_break (0);
191 break; 145 break;
192 case GNUNET_FS_STATUS_SEARCH_START: 146 case GNUNET_FS_STATUS_SEARCH_START:
193 FPRINTF (stderr, "Search %s started\n", event->value.search.pctx);
194 GNUNET_assert ((NULL == event->value.search.cctx) || 147 GNUNET_assert ((NULL == event->value.search.cctx) ||
195 (0 == strcmp ("sks_search", event->value.search.cctx)) || 148 (0 == strcmp ("sks_search", event->value.search.cctx)) ||
196 (0 == strcmp ("ksk_search", event->value.search.cctx))); 149 (0 == strcmp ("ksk_search", event->value.search.cctx)));
@@ -202,10 +155,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event)
202 GNUNET_assert (1 == event->value.search.anonymity); 155 GNUNET_assert (1 == event->value.search.anonymity);
203 break; 156 break;
204 case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED: 157 case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED:
205 FPRINTF (stderr, "%s", "Search result stopped\n");
206 return NULL; 158 return NULL;
207 case GNUNET_FS_STATUS_SEARCH_STOPPED: 159 case GNUNET_FS_STATUS_SEARCH_STOPPED:
208 FPRINTF (stderr, "%s", "Search stopped\n");
209 return NULL; 160 return NULL;
210 default: 161 default:
211 FPRINTF (stderr, "Unexpected event: %d\n", event->status); 162 FPRINTF (stderr, "Unexpected event: %d\n", event->status);
@@ -221,18 +172,20 @@ publish_cont (void *cls, const struct GNUNET_FS_Uri *ksk_uri, const char *emsg)
221 char *msg; 172 char *msg;
222 struct GNUNET_FS_Uri *sks_uri; 173 struct GNUNET_FS_Uri *sks_uri;
223 char sbuf[1024]; 174 char sbuf[1024];
224 struct GNUNET_CRYPTO_HashAsciiEncoded enc; 175 char buf[1024];
176 char *ret;
225 177
226 if (NULL != emsg) 178 if (NULL != emsg)
227 { 179 {
228 FPRINTF (stderr, "Error publishing ksk: %s\n", emsg); 180 FPRINTF (stderr, "Error publishing: %s\n", emsg);
229 err = 1; 181 err = 1;
230 GNUNET_FS_stop (fs); 182 GNUNET_FS_stop (fs);
231 return; 183 return;
232 } 184 }
233 FPRINTF (stderr, "%s", "Published ksk\n"); 185 ret = GNUNET_STRINGS_data_to_string (&nsid, sizeof (nsid), buf, sizeof (buf));
234 GNUNET_CRYPTO_hash_to_enc (&nsid, &enc); 186 GNUNET_assert (NULL != ret);
235 GNUNET_snprintf (sbuf, sizeof (sbuf), "gnunet://fs/sks/%s/this", &enc); 187 ret[0] = '\0';
188 GNUNET_snprintf (sbuf, sizeof (sbuf), "gnunet://fs/sks/%s/this", buf);
236 sks_uri = GNUNET_FS_uri_parse (sbuf, &msg); 189 sks_uri = GNUNET_FS_uri_parse (sbuf, &msg);
237 if (NULL == sks_uri) 190 if (NULL == sks_uri)
238 { 191 {
@@ -242,7 +195,6 @@ publish_cont (void *cls, const struct GNUNET_FS_Uri *ksk_uri, const char *emsg)
242 GNUNET_free_non_null (msg); 195 GNUNET_free_non_null (msg);
243 return; 196 return;
244 } 197 }
245 FPRINTF (stderr, "%s", "Starting searches\n");
246 ksk_search = 198 ksk_search =
247 GNUNET_FS_search_start (fs, ksk_uri, 1, GNUNET_FS_SEARCH_OPTION_NONE, 199 GNUNET_FS_search_start (fs, ksk_uri, 1, GNUNET_FS_SEARCH_OPTION_NONE,
248 "ksk_search"); 200 "ksk_search");
@@ -260,21 +212,17 @@ sks_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
260 struct GNUNET_FS_Uri *ksk_uri; 212 struct GNUNET_FS_Uri *ksk_uri;
261 char *msg; 213 char *msg;
262 struct GNUNET_FS_BlockOptions bo; 214 struct GNUNET_FS_BlockOptions bo;
263 char *suri;
264 215
265 if (NULL == uri) 216 if (NULL == uri)
266 { 217 {
267 fprintf (stderr, "Error publishing sks: %s\n", emsg); 218 fprintf (stderr, "Error publishing: %s\n", emsg);
268 err = 1; 219 err = 1;
269 GNUNET_FS_stop (fs); 220 GNUNET_FS_stop (fs);
270 return; 221 return;
271 } 222 }
272 FPRINTF (stderr, "%s", "Published sks\n");
273 meta = GNUNET_CONTAINER_meta_data_create (); 223 meta = GNUNET_CONTAINER_meta_data_create ();
274 msg = NULL; 224 msg = NULL;
275 GNUNET_asprintf (&suri, "gnunet://fs/ksk/ns-search%d", phase); 225 ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/ns-search", &msg);
276 ksk_uri = GNUNET_FS_uri_parse (suri, &msg);
277 GNUNET_free (suri);
278 GNUNET_assert (NULL == msg); 226 GNUNET_assert (NULL == msg);
279 ksk_expect_uri = GNUNET_FS_uri_dup (uri); 227 ksk_expect_uri = GNUNET_FS_uri_dup (uri);
280 bo.content_priority = 1; 228 bo.content_priority = 1;
@@ -298,12 +246,11 @@ adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
298 246
299 if (NULL != emsg) 247 if (NULL != emsg)
300 { 248 {
301 FPRINTF (stderr, "Error advertising: %s\n", emsg); 249 FPRINTF (stderr, "Error publishing: %s\n", emsg);
302 err = 1; 250 err = 1;
303 GNUNET_FS_stop (fs); 251 GNUNET_FS_stop (fs);
304 return; 252 return;
305 } 253 }
306 FPRINTF (stderr, "%s", "Created an advertising\n");
307 ns = GNUNET_FS_namespace_create (fs, "testNamespace"); 254 ns = GNUNET_FS_namespace_create (fs, "testNamespace");
308 GNUNET_assert (NULL != ns); 255 GNUNET_assert (NULL != ns);
309 meta = GNUNET_CONTAINER_meta_data_create (); 256 meta = GNUNET_CONTAINER_meta_data_create ();
@@ -314,7 +261,7 @@ adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
314 bo.replication_level = 0; 261 bo.replication_level = 0;
315 bo.expiration_time = 262 bo.expiration_time =
316 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); 263 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
317 GNUNET_FS_publish_sks (fs, ns, "this", "next", meta, uri, /* FIXME: this is non-sense (use CHK URI!?) */ 264 GNUNET_FS_publish_sks (fs, ns, "this", "next", meta, uri,
318 &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont, NULL); 265 &bo, GNUNET_FS_PUBLISH_OPTION_NONE, &sks_cont, NULL);
319 GNUNET_CONTAINER_meta_data_destroy (meta); 266 GNUNET_CONTAINER_meta_data_destroy (meta);
320 GNUNET_FS_namespace_delete (ns, GNUNET_NO); 267 GNUNET_FS_namespace_delete (ns, GNUNET_NO);
@@ -322,27 +269,29 @@ adv_cont (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
322 269
323 270
324static void 271static void
325ns_iterator (void *cls, const char *name, const struct GNUNET_HashCode * id) 272ns_iterator (void *cls, const char *name, const struct GNUNET_PseudonymIdentifier *id)
326{ 273{
327 int *ok = cls; 274 int *ok = cls;
328 275
329 FPRINTF (stderr, "Namespace in the list: %s\n", name);
330 if (0 != strcmp (name, "testNamespace")) 276 if (0 != strcmp (name, "testNamespace"))
331 return; 277 return;
332 *ok = GNUNET_YES; 278 *ok = GNUNET_YES;
333 nsid = *id; 279 nsid = *id;
334} 280}
335 281
282
336static void 283static void
337testCreatedNamespace (struct GNUNET_FS_Namespace *ns) 284testNamespace ()
338{ 285{
286 struct GNUNET_FS_Namespace *ns;
339 struct GNUNET_FS_BlockOptions bo; 287 struct GNUNET_FS_BlockOptions bo;
340 struct GNUNET_CONTAINER_MetaData *meta; 288 struct GNUNET_CONTAINER_MetaData *meta;
341 struct GNUNET_FS_Uri *ksk_uri; 289 struct GNUNET_FS_Uri *ksk_uri;
290 struct GNUNET_FS_Uri *sks_uri;
342 int ok; 291 int ok;
343 char *uri;
344 292
345 FPRINTF (stderr, "%s", "Listing namespaces\n"); 293 ns = GNUNET_FS_namespace_create (fs, "testNamespace");
294 GNUNET_assert (NULL != ns);
346 ok = GNUNET_NO; 295 ok = GNUNET_NO;
347 GNUNET_FS_namespace_list (fs, &ns_iterator, &ok); 296 GNUNET_FS_namespace_list (fs, &ns_iterator, &ok);
348 if (GNUNET_NO == ok) 297 if (GNUNET_NO == ok)
@@ -353,65 +302,24 @@ testCreatedNamespace (struct GNUNET_FS_Namespace *ns)
353 err = 1; 302 err = 1;
354 return; 303 return;
355 } 304 }
356 FPRINTF (stderr, "%s", "Creating an advertising\n");
357 meta = GNUNET_CONTAINER_meta_data_create (); 305 meta = GNUNET_CONTAINER_meta_data_create ();
358 GNUNET_asprintf (&uri, "gnunet://fs/ksk/testnsa%d", phase); 306 ksk_uri = GNUNET_FS_uri_parse ("gnunet://fs/ksk/testnsa", NULL);
359 ksk_uri = GNUNET_FS_uri_parse (uri, NULL);
360 GNUNET_free (uri);
361 bo.content_priority = 1; 307 bo.content_priority = 1;
362 bo.anonymity_level = 1; 308 bo.anonymity_level = 1;
363 bo.replication_level = 0; 309 bo.replication_level = 0;
364 bo.expiration_time = 310 bo.expiration_time =
365 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); 311 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
366 GNUNET_FS_namespace_advertise (fs, ksk_uri, ns, meta, &bo, "root", &adv_cont, 312 sks_uri = GNUNET_FS_uri_sks_create (ns, "root", NULL);
367 NULL); 313 GNUNET_FS_publish_ksk (fs,
368 GNUNET_FS_uri_destroy (ksk_uri); 314 ksk_uri, meta, sks_uri, &bo, GNUNET_FS_PUBLISH_OPTION_NONE,
369 GNUNET_FS_namespace_delete (ns, GNUNET_NO); 315 &adv_cont, NULL);
370 GNUNET_CONTAINER_meta_data_destroy (meta); 316 GNUNET_FS_uri_destroy (sks_uri);
371}
372
373static void
374do_ncc_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
375{
376 FPRINTF (stderr, "%s", "Asynchronous NS creation timed out\n");
377 kill_ncc_task = GNUNET_SCHEDULER_NO_TASK;
378 if (NULL == ncc)
379 return;
380 GNUNET_FS_namespace_create_stop (ncc);
381 ncc = NULL;
382 err = 1;
383}
384
385static void
386ns_created (void *cls, struct GNUNET_FS_Namespace *ns, const char *emsg)
387{
388 if (GNUNET_SCHEDULER_NO_TASK != kill_ncc_task)
389 GNUNET_SCHEDULER_cancel (kill_ncc_task);
390 kill_ncc_task = GNUNET_SCHEDULER_NO_TASK;
391 if (NULL == ns)
392 {
393 FPRINTF (stderr, "Asynchronous NS creation failed: %s\n", emsg);
394 err = 1;
395 return;
396 }
397
398 FPRINTF (stderr, "%s", "Namespace created asynchronously\n");
399 testCreatedNamespace (ns);
400}
401
402static void
403testNamespace ()
404{
405 struct GNUNET_FS_Namespace *ns;
406
407 FPRINTF (stderr, "%s", "Testing synchronous namespace creation\n");
408 ns = GNUNET_FS_namespace_create (fs, "testNamespace");
409 GNUNET_assert (NULL != ns);
410 testCreatedNamespace (ns);
411
412 kill_task = 317 kill_task =
413 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &do_timeout, 318 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &do_timeout,
414 NULL); 319 NULL);
320 GNUNET_FS_uri_destroy (ksk_uri);
321 GNUNET_FS_namespace_delete (ns, GNUNET_NO);
322 GNUNET_CONTAINER_meta_data_destroy (meta);
415} 323}
416 324
417 325
@@ -420,10 +328,8 @@ run (void *cls,
420 const struct GNUNET_CONFIGURATION_Handle *cfg, 328 const struct GNUNET_CONFIGURATION_Handle *cfg,
421 struct GNUNET_TESTING_Peer *peer) 329 struct GNUNET_TESTING_Peer *peer)
422{ 330{
423 config = cfg;
424 fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL, 331 fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL,
425 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); 332 GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END);
426 phase = 0;
427 testNamespace (); 333 testNamespace ();
428} 334}
429 335
diff --git a/src/fs/test_fs_uri.c b/src/fs/test_fs_uri.c
index 47fa2024b..6d0bfdea9 100644
--- a/src/fs/test_fs_uri.c
+++ b/src/fs/test_fs_uri.c
@@ -162,6 +162,11 @@ testNamespace (int i)
162 char *uri; 162 char *uri;
163 struct GNUNET_FS_Uri *ret; 163 struct GNUNET_FS_Uri *ret;
164 char *emsg; 164 char *emsg;
165 struct GNUNET_PseudonymHandle *ph;
166 struct GNUNET_PseudonymIdentifier id;
167 char buf[1024];
168 char ubuf[1024];
169 char *sret;
165 170
166 if (NULL != 171 if (NULL !=
167 (ret = 172 (ret =
@@ -187,11 +192,17 @@ testNamespace (int i)
187 GNUNET_assert (0); 192 GNUNET_assert (0);
188 } 193 }
189 GNUNET_free (emsg); 194 GNUNET_free (emsg);
190 ret = 195 ph = GNUNET_PSEUDONYM_create (NULL);
191 GNUNET_FS_uri_parse 196 GNUNET_PSEUDONYM_get_identifier (ph, &id);
192 ("gnunet://fs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test", 197 sret = GNUNET_STRINGS_data_to_string (&id, sizeof (id),
193 &emsg); 198 ubuf, sizeof (ubuf) - 1);
194 if (ret == NULL) 199 GNUNET_assert (NULL != sret);
200 sret[0] = '\0';
201 GNUNET_snprintf (buf, sizeof (buf),
202 "gnunet://fs/sks/%s/test",
203 ubuf);
204 ret = GNUNET_FS_uri_parse (buf, &emsg);
205 if (NULL == ret)
195 { 206 {
196 GNUNET_free (emsg); 207 GNUNET_free (emsg);
197 GNUNET_assert (0); 208 GNUNET_assert (0);
@@ -210,7 +221,7 @@ testNamespace (int i)
210 uri = GNUNET_FS_uri_to_string (ret); 221 uri = GNUNET_FS_uri_to_string (ret);
211 if (0 != 222 if (0 !=
212 strcmp (uri, 223 strcmp (uri,
213 "gnunet://fs/sks/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820/test")) 224 buf))
214 { 225 {
215 GNUNET_FS_uri_destroy (ret); 226 GNUNET_FS_uri_destroy (ret);
216 GNUNET_free (uri); 227 GNUNET_free (uri);