diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2017-09-16 22:39:15 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2017-09-16 22:39:15 +0200 |
commit | 67e0d73709ef557b52ba0527291d68c17fd6c60a (patch) | |
tree | 57dcf9848b436c01c3fc37e3d878445aaf142a4e /src/include | |
parent | d5ec12fdbc288f376ee2ee18aceb00e338191f28 (diff) | |
download | gnunet-67e0d73709ef557b52ba0527291d68c17fd6c60a.tar.gz gnunet-67e0d73709ef557b52ba0527291d68c17fd6c60a.zip |
-various fixes; add attribute list API
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 2 | ||||
-rw-r--r-- | src/include/gnunet_identity_provider_service.h | 108 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 7 |
3 files changed, 106 insertions, 11 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 69f6ce5d4..78d31a9ec 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -2168,7 +2168,7 @@ GNUNET_CRYPTO_cpabe_delete_key (struct GNUNET_CRYPTO_AbeKey *key); | |||
2168 | ssize_t | 2168 | ssize_t |
2169 | GNUNET_CRYPTO_cpabe_encrypt (const void *block, | 2169 | GNUNET_CRYPTO_cpabe_encrypt (const void *block, |
2170 | size_t size, | 2170 | size_t size, |
2171 | char *policy, | 2171 | const char *policy, |
2172 | const struct GNUNET_CRYPTO_AbeMasterKey *key, | 2172 | const struct GNUNET_CRYPTO_AbeMasterKey *key, |
2173 | void **result); | 2173 | void **result); |
2174 | 2174 | ||
diff --git a/src/include/gnunet_identity_provider_service.h b/src/include/gnunet_identity_provider_service.h index 2349e7012..aaa838a03 100644 --- a/src/include/gnunet_identity_provider_service.h +++ b/src/include/gnunet_identity_provider_service.h | |||
@@ -93,11 +93,9 @@ struct GNUNET_IDENTITY_PROVIDER_Attribute | |||
93 | { | 93 | { |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * Binary value stored as attribute value. Note: "data" must never | 96 | * Type of Attribute. |
97 | * be individually 'malloc'ed, but instead always points into some | ||
98 | * existing data area. | ||
99 | */ | 97 | */ |
100 | const void *data; | 98 | uint32_t attribute_type; |
101 | 99 | ||
102 | /** | 100 | /** |
103 | * Number of bytes in @e data. | 101 | * Number of bytes in @e data. |
@@ -105,9 +103,17 @@ struct GNUNET_IDENTITY_PROVIDER_Attribute | |||
105 | size_t data_size; | 103 | size_t data_size; |
106 | 104 | ||
107 | /** | 105 | /** |
108 | * Type of Attribute. | 106 | * The name of the attribute. Note "name" must never be individually |
107 | * free'd | ||
109 | */ | 108 | */ |
110 | uint32_t attribute_type; | 109 | const char* name; |
110 | |||
111 | /** | ||
112 | * Binary value stored as attribute value. Note: "data" must never | ||
113 | * be individually 'malloc'ed, but instead always points into some | ||
114 | * existing data area. | ||
115 | */ | ||
116 | const void *data; | ||
111 | 117 | ||
112 | }; | 118 | }; |
113 | 119 | ||
@@ -176,8 +182,7 @@ typedef void | |||
176 | * | 182 | * |
177 | * @param h handle to the identity provider | 183 | * @param h handle to the identity provider |
178 | * @param pkey private key of the identity | 184 | * @param pkey private key of the identity |
179 | * @param name the attribute name | 185 | * @param attr the attribute |
180 | * @param value the attribute value | ||
181 | * @param cont continuation to call when done | 186 | * @param cont continuation to call when done |
182 | * @param cont_cls closure for @a cont | 187 | * @param cont_cls closure for @a cont |
183 | * @return handle to abort the request | 188 | * @return handle to abort the request |
@@ -185,12 +190,95 @@ typedef void | |||
185 | struct GNUNET_IDENTITY_PROVIDER_Operation * | 190 | struct GNUNET_IDENTITY_PROVIDER_Operation * |
186 | GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 191 | GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle *h, |
187 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 192 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
188 | const char* name, | 193 | const struct GNUNET_IDENTITY_PROVIDER_Attribute *attr, |
189 | const struct GNUNET_IDENTITY_PROVIDER_Attribute *value, | ||
190 | GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cont, | 194 | GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cont, |
191 | void *cont_cls); | 195 | void *cont_cls); |
192 | 196 | ||
193 | 197 | ||
198 | /** | ||
199 | * Create a new attribute. | ||
200 | * | ||
201 | * @param name the attribute name | ||
202 | * @param type the attribute type | ||
203 | * @param data the attribute value | ||
204 | * @param data_size the attribute value size | ||
205 | * @return the new attribute | ||
206 | */ | ||
207 | struct GNUNET_IDENTITY_PROVIDER_Attribute * | ||
208 | GNUNET_IDENTITY_PROVIDER_attribute_new (const char* attr_name, | ||
209 | uint32_t attr_type, | ||
210 | const void* data, | ||
211 | size_t data_size); | ||
212 | |||
213 | /** | ||
214 | * Process an attribute that was stored in the idp. | ||
215 | * | ||
216 | * @param cls closure | ||
217 | * @param attr the attribute | ||
218 | */ | ||
219 | typedef void | ||
220 | (*GNUNET_IDENTITY_PROVIDER_AttributeResult) (void *cls, | ||
221 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | ||
222 | const struct GNUNET_IDENTITY_PROVIDER_Attribute *attr); | ||
223 | |||
224 | |||
225 | |||
226 | /** | ||
227 | * List all attributes for a local identity. | ||
228 | * This MUST lock the `struct GNUNET_IDENTITY_PROVIDER_Handle` | ||
229 | * for any other calls than #GNUNET_IDENTITY_PROVIDER_get_attributes_next() and | ||
230 | * #GNUNET_IDENTITY_PROVIDER_get_attributes_stop. @a proc will be called once | ||
231 | * immediately, and then again after | ||
232 | * #GNUNET_IDENTITY_PROVIDER_get_attributes_next() is invoked. | ||
233 | * | ||
234 | * On error (disconnect), @a error_cb will be invoked. | ||
235 | * On normal completion, @a finish_cb proc will be | ||
236 | * invoked. | ||
237 | * | ||
238 | * @param h handle to the idp | ||
239 | * @param identity identity to access | ||
240 | * @param error_cb function to call on error (i.e. disconnect), | ||
241 | * the handle is afterwards invalid | ||
242 | * @param error_cb_cls closure for @a error_cb | ||
243 | * @param proc function to call on each attribute; it | ||
244 | * will be called repeatedly with a value (if available) | ||
245 | * @param proc_cls closure for @a proc | ||
246 | * @param finish_cb function to call on completion | ||
247 | * the handle is afterwards invalid | ||
248 | * @param finish_cb_cls closure for @a finish_cb | ||
249 | * @return an iterator handle to use for iteration | ||
250 | */ | ||
251 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator * | ||
252 | GNUNET_IDENTITY_PROVIDER_get_attributes_start (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | ||
253 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | ||
254 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
255 | void *error_cb_cls, | ||
256 | GNUNET_IDENTITY_PROVIDER_AttributeResult proc, | ||
257 | void *proc_cls, | ||
258 | GNUNET_SCHEDULER_TaskCallback finish_cb, | ||
259 | void *finish_cb_cls); | ||
260 | |||
261 | |||
262 | /** | ||
263 | * Calls the record processor specified in #GNUNET_IDENTITY_PROVIDER_get_attributes_start | ||
264 | * for the next record. | ||
265 | * | ||
266 | * @param it the iterator | ||
267 | */ | ||
268 | void | ||
269 | GNUNET_IDENTITY_PROVIDER_get_attributes_next (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it); | ||
270 | |||
271 | |||
272 | /** | ||
273 | * Stops iteration and releases the idp handle for further calls. Must | ||
274 | * be called on any iteration that has not yet completed prior to calling | ||
275 | * #GNUNET_IDENTITY_PROVIDER_disconnect. | ||
276 | * | ||
277 | * @param it the iterator | ||
278 | */ | ||
279 | void | ||
280 | GNUNET_IDENTITY_PROVIDER_get_attributes_stop (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it); | ||
281 | |||
194 | 282 | ||
195 | 283 | ||
196 | /** | 284 | /** |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 5841bd4f8..e498af1f5 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -2632,6 +2632,13 @@ extern "C" | |||
2632 | 2632 | ||
2633 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE_RESPONSE 966 | 2633 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE_RESPONSE 966 |
2634 | 2634 | ||
2635 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_START 967 | ||
2636 | |||
2637 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_STOP 968 | ||
2638 | |||
2639 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_NEXT 969 | ||
2640 | |||
2641 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT 970 | ||
2635 | 2642 | ||
2636 | /************************************************** | 2643 | /************************************************** |
2637 | * | 2644 | * |