diff options
Diffstat (limited to 'src/fs/fs_namespace.c')
-rw-r--r-- | src/fs/fs_namespace.c | 288 |
1 files changed, 74 insertions, 214 deletions
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 | */ | ||
43 | struct 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 | */ | ||
357 | static void | ||
358 | ns_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 | */ | ||
396 | struct GNUNET_FS_NamespaceCreationContext * | ||
397 | GNUNET_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 | */ | ||
443 | void | ||
444 | GNUNET_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 | */ |
470 | int | 315 | int |
471 | GNUNET_FS_namespace_rename (struct GNUNET_FS_Handle *h, const char *old_name, const char *new_name) | 316 | GNUNET_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 | */ |
586 | int | 434 | int |
587 | GNUNET_FS_namespace_get_public_key_hash (struct GNUNET_FS_Namespace *ns, | 435 | GNUNET_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 | |||
607 | process_namespace (void *cls, const char *filename) | 455 | process_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 | ||