diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-03-05 16:10:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-03-05 16:10:55 +0000 |
commit | 2a23e57e4216593e83e7235e23988564825e4229 (patch) | |
tree | 89cdee0dd816e722214f76f4b9762140416ade20 /src/include | |
parent | dfeb2b787f31255761a808007779c6e992c47591 (diff) | |
download | gnunet-2a23e57e4216593e83e7235e23988564825e4229.tar.gz gnunet-2a23e57e4216593e83e7235e23988564825e4229.zip |
starting major change towards implementing #2564, this breaks some FS tests and FS APIs
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/block_fs.h | 98 | ||||
-rw-r--r-- | src/include/gnunet_block_lib.h | 102 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 121 | ||||
-rw-r--r-- | src/include/gnunet_pseudonym_lib.h | 271 | ||||
-rw-r--r-- | src/include/gnunet_signatures.h | 12 |
5 files changed, 320 insertions, 284 deletions
diff --git a/src/include/block_fs.h b/src/include/block_fs.h index 0b77adc49..6f37dcf0e 100644 --- a/src/include/block_fs.h +++ b/src/include/block_fs.h | |||
@@ -28,119 +28,49 @@ | |||
28 | 28 | ||
29 | #include "gnunet_util_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | 30 | ||
31 | /** | ||
32 | * @brief keyword block (advertising data under a keyword) | ||
33 | */ | ||
34 | struct KBlock | ||
35 | { | ||
36 | |||
37 | /** | ||
38 | * GNUNET_RSA_Signature using RSA-key generated from search keyword. | ||
39 | */ | ||
40 | struct GNUNET_CRYPTO_RsaSignature signature; | ||
41 | |||
42 | /** | ||
43 | * What is being signed and why? | ||
44 | */ | ||
45 | struct GNUNET_CRYPTO_RsaSignaturePurpose purpose; | ||
46 | |||
47 | /** | ||
48 | * Key generated (!) from the H(keyword) as the seed! | ||
49 | */ | ||
50 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace; | ||
51 | |||
52 | /* 0-terminated URI here */ | ||
53 | |||
54 | /* variable-size Meta-Data follows here */ | ||
55 | |||
56 | }; | ||
57 | |||
58 | 31 | ||
59 | /** | 32 | /** |
60 | * @brief namespace content block (advertising data under an identifier in a namespace) | 33 | * Maximum legal size for a ublock. |
61 | */ | 34 | */ |
62 | struct SBlock | 35 | #define MAX_UBLOCK_SIZE (60 * 1024) |
63 | { | ||
64 | 36 | ||
65 | /** | ||
66 | * GNUNET_RSA_Signature using RSA-key of the namespace | ||
67 | */ | ||
68 | struct GNUNET_CRYPTO_RsaSignature signature; | ||
69 | 37 | ||
70 | /** | ||
71 | * What is being signed and why? | ||
72 | */ | ||
73 | struct GNUNET_CRYPTO_RsaSignaturePurpose purpose; | ||
74 | |||
75 | /** | ||
76 | * Hash of the hash of the human-readable identifier used for | ||
77 | * this entry (the hash of the human-readable identifier is | ||
78 | * used as the key for decryption; the xor of this identifier | ||
79 | * and the hash of the "keyspace" is the datastore-query hash). | ||
80 | */ | ||
81 | struct GNUNET_HashCode identifier; | ||
82 | |||
83 | /** | ||
84 | * Public key of the namespace. | ||
85 | */ | ||
86 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace; | ||
87 | |||
88 | /* 0-terminated update-identifier here */ | ||
89 | |||
90 | /* 0-terminated URI here (except for NBlocks) */ | ||
91 | |||
92 | /* variable-size Meta-Data follows here */ | ||
93 | |||
94 | }; | ||
95 | 38 | ||
39 | GNUNET_NETWORK_STRUCT_BEGIN | ||
96 | 40 | ||
97 | /** | 41 | /** |
98 | * @brief namespace advertisement block (advertising root of a namespace) | 42 | * @brief universal block for keyword and namespace search results |
99 | */ | 43 | */ |
100 | struct NBlock | 44 | struct UBlock |
101 | { | 45 | { |
102 | 46 | ||
103 | /** | 47 | /** |
104 | * GNUNET_RSA_Signature using RSA-key generated from search keyword. | 48 | * Signature using pseudonym and search keyword / identifier. |
105 | */ | 49 | */ |
106 | struct GNUNET_CRYPTO_RsaSignature ksk_signature; | 50 | struct GNUNET_PseudonymSignature signature; |
107 | 51 | ||
108 | /** | 52 | /** |
109 | * What is being signed and why? | 53 | * What is being signed and why? |
110 | */ | 54 | */ |
111 | struct GNUNET_CRYPTO_RsaSignaturePurpose ksk_purpose; | 55 | struct GNUNET_PseudonymSignaturePurpose purpose; |
112 | 56 | ||
113 | /** | 57 | /** |
114 | * Key generated (!) from the H(keyword) as the seed! | 58 | * Public key used to sign this block. Hash of this value |
59 | * is the query. | ||
115 | */ | 60 | */ |
116 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace; | 61 | struct GNUNET_PseudonymIdentifier verification_key; |
117 | 62 | ||
118 | /** | 63 | /* rest of the data is encrypted */ |
119 | * GNUNET_RSA_Signature using RSA-key of the namespace | ||
120 | */ | ||
121 | struct GNUNET_CRYPTO_RsaSignature ns_signature; | ||
122 | |||
123 | /** | ||
124 | * What is being signed and why? | ||
125 | */ | ||
126 | struct GNUNET_CRYPTO_RsaSignaturePurpose ns_purpose; | ||
127 | 64 | ||
128 | /** | 65 | /* 0-terminated update-identifier here (ignored for keyword results) */ |
129 | * Public key of the namespace. | ||
130 | */ | ||
131 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace; | ||
132 | |||
133 | /* from here on, data is encrypted with H(keyword) */ | ||
134 | 66 | ||
135 | /* 0-terminated root identifier here */ | 67 | /* 0-terminated URI here */ |
136 | 68 | ||
137 | /* variable-size Meta-Data follows here */ | 69 | /* variable-size Meta-Data follows here */ |
138 | 70 | ||
139 | }; | 71 | }; |
140 | 72 | ||
141 | 73 | ||
142 | GNUNET_NETWORK_STRUCT_BEGIN | ||
143 | |||
144 | /** | 74 | /** |
145 | * @brief index block (indexing a DBlock that | 75 | * @brief index block (indexing a DBlock that |
146 | * can be obtained directly from reading | 76 | * can be obtained directly from reading |
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h index 002d5c11b..ac9d9d5f8 100644 --- a/src/include/gnunet_block_lib.h +++ b/src/include/gnunet_block_lib.h | |||
@@ -41,15 +41,15 @@ extern "C" | |||
41 | */ | 41 | */ |
42 | enum GNUNET_BLOCK_Type | 42 | enum GNUNET_BLOCK_Type |
43 | { | 43 | { |
44 | /** | 44 | /** |
45 | * Any type of block, used as a wildcard when searching. Should | 45 | * Any type of block, used as a wildcard when searching. Should |
46 | * never be attached to a specific block. | 46 | * never be attached to a specific block. |
47 | */ | 47 | */ |
48 | GNUNET_BLOCK_TYPE_ANY = 0, | 48 | GNUNET_BLOCK_TYPE_ANY = 0, |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Data block (leaf) in the CHK tree. | 51 | * Data block (leaf) in the CHK tree. |
52 | */ | 52 | */ |
53 | GNUNET_BLOCK_TYPE_FS_DBLOCK = 1, | 53 | GNUNET_BLOCK_TYPE_FS_DBLOCK = 1, |
54 | 54 | ||
55 | /** | 55 | /** |
@@ -57,67 +57,73 @@ enum GNUNET_BLOCK_Type | |||
57 | */ | 57 | */ |
58 | GNUNET_BLOCK_TYPE_FS_IBLOCK = 2, | 58 | GNUNET_BLOCK_TYPE_FS_IBLOCK = 2, |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Type of a block representing a keyword search result. Note that | 61 | * Legacy type, no longer in use. |
62 | * the values for KBLOCK, SBLOCK and NBLOCK must be consecutive. | 62 | */ |
63 | */ | ||
64 | GNUNET_BLOCK_TYPE_FS_KBLOCK = 3, | 63 | GNUNET_BLOCK_TYPE_FS_KBLOCK = 3, |
65 | 64 | ||
66 | /** | 65 | /** |
67 | * Type of a block that is used to advertise content in a namespace. | 66 | * Legacy type, no longer in use. |
68 | */ | 67 | */ |
69 | GNUNET_BLOCK_TYPE_FS_SBLOCK = 4, | 68 | GNUNET_BLOCK_TYPE_FS_SBLOCK = 4, |
70 | 69 | ||
71 | /** | 70 | /** |
72 | * Type of a block that is used to advertise a namespace. | 71 | * Legacy type, no longer in use. |
73 | */ | 72 | */ |
74 | GNUNET_BLOCK_TYPE_FS_NBLOCK = 5, | 73 | GNUNET_BLOCK_TYPE_FS_NBLOCK = 5, |
75 | 74 | ||
76 | /** | 75 | /** |
77 | * Type of a block representing a block to be encoded on demand from disk. | 76 | * Type of a block representing a block to be encoded on demand from disk. |
78 | * Should never appear on the network directly. | 77 | * Should never appear on the network directly. |
79 | */ | 78 | */ |
80 | GNUNET_BLOCK_TYPE_FS_ONDEMAND = 6, | 79 | GNUNET_BLOCK_TYPE_FS_ONDEMAND = 6, |
81 | 80 | ||
82 | /** | 81 | /** |
83 | * Type of a block that contains a HELLO for a peer (for | 82 | * Type of a block that contains a HELLO for a peer (for |
84 | * DHT find-peer operations). | 83 | * DHT find-peer operations). |
85 | */ | 84 | */ |
86 | GNUNET_BLOCK_TYPE_DHT_HELLO = 7, | 85 | GNUNET_BLOCK_TYPE_DHT_HELLO = 7, |
87 | 86 | ||
88 | /** | 87 | /** |
89 | * Block for testing. | 88 | * Block for testing. |
90 | */ | 89 | */ |
91 | GNUNET_BLOCK_TYPE_TEST = 8, | 90 | GNUNET_BLOCK_TYPE_TEST = 8, |
92 | 91 | ||
93 | /** | 92 | /** |
94 | * Block for storing .gnunet-domains | 93 | * Type of a block representing any type of search result |
95 | */ | 94 | * (universal). Implemented in the context of #2564, replaces |
95 | * SBLOCKS, KBLOCKS and NBLOCKS. | ||
96 | */ | ||
97 | GNUNET_BLOCK_TYPE_FS_UBLOCK = 9, | ||
98 | |||
99 | /** | ||
100 | * Block for storing .gnunet-domains | ||
101 | */ | ||
96 | GNUNET_BLOCK_TYPE_DNS = 10, | 102 | GNUNET_BLOCK_TYPE_DNS = 10, |
97 | 103 | ||
98 | /** | 104 | /** |
99 | * Block for storing record data | 105 | * Block for storing record data |
100 | */ | 106 | */ |
101 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11, | 107 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11, |
102 | 108 | ||
103 | /** | 109 | /** |
104 | * Block for storing mesh peers | 110 | * Block for storing mesh peers |
105 | */ | 111 | */ |
106 | GNUNET_BLOCK_TYPE_MESH_PEER = 20, | 112 | GNUNET_BLOCK_TYPE_MESH_PEER = 20, |
107 | 113 | ||
108 | /** | 114 | /** |
109 | * Block for finding peers by type | 115 | * Block for finding peers by type |
110 | */ | 116 | */ |
111 | GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE = 21, | 117 | GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE = 21, |
112 | 118 | ||
113 | /** | 119 | /** |
114 | * Block to store a mesh regex state | 120 | * Block to store a mesh regex state |
115 | */ | 121 | */ |
116 | GNUNET_BLOCK_TYPE_REGEX = 22, | 122 | GNUNET_BLOCK_TYPE_REGEX = 22, |
117 | 123 | ||
118 | /** | 124 | /** |
119 | * Block to store a mesh regex accepting state | 125 | * Block to store a mesh regex accepting state |
120 | */ | 126 | */ |
121 | GNUNET_BLOCK_TYPE_REGEX_ACCEPT = 23 | 127 | GNUNET_BLOCK_TYPE_REGEX_ACCEPT = 23 |
122 | }; | 128 | }; |
123 | 129 | ||
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index efe2cd004..931406e2d 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2004--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 |
@@ -54,8 +54,9 @@ extern "C" | |||
54 | * 6.1.x: with simplified namespace support | 54 | * 6.1.x: with simplified namespace support |
55 | * 9.0.0: CPS-style integrated API | 55 | * 9.0.0: CPS-style integrated API |
56 | * 9.1.1: asynchronous directory scanning | 56 | * 9.1.1: asynchronous directory scanning |
57 | * 9.2.0: unified K-Block and S-block format (#2564) | ||
57 | */ | 58 | */ |
58 | #define GNUNET_FS_VERSION 0x00090103 | 59 | #define GNUNET_FS_VERSION 0x00090200 |
59 | 60 | ||
60 | 61 | ||
61 | /* ******************** URI API *********************** */ | 62 | /* ******************** URI API *********************** */ |
@@ -342,25 +343,26 @@ GNUNET_FS_uri_sks_create (struct GNUNET_FS_Namespace *ns, const char *id, | |||
342 | /** | 343 | /** |
343 | * Create an SKS URI from a namespace ID and an identifier. | 344 | * Create an SKS URI from a namespace ID and an identifier. |
344 | * | 345 | * |
345 | * @param nsid namespace ID | 346 | * @param pseudonym pseudonym to use |
346 | * @param id identifier | 347 | * @param id identifier |
347 | * @return an FS URI for the given namespace and identifier | 348 | * @return an FS URI for the given namespace and identifier |
348 | */ | 349 | */ |
349 | struct GNUNET_FS_Uri * | 350 | struct GNUNET_FS_Uri * |
350 | GNUNET_FS_uri_sks_create_from_nsid (struct GNUNET_HashCode * nsid, const char *id); | 351 | GNUNET_FS_uri_sks_create_from_nsid (struct GNUNET_PseudonymIdentifier *pseudonym, |
352 | const char *id); | ||
351 | 353 | ||
352 | 354 | ||
353 | /** | 355 | /** |
354 | * Get the ID of a namespace from the given | 356 | * Get the public key of a namespace from the given |
355 | * namespace URI. | 357 | * namespace URI. |
356 | * | 358 | * |
357 | * @param uri the uri to get the namespace ID from | 359 | * @param uri the uri to get the namespace ID from |
358 | * @param nsid where to store the ID of the namespace | 360 | * @param pseudonym where to store the public key of the namespace |
359 | * @return GNUNET_OK on success | 361 | * @return GNUNET_OK on success |
360 | */ | 362 | */ |
361 | int | 363 | int |
362 | GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri, | 364 | GNUNET_FS_uri_sks_get_namespace (const struct GNUNET_FS_Uri *uri, |
363 | struct GNUNET_HashCode * nsid); | 365 | struct GNUNET_PseudonymIdentifier *pseudonym); |
364 | 366 | ||
365 | 367 | ||
366 | /** | 368 | /** |
@@ -1403,9 +1405,9 @@ struct GNUNET_FS_ProgressInfo | |||
1403 | const struct GNUNET_CONTAINER_MetaData *meta; | 1405 | const struct GNUNET_CONTAINER_MetaData *meta; |
1404 | 1406 | ||
1405 | /** | 1407 | /** |
1406 | * Hash-identifier for the namespace. | 1408 | * Public key of the namespace. |
1407 | */ | 1409 | */ |
1408 | struct GNUNET_HashCode id; | 1410 | struct GNUNET_PseudonymIdentifier pseudonym; |
1409 | 1411 | ||
1410 | } ns; | 1412 | } ns; |
1411 | 1413 | ||
@@ -2189,60 +2191,6 @@ GNUNET_FS_unindex_stop (struct GNUNET_FS_UnindexContext *uc); | |||
2189 | 2191 | ||
2190 | 2192 | ||
2191 | /** | 2193 | /** |
2192 | * Context for advertising a namespace. | ||
2193 | */ | ||
2194 | struct GNUNET_FS_AdvertisementContext; | ||
2195 | |||
2196 | |||
2197 | /** | ||
2198 | * Publish an advertismement for a namespace. | ||
2199 | * | ||
2200 | * @param h handle to the file sharing subsystem | ||
2201 | * @param ksk_uri keywords to use for advertisment | ||
2202 | * @param ns handle for the namespace that should be advertised | ||
2203 | * @param meta meta-data for the namespace advertisement | ||
2204 | * @param bo block options | ||
2205 | * @param rootEntry name of the root of the namespace | ||
2206 | * @param cont continuation | ||
2207 | * @param cont_cls closure for cont | ||
2208 | * @return NULL on error ('cont' will still be called) | ||
2209 | */ | ||
2210 | struct GNUNET_FS_AdvertisementContext * | ||
2211 | GNUNET_FS_namespace_advertise (struct GNUNET_FS_Handle *h, | ||
2212 | struct GNUNET_FS_Uri *ksk_uri, | ||
2213 | struct GNUNET_FS_Namespace *ns, | ||
2214 | const struct GNUNET_CONTAINER_MetaData *meta, | ||
2215 | const struct GNUNET_FS_BlockOptions *bo, | ||
2216 | const char *rootEntry, | ||
2217 | GNUNET_FS_PublishContinuation cont, | ||
2218 | void *cont_cls); | ||
2219 | |||
2220 | |||
2221 | /** | ||
2222 | * Create an SKS uri that points to the root entry of the namespace, | ||
2223 | * then insert that SKS uri into metadata. | ||
2224 | * | ||
2225 | * @param ns handle for the namespace that should be advertised | ||
2226 | * @param meta meta-data into which namespace advertisement should be inserted | ||
2227 | * @param rootEntry name of the root of the namespace (use NULL to use default) | ||
2228 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | ||
2229 | */ | ||
2230 | int | ||
2231 | GNUNET_FS_namespace_insert_advertisement_into_metadata ( | ||
2232 | struct GNUNET_FS_Namespace *ns, struct GNUNET_CONTAINER_MetaData *meta, | ||
2233 | const char *rootEntry); | ||
2234 | |||
2235 | |||
2236 | /** | ||
2237 | * Abort the namespace advertisement operation. | ||
2238 | * | ||
2239 | * @param ac context of the operation to abort. | ||
2240 | */ | ||
2241 | void | ||
2242 | GNUNET_FS_namespace_advertise_cancel (struct GNUNET_FS_AdvertisementContext *ac); | ||
2243 | |||
2244 | |||
2245 | /** | ||
2246 | * Create a namespace with the given name; if one already | 2194 | * Create a namespace with the given name; if one already |
2247 | * exists, return a handle to the existing namespace. | 2195 | * exists, return a handle to the existing namespace. |
2248 | * | 2196 | * |
@@ -2268,45 +2216,6 @@ GNUNET_FS_namespace_open_existing (struct GNUNET_FS_Handle *h, const char *name) | |||
2268 | 2216 | ||
2269 | 2217 | ||
2270 | /** | 2218 | /** |
2271 | * Context for creating a namespace asynchronously. | ||
2272 | */ | ||
2273 | struct GNUNET_FS_NamespaceCreationContext; | ||
2274 | |||
2275 | /** | ||
2276 | * Function called upon completion of 'GNUNET_FS_namespace_create_start'. | ||
2277 | * | ||
2278 | * @param cls closure | ||
2279 | * @param ns NULL on error, otherwise the namespace (which must be free'd by the callee) | ||
2280 | * @param emsg NULL on success, otherwise an error message | ||
2281 | */ | ||
2282 | typedef void (*GNUNET_FS_NamespaceCreationCallback)(void *cls, | ||
2283 | struct GNUNET_FS_Namespace *ns, const char *emsg); | ||
2284 | |||
2285 | |||
2286 | /** | ||
2287 | * Create a namespace with the given name; if one already | ||
2288 | * exists, return a handle to the existing namespace immediately. | ||
2289 | * Otherwise create a namespace asynchronously. | ||
2290 | * | ||
2291 | * @param h handle to the file sharing subsystem | ||
2292 | * @param name name to use for the namespace | ||
2293 | * @return namespace creation context, NULL on error (i.e. invalid filename) | ||
2294 | */ | ||
2295 | struct GNUNET_FS_NamespaceCreationContext * | ||
2296 | GNUNET_FS_namespace_create_start (struct GNUNET_FS_Handle *h, const char *name, | ||
2297 | GNUNET_FS_NamespaceCreationCallback cont, void *cont_cls); | ||
2298 | |||
2299 | |||
2300 | /** | ||
2301 | * Abort namespace creation. | ||
2302 | * | ||
2303 | * @param ncc namespace creation context to abort | ||
2304 | */ | ||
2305 | void | ||
2306 | GNUNET_FS_namespace_create_stop (struct GNUNET_FS_NamespaceCreationContext *ncc); | ||
2307 | |||
2308 | |||
2309 | /** | ||
2310 | * Rename a local namespace. | 2219 | * Rename a local namespace. |
2311 | * | 2220 | * |
2312 | * @param h handle to the file sharing subsystem | 2221 | * @param h handle to the file sharing subsystem |
@@ -2338,8 +2247,8 @@ GNUNET_FS_namespace_dup (struct GNUNET_FS_Namespace *ns); | |||
2338 | * GNUNET_SYSERR on failure (contents of id remain intact) | 2247 | * GNUNET_SYSERR on failure (contents of id remain intact) |
2339 | */ | 2248 | */ |
2340 | int | 2249 | int |
2341 | GNUNET_FS_namespace_get_public_key_hash (struct GNUNET_FS_Namespace *ns, | 2250 | GNUNET_FS_namespace_get_public_identifier (struct GNUNET_FS_Namespace *ns, |
2342 | struct GNUNET_HashCode *id); | 2251 | struct GNUNET_PseudonymIdentifier *id); |
2343 | 2252 | ||
2344 | 2253 | ||
2345 | /** | 2254 | /** |
@@ -2364,10 +2273,10 @@ GNUNET_FS_namespace_delete (struct GNUNET_FS_Namespace *ns, int freeze); | |||
2364 | * | 2273 | * |
2365 | * @param cls closure | 2274 | * @param cls closure |
2366 | * @param name human-readable identifier of the namespace | 2275 | * @param name human-readable identifier of the namespace |
2367 | * @param id hash identifier for the namespace | 2276 | * @param id identifier for the namespace |
2368 | */ | 2277 | */ |
2369 | typedef void (*GNUNET_FS_NamespaceInfoProcessor) (void *cls, const char *name, | 2278 | typedef void (*GNUNET_FS_NamespaceInfoProcessor) (void *cls, const char *name, |
2370 | const struct GNUNET_HashCode * id); | 2279 | const struct GNUNET_PseudonymIdentifier *id); |
2371 | 2280 | ||
2372 | 2281 | ||
2373 | /** | 2282 | /** |
diff --git a/src/include/gnunet_pseudonym_lib.h b/src/include/gnunet_pseudonym_lib.h index 6ec51b678..11b5cd9e4 100644 --- a/src/include/gnunet_pseudonym_lib.h +++ b/src/include/gnunet_pseudonym_lib.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 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 |
@@ -39,6 +39,166 @@ extern "C" | |||
39 | #include "gnunet_configuration_lib.h" | 39 | #include "gnunet_configuration_lib.h" |
40 | #include "gnunet_container_lib.h" | 40 | #include "gnunet_container_lib.h" |
41 | 41 | ||
42 | |||
43 | /** | ||
44 | * Identifier for a GNUnet pseudonym (the public key). | ||
45 | */ | ||
46 | struct GNUNET_PseudonymIdentifier | ||
47 | { | ||
48 | /** | ||
49 | * The public key of the pseudonym. | ||
50 | */ | ||
51 | char public_key[42]; | ||
52 | }; | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Handle for a pseudonym (private key). | ||
57 | */ | ||
58 | struct GNUNET_PseudonymHandle; | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Signature made with a pseudonym (includes the full public key) | ||
63 | */ | ||
64 | struct GNUNET_PseudonymSignature | ||
65 | { | ||
66 | |||
67 | /** | ||
68 | * Who created the signature? (public key of the signer) | ||
69 | */ | ||
70 | struct GNUNET_PseudonymIdentifier signer; | ||
71 | |||
72 | /** | ||
73 | * Binary signature data, padded with zeros if needed. | ||
74 | */ | ||
75 | char signature[42]; | ||
76 | }; | ||
77 | |||
78 | |||
79 | /** | ||
80 | * Purpose for signature made with a pseudonym. | ||
81 | */ | ||
82 | struct GNUNET_PseudonymSignaturePurpose | ||
83 | { | ||
84 | /** | ||
85 | * How many bytes are being signed (including this header)? | ||
86 | */ | ||
87 | uint32_t size; | ||
88 | |||
89 | /** | ||
90 | * What is the context/purpose of the signature? | ||
91 | */ | ||
92 | uint32_t purpose; | ||
93 | }; | ||
94 | |||
95 | |||
96 | /** | ||
97 | * Create a pseudonym. | ||
98 | * | ||
99 | * @param filename name of the file to use for storage, NULL for in-memory only | ||
100 | * @return handle to the private key of the pseudonym | ||
101 | */ | ||
102 | struct GNUNET_PseudonymHandle * | ||
103 | GNUNET_PSEUDONYM_create (const char *filename); | ||
104 | |||
105 | |||
106 | /** | ||
107 | * Create a pseudonym, from a file that must already exist. | ||
108 | * | ||
109 | * @param filename name of the file to use for storage, NULL for in-memory only | ||
110 | * @return handle to the private key of the pseudonym | ||
111 | */ | ||
112 | struct GNUNET_PseudonymHandle * | ||
113 | GNUNET_PSEUDONYM_create_from_existing_file (const char *filename); | ||
114 | |||
115 | |||
116 | /** | ||
117 | * Get the handle for the 'anonymous' pseudonym shared by all users. | ||
118 | * That pseudonym uses a fixed 'secret' for the private key; this | ||
119 | * construction is useful to make anonymous and pseudonymous APIs | ||
120 | * (and packets) indistinguishable on the network. See #2564. | ||
121 | * | ||
122 | * @return handle to the (non-secret) private key of the 'anonymous' pseudonym | ||
123 | */ | ||
124 | struct GNUNET_PseudonymHandle * | ||
125 | GNUNET_PSEUDONYM_get_anonymous_pseudonym_handle (void); | ||
126 | |||
127 | |||
128 | /** | ||
129 | * Destroy a pseudonym handle. Does NOT remove the private key from | ||
130 | * the disk. | ||
131 | * | ||
132 | * @param ph pseudonym handle to destroy | ||
133 | */ | ||
134 | void | ||
135 | GNUNET_PSEUDONYM_destroy (struct GNUNET_PseudonymHandle *ph); | ||
136 | |||
137 | |||
138 | /** | ||
139 | * Cryptographically sign some data with the pseudonym. | ||
140 | * | ||
141 | * @param ph private key used for signing (corresponds to 'x' in #2564) | ||
142 | * @param purpose data to sign | ||
143 | * @param seed hash of the plaintext of the data that we are signing, | ||
144 | * used for deterministic PRNG for anonymous signing; | ||
145 | * corresponds to 'k' in section 2.7 of #2564 | ||
146 | * @param signing_key modifier to apply to the private key for signing; | ||
147 | * corresponds to 'h' in section 2.3 of #2564. | ||
148 | * @param signature where to store the signature | ||
149 | */ | ||
150 | void | ||
151 | GNUNET_PSEUDONYM_sign (struct GNUNET_PseudonymHandle *ph, | ||
152 | const struct GNUNET_PseudonymSignaturePurpose *purpose, | ||
153 | const struct GNUNET_HashCode *seed, | ||
154 | const struct GNUNET_HashCode *signing_key, | ||
155 | struct GNUNET_PseudonymSignature *signature); | ||
156 | |||
157 | |||
158 | /** | ||
159 | * Given a pseudonym and a signing key, derive the corresponding public | ||
160 | * key that would be used to verify the resulting signature. | ||
161 | * | ||
162 | * @param pseudonym the public key (g^x) | ||
163 | * @param signing_key input to derive 'h' (see section 2.4 of #2564) | ||
164 | * @param verification_key resulting public key to verify the signature | ||
165 | * created from the 'ph' of 'pseudonym' and the 'signing_key'; | ||
166 | * the value stored here can then be given to GNUNET_PSEUDONYM_verify. | ||
167 | */ | ||
168 | void | ||
169 | GNUNET_PSEUDONYM_derive_verification_key (struct GNUNET_PseudonymIdentifier *pseudonym, | ||
170 | const struct GNUNET_HashCode *signing_key, | ||
171 | struct GNUNET_PseudonymIdentifier *verification_key); | ||
172 | |||
173 | |||
174 | /** | ||
175 | * Verify a signature made with a pseudonym. | ||
176 | * | ||
177 | * @param purpose data that was signed | ||
178 | * @param signature signature to verify | ||
179 | * @param verification_key public key to use for checking the signature; | ||
180 | * corresponds to 'g^(x+h)' in section 2.4 of #2564. | ||
181 | * @return GNUNET_OK on success (signature valid, 'pseudonym' set), | ||
182 | * GNUNET_SYSERR if the signature is invalid | ||
183 | */ | ||
184 | int | ||
185 | GNUNET_PSEUDONYM_verify (const struct GNUNET_PseudonymSignaturePurpose *purpose, | ||
186 | const struct GNUNET_PseudonymSignature *signature, | ||
187 | const struct GNUNET_PseudonymIdentifier *verification_key); | ||
188 | |||
189 | |||
190 | /** | ||
191 | * Get the identifier (public key) of a pseudonym. | ||
192 | * | ||
193 | * @param ph pseudonym handle with the private key | ||
194 | * @param pseudonym pseudonym identifier (set based on 'ph') | ||
195 | */ | ||
196 | void | ||
197 | GNUNET_PSEUDONYM_get_identifier (struct GNUNET_PseudonymHandle *ph, | ||
198 | struct GNUNET_PseudonymIdentifier *pseudonym); | ||
199 | |||
200 | |||
201 | |||
42 | /** | 202 | /** |
43 | * Iterator over all known pseudonyms. | 203 | * Iterator over all known pseudonyms. |
44 | * | 204 | * |
@@ -51,23 +211,26 @@ extern "C" | |||
51 | * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort | 211 | * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort |
52 | */ | 212 | */ |
53 | typedef int (*GNUNET_PSEUDONYM_Iterator) (void *cls, | 213 | typedef int (*GNUNET_PSEUDONYM_Iterator) (void *cls, |
54 | const struct GNUNET_HashCode * pseudonym, | 214 | const struct GNUNET_PseudonymIdentifier *pseudonym, |
55 | const char *name, | 215 | const char *name, |
56 | const char *unique_name, | 216 | const char *unique_name, |
57 | const struct GNUNET_CONTAINER_MetaData | 217 | const struct GNUNET_CONTAINER_MetaData *md, |
58 | * md, int rating); | 218 | int32_t rating); |
219 | |||
59 | 220 | ||
60 | /** | 221 | /** |
61 | * Change the ranking of a pseudonym. | 222 | * Change the rank of a pseudonym. |
62 | * | 223 | * |
63 | * @param cfg overall configuration | 224 | * @param cfg overall configuration |
64 | * @param nsid id of the pseudonym | 225 | * @param pseudonym identity of the pseudonym |
65 | * @param delta by how much should the rating be changed? | 226 | * @param delta by how much should the rating be changed? |
66 | * @return new rating of the namespace | 227 | * @return new rating of the pseudonym |
67 | */ | 228 | */ |
68 | int | 229 | int |
69 | GNUNET_PSEUDONYM_rank (const struct GNUNET_CONFIGURATION_Handle *cfg, | 230 | GNUNET_PSEUDONYM_rank (const struct GNUNET_CONFIGURATION_Handle *cfg, |
70 | const struct GNUNET_HashCode * nsid, int delta); | 231 | const struct GNUNET_PseudonymIdentifier *pseudonym, |
232 | int32_t delta); | ||
233 | |||
71 | 234 | ||
72 | /** | 235 | /** |
73 | * Add a pseudonym to the set of known pseudonyms. | 236 | * Add a pseudonym to the set of known pseudonyms. |
@@ -77,10 +240,11 @@ GNUNET_PSEUDONYM_rank (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
77 | * @param cfg overall configuration | 240 | * @param cfg overall configuration |
78 | * @param id the pseudonym identifier | 241 | * @param id the pseudonym identifier |
79 | * @param meta metadata for the pseudonym | 242 | * @param meta metadata for the pseudonym |
243 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | ||
80 | */ | 244 | */ |
81 | void | 245 | int |
82 | GNUNET_PSEUDONYM_add (const struct GNUNET_CONFIGURATION_Handle *cfg, | 246 | GNUNET_PSEUDONYM_add (const struct GNUNET_CONFIGURATION_Handle *cfg, |
83 | const struct GNUNET_HashCode * id, | 247 | const struct GNUNET_PseudonymIdentifier *pseudonym, |
84 | const struct GNUNET_CONTAINER_MetaData *meta); | 248 | const struct GNUNET_CONTAINER_MetaData *meta); |
85 | 249 | ||
86 | 250 | ||
@@ -89,37 +253,51 @@ GNUNET_PSEUDONYM_add (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
89 | * | 253 | * |
90 | * @param cfg overall configuration | 254 | * @param cfg overall configuration |
91 | * @param iterator function to call for each pseudonym | 255 | * @param iterator function to call for each pseudonym |
92 | * @param closure closure for iterator | 256 | * @param iterator_cls closure for iterator |
93 | * @return number of pseudonyms found | 257 | * @return number of pseudonyms found |
94 | */ | 258 | */ |
95 | int | 259 | int |
96 | GNUNET_PSEUDONYM_list_all (const struct GNUNET_CONFIGURATION_Handle *cfg, | 260 | GNUNET_PSEUDONYM_list_all (const struct GNUNET_CONFIGURATION_Handle *cfg, |
97 | GNUNET_PSEUDONYM_Iterator iterator, void *closure); | 261 | GNUNET_PSEUDONYM_Iterator iterator, |
262 | void *iterator_cls); | ||
263 | |||
264 | |||
265 | /** | ||
266 | * Handle for a discovery callback registration. | ||
267 | */ | ||
268 | struct GNUNET_PSEUDONYM_DiscoveryHandle; | ||
269 | |||
98 | 270 | ||
99 | /** | 271 | /** |
100 | * Register callback to be invoked whenever we discover | 272 | * Register callback to be invoked whenever we discover |
101 | * a new pseudonym. | 273 | * a new pseudonym. |
274 | * | ||
275 | * @param cfg our configuration | ||
276 | * @param iterator function to invoke on discovery | ||
277 | * @param iterator_cls closure for iterator | ||
278 | * @return registration handle | ||
102 | */ | 279 | */ |
103 | int | 280 | struct GNUNET_PSEUDONYM_DiscoveryHandle * |
104 | GNUNET_PSEUDONYM_discovery_callback_register (const struct | 281 | GNUNET_PSEUDONYM_discovery_callback_register (const struct GNUNET_CONFIGURATION_Handle *cfg, |
105 | GNUNET_CONFIGURATION_Handle *cfg, | 282 | GNUNET_PSEUDONYM_Iterator iterator, |
106 | GNUNET_PSEUDONYM_Iterator | 283 | void *iterator_cls); |
107 | iterator, void *closure); | 284 | |
108 | 285 | ||
109 | /** | 286 | /** |
110 | * Unregister namespace discovery callback. | 287 | * Unregister pseudonym discovery callback. |
288 | * | ||
289 | * @param dh registration to unregister | ||
111 | */ | 290 | */ |
112 | int | 291 | void |
113 | GNUNET_PSEUDONYM_discovery_callback_unregister (GNUNET_PSEUDONYM_Iterator | 292 | GNUNET_PSEUDONYM_discovery_callback_unregister (struct GNUNET_PSEUDONYM_DiscoveryHandle *dh); |
114 | iterator, void *closure); | 293 | |
115 | 294 | ||
116 | /** | 295 | /** |
117 | * Return unique variant of the namespace name. | 296 | * Return unique variant of the pseudonym name. Use after |
118 | * Use after GNUNET_PSEUDONYM_id_to_name() to make sure | 297 | * GNUNET_PSEUDONYM_id_to_name() to make sure that name is unique. |
119 | * that name is unique. | ||
120 | * | 298 | * |
121 | * @param cfg configuration | 299 | * @param cfg configuration |
122 | * @param nsid cryptographic ID of the namespace | 300 | * @param pseudonym cryptographic ID of the pseudonym |
123 | * @param name name to uniquify | 301 | * @param name name to uniquify |
124 | * @param suffix if not NULL, filled with the suffix value | 302 | * @param suffix if not NULL, filled with the suffix value |
125 | * @return NULL on failure (should never happen), name on success. | 303 | * @return NULL on failure (should never happen), name on success. |
@@ -127,18 +305,20 @@ GNUNET_PSEUDONYM_discovery_callback_unregister (GNUNET_PSEUDONYM_Iterator | |||
127 | */ | 305 | */ |
128 | char * | 306 | char * |
129 | GNUNET_PSEUDONYM_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg, | 307 | GNUNET_PSEUDONYM_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg, |
130 | const struct GNUNET_HashCode * nsid, const char *name, unsigned int *suffix); | 308 | const struct GNUNET_PseudonymIdentifier *pseudonym, |
309 | const char *name, | ||
310 | unsigned int *suffix); | ||
311 | |||
131 | 312 | ||
132 | /** | 313 | /** |
133 | * Get namespace name, metadata and rank | 314 | * Get pseudonym name, metadata and rank. This is a wrapper around |
134 | * This is a wrapper around internal read_info() call, and ensures that | 315 | * internal read_info() call, and ensures that returned data is not |
135 | * returned data is not invalid (not NULL). | 316 | * invalid (not NULL). Writing back information returned by this |
136 | * Writing back information returned by this function will give | 317 | * function will give a name "no-name" to pseudonyms that have no |
137 | * a name "no-name" to pseudonyms that have no name. This side-effect is | 318 | * name. This side-effect is unavoidable, but hardly harmful. |
138 | * unavoidable, but hardly harmful. | ||
139 | * | 319 | * |
140 | * @param cfg configuration | 320 | * @param cfg configuration |
141 | * @param nsid cryptographic ID of the namespace | 321 | * @param pseudonym cryptographic ID of the pseudonym |
142 | * @param ret_meta a location to store metadata pointer. NULL, if metadata | 322 | * @param ret_meta a location to store metadata pointer. NULL, if metadata |
143 | * is not needed. Destroy with GNUNET_CONTAINER_meta_data_destroy(). | 323 | * is not needed. Destroy with GNUNET_CONTAINER_meta_data_destroy(). |
144 | * @param ret_rank a location to store rank. NULL, if rank not needed. | 324 | * @param ret_rank a location to store rank. NULL, if rank not needed. |
@@ -152,27 +332,32 @@ GNUNET_PSEUDONYM_name_uniquify (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
152 | */ | 332 | */ |
153 | int | 333 | int |
154 | GNUNET_PSEUDONYM_get_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | 334 | GNUNET_PSEUDONYM_get_info (const struct GNUNET_CONFIGURATION_Handle *cfg, |
155 | const struct GNUNET_HashCode * nsid, struct GNUNET_CONTAINER_MetaData **ret_meta, | 335 | const struct GNUNET_PseudonymIdentifier *pseudonym, |
156 | int32_t *ret_rank, char **ret_name, int *name_is_a_dup); | 336 | struct GNUNET_CONTAINER_MetaData **ret_meta, |
337 | int32_t *ret_rank, | ||
338 | char **ret_name, | ||
339 | int *name_is_a_dup); | ||
157 | 340 | ||
158 | 341 | ||
159 | /** | 342 | /** |
160 | * Get the namespace ID belonging to the given namespace name. | 343 | * Get the pseudonym ID belonging to the given pseudonym name. |
161 | * | 344 | * |
162 | * @param cfg configuration to use | 345 | * @param cfg configuration to use |
163 | * @param ns_uname unique (!) human-readable name for the namespace | 346 | * @param ps_uname unique (!) human-readable name for the pseudonym |
164 | * @param nsid set to namespace ID based on 'ns_uname' | 347 | * @param pseudonym set to pseudonym ID based on 'ns_uname' |
165 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 348 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
166 | */ | 349 | */ |
167 | int | 350 | int |
168 | GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, | 351 | GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, |
169 | const char *ns_uname, struct GNUNET_HashCode * nsid); | 352 | const char *ps_uname, |
353 | struct GNUNET_PseudonymIdentifier *pseudonym); | ||
354 | |||
170 | 355 | ||
171 | /** | 356 | /** |
172 | * Set the pseudonym metadata, rank and name. | 357 | * Set the pseudonym metadata, rank and name. |
173 | * | 358 | * |
174 | * @param cfg overall configuration | 359 | * @param cfg overall configuration |
175 | * @param nsid id of the pseudonym | 360 | * @param pseudonym id of the pseudonym |
176 | * @param name name to set. Must be the non-unique version of it. | 361 | * @param name name to set. Must be the non-unique version of it. |
177 | * May be NULL, in which case it erases pseudonym's name! | 362 | * May be NULL, in which case it erases pseudonym's name! |
178 | * @param md metadata to set | 363 | * @param md metadata to set |
@@ -182,8 +367,10 @@ GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
182 | */ | 367 | */ |
183 | int | 368 | int |
184 | GNUNET_PSEUDONYM_set_info (const struct GNUNET_CONFIGURATION_Handle *cfg, | 369 | GNUNET_PSEUDONYM_set_info (const struct GNUNET_CONFIGURATION_Handle *cfg, |
185 | const struct GNUNET_HashCode * nsid, const char *name, | 370 | const struct GNUNET_PseudonymIdentifier *pseudonym, |
186 | const struct GNUNET_CONTAINER_MetaData *md, int rank); | 371 | const char *name, |
372 | const struct GNUNET_CONTAINER_MetaData *md, | ||
373 | int32_t rank); | ||
187 | 374 | ||
188 | 375 | ||
189 | #if 0 /* keep Emacsens' auto-indent happy */ | 376 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h index 2a2ba4755..a821a74df 100644 --- a/src/include/gnunet_signatures.h +++ b/src/include/gnunet_signatures.h | |||
@@ -66,22 +66,22 @@ extern "C" | |||
66 | #define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT 5 | 66 | #define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT 5 |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Signature in a KBlock of the FS module. | 69 | * Obsolete, legacy value. |
70 | */ | 70 | */ |
71 | #define GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK 6 | 71 | #define GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK 6 |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Signature of content URI placed into a namespace. | 74 | * Obsolete, legacy value. |
75 | */ | 75 | */ |
76 | #define GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK 7 | 76 | #define GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK 7 |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Signature of advertisment for a namespace. | 79 | * Obsolete, legacy value. |
80 | */ | 80 | */ |
81 | #define GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK 8 | 81 | #define GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK 8 |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Keyword-based signature of advertisment for a namespace. | 84 | * Obsolete, legacy value. |
85 | */ | 85 | */ |
86 | #define GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG 9 | 86 | #define GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG 9 |
87 | 87 | ||
@@ -121,6 +121,10 @@ extern "C" | |||
121 | #define GNUNET_SIGNATURE_PURPOSE_SET_ECC_KEY 16 | 121 | #define GNUNET_SIGNATURE_PURPOSE_SET_ECC_KEY 16 |
122 | 122 | ||
123 | 123 | ||
124 | /** | ||
125 | * UBlock Signature, done using DSS, not ECC | ||
126 | */ | ||
127 | #define GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK 17 | ||
124 | 128 | ||
125 | #if 0 /* keep Emacsens' auto-indent happy */ | 129 | #if 0 /* keep Emacsens' auto-indent happy */ |
126 | { | 130 | { |