diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-02-15 13:58:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-02-15 13:58:52 +0000 |
commit | bdeb59bc30331d6fd9f05d56d44a30f281b46195 (patch) | |
tree | 4ed1830fec733e90ac15323b4e4851f704a35c64 /src/fs/fs_uri.c | |
parent | 140fdac7581295bd7d9dd90ead81bf31f8473cbf (diff) | |
download | gnunet-bdeb59bc30331d6fd9f05d56d44a30f281b46195.tar.gz gnunet-bdeb59bc30331d6fd9f05d56d44a30f281b46195.zip |
-fixes to make stream tests pass with ecc in core
Diffstat (limited to 'src/fs/fs_uri.c')
-rw-r--r-- | src/fs/fs_uri.c | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index fa6d411db..d38a5354d 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c | |||
@@ -102,22 +102,22 @@ GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, struct GNUNET_HashCode * | |||
102 | { | 102 | { |
103 | switch (uri->type) | 103 | switch (uri->type) |
104 | { | 104 | { |
105 | case chk: | 105 | case GNUNET_FS_URI_CHK: |
106 | *key = uri->data.chk.chk.query; | 106 | *key = uri->data.chk.chk.query; |
107 | return; | 107 | return; |
108 | case sks: | 108 | case GNUNET_FS_URI_SKS: |
109 | GNUNET_CRYPTO_hash (uri->data.sks.identifier, | 109 | GNUNET_CRYPTO_hash (uri->data.sks.identifier, |
110 | strlen (uri->data.sks.identifier), key); | 110 | strlen (uri->data.sks.identifier), key); |
111 | break; | 111 | break; |
112 | case ksk: | 112 | case GNUNET_FS_URI_KSK: |
113 | if (uri->data.ksk.keywordCount > 0) | 113 | if (uri->data.ksk.keywordCount > 0) |
114 | GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0], | 114 | GNUNET_CRYPTO_hash (uri->data.ksk.keywords[0], |
115 | strlen (uri->data.ksk.keywords[0]), key); | 115 | strlen (uri->data.ksk.keywords[0]), key); |
116 | break; | 116 | break; |
117 | case loc: | 117 | case GNUNET_FS_URI_LOC: |
118 | GNUNET_CRYPTO_hash (&uri->data.loc.fi, | 118 | GNUNET_CRYPTO_hash (&uri->data.loc.fi, |
119 | sizeof (struct FileIdentifier) + | 119 | sizeof (struct FileIdentifier) + |
120 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 120 | sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), |
121 | key); | 121 | key); |
122 | break; | 122 | break; |
123 | default: | 123 | default: |
@@ -144,7 +144,7 @@ GNUNET_FS_uri_ksk_to_string_fancy (const struct GNUNET_FS_Uri *uri) | |||
144 | char **keywords; | 144 | char **keywords; |
145 | unsigned int keywordCount; | 145 | unsigned int keywordCount; |
146 | 146 | ||
147 | if ((uri == NULL) || (uri->type != ksk)) | 147 | if ((uri == NULL) || (uri->type != GNUNET_FS_URI_KSK)) |
148 | { | 148 | { |
149 | GNUNET_break (0); | 149 | GNUNET_break (0); |
150 | return NULL; | 150 | return NULL; |
@@ -330,7 +330,7 @@ uri_ksk_parse (const char *s, char **emsg) | |||
330 | GNUNET_assert (max == 0); | 330 | GNUNET_assert (max == 0); |
331 | GNUNET_free (dup); | 331 | GNUNET_free (dup); |
332 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 332 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
333 | ret->type = ksk; | 333 | ret->type = GNUNET_FS_URI_KSK; |
334 | ret->data.ksk.keywordCount = iret; | 334 | ret->data.ksk.keywordCount = iret; |
335 | ret->data.ksk.keywords = keywords; | 335 | ret->data.ksk.keywords = keywords; |
336 | return ret; | 336 | return ret; |
@@ -383,7 +383,7 @@ uri_sks_parse (const char *s, char **emsg) | |||
383 | identifier = | 383 | identifier = |
384 | GNUNET_strdup (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)]); | 384 | GNUNET_strdup (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)]); |
385 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 385 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
386 | ret->type = sks; | 386 | ret->type = GNUNET_FS_URI_SKS; |
387 | ret->data.sks.ns = ns; | 387 | ret->data.sks.ns = ns; |
388 | ret->data.sks.identifier = identifier; | 388 | ret->data.sks.identifier = identifier; |
389 | return ret; | 389 | return ret; |
@@ -441,7 +441,7 @@ uri_chk_parse (const char *s, char **emsg) | |||
441 | } | 441 | } |
442 | fi.file_length = GNUNET_htonll (flen); | 442 | fi.file_length = GNUNET_htonll (flen); |
443 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 443 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
444 | ret->type = chk; | 444 | ret->type = GNUNET_FS_URI_CHK; |
445 | ret->data.chk = fi; | 445 | ret->data.chk = fi; |
446 | return ret; | 446 | return ret; |
447 | } | 447 | } |
@@ -520,13 +520,13 @@ enc2bin (const char *input, void *data, size_t size) | |||
520 | */ | 520 | */ |
521 | struct LocUriAssembly | 521 | struct LocUriAssembly |
522 | { | 522 | { |
523 | struct GNUNET_CRYPTO_RsaSignaturePurpose purpose; | 523 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; |
524 | 524 | ||
525 | struct GNUNET_TIME_AbsoluteNBO exptime; | 525 | struct GNUNET_TIME_AbsoluteNBO exptime; |
526 | 526 | ||
527 | struct FileIdentifier fi; | 527 | struct FileIdentifier fi; |
528 | 528 | ||
529 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded peer; | 529 | struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded peer; |
530 | 530 | ||
531 | }; | 531 | }; |
532 | 532 | ||
@@ -552,7 +552,7 @@ uri_loc_parse (const char *s, char **emsg) | |||
552 | unsigned long long exptime; | 552 | unsigned long long exptime; |
553 | unsigned long long flen; | 553 | unsigned long long flen; |
554 | struct GNUNET_TIME_Absolute et; | 554 | struct GNUNET_TIME_Absolute et; |
555 | struct GNUNET_CRYPTO_RsaSignature sig; | 555 | struct GNUNET_CRYPTO_EccSignature sig; |
556 | struct LocUriAssembly ass; | 556 | struct LocUriAssembly ass; |
557 | int ret; | 557 | int ret; |
558 | size_t slen; | 558 | size_t slen; |
@@ -597,7 +597,7 @@ uri_loc_parse (const char *s, char **emsg) | |||
597 | npos++; | 597 | npos++; |
598 | ret = | 598 | ret = |
599 | enc2bin (&s[npos], &ass.peer, | 599 | enc2bin (&s[npos], &ass.peer, |
600 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | 600 | sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)); |
601 | if (ret == -1) | 601 | if (ret == -1) |
602 | { | 602 | { |
603 | *emsg = | 603 | *emsg = |
@@ -610,7 +610,7 @@ uri_loc_parse (const char *s, char **emsg) | |||
610 | *emsg = GNUNET_strdup (_("SKS URI malformed (could not find signature)")); | 610 | *emsg = GNUNET_strdup (_("SKS URI malformed (could not find signature)")); |
611 | goto ERR; | 611 | goto ERR; |
612 | } | 612 | } |
613 | ret = enc2bin (&s[npos], &sig, sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 613 | ret = enc2bin (&s[npos], &sig, sizeof (struct GNUNET_CRYPTO_EccSignature)); |
614 | if (ret == -1) | 614 | if (ret == -1) |
615 | { | 615 | { |
616 | *emsg = GNUNET_strdup (_("SKS URI malformed (could not decode signature)")); | 616 | *emsg = GNUNET_strdup (_("SKS URI malformed (could not decode signature)")); |
@@ -634,7 +634,7 @@ uri_loc_parse (const char *s, char **emsg) | |||
634 | et.abs_value = exptime; | 634 | et.abs_value = exptime; |
635 | ass.exptime = GNUNET_TIME_absolute_hton (et); | 635 | ass.exptime = GNUNET_TIME_absolute_hton (et); |
636 | if (GNUNET_OK != | 636 | if (GNUNET_OK != |
637 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT, | 637 | GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT, |
638 | &ass.purpose, &sig, &ass.peer)) | 638 | &ass.purpose, &sig, &ass.peer)) |
639 | { | 639 | { |
640 | *emsg = | 640 | *emsg = |
@@ -642,7 +642,7 @@ uri_loc_parse (const char *s, char **emsg) | |||
642 | goto ERR; | 642 | goto ERR; |
643 | } | 643 | } |
644 | uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 644 | uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
645 | uri->type = loc; | 645 | uri->type = GNUNET_FS_URI_LOC; |
646 | uri->data.loc.fi = ass.fi; | 646 | uri->data.loc.fi = ass.fi; |
647 | uri->data.loc.peer = ass.peer; | 647 | uri->data.loc.peer = ass.peer; |
648 | uri->data.loc.expirationTime = et; | 648 | uri->data.loc.expirationTime = et; |
@@ -696,15 +696,15 @@ GNUNET_FS_uri_destroy (struct GNUNET_FS_Uri *uri) | |||
696 | GNUNET_assert (uri != NULL); | 696 | GNUNET_assert (uri != NULL); |
697 | switch (uri->type) | 697 | switch (uri->type) |
698 | { | 698 | { |
699 | case ksk: | 699 | case GNUNET_FS_URI_KSK: |
700 | for (i = 0; i < uri->data.ksk.keywordCount; i++) | 700 | for (i = 0; i < uri->data.ksk.keywordCount; i++) |
701 | GNUNET_free (uri->data.ksk.keywords[i]); | 701 | GNUNET_free (uri->data.ksk.keywords[i]); |
702 | GNUNET_array_grow (uri->data.ksk.keywords, uri->data.ksk.keywordCount, 0); | 702 | GNUNET_array_grow (uri->data.ksk.keywords, uri->data.ksk.keywordCount, 0); |
703 | break; | 703 | break; |
704 | case sks: | 704 | case GNUNET_FS_URI_SKS: |
705 | GNUNET_free (uri->data.sks.identifier); | 705 | GNUNET_free (uri->data.sks.identifier); |
706 | break; | 706 | break; |
707 | case loc: | 707 | case GNUNET_FS_URI_LOC: |
708 | break; | 708 | break; |
709 | default: | 709 | default: |
710 | /* do nothing */ | 710 | /* do nothing */ |
@@ -722,7 +722,7 @@ GNUNET_FS_uri_destroy (struct GNUNET_FS_Uri *uri) | |||
722 | unsigned int | 722 | unsigned int |
723 | GNUNET_FS_uri_ksk_get_keyword_count (const struct GNUNET_FS_Uri *uri) | 723 | GNUNET_FS_uri_ksk_get_keyword_count (const struct GNUNET_FS_Uri *uri) |
724 | { | 724 | { |
725 | if (uri->type != ksk) | 725 | if (uri->type != GNUNET_FS_URI_KSK) |
726 | return 0; | 726 | return 0; |
727 | return uri->data.ksk.keywordCount; | 727 | return uri->data.ksk.keywordCount; |
728 | } | 728 | } |
@@ -745,7 +745,7 @@ GNUNET_FS_uri_ksk_get_keywords (const struct GNUNET_FS_Uri *uri, | |||
745 | unsigned int i; | 745 | unsigned int i; |
746 | char *keyword; | 746 | char *keyword; |
747 | 747 | ||
748 | if (uri->type != ksk) | 748 | if (uri->type != GNUNET_FS_URI_KSK) |
749 | return -1; | 749 | return -1; |
750 | if (iterator == NULL) | 750 | if (iterator == NULL) |
751 | return uri->data.ksk.keywordCount; | 751 | return uri->data.ksk.keywordCount; |
@@ -777,7 +777,7 @@ GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, const char *keyword, | |||
777 | const char *old; | 777 | const char *old; |
778 | char *n; | 778 | char *n; |
779 | 779 | ||
780 | GNUNET_assert (uri->type == ksk); | 780 | GNUNET_assert (uri->type == GNUNET_FS_URI_KSK); |
781 | for (i = 0; i < uri->data.ksk.keywordCount; i++) | 781 | for (i = 0; i < uri->data.ksk.keywordCount; i++) |
782 | { | 782 | { |
783 | old = uri->data.ksk.keywords[i]; | 783 | old = uri->data.ksk.keywords[i]; |
@@ -803,7 +803,7 @@ GNUNET_FS_uri_ksk_remove_keyword (struct GNUNET_FS_Uri *uri, | |||
803 | unsigned int i; | 803 | unsigned int i; |
804 | char *old; | 804 | char *old; |
805 | 805 | ||
806 | GNUNET_assert (uri->type == ksk); | 806 | GNUNET_assert (uri->type == GNUNET_FS_URI_KSK); |
807 | for (i = 0; i < uri->data.ksk.keywordCount; i++) | 807 | for (i = 0; i < uri->data.ksk.keywordCount; i++) |
808 | { | 808 | { |
809 | old = uri->data.ksk.keywords[i]; | 809 | old = uri->data.ksk.keywords[i]; |
@@ -831,10 +831,10 @@ int | |||
831 | GNUNET_FS_uri_loc_get_peer_identity (const struct GNUNET_FS_Uri *uri, | 831 | GNUNET_FS_uri_loc_get_peer_identity (const struct GNUNET_FS_Uri *uri, |
832 | struct GNUNET_PeerIdentity *peer) | 832 | struct GNUNET_PeerIdentity *peer) |
833 | { | 833 | { |
834 | if (uri->type != loc) | 834 | if (uri->type != GNUNET_FS_URI_LOC) |
835 | return GNUNET_SYSERR; | 835 | return GNUNET_SYSERR; |
836 | GNUNET_CRYPTO_hash (&uri->data.loc.peer, | 836 | GNUNET_CRYPTO_hash (&uri->data.loc.peer, |
837 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 837 | sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), |
838 | &peer->hashPubKey); | 838 | &peer->hashPubKey); |
839 | return GNUNET_OK; | 839 | return GNUNET_OK; |
840 | } | 840 | } |
@@ -849,7 +849,7 @@ GNUNET_FS_uri_loc_get_peer_identity (const struct GNUNET_FS_Uri *uri, | |||
849 | struct GNUNET_TIME_Absolute | 849 | struct GNUNET_TIME_Absolute |
850 | GNUNET_FS_uri_loc_get_expiration (const struct GNUNET_FS_Uri *uri) | 850 | GNUNET_FS_uri_loc_get_expiration (const struct GNUNET_FS_Uri *uri) |
851 | { | 851 | { |
852 | GNUNET_assert (uri->type == loc); | 852 | GNUNET_assert (uri->type == GNUNET_FS_URI_LOC); |
853 | return uri->data.loc.expirationTime; | 853 | return uri->data.loc.expirationTime; |
854 | } | 854 | } |
855 | 855 | ||
@@ -866,10 +866,10 @@ GNUNET_FS_uri_loc_get_uri (const struct GNUNET_FS_Uri *uri) | |||
866 | { | 866 | { |
867 | struct GNUNET_FS_Uri *ret; | 867 | struct GNUNET_FS_Uri *ret; |
868 | 868 | ||
869 | if (uri->type != loc) | 869 | if (uri->type != GNUNET_FS_URI_LOC) |
870 | return NULL; | 870 | return NULL; |
871 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 871 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
872 | ret->type = chk; | 872 | ret->type = GNUNET_FS_URI_CHK; |
873 | ret->data.chk = uri->data.loc.fi; | 873 | ret->data.chk = uri->data.loc.fi; |
874 | return ret; | 874 | return ret; |
875 | } | 875 | } |
@@ -889,22 +889,22 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri, | |||
889 | struct GNUNET_TIME_Absolute expiration_time) | 889 | struct GNUNET_TIME_Absolute expiration_time) |
890 | { | 890 | { |
891 | struct GNUNET_FS_Uri *uri; | 891 | struct GNUNET_FS_Uri *uri; |
892 | struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; | 892 | struct GNUNET_CRYPTO_EccPrivateKey *my_private_key; |
893 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded my_public_key; | 893 | struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; |
894 | char *keyfile; | 894 | char *keyfile; |
895 | struct LocUriAssembly ass; | 895 | struct LocUriAssembly ass; |
896 | 896 | ||
897 | if (baseUri->type != chk) | 897 | if (baseUri->type != GNUNET_FS_URI_CHK) |
898 | return NULL; | 898 | return NULL; |
899 | if (GNUNET_OK != | 899 | if (GNUNET_OK != |
900 | GNUNET_CONFIGURATION_get_value_filename (cfg, "GNUNETD", "HOSTKEY", | 900 | GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", "PRIVATE_KEY", |
901 | &keyfile)) | 901 | &keyfile)) |
902 | { | 902 | { |
903 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 903 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
904 | _("Lacking key configuration settings.\n")); | 904 | _("Lacking key configuration settings.\n")); |
905 | return NULL; | 905 | return NULL; |
906 | } | 906 | } |
907 | if (NULL == (my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile))) | 907 | if (NULL == (my_private_key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile))) |
908 | { | 908 | { |
909 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 909 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
910 | _("Could not access hostkey file `%s'.\n"), keyfile); | 910 | _("Could not access hostkey file `%s'.\n"), keyfile); |
@@ -912,21 +912,21 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri, | |||
912 | return NULL; | 912 | return NULL; |
913 | } | 913 | } |
914 | GNUNET_free (keyfile); | 914 | GNUNET_free (keyfile); |
915 | GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); | 915 | GNUNET_CRYPTO_ecc_key_get_public (my_private_key, &my_public_key); |
916 | ass.purpose.size = htonl (sizeof (struct LocUriAssembly)); | 916 | ass.purpose.size = htonl (sizeof (struct LocUriAssembly)); |
917 | ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT); | 917 | ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT); |
918 | ass.exptime = GNUNET_TIME_absolute_hton (expiration_time); | 918 | ass.exptime = GNUNET_TIME_absolute_hton (expiration_time); |
919 | ass.fi = baseUri->data.chk; | 919 | ass.fi = baseUri->data.chk; |
920 | ass.peer = my_public_key; | 920 | ass.peer = my_public_key; |
921 | uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 921 | uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
922 | uri->type = loc; | 922 | uri->type = GNUNET_FS_URI_LOC; |
923 | uri->data.loc.fi = baseUri->data.chk; | 923 | uri->data.loc.fi = baseUri->data.chk; |
924 | uri->data.loc.expirationTime = expiration_time; | 924 | uri->data.loc.expirationTime = expiration_time; |
925 | uri->data.loc.peer = my_public_key; | 925 | uri->data.loc.peer = my_public_key; |
926 | GNUNET_assert (GNUNET_OK == | 926 | GNUNET_assert (GNUNET_OK == |
927 | GNUNET_CRYPTO_rsa_sign (my_private_key, &ass.purpose, | 927 | GNUNET_CRYPTO_ecc_sign (my_private_key, &ass.purpose, |
928 | &uri->data.loc.contentSignature)); | 928 | &uri->data.loc.contentSignature)); |
929 | GNUNET_CRYPTO_rsa_key_free (my_private_key); | 929 | GNUNET_CRYPTO_ecc_key_free (my_private_key); |
930 | return uri; | 930 | return uri; |
931 | } | 931 | } |
932 | 932 | ||
@@ -947,7 +947,7 @@ GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, const char *id, | |||
947 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk; | 947 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk; |
948 | 948 | ||
949 | ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 949 | ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
950 | ns_uri->type = sks; | 950 | ns_uri->type = GNUNET_FS_URI_SKS; |
951 | GNUNET_CRYPTO_rsa_key_get_public (ns->key, &pk); | 951 | GNUNET_CRYPTO_rsa_key_get_public (ns->key, &pk); |
952 | GNUNET_CRYPTO_hash (&pk, sizeof (pk), &ns_uri->data.sks.ns); | 952 | GNUNET_CRYPTO_hash (&pk, sizeof (pk), &ns_uri->data.sks.ns); |
953 | ns_uri->data.sks.identifier = GNUNET_strdup (id); | 953 | ns_uri->data.sks.identifier = GNUNET_strdup (id); |
@@ -968,7 +968,7 @@ GNUNET_FS_uri_sks_create_from_nsid (struct GNUNET_HashCode * nsid, const char *i | |||
968 | struct GNUNET_FS_Uri *ns_uri; | 968 | struct GNUNET_FS_Uri *ns_uri; |
969 | 969 | ||
970 | ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 970 | ns_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
971 | ns_uri->type = sks; | 971 | ns_uri->type = GNUNET_FS_URI_SKS; |
972 | ns_uri->data.sks.ns = *nsid; | 972 | ns_uri->data.sks.ns = *nsid; |
973 | ns_uri->data.sks.identifier = GNUNET_strdup (id); | 973 | ns_uri->data.sks.identifier = GNUNET_strdup (id); |
974 | return ns_uri; | 974 | return ns_uri; |
@@ -1002,7 +1002,7 @@ GNUNET_FS_uri_ksk_merge (const struct GNUNET_FS_Uri *u1, | |||
1002 | return GNUNET_FS_uri_dup (u2); | 1002 | return GNUNET_FS_uri_dup (u2); |
1003 | if (u2 == NULL) | 1003 | if (u2 == NULL) |
1004 | return GNUNET_FS_uri_dup (u1); | 1004 | return GNUNET_FS_uri_dup (u1); |
1005 | if ((u1->type != ksk) || (u2->type != ksk)) | 1005 | if ((u1->type != GNUNET_FS_URI_KSK) || (u2->type != GNUNET_FS_URI_KSK)) |
1006 | { | 1006 | { |
1007 | GNUNET_break (0); | 1007 | GNUNET_break (0); |
1008 | return NULL; | 1008 | return NULL; |
@@ -1027,7 +1027,7 @@ GNUNET_FS_uri_ksk_merge (const struct GNUNET_FS_Uri *u1, | |||
1027 | kl[kc++] = GNUNET_strdup (kp); | 1027 | kl[kc++] = GNUNET_strdup (kp); |
1028 | } | 1028 | } |
1029 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 1029 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
1030 | ret->type = ksk; | 1030 | ret->type = GNUNET_FS_URI_KSK; |
1031 | ret->data.ksk.keywordCount = kc; | 1031 | ret->data.ksk.keywordCount = kc; |
1032 | ret->data.ksk.keywords = kl; | 1032 | ret->data.ksk.keywords = kl; |
1033 | return ret; | 1033 | return ret; |
@@ -1052,7 +1052,7 @@ GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri) | |||
1052 | memcpy (ret, uri, sizeof (struct GNUNET_FS_Uri)); | 1052 | memcpy (ret, uri, sizeof (struct GNUNET_FS_Uri)); |
1053 | switch (ret->type) | 1053 | switch (ret->type) |
1054 | { | 1054 | { |
1055 | case ksk: | 1055 | case GNUNET_FS_URI_KSK: |
1056 | if (ret->data.ksk.keywordCount >= | 1056 | if (ret->data.ksk.keywordCount >= |
1057 | GNUNET_MAX_MALLOC_CHECKED / sizeof (char *)) | 1057 | GNUNET_MAX_MALLOC_CHECKED / sizeof (char *)) |
1058 | { | 1058 | { |
@@ -1070,10 +1070,10 @@ GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri) | |||
1070 | else | 1070 | else |
1071 | ret->data.ksk.keywords = NULL; /* just to be sure */ | 1071 | ret->data.ksk.keywords = NULL; /* just to be sure */ |
1072 | break; | 1072 | break; |
1073 | case sks: | 1073 | case GNUNET_FS_URI_SKS: |
1074 | ret->data.sks.identifier = GNUNET_strdup (uri->data.sks.identifier); | 1074 | ret->data.sks.identifier = GNUNET_strdup (uri->data.sks.identifier); |
1075 | break; | 1075 | break; |
1076 | case loc: | 1076 | case GNUNET_FS_URI_LOC: |
1077 | break; | 1077 | break; |
1078 | default: | 1078 | default: |
1079 | break; | 1079 | break; |
@@ -1218,7 +1218,7 @@ GNUNET_FS_uri_ksk_create_from_args (unsigned int argc, const char **argv) | |||
1218 | return uri; | 1218 | return uri; |
1219 | GNUNET_free_non_null (emsg); | 1219 | GNUNET_free_non_null (emsg); |
1220 | uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 1220 | uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
1221 | uri->type = ksk; | 1221 | uri->type = GNUNET_FS_URI_KSK; |
1222 | uri->data.ksk.keywordCount = argc; | 1222 | uri->data.ksk.keywordCount = argc; |
1223 | uri->data.ksk.keywords = GNUNET_malloc (argc * sizeof (char *)); | 1223 | uri->data.ksk.keywords = GNUNET_malloc (argc * sizeof (char *)); |
1224 | for (i = 0; i < argc; i++) | 1224 | for (i = 0; i < argc; i++) |
@@ -1265,12 +1265,12 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1, | |||
1265 | return GNUNET_NO; | 1265 | return GNUNET_NO; |
1266 | switch (u1->type) | 1266 | switch (u1->type) |
1267 | { | 1267 | { |
1268 | case chk: | 1268 | case GNUNET_FS_URI_CHK: |
1269 | if (0 == | 1269 | if (0 == |
1270 | memcmp (&u1->data.chk, &u2->data.chk, sizeof (struct FileIdentifier))) | 1270 | memcmp (&u1->data.chk, &u2->data.chk, sizeof (struct FileIdentifier))) |
1271 | return GNUNET_YES; | 1271 | return GNUNET_YES; |
1272 | return GNUNET_NO; | 1272 | return GNUNET_NO; |
1273 | case sks: | 1273 | case GNUNET_FS_URI_SKS: |
1274 | if ((0 == | 1274 | if ((0 == |
1275 | memcmp (&u1->data.sks.ns, &u2->data.sks.ns, | 1275 | memcmp (&u1->data.sks.ns, &u2->data.sks.ns, |
1276 | sizeof (struct GNUNET_HashCode))) && | 1276 | sizeof (struct GNUNET_HashCode))) && |
@@ -1278,7 +1278,7 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1, | |||
1278 | 1278 | ||
1279 | return GNUNET_YES; | 1279 | return GNUNET_YES; |
1280 | return GNUNET_NO; | 1280 | return GNUNET_NO; |
1281 | case ksk: | 1281 | case GNUNET_FS_URI_KSK: |
1282 | if (u1->data.ksk.keywordCount != u2->data.ksk.keywordCount) | 1282 | if (u1->data.ksk.keywordCount != u2->data.ksk.keywordCount) |
1283 | return GNUNET_NO; | 1283 | return GNUNET_NO; |
1284 | for (i = 0; i < u1->data.ksk.keywordCount; i++) | 1284 | for (i = 0; i < u1->data.ksk.keywordCount; i++) |
@@ -1296,11 +1296,11 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1, | |||
1296 | return GNUNET_NO; | 1296 | return GNUNET_NO; |
1297 | } | 1297 | } |
1298 | return GNUNET_YES; | 1298 | return GNUNET_YES; |
1299 | case loc: | 1299 | case GNUNET_FS_URI_LOC: |
1300 | if (memcmp | 1300 | if (memcmp |
1301 | (&u1->data.loc, &u2->data.loc, | 1301 | (&u1->data.loc, &u2->data.loc, |
1302 | sizeof (struct FileIdentifier) + | 1302 | sizeof (struct FileIdentifier) + |
1303 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + | 1303 | sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) + |
1304 | sizeof (struct GNUNET_TIME_Absolute) + sizeof (unsigned short) + | 1304 | sizeof (struct GNUNET_TIME_Absolute) + sizeof (unsigned short) + |
1305 | sizeof (unsigned short)) != 0) | 1305 | sizeof (unsigned short)) != 0) |
1306 | return GNUNET_NO; | 1306 | return GNUNET_NO; |
@@ -1320,7 +1320,7 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1, | |||
1320 | int | 1320 | int |
1321 | GNUNET_FS_uri_test_sks (const struct GNUNET_FS_Uri *uri) | 1321 | GNUNET_FS_uri_test_sks (const struct GNUNET_FS_Uri *uri) |
1322 | { | 1322 | { |
1323 | return uri->type == sks; | 1323 | return uri->type == GNUNET_FS_URI_SKS; |
1324 | } | 1324 | } |
1325 | 1325 | ||
1326 | 1326 | ||
@@ -1380,7 +1380,7 @@ GNUNET_FS_uri_sks_to_string_fancy (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1380 | char *name; | 1380 | char *name; |
1381 | char *unique_name; | 1381 | char *unique_name; |
1382 | 1382 | ||
1383 | if (uri->type != sks) | 1383 | if (uri->type != GNUNET_FS_URI_SKS) |
1384 | return NULL; | 1384 | return NULL; |
1385 | (void) GNUNET_PSEUDONYM_get_info (cfg, &uri->data.sks.ns, | 1385 | (void) GNUNET_PSEUDONYM_get_info (cfg, &uri->data.sks.ns, |
1386 | NULL, NULL, &name, NULL); | 1386 | NULL, NULL, &name, NULL); |
@@ -1404,13 +1404,13 @@ GNUNET_FS_uri_test_ksk (const struct GNUNET_FS_Uri *uri) | |||
1404 | #if EXTRA_CHECKS | 1404 | #if EXTRA_CHECKS |
1405 | unsigned int i; | 1405 | unsigned int i; |
1406 | 1406 | ||
1407 | if (uri->type == ksk) | 1407 | if (uri->type == GNUNET_FS_URI_KSK) |
1408 | { | 1408 | { |
1409 | for (i=0;i < uri->data.ksk.keywordCount; i++) | 1409 | for (i=0;i < uri->data.ksk.keywordCount; i++) |
1410 | GNUNET_assert (uri->data.ksk.keywords[i] != NULL); | 1410 | GNUNET_assert (uri->data.ksk.keywords[i] != NULL); |
1411 | } | 1411 | } |
1412 | #endif | 1412 | #endif |
1413 | return uri->type == ksk; | 1413 | return uri->type == GNUNET_FS_URI_KSK; |
1414 | } | 1414 | } |
1415 | 1415 | ||
1416 | 1416 | ||
@@ -1423,7 +1423,7 @@ GNUNET_FS_uri_test_ksk (const struct GNUNET_FS_Uri *uri) | |||
1423 | int | 1423 | int |
1424 | GNUNET_FS_uri_test_chk (const struct GNUNET_FS_Uri *uri) | 1424 | GNUNET_FS_uri_test_chk (const struct GNUNET_FS_Uri *uri) |
1425 | { | 1425 | { |
1426 | return uri->type == chk; | 1426 | return uri->type == GNUNET_FS_URI_CHK; |
1427 | } | 1427 | } |
1428 | 1428 | ||
1429 | 1429 | ||
@@ -1439,9 +1439,9 @@ GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri * uri) | |||
1439 | { | 1439 | { |
1440 | switch (uri->type) | 1440 | switch (uri->type) |
1441 | { | 1441 | { |
1442 | case chk: | 1442 | case GNUNET_FS_URI_CHK: |
1443 | return GNUNET_ntohll (uri->data.chk.file_length); | 1443 | return GNUNET_ntohll (uri->data.chk.file_length); |
1444 | case loc: | 1444 | case GNUNET_FS_URI_LOC: |
1445 | return GNUNET_ntohll (uri->data.loc.fi.file_length); | 1445 | return GNUNET_ntohll (uri->data.loc.fi.file_length); |
1446 | default: | 1446 | default: |
1447 | GNUNET_assert (0); | 1447 | GNUNET_assert (0); |
@@ -1459,7 +1459,7 @@ GNUNET_FS_uri_chk_get_file_size (const struct GNUNET_FS_Uri * uri) | |||
1459 | int | 1459 | int |
1460 | GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri) | 1460 | GNUNET_FS_uri_test_loc (const struct GNUNET_FS_Uri *uri) |
1461 | { | 1461 | { |
1462 | return uri->type == loc; | 1462 | return uri->type == GNUNET_FS_URI_LOC; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | 1465 | ||
@@ -1806,7 +1806,7 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData | |||
1806 | if (md == NULL) | 1806 | if (md == NULL) |
1807 | return NULL; | 1807 | return NULL; |
1808 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); | 1808 | ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); |
1809 | ret->type = ksk; | 1809 | ret->type = GNUNET_FS_URI_KSK; |
1810 | ent = GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL); | 1810 | ent = GNUNET_CONTAINER_meta_data_iterate (md, NULL, NULL); |
1811 | if (ent > 0) | 1811 | if (ent > 0) |
1812 | { | 1812 | { |
@@ -1871,7 +1871,7 @@ uri_ksk_to_string (const struct GNUNET_FS_Uri *uri) | |||
1871 | size_t slen; | 1871 | size_t slen; |
1872 | const char *keyword; | 1872 | const char *keyword; |
1873 | 1873 | ||
1874 | if (uri->type != ksk) | 1874 | if (uri->type != GNUNET_FS_URI_KSK) |
1875 | return NULL; | 1875 | return NULL; |
1876 | keywords = uri->data.ksk.keywords; | 1876 | keywords = uri->data.ksk.keywords; |
1877 | keywordCount = uri->data.ksk.keywordCount; | 1877 | keywordCount = uri->data.ksk.keywordCount; |
@@ -1936,7 +1936,7 @@ uri_sks_to_string (const struct GNUNET_FS_Uri *uri) | |||
1936 | char *ret; | 1936 | char *ret; |
1937 | struct GNUNET_CRYPTO_HashAsciiEncoded nsasc; | 1937 | struct GNUNET_CRYPTO_HashAsciiEncoded nsasc; |
1938 | 1938 | ||
1939 | if (uri->type != sks) | 1939 | if (uri->type != GNUNET_FS_URI_SKS) |
1940 | return NULL; | 1940 | return NULL; |
1941 | ns = &uri->data.sks.ns; | 1941 | ns = &uri->data.sks.ns; |
1942 | identifier = uri->data.sks.identifier; | 1942 | identifier = uri->data.sks.identifier; |
@@ -1961,7 +1961,7 @@ uri_chk_to_string (const struct GNUNET_FS_Uri *uri) | |||
1961 | struct GNUNET_CRYPTO_HashAsciiEncoded keyhash; | 1961 | struct GNUNET_CRYPTO_HashAsciiEncoded keyhash; |
1962 | struct GNUNET_CRYPTO_HashAsciiEncoded queryhash; | 1962 | struct GNUNET_CRYPTO_HashAsciiEncoded queryhash; |
1963 | 1963 | ||
1964 | if (uri->type != chk) | 1964 | if (uri->type != GNUNET_FS_URI_CHK) |
1965 | return NULL; | 1965 | return NULL; |
1966 | fi = &uri->data.chk; | 1966 | fi = &uri->data.chk; |
1967 | GNUNET_CRYPTO_hash_to_enc (&fi->chk.key, &keyhash); | 1967 | GNUNET_CRYPTO_hash_to_enc (&fi->chk.key, &keyhash); |
@@ -2040,10 +2040,10 @@ uri_loc_to_string (const struct GNUNET_FS_Uri *uri) | |||
2040 | GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.query, &queryhash); | 2040 | GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.query, &queryhash); |
2041 | peerId = | 2041 | peerId = |
2042 | bin2enc (&uri->data.loc.peer, | 2042 | bin2enc (&uri->data.loc.peer, |
2043 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | 2043 | sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)); |
2044 | peerSig = | 2044 | peerSig = |
2045 | bin2enc (&uri->data.loc.contentSignature, | 2045 | bin2enc (&uri->data.loc.contentSignature, |
2046 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 2046 | sizeof (struct GNUNET_CRYPTO_EccSignature)); |
2047 | GNUNET_asprintf (&ret, "%s%s%s.%s.%llu.%s.%s.%llu", GNUNET_FS_URI_PREFIX, | 2047 | GNUNET_asprintf (&ret, "%s%s%s.%s.%llu.%s.%s.%llu", GNUNET_FS_URI_PREFIX, |
2048 | GNUNET_FS_URI_LOC_INFIX, (const char *) &keyhash, | 2048 | GNUNET_FS_URI_LOC_INFIX, (const char *) &keyhash, |
2049 | (const char *) &queryhash, | 2049 | (const char *) &queryhash, |
@@ -2073,13 +2073,13 @@ GNUNET_FS_uri_to_string (const struct GNUNET_FS_Uri *uri) | |||
2073 | } | 2073 | } |
2074 | switch (uri->type) | 2074 | switch (uri->type) |
2075 | { | 2075 | { |
2076 | case ksk: | 2076 | case GNUNET_FS_URI_KSK: |
2077 | return uri_ksk_to_string (uri); | 2077 | return uri_ksk_to_string (uri); |
2078 | case sks: | 2078 | case GNUNET_FS_URI_SKS: |
2079 | return uri_sks_to_string (uri); | 2079 | return uri_sks_to_string (uri); |
2080 | case chk: | 2080 | case GNUNET_FS_URI_CHK: |
2081 | return uri_chk_to_string (uri); | 2081 | return uri_chk_to_string (uri); |
2082 | case loc: | 2082 | case GNUNET_FS_URI_LOC: |
2083 | return uri_loc_to_string (uri); | 2083 | return uri_loc_to_string (uri); |
2084 | default: | 2084 | default: |
2085 | GNUNET_break (0); | 2085 | GNUNET_break (0); |