diff options
Diffstat (limited to 'src/include/gnunet_fs_service.h')
-rw-r--r-- | src/include/gnunet_fs_service.h | 375 |
1 files changed, 29 insertions, 346 deletions
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index afe53b0e0..5dcee17cd 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -26,7 +26,6 @@ | |||
26 | #define GNUNET_FS_LIB_H | 26 | #define GNUNET_FS_LIB_H |
27 | 27 | ||
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_scheduler_lib.h" | ||
30 | 29 | ||
31 | #ifdef __cplusplus | 30 | #ifdef __cplusplus |
32 | extern "C" | 31 | extern "C" |
@@ -81,78 +80,6 @@ struct GNUNET_FS_Uri; | |||
81 | 80 | ||
82 | 81 | ||
83 | /** | 82 | /** |
84 | * Identifier for a GNUnet pseudonym (the public key). Q-point, Q=dP. | ||
85 | * Note that we (ab)use an identifier of 'Q=G=1P' to mean the | ||
86 | * 'anonymous' pseudonym. | ||
87 | */ | ||
88 | struct GNUNET_FS_PseudonymIdentifier | ||
89 | { | ||
90 | /** | ||
91 | * Q consists of an x- and a y-value, each mod p (256 bits), | ||
92 | * given here in affine coordinates. | ||
93 | */ | ||
94 | unsigned char q_x[256 / 8]; | ||
95 | |||
96 | /** | ||
97 | * Q consists of an x- and a y-value, each mod p (256 bits), | ||
98 | * given here in affine coordinates. | ||
99 | */ | ||
100 | unsigned char q_y[256 / 8]; | ||
101 | |||
102 | }; | ||
103 | |||
104 | |||
105 | /** | ||
106 | * Handle for a pseudonym (private key). | ||
107 | */ | ||
108 | struct GNUNET_FS_PseudonymHandle; | ||
109 | |||
110 | |||
111 | /** | ||
112 | * Signature made with a pseudonym (includes the full public key). | ||
113 | * The ECDSA signature is a pair (r,s) with r = x1 mod n where | ||
114 | * (x1,y1) = kG for "random" k and s = k^{-1}(z + rd) mod n, | ||
115 | * where z is derived from the hash of the message that is being | ||
116 | * signed. | ||
117 | */ | ||
118 | struct GNUNET_FS_PseudonymSignature | ||
119 | { | ||
120 | |||
121 | /** | ||
122 | * Who created the signature? (public key of the signer), 'd' value in NIST P-256. | ||
123 | */ | ||
124 | struct GNUNET_FS_PseudonymIdentifier signer; | ||
125 | |||
126 | /** | ||
127 | * Binary ECDSA signature data, r-value. Value is mod n, and n is 256 bits. | ||
128 | */ | ||
129 | unsigned char sig_r[256 / 8]; | ||
130 | |||
131 | /** | ||
132 | * Binary ECDSA signature data, s-value. Value is mod n, and n is 256 bits. | ||
133 | */ | ||
134 | unsigned char sig_s[256 / 8]; | ||
135 | }; | ||
136 | |||
137 | |||
138 | /** | ||
139 | * Purpose for signature made with a pseudonym. | ||
140 | */ | ||
141 | struct GNUNET_FS_PseudonymSignaturePurpose | ||
142 | { | ||
143 | /** | ||
144 | * How many bytes are being signed (including this header)? | ||
145 | */ | ||
146 | uint32_t size; | ||
147 | |||
148 | /** | ||
149 | * What is the context/purpose of the signature? | ||
150 | */ | ||
151 | uint32_t purpose; | ||
152 | }; | ||
153 | |||
154 | |||
155 | /** | ||
156 | * Iterator over keywords | 83 | * Iterator over keywords |
157 | * | 84 | * |
158 | * @param cls closure | 85 | * @param cls closure |
@@ -165,120 +92,11 @@ typedef int (*GNUNET_FS_KeywordIterator) (void *cls, const char *keyword, | |||
165 | 92 | ||
166 | 93 | ||
167 | 94 | ||
168 | |||
169 | /** | ||
170 | * Create a pseudonym. | ||
171 | * | ||
172 | * @param filename name of the file to use for storage, NULL for in-memory only | ||
173 | * @return handle to the private key of the pseudonym | ||
174 | */ | ||
175 | struct GNUNET_FS_PseudonymHandle * | ||
176 | GNUNET_FS_pseudonym_create (const char *filename); | ||
177 | |||
178 | |||
179 | /** | ||
180 | * Create a pseudonym, from a file that must already exist. | ||
181 | * | ||
182 | * @param filename name of the file to use for storage, NULL for in-memory only | ||
183 | * @return handle to the private key of the pseudonym | ||
184 | */ | ||
185 | struct GNUNET_FS_PseudonymHandle * | ||
186 | GNUNET_FS_pseudonym_create_from_existing_file (const char *filename); | ||
187 | |||
188 | |||
189 | /** | ||
190 | * Get the handle for the 'anonymous' pseudonym shared by all users. | ||
191 | * That pseudonym uses a fixed 'secret' for the private key; this | ||
192 | * construction is useful to make anonymous and pseudonymous APIs | ||
193 | * (and packets) indistinguishable on the network. See #2564. | ||
194 | * | ||
195 | * @return handle to the (non-secret) private key of the 'anonymous' pseudonym | ||
196 | */ | ||
197 | struct GNUNET_FS_PseudonymHandle * | ||
198 | GNUNET_FS_pseudonym_get_anonymous_pseudonym_handle (void); | ||
199 | |||
200 | |||
201 | /** | ||
202 | * Destroy a pseudonym handle. Does NOT remove the private key from | ||
203 | * the disk. | ||
204 | * | ||
205 | * @param ph pseudonym handle to destroy | ||
206 | */ | ||
207 | void | ||
208 | GNUNET_FS_pseudonym_destroy (struct GNUNET_FS_PseudonymHandle *ph); | ||
209 | |||
210 | |||
211 | /** | ||
212 | * Cryptographically sign some data with the pseudonym. | ||
213 | * | ||
214 | * @param ph private key used for signing (corresponds to 'x' in #2564) | ||
215 | * @param purpose data to sign | ||
216 | * @param seed hash of the plaintext of the data that we are signing, | ||
217 | * used for deterministic PRNG for anonymous signing; | ||
218 | * corresponds to 'k' in section 2.7 of #2564 | ||
219 | * @param signing_key modifier to apply to the private key for signing; | ||
220 | * corresponds to 'h' in section 2.3 of #2564. | ||
221 | * @param signature where to store the signature | ||
222 | * @return GNUNET_SYSERR on failure | ||
223 | */ | ||
224 | int | ||
225 | GNUNET_FS_pseudonym_sign (struct GNUNET_FS_PseudonymHandle *ph, | ||
226 | const struct GNUNET_FS_PseudonymSignaturePurpose *purpose, | ||
227 | const struct GNUNET_HashCode *seed, | ||
228 | const struct GNUNET_HashCode *signing_key, | ||
229 | struct GNUNET_FS_PseudonymSignature *signature); | ||
230 | |||
231 | |||
232 | /** | ||
233 | * Given a pseudonym and a signing key, derive the corresponding public | ||
234 | * key that would be used to verify the resulting signature. | ||
235 | * | ||
236 | * @param pseudonym the public key (g^x in DSA, dQ in ECDSA) | ||
237 | * @param signing_key input to derive 'h' (see section 2.4 of #2564) | ||
238 | * @param verification_key resulting public key to verify the signature | ||
239 | * created from the 'ph' of 'pseudonym' and the 'signing_key'; | ||
240 | * the value stored here can then be given to GNUNET_FS_pseudonym_verify. | ||
241 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | ||
242 | */ | ||
243 | int | ||
244 | GNUNET_FS_pseudonym_derive_verification_key (struct GNUNET_FS_PseudonymIdentifier *pseudonym, | ||
245 | const struct GNUNET_HashCode *signing_key, | ||
246 | struct GNUNET_FS_PseudonymIdentifier *verification_key); | ||
247 | |||
248 | |||
249 | /** | ||
250 | * Verify a signature made with a pseudonym. | ||
251 | * | ||
252 | * @param purpose data that was signed | ||
253 | * @param signature signature to verify | ||
254 | * @param verification_key public key to use for checking the signature; | ||
255 | * corresponds to 'g^(x+h)' in section 2.4 of #2564. | ||
256 | * @return GNUNET_OK on success (signature valid, 'pseudonym' set), | ||
257 | * GNUNET_SYSERR if the signature is invalid | ||
258 | */ | ||
259 | int | ||
260 | GNUNET_FS_pseudonym_verify (const struct GNUNET_FS_PseudonymSignaturePurpose *purpose, | ||
261 | const struct GNUNET_FS_PseudonymSignature *signature, | ||
262 | const struct GNUNET_FS_PseudonymIdentifier *verification_key); | ||
263 | |||
264 | |||
265 | /** | ||
266 | * Get the identifier (public key) of a pseudonym. | ||
267 | * | ||
268 | * @param ph pseudonym handle with the private key | ||
269 | * @param pseudonym pseudonym identifier (set based on 'ph') | ||
270 | */ | ||
271 | void | ||
272 | GNUNET_FS_pseudonym_get_identifier (struct GNUNET_FS_PseudonymHandle *ph, | ||
273 | struct GNUNET_FS_PseudonymIdentifier *pseudonym); | ||
274 | |||
275 | |||
276 | |||
277 | /** | 95 | /** |
278 | * Iterator over all known pseudonyms. | 96 | * Iterator over all known pseudonyms. |
279 | * | 97 | * |
280 | * @param cls closure | 98 | * @param cls closure |
281 | * @param pseudonym hash code of public key of pseudonym | 99 | * @param pseudonym public key of pseudonym |
282 | * @param name name of the pseudonym (might be NULL) | 100 | * @param name name of the pseudonym (might be NULL) |
283 | * @param unique_name unique name of the pseudonym (might be NULL) | 101 | * @param unique_name unique name of the pseudonym (might be NULL) |
284 | * @param md meta data known about the pseudonym | 102 | * @param md meta data known about the pseudonym |
@@ -286,11 +104,11 @@ GNUNET_FS_pseudonym_get_identifier (struct GNUNET_FS_PseudonymHandle *ph, | |||
286 | * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort | 104 | * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort |
287 | */ | 105 | */ |
288 | typedef int (*GNUNET_FS_PseudonymIterator) (void *cls, | 106 | typedef int (*GNUNET_FS_PseudonymIterator) (void *cls, |
289 | const struct GNUNET_FS_PseudonymIdentifier *pseudonym, | 107 | const struct GNUNET_CRYPTO_EccPublicKey *pseudonym, |
290 | const char *name, | 108 | const char *name, |
291 | const char *unique_name, | 109 | const char *unique_name, |
292 | const struct GNUNET_CONTAINER_MetaData *md, | 110 | const struct GNUNET_CONTAINER_MetaData *md, |
293 | int32_t rating); | 111 | int32_t rating); |
294 | 112 | ||
295 | 113 | ||
296 | /** | 114 | /** |
@@ -303,7 +121,7 @@ typedef int (*GNUNET_FS_PseudonymIterator) (void *cls, | |||
303 | */ | 121 | */ |
304 | int | 122 | int |
305 | GNUNET_FS_pseudonym_rank (const struct GNUNET_CONFIGURATION_Handle *cfg, | 123 | GNUNET_FS_pseudonym_rank (const struct GNUNET_CONFIGURATION_Handle *cfg, |
306 | const struct GNUNET_FS_PseudonymIdentifier *pseudonym, | 124 | const struct GNUNET_CRYPTO_EccPublicKey *pseudonym, |
307 | int32_t delta); | 125 | int32_t delta); |
308 | 126 | ||
309 | 127 | ||
@@ -319,7 +137,7 @@ GNUNET_FS_pseudonym_rank (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
319 | */ | 137 | */ |
320 | int | 138 | int |
321 | GNUNET_FS_pseudonym_add (const struct GNUNET_CONFIGURATION_Handle *cfg, | 139 | GNUNET_FS_pseudonym_add (const struct GNUNET_CONFIGURATION_Handle *cfg, |
322 | const struct GNUNET_FS_PseudonymIdentifier *pseudonym, | 140 | const struct GNUNET_CRYPTO_EccPublicKey *pseudonym, |
323 | const struct GNUNET_CONTAINER_MetaData *meta); | 141 | const struct GNUNET_CONTAINER_MetaData *meta); |
324 | 142 | ||
325 | 143 | ||
@@ -340,7 +158,7 @@ GNUNET_FS_pseudonym_list_all (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
340 | /** | 158 | /** |
341 | * Handle for a discovery callback registration. | 159 | * Handle for a discovery callback registration. |
342 | */ | 160 | */ |
343 | struct GNUNET_FS_pseudonym_DiscoveryHandle; | 161 | struct GNUNET_FS_Pseudonym_DiscoveryHandle; |
344 | 162 | ||
345 | 163 | ||
346 | /** | 164 | /** |
@@ -352,7 +170,7 @@ struct GNUNET_FS_pseudonym_DiscoveryHandle; | |||
352 | * @param iterator_cls closure for iterator | 170 | * @param iterator_cls closure for iterator |
353 | * @return registration handle | 171 | * @return registration handle |
354 | */ | 172 | */ |
355 | struct GNUNET_FS_pseudonym_DiscoveryHandle * | 173 | struct GNUNET_FS_Pseudonym_DiscoveryHandle * |
356 | GNUNET_FS_pseudonym_discovery_callback_register (const struct GNUNET_CONFIGURATION_Handle *cfg, | 174 | GNUNET_FS_pseudonym_discovery_callback_register (const struct GNUNET_CONFIGURATION_Handle *cfg, |
357 | GNUNET_FS_PseudonymIterator iterator, | 175 | GNUNET_FS_PseudonymIterator iterator, |
358 | void *iterator_cls); | 176 | void *iterator_cls); |
@@ -364,7 +182,7 @@ GNUNET_FS_pseudonym_discovery_callback_register (const struct GNUNET_CONFIGURATI | |||
364 | * @param dh registration to unregister | 182 | * @param dh registration to unregister |
365 | */ | 183 | */ |
366 | void | 184 | void |
367 | GNUNET_FS_pseudonym_discovery_callback_unregister (struct GNUNET_FS_pseudonym_DiscoveryHandle *dh); | 185 | GNUNET_FS_pseudonym_discovery_callback_unregister (struct GNUNET_FS_Pseudonym_DiscoveryHandle *dh); |
368 | 186 | ||
369 | 187 | ||
370 | /** | 188 | /** |
@@ -380,7 +198,7 @@ GNUNET_FS_pseudonym_discovery_callback_unregister (struct GNUNET_FS_pseudonym_Di | |||
380 | */ | 198 | */ |
381 | char * | 199 | char * |
382 | GNUNET_FS_pseudonym_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg, | 200 | GNUNET_FS_pseudonym_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg, |
383 | const struct GNUNET_FS_PseudonymIdentifier *pseudonym, | 201 | const struct GNUNET_CRYPTO_EccPublicKey *pseudonym, |
384 | const char *name, | 202 | const char *name, |
385 | unsigned int *suffix); | 203 | unsigned int *suffix); |
386 | 204 | ||
@@ -407,7 +225,7 @@ GNUNET_FS_pseudonym_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg | |||
407 | */ | 225 | */ |
408 | int | 226 | int |
409 | GNUNET_FS_pseudonym_get_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | 227 | GNUNET_FS_pseudonym_get_info (const struct GNUNET_CONFIGURATION_Handle *cfg, |
410 | const struct GNUNET_FS_PseudonymIdentifier *pseudonym, | 228 | const struct GNUNET_CRYPTO_EccPublicKey *pseudonym, |
411 | struct GNUNET_CONTAINER_MetaData **ret_meta, | 229 | struct GNUNET_CONTAINER_MetaData **ret_meta, |
412 | int32_t *ret_rank, | 230 | int32_t *ret_rank, |
413 | char **ret_name, | 231 | char **ret_name, |
@@ -425,7 +243,7 @@ GNUNET_FS_pseudonym_get_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
425 | int | 243 | int |
426 | GNUNET_FS_pseudonym_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, | 244 | GNUNET_FS_pseudonym_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, |
427 | const char *ns_uname, | 245 | const char *ns_uname, |
428 | struct GNUNET_FS_PseudonymIdentifier *pseudonym); | 246 | struct GNUNET_CRYPTO_EccPublicKey *pseudonym); |
429 | 247 | ||
430 | 248 | ||
431 | /** | 249 | /** |
@@ -442,25 +260,13 @@ GNUNET_FS_pseudonym_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
442 | */ | 260 | */ |
443 | int | 261 | int |
444 | GNUNET_FS_pseudonym_set_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | 262 | GNUNET_FS_pseudonym_set_info (const struct GNUNET_CONFIGURATION_Handle *cfg, |
445 | const struct GNUNET_FS_PseudonymIdentifier *pseudonym, | 263 | const struct GNUNET_CRYPTO_EccPublicKey *pseudonym, |
446 | const char *name, | 264 | const char *name, |
447 | const struct GNUNET_CONTAINER_MetaData *md, | 265 | const struct GNUNET_CONTAINER_MetaData *md, |
448 | int32_t rank); | 266 | int32_t rank); |
449 | 267 | ||
450 | 268 | ||
451 | /** | 269 | /** |
452 | * Remove pseudonym from the set of known pseudonyms. | ||
453 | * | ||
454 | * @param cfg overall configuration | ||
455 | * @param id the pseudonym identifier | ||
456 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | ||
457 | */ | ||
458 | int | ||
459 | GNUNET_FS_pseudonym_remove (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
460 | const struct GNUNET_FS_PseudonymIdentifier *id); | ||
461 | |||
462 | |||
463 | /** | ||
464 | * Get a unique key from a URI. This is for putting URIs | 270 | * Get a unique key from a URI. This is for putting URIs |
465 | * into HashMaps. The key may change between FS implementations. | 271 | * into HashMaps. The key may change between FS implementations. |
466 | * | 272 | * |
@@ -468,7 +274,8 @@ GNUNET_FS_pseudonym_remove (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
468 | * @param key wherer to store the unique key | 274 | * @param key wherer to store the unique key |
469 | */ | 275 | */ |
470 | void | 276 | void |
471 | GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, struct GNUNET_HashCode * key); | 277 | GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, |
278 | struct GNUNET_HashCode *key); | ||
472 | 279 | ||
473 | 280 | ||
474 | /** | 281 | /** |
@@ -501,7 +308,8 @@ GNUNET_FS_uri_ksk_to_string_fancy (const struct GNUNET_FS_Uri *uri); | |||
501 | * @param is_mandatory is this keyword mandatory? | 308 | * @param is_mandatory is this keyword mandatory? |
502 | */ | 309 | */ |
503 | void | 310 | void |
504 | GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, const char *keyword, | 311 | GNUNET_FS_uri_ksk_add_keyword (struct GNUNET_FS_Uri *uri, |
312 | const char *keyword, | ||
505 | int is_mandatory); | 313 | int is_mandatory); |
506 | 314 | ||
507 | 315 | ||
@@ -695,34 +503,15 @@ GNUNET_FS_uri_test_sks (const struct GNUNET_FS_Uri *uri); | |||
695 | 503 | ||
696 | 504 | ||
697 | /** | 505 | /** |
698 | * Handle to one of our namespaces. | ||
699 | */ | ||
700 | struct GNUNET_FS_Namespace; | ||
701 | |||
702 | |||
703 | /** | ||
704 | * Create an SKS URI from a namespace and an identifier. | ||
705 | * | ||
706 | * @param ns namespace | ||
707 | * @param id identifier | ||
708 | * @param emsg where to store an error message | ||
709 | * @return an FS URI for the given namespace and identifier | ||
710 | */ | ||
711 | struct GNUNET_FS_Uri * | ||
712 | GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, const char *id, | ||
713 | char **emsg); | ||
714 | |||
715 | |||
716 | /** | ||
717 | * Create an SKS URI from a namespace ID and an identifier. | 506 | * Create an SKS URI from a namespace ID and an identifier. |
718 | * | 507 | * |
719 | * @param pseudonym pseudonym to use | 508 | * @param ns pseudonym to use |
720 | * @param id identifier | 509 | * @param id identifier |
721 | * @return an FS URI for the given namespace and identifier | 510 | * @return an FS URI for the given namespace and identifier |
722 | */ | 511 | */ |
723 | struct GNUNET_FS_Uri * | 512 | struct GNUNET_FS_Uri * |
724 | GNUNET_FS_uri_sks_create_from_nsid (struct GNUNET_FS_PseudonymIdentifier *pseudonym, | 513 | GNUNET_FS_uri_sks_create (const struct GNUNET_CRYPTO_EccPublicKey *ns, |
725 | const char *id); | 514 | const char *id); |
726 | 515 | ||
727 | 516 | ||
728 | /** | 517 | /** |
@@ -735,7 +524,7 @@ GNUNET_FS_uri_sks_create_from_nsid (struct GNUNET_FS_PseudonymIdentifier *pseudo | |||
735 | */ | 524 | */ |
736 | int | 525 | int |
737 | GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri, | 526 | GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri, |
738 | struct GNUNET_FS_PseudonymIdentifier *pseudonym); | 527 | struct GNUNET_CRYPTO_EccPublicKey *pseudonym); |
739 | 528 | ||
740 | 529 | ||
741 | /** | 530 | /** |
@@ -1757,12 +1546,6 @@ struct GNUNET_FS_ProgressInfo | |||
1757 | { | 1546 | { |
1758 | 1547 | ||
1759 | /** | 1548 | /** |
1760 | * Handle to the namespace (NULL if it is not a local | ||
1761 | * namespace). | ||
1762 | */ | ||
1763 | struct GNUNET_FS_Namespace *ns; | ||
1764 | |||
1765 | /** | ||
1766 | * Short, human-readable name of the namespace. | 1549 | * Short, human-readable name of the namespace. |
1767 | */ | 1550 | */ |
1768 | const char *name; | 1551 | const char *name; |
@@ -1780,7 +1563,7 @@ struct GNUNET_FS_ProgressInfo | |||
1780 | /** | 1563 | /** |
1781 | * Public key of the namespace. | 1564 | * Public key of the namespace. |
1782 | */ | 1565 | */ |
1783 | struct GNUNET_FS_PseudonymIdentifier pseudonym; | 1566 | struct GNUNET_CRYPTO_EccPublicKey pseudonym; |
1784 | 1567 | ||
1785 | } ns; | 1568 | } ns; |
1786 | 1569 | ||
@@ -2379,6 +2162,7 @@ enum GNUNET_FS_PublishOptions | |||
2379 | GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY = 1 | 2162 | GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY = 1 |
2380 | }; | 2163 | }; |
2381 | 2164 | ||
2165 | |||
2382 | /** | 2166 | /** |
2383 | * Publish a file or directory. | 2167 | * Publish a file or directory. |
2384 | * | 2168 | * |
@@ -2395,7 +2179,8 @@ enum GNUNET_FS_PublishOptions | |||
2395 | struct GNUNET_FS_PublishContext * | 2179 | struct GNUNET_FS_PublishContext * |
2396 | GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, | 2180 | GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, |
2397 | struct GNUNET_FS_FileInformation *fi, | 2181 | struct GNUNET_FS_FileInformation *fi, |
2398 | struct GNUNET_FS_Namespace *ns, const char *nid, | 2182 | const struct GNUNET_CRYPTO_EccPrivateKey *ns, |
2183 | const char *nid, | ||
2399 | const char *nuid, | 2184 | const char *nuid, |
2400 | enum GNUNET_FS_PublishOptions options); | 2185 | enum GNUNET_FS_PublishOptions options); |
2401 | 2186 | ||
@@ -2421,7 +2206,7 @@ GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc); | |||
2421 | * @param emsg error message, NULL on success | 2206 | * @param emsg error message, NULL on success |
2422 | */ | 2207 | */ |
2423 | typedef void (*GNUNET_FS_PublishContinuation) (void *cls, | 2208 | typedef void (*GNUNET_FS_PublishContinuation) (void *cls, |
2424 | const struct GNUNET_FS_Uri * uri, | 2209 | const struct GNUNET_FS_Uri *uri, |
2425 | const char *emsg); | 2210 | const char *emsg); |
2426 | 2211 | ||
2427 | 2212 | ||
@@ -2486,7 +2271,7 @@ struct GNUNET_FS_PublishSksContext; | |||
2486 | */ | 2271 | */ |
2487 | struct GNUNET_FS_PublishSksContext * | 2272 | struct GNUNET_FS_PublishSksContext * |
2488 | GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, | 2273 | GNUNET_FS_publish_sks (struct GNUNET_FS_Handle *h, |
2489 | struct GNUNET_FS_Namespace *ns, | 2274 | const struct GNUNET_CRYPTO_EccPrivateKey *ns, |
2490 | const char *identifier, const char *update, | 2275 | const char *identifier, const char *update, |
2491 | const struct GNUNET_CONTAINER_MetaData *meta, | 2276 | const struct GNUNET_CONTAINER_MetaData *meta, |
2492 | const struct GNUNET_FS_Uri *uri, | 2277 | const struct GNUNET_FS_Uri *uri, |
@@ -2568,110 +2353,6 @@ GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc); | |||
2568 | 2353 | ||
2569 | 2354 | ||
2570 | /** | 2355 | /** |
2571 | * Create a namespace with the given name; if one already | ||
2572 | * exists, return a handle to the existing namespace. | ||
2573 | * | ||
2574 | * @param h handle to the file sharing subsystem | ||
2575 | * @param name name to use for the namespace | ||
2576 | * @return handle to the namespace, NULL on error (i.e. invalid filename) | ||
2577 | */ | ||
2578 | struct GNUNET_FS_Namespace * | ||
2579 | GNUNET_FS_namespace_create (struct GNUNET_FS_Handle *h, const char *name); | ||
2580 | |||
2581 | |||
2582 | /** | ||
2583 | * Open the namespace with the given name; if it does not exist, | ||
2584 | * or the key file is corrupted, the function fails. | ||
2585 | * | ||
2586 | * @param h handle to the file sharing subsystem | ||
2587 | * @param name name of the namespace | ||
2588 | * @return handle to the namespace, | ||
2589 | * NULL on error (i.e. invalid filename, non-existent filename) | ||
2590 | */ | ||
2591 | struct GNUNET_FS_Namespace * | ||
2592 | GNUNET_FS_namespace_open_existing (struct GNUNET_FS_Handle *h, const char *name); | ||
2593 | |||
2594 | |||
2595 | /** | ||
2596 | * Rename a local namespace. | ||
2597 | * | ||
2598 | * @param h handle to the file sharing subsystem | ||
2599 | * @param old_name old name of the namespace | ||
2600 | * @param new_name new name of the namespace | ||
2601 | * @return GNUNET_OK on success, GNUNET_SYSERR on error (see errno for details) | ||
2602 | */ | ||
2603 | int | ||
2604 | GNUNET_FS_namespace_rename (struct GNUNET_FS_Handle *h, | ||
2605 | const char *old_name, | ||
2606 | const char *new_name); | ||
2607 | |||
2608 | |||
2609 | /** | ||
2610 | * Duplicate a namespace handle. | ||
2611 | * | ||
2612 | * @param ns namespace handle | ||
2613 | * @return duplicated handle to the namespace | ||
2614 | */ | ||
2615 | struct GNUNET_FS_Namespace * | ||
2616 | GNUNET_FS_namespace_dup (struct GNUNET_FS_Namespace *ns); | ||
2617 | |||
2618 | |||
2619 | /** | ||
2620 | * Get hash of the public key of a namespace. | ||
2621 | * | ||
2622 | * @param ns namespace | ||
2623 | * @param id buffer to store the key in | ||
2624 | * @return GNUNET_OK on success | ||
2625 | * GNUNET_SYSERR on failure (contents of id remain intact) | ||
2626 | */ | ||
2627 | int | ||
2628 | GNUNET_FS_namespace_get_public_identifier (struct GNUNET_FS_Namespace *ns, | ||
2629 | struct GNUNET_FS_PseudonymIdentifier *id); | ||
2630 | |||
2631 | |||
2632 | /** | ||
2633 | * Delete a namespace handle. Can be used for a clean shutdown (free | ||
2634 | * memory) or also to freeze the namespace to prevent further | ||
2635 | * insertions by anyone. | ||
2636 | * | ||
2637 | * @param ns handle to the namespace that should be deleted / freed | ||
2638 | * @param freeze prevents future insertions; creating a namespace | ||
2639 | * with the same name again will create a fresh namespace instead | ||
2640 | * | ||
2641 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | ||
2642 | */ | ||
2643 | int | ||
2644 | GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *ns, int freeze); | ||
2645 | |||
2646 | |||
2647 | /** | ||
2648 | * Callback with information about local (!) namespaces. | ||
2649 | * Contains the names of the local namespace and the global | ||
2650 | * ID. | ||
2651 | * | ||
2652 | * @param cls closure | ||
2653 | * @param name human-readable identifier of the namespace | ||
2654 | * @param id identifier for the namespace | ||
2655 | */ | ||
2656 | typedef void (*GNUNET_FS_NamespaceInfoProcessor) (void *cls, const char *name, | ||
2657 | const struct GNUNET_FS_PseudonymIdentifier *id); | ||
2658 | |||
2659 | |||
2660 | /** | ||
2661 | * Build a list of all available local (!) namespaces The returned | ||
2662 | * names are only the nicknames since we only iterate over the local | ||
2663 | * namespaces. | ||
2664 | * | ||
2665 | * @param h handle to the file sharing subsystem | ||
2666 | * @param cb function to call on each known namespace | ||
2667 | * @param cb_cls closure for cb | ||
2668 | */ | ||
2669 | void | ||
2670 | GNUNET_FS_namespace_list (struct GNUNET_FS_Handle *h, | ||
2671 | GNUNET_FS_NamespaceInfoProcessor cb, void *cb_cls); | ||
2672 | |||
2673 | |||
2674 | /** | ||
2675 | * Function called on updateable identifiers. | 2356 | * Function called on updateable identifiers. |
2676 | * | 2357 | * |
2677 | * @param cls closure | 2358 | * @param cls closure |
@@ -2703,13 +2384,15 @@ typedef void (*GNUNET_FS_IdentifierProcessor) (void *cls, const char *last_id, | |||
2703 | * cause the library to call "ip" with all children of the node. Note | 2384 | * cause the library to call "ip" with all children of the node. Note |
2704 | * that cycles within an SCC are possible (including self-loops). | 2385 | * that cycles within an SCC are possible (including self-loops). |
2705 | * | 2386 | * |
2387 | * @param h fs handle to use | ||
2706 | * @param ns namespace to inspect for updateable content | 2388 | * @param ns namespace to inspect for updateable content |
2707 | * @param next_id ID to look for; use NULL to look for SCC roots | 2389 | * @param next_id ID to look for; use NULL to look for SCC roots |
2708 | * @param ip function to call on each updateable identifier | 2390 | * @param ip function to call on each updateable identifier |
2709 | * @param ip_cls closure for ip | 2391 | * @param ip_cls closure for ip |
2710 | */ | 2392 | */ |
2711 | void | 2393 | void |
2712 | GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *ns, | 2394 | GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Handle *h, |
2395 | const struct GNUNET_CRYPTO_EccPrivateKey *ns, | ||
2713 | const char *next_id, | 2396 | const char *next_id, |
2714 | GNUNET_FS_IdentifierProcessor ip, | 2397 | GNUNET_FS_IdentifierProcessor ip, |
2715 | void *ip_cls); | 2398 | void *ip_cls); |