diff options
Diffstat (limited to 'src/fs/fs_search.c')
-rw-r--r-- | src/fs/fs_search.c | 249 |
1 files changed, 88 insertions, 161 deletions
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 | */ |
591 | static int | 590 | static int |
592 | decrypt_block_with_keyword (const struct GNUNET_FS_SearchContext *sc, | 591 | decrypt_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 | */ |
636 | static void | 637 | static void |
637 | process_kblock (struct GNUNET_FS_SearchContext *sc, const struct KBlock *kb, | 638 | process_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 | */ | ||
695 | static void | ||
696 | process_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 | */ |
759 | static void | 696 | static void |
760 | process_sblock (struct GNUNET_FS_SearchContext *sc, const struct SBlock *sb, | 697 | process_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); |