aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_abe_lib.h193
-rw-r--r--src/include/gnunet_credential_service.h297
-rw-r--r--src/include/gnunet_gnsrecord_lib.h22
-rw-r--r--src/include/gnunet_identity_attribute_lib.h277
-rw-r--r--src/include/gnunet_identity_attribute_plugin.h149
-rw-r--r--src/include/gnunet_identity_provider_plugin.h123
-rw-r--r--src/include/gnunet_identity_provider_service.h333
-rw-r--r--src/include/gnunet_jsonapi_lib.h2
-rw-r--r--src/include/gnunet_protocols.h42
-rw-r--r--src/include/gnunet_rest_lib.h4
-rw-r--r--src/include/gnunet_rest_plugin.h2
-rw-r--r--src/include/gnunet_signatures.h5
12 files changed, 1300 insertions, 149 deletions
diff --git a/src/include/gnunet_abe_lib.h b/src/include/gnunet_abe_lib.h
new file mode 100644
index 000000000..f73ea2431
--- /dev/null
+++ b/src/include/gnunet_abe_lib.h
@@ -0,0 +1,193 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2001-2018 GNUnet e.V.
4
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
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @file include/gnunet_abe_lib.h
23 * @brief Attribute-Based Encryption primitives for GNUnet
24 *
25 * @author Martin Schanzenbach
26 *
27 * @defgroup abe ABE Crypto library: Attribute-Based Encryption operations
28 *
29 */
30#ifndef GNUNET_ABE_LIB_H
31#define GNUNET_ABE_LIB_H
32
33#ifdef __cplusplus
34extern "C"
35{
36#if 0 /* keep Emacsens' auto-indent happy */
37}
38#endif
39#endif
40
41#include "gnunet_common.h"
42#include <gcrypt.h>
43
44/**
45 * @brief type for ABE master keys
46 */
47struct GNUNET_CRYPTO_AbeMasterKey;
48
49/**
50 * @brief type for ABE keys
51 */
52struct GNUNET_CRYPTO_AbeKey;
53
54
55
56/**
57 * @ingroup abe
58 * Create a new CP-ABE master key. Caller must free return value.
59 *
60 * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_master_key
61 */
62struct GNUNET_ABE_AbeMasterKey *
63GNUNET_ABE_cpabe_create_master_key (void);
64
65/**
66 * @ingroup abe
67 * Delete a CP-ABE master key.
68 *
69 * @param key the master key
70 * @return fresh private key; free using #GNUNET_free
71 */
72void
73GNUNET_ABE_cpabe_delete_master_key (struct GNUNET_ABE_AbeMasterKey *key);
74
75/**
76 * @ingroup abe
77 * Create a new CP-ABE key. Caller must free return value.
78 *
79 * @param key the master key
80 * @param attrs the attributes to append to the key
81 * @return fresh private key; free using #GNUNET_ABE_cpabe_delete_key
82 */
83struct GNUNET_ABE_AbeKey *
84GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key,
85 char **attrs);
86
87/**
88 * @ingroup abe
89 * Delete a CP-ABE key.
90 *
91 * @param key the key to delete
92 * @param delete_pub GNUNE_YES if the public key should also be freed (bug in gabe)
93 * @return fresh private key; free using #GNUNET_free
94 */
95void
96GNUNET_ABE_cpabe_delete_key (struct GNUNET_ABE_AbeKey *key,
97 int delete_pub);
98
99
100/**
101 * @ingroup abe
102 * Encrypt a block using sessionkey.
103 *
104 * @param block the block to encrypt
105 * @param size the size of the @a block
106 * @param policy the ABE policy
107 * @param key the key used to encrypt
108 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
109 * @return the size of the encrypted block, -1 for errors
110 */
111ssize_t
112GNUNET_ABE_cpabe_encrypt (const void *block,
113 size_t size,
114 const char *policy,
115 const struct GNUNET_ABE_AbeMasterKey *key,
116 void **result);
117
118/**
119 * @ingroup abe
120 * Decrypt a block using the ABE key.
121 *
122 * @param block the block to encrypt
123 * @param size the size of the @a block
124 * @param key the key used to decrypt
125 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
126 * @return the size of the encrypted block, -1 for errors
127 */
128ssize_t
129GNUNET_ABE_cpabe_decrypt (const void *block,
130 size_t size,
131 const struct GNUNET_ABE_AbeKey *key,
132 void **result);
133
134/**
135 * @ingroup abe
136 * Serialize an ABE key.
137 *
138 * @param key the key to serialize
139 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
140 * @return the size of the encrypted block, -1 for errors
141 */
142ssize_t
143GNUNET_ABE_cpabe_serialize_key (const struct GNUNET_ABE_AbeKey *key,
144 void **result);
145
146/**
147 * @ingroup abe
148 * Deserialize a serialized ABE key.
149 *
150 * @param data the data to deserialize
151 * @param len the length of the data.
152 * @return the ABE key. NULL of unsuccessful
153 */
154struct GNUNET_ABE_AbeKey*
155GNUNET_ABE_cpabe_deserialize_key (const void *data,
156 size_t len);
157
158/**
159 * @ingroup abe
160 * Serialize an ABE master key.
161 *
162 * @param key the key to serialize
163 * @param result the result buffer. Will be allocated. Free using #GNUNET_free
164 * @return the size of the encrypted block, -1 for errors
165 */
166ssize_t
167GNUNET_ABE_cpabe_serialize_master_key (const struct GNUNET_ABE_AbeMasterKey *key,
168 void **result);
169
170/**
171 * @ingroup abe
172 * Deserialize an ABE master key.
173 *
174 * @param data the data to deserialize
175 * @param len the length of the data.
176 * @return the ABE key. NULL of unsuccessful
177 */
178struct GNUNET_ABE_AbeMasterKey*
179GNUNET_ABE_cpabe_deserialize_master_key (const void *data,
180 size_t len);
181
182
183#if 0 /* keep Emacsens' auto-indent happy */
184{
185#endif
186#ifdef __cplusplus
187}
188#endif
189
190
191/* ifndef GNUNET_ABE_LIB_H */
192#endif
193/* end of gnunet_abe_lib.h */
diff --git a/src/include/gnunet_credential_service.h b/src/include/gnunet_credential_service.h
index 9e765c12b..7d6f9e973 100644
--- a/src/include/gnunet_credential_service.h
+++ b/src/include/gnunet_credential_service.h
@@ -34,6 +34,7 @@
34 34
35#include "gnunet_util_lib.h" 35#include "gnunet_util_lib.h"
36#include "gnunet_gns_service.h" 36#include "gnunet_gns_service.h"
37#include "gnunet_identity_service.h"
37 38
38#ifdef __cplusplus 39#ifdef __cplusplus
39extern "C" 40extern "C"
@@ -52,7 +53,157 @@ struct GNUNET_CREDENTIAL_Handle;
52/** 53/**
53 * Handle to control a lookup operation. 54 * Handle to control a lookup operation.
54 */ 55 */
55struct GNUNET_CREDENTIAL_LookupRequest; 56struct GNUNET_CREDENTIAL_Request;
57
58/*
59* Enum used for checking whether the issuer has the authority to issue credentials or is just a subject
60*/
61enum GNUNET_CREDENTIAL_CredentialFlags {
62
63 //Subject had credentials before, but have been revoked now
64 GNUNET_CREDENTIAL_FLAG_REVOKED=0,
65
66 //Subject flag indicates that the subject is a holder of this credential and may present it as such
67 GNUNET_CREDENTIAL_FLAG_SUBJECT=1,
68
69 //Issuer flag is used to signify that the subject is allowed to issue this credential and delegate issuance
70 GNUNET_CREDENTIAL_FLAG_ISSUER=2
71
72};
73
74GNUNET_NETWORK_STRUCT_BEGIN
75/**
76 * The attribute delegation record
77 */
78struct GNUNET_CREDENTIAL_DelegationRecord {
79
80 /**
81 * Number of delegation sets in this record
82 */
83 uint32_t set_count;
84
85 /**
86 * Length of delegation sets
87 */
88 uint64_t data_size;
89 /**
90 * Followed by set_count DelegationSetRecords
91 *
92 */
93};
94
95/**
96 * The attribute delegation record
97 */
98struct GNUNET_CREDENTIAL_DelegationRecordSet {
99
100 /**
101 * Public key of the subject this attribute was delegated to
102 */
103 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
104
105 /**
106 * Length of attribute, may be 0
107 */
108 uint32_t subject_attribute_len;
109};
110
111
112GNUNET_NETWORK_STRUCT_END
113
114/**
115 * The attribute delegation record
116 */
117struct GNUNET_CREDENTIAL_DelegationSet {
118
119 /**
120 * Public key of the subject this attribute was delegated to
121 */
122 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
123
124 uint32_t subject_attribute_len;
125
126 /**
127 * The subject attribute
128 */
129 const char *subject_attribute;
130};
131
132
133/**
134 * A delegation
135 */
136struct GNUNET_CREDENTIAL_Delegation {
137
138 /**
139 * The issuer of the delegation
140 */
141 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
142
143 /**
144 * Public key of the subject this attribute was delegated to
145 */
146 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
147
148 /**
149 * Length of the attribute
150 */
151 uint32_t issuer_attribute_len;
152
153 /**
154 * The attribute
155 */
156 const char *issuer_attribute;
157
158 /**
159 * Length of the attribute
160 */
161 uint32_t subject_attribute_len;
162
163 /**
164 * The attribute
165 */
166 const char *subject_attribute;
167};
168
169
170/**
171 * A credential
172 */
173struct GNUNET_CREDENTIAL_Credential {
174
175 /**
176 * The issuer of the credential
177 */
178 struct GNUNET_CRYPTO_EcdsaPublicKey issuer_key;
179
180 /**
181 * Public key of the subject this credential was issued to
182 */
183 struct GNUNET_CRYPTO_EcdsaPublicKey subject_key;
184
185 /**
186 * Signature of this credential
187 */
188 struct GNUNET_CRYPTO_EcdsaSignature signature;
189
190 /**
191 * Expiration of this credential
192 */
193 struct GNUNET_TIME_Absolute expiration;
194
195 /**
196 * Length of the attribute
197 */
198 uint32_t issuer_attribute_len;
199
200 /**
201 * The attribute
202 */
203 const char *issuer_attribute;
204
205};
206
56 207
57 208
58/** 209/**
@@ -61,7 +212,7 @@ struct GNUNET_CREDENTIAL_LookupRequest;
61 * @param cfg configuration to use 212 * @param cfg configuration to use
62 * @return handle to the Credential service, or NULL on error 213 * @return handle to the Credential service, or NULL on error
63 */ 214 */
64struct GNUNET_Credential_Handle * 215struct GNUNET_CREDENTIAL_Handle *
65GNUNET_CREDENTIAL_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); 216GNUNET_CREDENTIAL_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
66 217
67 218
@@ -75,73 +226,131 @@ GNUNET_CREDENTIAL_disconnect (struct GNUNET_CREDENTIAL_Handle *handle);
75 226
76 227
77/** 228/**
78 * Iterator called on obtained result for a Credential lookup. 229 * Iterator called on obtained result for an attribute verification.
230 *
231 * @param cls closure
232 * @param d_count the number of delegations processed
233 * @param delegation_chain the delegations processed
234 * @param c_count the number of credentials found
235 * @param credential the credentials
236 */
237typedef void (*GNUNET_CREDENTIAL_CredentialResultProcessor) (void *cls,
238 unsigned int d_count,
239 struct GNUNET_CREDENTIAL_Delegation *delegation_chain,
240 unsigned int c_count,
241 struct GNUNET_CREDENTIAL_Credential *credential);
242
243/**
244 * Iterator called on obtained result for an attribute delegation.
245 *
246 * @param cls closure
247 * @param success GNUNET_YES if successful
248 * @param result the record data that can be handed to the subject
249 */
250typedef void (*GNUNET_CREDENTIAL_DelegateResultProcessor) (void *cls,
251 uint32_t success);
252
253/**
254 * Iterator called on obtained result for an attribute delegation removal.
79 * 255 *
80 * @param cls closure 256 * @param cls closure
81 * @param issuer the issuer chain 257 * @param success GNUNET_YES if successful
82 * @param issuer_len length of issuer chain 258 * @param result the record data that can be handed to the subject
83 * @param value the value returned
84 */ 259 */
85typedef void 260typedef void (*GNUNET_CREDENTIAL_RemoveDelegateResultProcessor) (void *cls,
86(*GNUNET_CREDENTIAL_LookupResultProcessor) (void *cls, 261 uint32_t success);
87 struct GNUNET_IDENTITY_Ego *issuer,
88 uint16_t issuer_len,
89 const struct GNUNET_CREDENTIAL_Value *value);
90 262
91 263
92/** 264/**
93 * Perform an asynchronous lookup operation for a credential. 265 * Performs attribute verification.
266 * Checks if there is a delegation chain from
267 * attribute ``issuer_attribute'' issued by the issuer
268 * with public key ``issuer_key'' maps to the attribute
269 * ``subject_attribute'' claimed by the subject with key
270 * ``subject_key''
94 * 271 *
95 * @param handle handle to the Credential service 272 * @param handle handle to the Credential service
96 * @param credential the credential to look up 273 * @param issuer_key the issuer public key
97 * @param subject Ego to check the credential for 274 * @param issuer_attribute the issuer attribute
275 * @param subject_key the subject public key
276 * @param credential_count number of credentials
277 * @param credentials the subject credentials
98 * @param proc function to call on result 278 * @param proc function to call on result
99 * @param proc_cls closure for processor 279 * @param proc_cls closure for processor
100 * @return handle to the queued request 280 * @return handle to the queued request
101 */ 281 */
102struct GNUNET_CREDENTIAL_LookupRequest * 282struct GNUNET_CREDENTIAL_Request*
103GNUNET_CREDENTIAL_lookup (struct GNUNET_CREDENTIAL_Handle *handle, 283GNUNET_CREDENTIAL_verify (struct GNUNET_CREDENTIAL_Handle *handle,
104 const char *credential, 284 const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
105 const struct GNUNET_IDENTITY_Ego *subject, 285 const char *issuer_attribute,
106 GNUNET_CREDENTIAL_LookupResultProcessor proc, 286 const struct GNUNET_CRYPTO_EcdsaPublicKey *subject_key,
287 uint32_t credential_count,
288 const struct GNUNET_CREDENTIAL_Credential *credentials,
289 GNUNET_CREDENTIAL_CredentialResultProcessor proc,
107 void *proc_cls); 290 void *proc_cls);
108 291
292struct GNUNET_CREDENTIAL_Request*
293GNUNET_CREDENTIAL_collect (struct GNUNET_CREDENTIAL_Handle *handle,
294 const struct GNUNET_CRYPTO_EcdsaPublicKey *issuer_key,
295 const char *issuer_attribute,
296 const struct GNUNET_CRYPTO_EcdsaPrivateKey *subject_key,
297 GNUNET_CREDENTIAL_CredentialResultProcessor proc,
298 void *proc_cls);
109 299
110/** 300/**
111 * Issue a credential to an identity 301 * Delegate an attribute
112 * 302 *
113 * @param handle handle to the Credential service 303 * @param handle handle to the Credential service
114 * @param issuer the identity that issues the credential 304 * @param issuer the ego that should be used to delegate the attribute
115 * @param subject the subject of the credential 305 * @param attribute the name of the attribute to delegate
116 * @param credential the name of the credential 306 * @param subject the subject of the delegation
117 * @param value the value of the credential 307 * @param delegated_attribute the name of the attribute that is delegated to
308 * @param proc the result callback
309 * @param proc_cls the result closure context
118 * @return handle to the queued request 310 * @return handle to the queued request
119 */ 311 */
120struct GNUNET_CREDENTIAL_IssueRequest * 312struct GNUNET_CREDENTIAL_Request *
121GNUNET_CREDENTIAL_issue (struct GNUNET_CREDENTIAL_Handle *handle, 313GNUNET_CREDENTIAL_add_delegation (struct GNUNET_CREDENTIAL_Handle *handle,
122 struct GNUNET_IDENTITY_Ego *issuer, 314 struct GNUNET_IDENTITY_Ego *issuer,
123 struct GNUNET_IDENTITY_Ego *subject, 315 const char *attribute,
124 const char *credential, 316 struct GNUNET_CRYPTO_EcdsaPublicKey *subject,
125 struct GNUNET_CREDENTIAL_Value *value, 317 const char *delegated_attribute,
126 GNUNET_CREDENTIAL_IssueResultProcessor proc, 318 GNUNET_CREDENTIAL_DelegateResultProcessor proc,
127 void *proc_cls); 319 void *proc_cls);
128 320
129/** 321/**
130 * Remove a credential 322 * Remove a delegation
131 * 323 *
132 * @param handle handle to the Credential service 324 * @param handle handle to the Credential service
133 * @param issuer the identity that issued the credential 325 * @param issuer the ego that was used to delegate the attribute
134 * @param subject the subject of the credential 326 * @param attribute the name of the attribute that is delegated
135 * @param credential the name of the credential 327 * @param proc the callback
328 * @param proc_cls callback closure
136 * @return handle to the queued request 329 * @return handle to the queued request
137 */ 330 */
138struct GNUNET_CREDENTIAL_IssueRequest * 331struct GNUNET_CREDENTIAL_Request *
139GNUNET_CREDENTIAL_remove (struct GNUNET_CREDENTIAL_Handle *handle, 332GNUNET_CREDENTIAL_remove_delegation (struct GNUNET_CREDENTIAL_Handle *handle,
140 struct GNUNET_IDENTITY_Ego *issuer, 333 struct GNUNET_IDENTITY_Ego *issuer,
141 struct GNUNET_IDENTITY_Ego *subject, 334 const char *attribute,
142 const char *credential, 335 GNUNET_CREDENTIAL_RemoveDelegateResultProcessor proc,
143 GNUNET_CREDENTIAL_IssueResultProcessor proc, 336 void *proc_cls);
144 void *proc_cls); 337
338
339
340/**
341 * Issue an attribute to a subject
342 *
343 * @param issuer the ego that should be used to issue the attribute
344 * @param subject the subject of the attribute
345 * @param attribute the name of the attribute
346 * @param expiration the TTL of the credential
347 * @return handle to the queued request
348 */
349struct GNUNET_CREDENTIAL_Credential*
350GNUNET_CREDENTIAL_credential_issue (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer,
351 struct GNUNET_CRYPTO_EcdsaPublicKey *subject,
352 const char *attribute,
353 struct GNUNET_TIME_Absolute *expiration);
145 354
146 355
147 356
@@ -151,7 +360,7 @@ GNUNET_CREDENTIAL_remove (struct GNUNET_CREDENTIAL_Handle *handle,
151 * @param lr the lookup request to cancel 360 * @param lr the lookup request to cancel
152 */ 361 */
153void 362void
154GNUNET_CREDENTIAL_lookup_cancel (struct GNUNET_CREDENTIAL_LookupRequest *lr); 363GNUNET_CREDENTIAL_request_cancel (struct GNUNET_CREDENTIAL_Request *lr);
155 364
156 365
157#if 0 /* keep Emacsens' auto-indent happy */ 366#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h
index 985ae1f7a..d03b4db3b 100644
--- a/src/include/gnunet_gnsrecord_lib.h
+++ b/src/include/gnunet_gnsrecord_lib.h
@@ -109,9 +109,29 @@ extern "C"
109#define GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA 65546 109#define GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA 65546
110 110
111/** 111/**
112 * Record type for credential
113 */
114#define GNUNET_GNSRECORD_TYPE_CREDENTIAL 65547
115
116/**
117 * Record type for policies
118 */
119#define GNUNET_GNSRECORD_TYPE_POLICY 65548
120
121/**
112 * Record type for reverse lookups 122 * Record type for reverse lookups
113 */ 123 */
114#define GNUNET_GNSRECORD_TYPE_REVERSE 65548 124#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE 65549
125
126/**
127 * Record type for ABE records
128 */
129#define GNUNET_GNSRECORD_TYPE_ABE_KEY 65550
130
131/**
132 * Record type for ABE master keys
133 */
134#define GNUNET_GNSRECORD_TYPE_ABE_MASTER 65551
115 135
116/** 136/**
117 * Flags that can be set for a record. 137 * Flags that can be set for a record.
diff --git a/src/include/gnunet_identity_attribute_lib.h b/src/include/gnunet_identity_attribute_lib.h
new file mode 100644
index 000000000..316b0bf95
--- /dev/null
+++ b/src/include/gnunet_identity_attribute_lib.h
@@ -0,0 +1,277 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2017 GNUnet e.V.
4
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
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @author Martin Schanzenbach
23 *
24 * @file
25 * Identity attribute definitions
26 *
27 * @defgroup identity-provider Identity Provider service
28 * @{
29 */
30#ifndef GNUNET_IDENTITY_ATTRIBUTE_LIB_H
31#define GNUNET_IDENTITY_ATTRIBUTE_LIB_H
32
33#ifdef __cplusplus
34extern "C"
35{
36#if 0 /* keep Emacsens' auto-indent happy */
37}
38#endif
39#endif
40
41#include "gnunet_util_lib.h"
42
43
44/**
45 * No value attribute.
46 */
47#define GNUNET_IDENTITY_ATTRIBUTE_TYPE_NONE 0
48
49/**
50 * String attribute.
51 */
52#define GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING 1
53
54
55
56/**
57 * An attribute.
58 */
59struct GNUNET_IDENTITY_ATTRIBUTE_Claim
60{
61 /**
62 * The name of the attribute. Note "name" must never be individually
63 * free'd
64 */
65 const char* name;
66
67 /**
68 * Type of Claim
69 */
70 uint32_t type;
71
72 /**
73 * Version
74 */
75 uint32_t version;
76
77 /**
78 * Number of bytes in @e data.
79 */
80 size_t data_size;
81
82 /**
83 * Binary value stored as attribute value. Note: "data" must never
84 * be individually 'malloc'ed, but instead always points into some
85 * existing data area.
86 */
87 const void *data;
88
89};
90
91struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList
92{
93 /**
94 * List head
95 */
96 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *list_head;
97
98 /**
99 * List tail
100 */
101 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *list_tail;
102};
103
104struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry
105{
106 /**
107 * DLL
108 */
109 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *prev;
110
111 /**
112 * DLL
113 */
114 struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *next;
115
116 /**
117 * The attribute claim
118 */
119 struct GNUNET_IDENTITY_ATTRIBUTE_Claim *claim;
120};
121
122/**
123 * Create a new attribute claim.
124 *
125 * @param attr_name the attribute name
126 * @param type the attribute type
127 * @param data the attribute value
128 * @param data_size the attribute value size
129 * @return the new attribute
130 */
131struct GNUNET_IDENTITY_ATTRIBUTE_Claim *
132GNUNET_IDENTITY_ATTRIBUTE_claim_new (const char* attr_name,
133 uint32_t type,
134 const void* data,
135 size_t data_size);
136
137
138/**
139 * Get required size for serialization buffer
140 *
141 * @param attrs the attribute list to serialize
142 *
143 * @return the required buffer size
144 */
145size_t
146GNUNET_IDENTITY_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
147
148void
149GNUNET_IDENTITY_ATTRIBUTE_list_destroy (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
150
151
152/**
153 * Serialize an attribute list
154 *
155 * @param attrs the attribute list to serialize
156 * @param result the serialized attribute
157 *
158 * @return length of serialized data
159 */
160size_t
161GNUNET_IDENTITY_ATTRIBUTE_list_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs,
162 char *result);
163
164/**
165 * Deserialize an attribute list
166 *
167 * @param data the serialized attribute list
168 * @param data_size the length of the serialized data
169 *
170 * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller
171 */
172struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *
173GNUNET_IDENTITY_ATTRIBUTE_list_deserialize (const char* data,
174 size_t data_size);
175
176
177/**
178 * Get required size for serialization buffer
179 *
180 * @param attr the attribute to serialize
181 *
182 * @return the required buffer size
183 */
184size_t
185GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr);
186
187
188
189/**
190 * Serialize an attribute
191 *
192 * @param attr the attribute to serialize
193 * @param result the serialized attribute
194 *
195 * @return length of serialized data
196 */
197size_t
198GNUNET_IDENTITY_ATTRIBUTE_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr,
199 char *result);
200
201/**
202 * Deserialize an attribute
203 *
204 * @param data the serialized attribute
205 * @param data_size the length of the serialized data
206 *
207 * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller
208 */
209struct GNUNET_IDENTITY_ATTRIBUTE_Claim *
210GNUNET_IDENTITY_ATTRIBUTE_deserialize (const char* data,
211 size_t data_size);
212
213struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList*
214GNUNET_IDENTITY_ATTRIBUTE_list_dup (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
215
216/**
217 * Convert a type name to the corresponding number
218 *
219 * @param typename name to convert
220 * @return corresponding number, UINT32_MAX on error
221 */
222uint32_t
223GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename);
224
225/**
226 * Convert human-readable version of a 'claim' of an attribute to the binary
227 * representation
228 *
229 * @param type type of the claim
230 * @param s human-readable string
231 * @param data set to value in binary encoding (will be allocated)
232 * @param data_size set to number of bytes in @a data
233 * @return #GNUNET_OK on success
234 */
235int
236GNUNET_IDENTITY_ATTRIBUTE_string_to_value (uint32_t type,
237 const char *s,
238 void **data,
239 size_t *data_size);
240
241/**
242 * Convert the 'claim' of an attribute to a string
243 *
244 * @param type the type of attribute
245 * @param data claim in binary encoding
246 * @param data_size number of bytes in @a data
247 * @return NULL on error, otherwise human-readable representation of the claim
248 */
249char *
250GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type,
251 const void* data,
252 size_t data_size);
253
254/**
255 * Convert a type number to the corresponding type string
256 *
257 * @param type number of a type
258 * @return corresponding typestring, NULL on error
259 */
260const char*
261GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type);
262
263
264#if 0 /* keep Emacsens' auto-indent happy */
265{
266#endif
267#ifdef __cplusplus
268}
269#endif
270
271
272/* ifndef GNUNET_IDENTITY_ATTRIBUTE_LIB_H */
273#endif
274
275/** @} */ /* end of group identity */
276
277/* end of gnunet_identity_attribute_lib.h */
diff --git a/src/include/gnunet_identity_attribute_plugin.h b/src/include/gnunet_identity_attribute_plugin.h
new file mode 100644
index 000000000..edeed57fd
--- /dev/null
+++ b/src/include/gnunet_identity_attribute_plugin.h
@@ -0,0 +1,149 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2012, 2013 GNUnet e.V.
4
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
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @author Martin Schanzenbach
23 *
24 * @file
25 * Plugin API for the idp database backend
26 *
27 * @defgroup identity-provider-plugin IdP service plugin API
28 * Plugin API for the idp database backend
29 * @{
30 */
31#ifndef GNUNET_IDENTITY_ATTRIBUTE_PLUGIN_H
32#define GNUNET_IDENTITY_ATTRIBUTE_PLUGIN_H
33
34#include "gnunet_util_lib.h"
35#include "gnunet_identity_attribute_lib.h"
36
37#ifdef __cplusplus
38extern "C"
39{
40#if 0 /* keep Emacsens' auto-indent happy */
41}
42#endif
43#endif
44
45
46/**
47 * Function called to convert the binary value @a data of an attribute of
48 * type @a type to a human-readable string.
49 *
50 * @param cls closure
51 * @param type type of the attribute
52 * @param data value in binary encoding
53 * @param data_size number of bytes in @a data
54 * @return NULL on error, otherwise human-readable representation of the value
55 */
56typedef char * (*GNUNET_IDENTITY_ATTRIBUTE_ValueToStringFunction) (void *cls,
57 uint32_t type,
58 const void *data,
59 size_t data_size);
60
61
62/**
63 * Function called to convert human-readable version of the value @a s
64 * of an attribute of type @a type to the respective binary
65 * representation.
66 *
67 * @param cls closure
68 * @param type type of the attribute
69 * @param s human-readable string
70 * @param data set to value in binary encoding (will be allocated)
71 * @param data_size set to number of bytes in @a data
72 * @return #GNUNET_OK on success
73 */
74typedef int (*GNUNET_IDENTITY_ATTRIBUTE_StringToValueFunction) (void *cls,
75 uint32_t type,
76 const char *s,
77 void **data,
78 size_t *data_size);
79
80
81/**
82 * Function called to convert a type name to the
83 * corresponding number.
84 *
85 * @param cls closure
86 * @param typename name to convert
87 * @return corresponding number, UINT32_MAX on error
88 */
89typedef uint32_t (*GNUNET_IDENTITY_ATTRIBUTE_TypenameToNumberFunction) (void *cls,
90 const char *typename);
91
92
93/**
94 * Function called to convert a type number (i.e. 1) to the
95 * corresponding type string
96 *
97 * @param cls closure
98 * @param type number of a type to convert
99 * @return corresponding typestring, NULL on error
100 */
101typedef const char * (*GNUNET_IDENTITY_ATTRIBUTE_NumberToTypenameFunction) (void *cls,
102 uint32_t type);
103
104
105/**
106 * Each plugin is required to return a pointer to a struct of this
107 * type as the return value from its entry point.
108 */
109struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions
110{
111
112 /**
113 * Closure for all of the callbacks.
114 */
115 void *cls;
116
117 /**
118 * Conversion to string.
119 */
120 GNUNET_IDENTITY_ATTRIBUTE_ValueToStringFunction value_to_string;
121
122 /**
123 * Conversion to binary.
124 */
125 GNUNET_IDENTITY_ATTRIBUTE_StringToValueFunction string_to_value;
126
127 /**
128 * Typename to number.
129 */
130 GNUNET_IDENTITY_ATTRIBUTE_TypenameToNumberFunction typename_to_number;
131
132 /**
133 * Number to typename.
134 */
135 GNUNET_IDENTITY_ATTRIBUTE_NumberToTypenameFunction number_to_typename;
136
137};
138
139
140#if 0 /* keep Emacsens' auto-indent happy */
141{
142#endif
143#ifdef __cplusplus
144}
145#endif
146
147#endif
148
149/** @} */ /* end of group */
diff --git a/src/include/gnunet_identity_provider_plugin.h b/src/include/gnunet_identity_provider_plugin.h
new file mode 100644
index 000000000..4b5098d58
--- /dev/null
+++ b/src/include/gnunet_identity_provider_plugin.h
@@ -0,0 +1,123 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2012, 2013 GNUnet e.V.
4
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
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @author Martin Schanzenbach
23 *
24 * @file
25 * Plugin API for the idp database backend
26 *
27 * @defgroup identity-provider-plugin IdP service plugin API
28 * Plugin API for the idp database backend
29 * @{
30 */
31#ifndef GNUNET_IDENTITY_PROVIDER_PLUGIN_H
32#define GNUNET_IDENTITY_PROVIDER_PLUGIN_H
33
34#include "gnunet_util_lib.h"
35#include "gnunet_identity_provider_service.h"
36
37#ifdef __cplusplus
38extern "C"
39{
40#if 0 /* keep Emacsens' auto-indent happy */
41}
42#endif
43#endif
44
45
46/**
47 * Function called by for each matching ticket.
48 *
49 * @param cls closure
50 * @param ticket the ticket
51 */
52typedef void (*GNUNET_IDENTITY_PROVIDER_TicketIterator) (void *cls,
53 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
54 const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
55
56
57/**
58 * @brief struct returned by the initialization function of the plugin
59 */
60struct GNUNET_IDENTITY_PROVIDER_PluginFunctions
61{
62
63 /**
64 * Closure to pass to all plugin functions.
65 */
66 void *cls;
67
68 /**
69 * Store a ticket in the database.
70 *
71 * @param cls closure (internal context for the plugin)
72 * @param ticket the ticket to store
73 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
74 */
75 int (*store_ticket) (void *cls,
76 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
77 const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
78
79 /**
80 * Delete a ticket from the database.
81 *
82 * @param cls closure (internal context for the plugin)
83 * @param ticket the ticket to store
84 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
85 */
86 int (*delete_ticket) (void *cls,
87 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket);
88
89
90
91 /**
92 * Iterate over all tickets
93 *
94 * @param cls closure (internal context for the plugin)
95 * @param identity the identity
96 * @param audience GNUNET_YES if the identity is the audience of the ticket
97 * else it is considered the issuer
98 * @param iter function to call with the result
99 * @param iter_cls closure for @a iter
100 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
101 */
102 int (*iterate_tickets) (void *cls,
103 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
104 int audience,
105 uint64_t offset,
106 GNUNET_IDENTITY_PROVIDER_TicketIterator iter, void *iter_cls);
107
108 int (*get_ticket_attributes) (void* cls,
109 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
110 GNUNET_IDENTITY_PROVIDER_TicketIterator iter,
111 void *iter_cls);
112};
113
114#if 0 /* keep Emacsens' auto-indent happy */
115{
116#endif
117#ifdef __cplusplus
118}
119#endif
120
121#endif
122
123/** @} */ /* end of group */
diff --git a/src/include/gnunet_identity_provider_service.h b/src/include/gnunet_identity_provider_service.h
index e533f6f8c..be935e898 100644
--- a/src/include/gnunet_identity_provider_service.h
+++ b/src/include/gnunet_identity_provider_service.h
@@ -39,7 +39,7 @@ extern "C"
39#endif 39#endif
40 40
41#include "gnunet_util_lib.h" 41#include "gnunet_util_lib.h"
42 42#include "gnunet_identity_attribute_lib.h"
43 43
44/** 44/**
45 * Version number of GNUnet Identity Provider API. 45 * Version number of GNUnet Identity Provider API.
@@ -57,169 +57,310 @@ struct GNUNET_IDENTITY_PROVIDER_Handle;
57struct GNUNET_IDENTITY_PROVIDER_Token; 57struct GNUNET_IDENTITY_PROVIDER_Token;
58 58
59/** 59/**
60 * Handle for a ticket 60 * The ticket
61 */ 61 */
62struct GNUNET_IDENTITY_PROVIDER_Ticket; 62struct GNUNET_IDENTITY_PROVIDER_Ticket
63{
64 /**
65 * The ticket issuer
66 */
67 struct GNUNET_CRYPTO_EcdsaPublicKey identity;
68
69 /**
70 * The ticket audience
71 */
72 struct GNUNET_CRYPTO_EcdsaPublicKey audience;
73
74 /**
75 * The ticket random (NBO)
76 */
77 uint64_t rnd;
78};
63 79
64/** 80/**
65 * Handle for an operation with the identity provider service. 81 * Handle for an operation with the identity provider service.
66 */ 82 */
67struct GNUNET_IDENTITY_PROVIDER_Operation; 83struct GNUNET_IDENTITY_PROVIDER_Operation;
68 84
85
69/** 86/**
70 * Method called when a token has been exchanged for a ticket. 87 * Connect to the identity provider service.
71 * On success returns a token
72 * 88 *
73 * @param cls closure 89 * @param cfg Configuration to contact the identity provider service.
74 * @param token the token 90 * @return handle to communicate with identity provider service
75 */ 91 */
76typedef void 92struct GNUNET_IDENTITY_PROVIDER_Handle *
77(*GNUNET_IDENTITY_PROVIDER_ExchangeCallback)(void *cls, 93GNUNET_IDENTITY_PROVIDER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
78 const struct GNUNET_IDENTITY_PROVIDER_Token *token,
79 uint64_t ticket_nonce);
80 94
81/** 95/**
82 * Method called when a token has been issued. 96 * Continuation called to notify client about result of the
83 * On success returns a ticket that can be given to the audience to retrive the 97 * operation.
84 * token
85 * 98 *
86 * @param cls closure 99 * @param cls closure
87 * @param grant the label in GNS pointing to the token 100 * @param success #GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate)
88 * @param ticket the ticket 101 * #GNUNET_NO if content was already there or not found
89 * @param token the issued token 102 * #GNUNET_YES (or other positive value) on success
90 * @param name name assigned by the user for this ego, 103 * @param emsg NULL on success, otherwise an error message
91 * NULL if the user just deleted the ego and it
92 * must thus no longer be used
93 */ 104 */
94typedef void 105typedef void
95(*GNUNET_IDENTITY_PROVIDER_IssueCallback)(void *cls, 106(*GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus) (void *cls,
96 const char *grant, 107 int32_t success,
97 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, 108 const char *emsg);
98 const struct GNUNET_IDENTITY_PROVIDER_Token *token);
99 109
100 110
101/** 111/**
102 * Connect to the identity provider service. 112 * Store an attribute. If the attribute is already present,
113 * it is replaced with the new attribute.
103 * 114 *
104 * @param cfg Configuration to contact the identity provider service. 115 * @param h handle to the identity provider
105 * @return handle to communicate with identity provider service 116 * @param pkey private key of the identity
117 * @param attr the attribute
118 * @param cont continuation to call when done
119 * @param cont_cls closure for @a cont
120 * @return handle to abort the request
106 */ 121 */
107struct GNUNET_IDENTITY_PROVIDER_Handle * 122struct GNUNET_IDENTITY_PROVIDER_Operation *
108GNUNET_IDENTITY_PROVIDER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); 123GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
124 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
125 const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr,
126 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cont,
127 void *cont_cls);
109 128
110 129
111/** 130/**
112 * Issue a token for a specific audience. 131 * Process an attribute that was stored in the idp.
113 * 132 *
114 * @param id identity provider service to use 133 * @param cls closure
115 * @param iss issuer (identity) 134 * @param identity the identity
116 * @param aud audience (identity) 135 * @param attr the attribute
117 * @param scope the identity attributes requested, comman separated
118 * @param expiration the token expiration
119 * @param nonce the nonce that will be included in token and ticket
120 * @param cb callback to call with result
121 * @param cb_cls closure
122 * @return handle to abort the operation
123 */ 136 */
124struct GNUNET_IDENTITY_PROVIDER_Operation * 137typedef void
125GNUNET_IDENTITY_PROVIDER_issue_token (struct GNUNET_IDENTITY_PROVIDER_Handle *id, 138(*GNUNET_IDENTITY_PROVIDER_AttributeResult) (void *cls,
126 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss_key, 139 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
127 const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, 140 const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr);
128 const char* scope, 141
129 struct GNUNET_TIME_Absolute expiration,
130 uint64_t nonce,
131 GNUNET_IDENTITY_PROVIDER_IssueCallback cb,
132 void *cb_cls);
133 142
134 143
135/** 144/**
136 * Exchange a ticket for a token. Intended to be used by audience that 145 * List all attributes for a local identity.
137 * received a ticket. 146 * This MUST lock the `struct GNUNET_IDENTITY_PROVIDER_Handle`
147 * for any other calls than #GNUNET_IDENTITY_PROVIDER_get_attributes_next() and
148 * #GNUNET_IDENTITY_PROVIDER_get_attributes_stop. @a proc will be called once
149 * immediately, and then again after
150 * #GNUNET_IDENTITY_PROVIDER_get_attributes_next() is invoked.
138 * 151 *
139 * @param id identity provider service to use 152 * On error (disconnect), @a error_cb will be invoked.
140 * @param ticket the ticket to exchange 153 * On normal completion, @a finish_cb proc will be
141 * @param aud_privkey the audience of the ticket 154 * invoked.
142 * @param cont function to call once the operation finished 155 *
143 * @param cont_cls closure for @a cont 156 * @param h handle to the idp
144 * @return handle to abort the operation 157 * @param identity identity to access
158 * @param error_cb function to call on error (i.e. disconnect),
159 * the handle is afterwards invalid
160 * @param error_cb_cls closure for @a error_cb
161 * @param proc function to call on each attribute; it
162 * will be called repeatedly with a value (if available)
163 * @param proc_cls closure for @a proc
164 * @param finish_cb function to call on completion
165 * the handle is afterwards invalid
166 * @param finish_cb_cls closure for @a finish_cb
167 * @return an iterator handle to use for iteration
145 */ 168 */
146struct GNUNET_IDENTITY_PROVIDER_Operation * 169struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *
147GNUNET_IDENTITY_PROVIDER_exchange_ticket (struct GNUNET_IDENTITY_PROVIDER_Handle *id, 170GNUNET_IDENTITY_PROVIDER_get_attributes_start (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
148 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, 171 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
149 const struct GNUNET_CRYPTO_EcdsaPrivateKey *aud_privkey, 172 GNUNET_SCHEDULER_TaskCallback error_cb,
150 GNUNET_IDENTITY_PROVIDER_ExchangeCallback cont, 173 void *error_cb_cls,
151 void *cont_cls); 174 GNUNET_IDENTITY_PROVIDER_AttributeResult proc,
175 void *proc_cls,
176 GNUNET_SCHEDULER_TaskCallback finish_cb,
177 void *finish_cb_cls);
152 178
153 179
154/** 180/**
155 * Disconnect from identity provider service. 181 * Calls the record processor specified in #GNUNET_IDENTITY_PROVIDER_get_attributes_start
182 * for the next record.
156 * 183 *
157 * @param h identity provider service to disconnect 184 * @param it the iterator
158 */ 185 */
159void 186void
160GNUNET_IDENTITY_PROVIDER_disconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h); 187GNUNET_IDENTITY_PROVIDER_get_attributes_next (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it);
161 188
162 189
163/** 190/**
164 * Cancel an identity provider operation. Note that the operation MAY still 191 * Stops iteration and releases the idp handle for further calls. Must
165 * be executed; this merely cancels the continuation; if the request 192 * be called on any iteration that has not yet completed prior to calling
166 * was already transmitted, the service may still choose to complete 193 * #GNUNET_IDENTITY_PROVIDER_disconnect.
167 * the operation.
168 * 194 *
169 * @param op operation to cancel 195 * @param it the iterator
170 */ 196 */
171void 197void
172GNUNET_IDENTITY_PROVIDER_cancel (struct GNUNET_IDENTITY_PROVIDER_Operation *op); 198GNUNET_IDENTITY_PROVIDER_get_attributes_stop (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it);
173 199
174 200
175/** 201/**
176 * Convenience API 202 * Method called when a token has been issued.
203 * On success returns a ticket that can be given to the audience to retrive the
204 * token
205 *
206 * @param cls closure
207 * @param ticket the ticket
177 */ 208 */
209typedef void
210(*GNUNET_IDENTITY_PROVIDER_TicketCallback)(void *cls,
211 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket);
178 212
179/** 213/**
180 * Destroy token 214 * Issues a ticket to another identity. The identity may use
215 * GNUNET_IDENTITY_PROVIDER_ticket_consume to consume the ticket
216 * and retrieve the attributes specified in the AttributeList.
181 * 217 *
182 * @param token the token 218 * @param h the identity provider to use
219 * @param iss the issuing identity
220 * @param rp the subject of the ticket (the relying party)
221 * @param attrs the attributes that the relying party is given access to
222 * @param cb the callback
223 * @param cb_cls the callback closure
224 * @return handle to abort the operation
183 */ 225 */
184void 226struct GNUNET_IDENTITY_PROVIDER_Operation *
185GNUNET_IDENTITY_PROVIDER_token_destroy(struct GNUNET_IDENTITY_PROVIDER_Token *token); 227GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
228 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
229 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
230 const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs,
231 GNUNET_IDENTITY_PROVIDER_TicketCallback cb,
232 void *cb_cls);
186 233
187/** 234/**
188 * Returns string representation of token. A JSON-Web-Token. 235 * Revoked an issued ticket. The relying party will be unable to retrieve
236 * updated attributes.
189 * 237 *
190 * @param token the token 238 * @param h the identity provider to use
191 * @return The JWT (must be freed) 239 * @param identity the issuing identity
240 * @param ticket the ticket to revoke
241 * @param cb the callback
242 * @param cb_cls the callback closure
243 * @return handle to abort the operation
192 */ 244 */
193char * 245struct GNUNET_IDENTITY_PROVIDER_Operation *
194GNUNET_IDENTITY_PROVIDER_token_to_string (const struct GNUNET_IDENTITY_PROVIDER_Token *token); 246GNUNET_IDENTITY_PROVIDER_ticket_revoke (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
247 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
248 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
249 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cb,
250 void *cb_cls);
251
252
195 253
196/** 254/**
197 * Returns string representation of ticket. Base64-Encoded 255 * Consumes an issued ticket. The ticket is persisted
256 * and used to retrieve identity information from the issuer
198 * 257 *
199 * @param ticket the ticket 258 * @param h the identity provider to use
200 * @return the Base64-Encoded ticket 259 * @param identity the identity that is the subject of the issued ticket (the audience)
260 * @param ticket the issued ticket to consume
261 * @param cb the callback to call
262 * @param cb_cls the callback closure
263 * @return handle to abort the operation
264 */
265struct GNUNET_IDENTITY_PROVIDER_Operation *
266GNUNET_IDENTITY_PROVIDER_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
267 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
268 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
269 GNUNET_IDENTITY_PROVIDER_AttributeResult cb,
270 void *cb_cls);
271
272/**
273 * Lists all tickets that have been issued to remote
274 * identites (relying parties)
275 *
276 * @param h the identity provider to use
277 * @param identity the issuing identity
278 * @param error_cb function to call on error (i.e. disconnect),
279 * the handle is afterwards invalid
280 * @param error_cb_cls closure for @a error_cb
281 * @param proc function to call on each ticket; it
282 * will be called repeatedly with a value (if available)
283 * @param proc_cls closure for @a proc
284 * @param finish_cb function to call on completion
285 * the handle is afterwards invalid
286 * @param finish_cb_cls closure for @a finish_cb
287 * @return an iterator handle to use for iteration
288 */
289struct GNUNET_IDENTITY_PROVIDER_TicketIterator *
290GNUNET_IDENTITY_PROVIDER_ticket_iteration_start (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
291 const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity,
292 GNUNET_SCHEDULER_TaskCallback error_cb,
293 void *error_cb_cls,
294 GNUNET_IDENTITY_PROVIDER_TicketCallback proc,
295 void *proc_cls,
296 GNUNET_SCHEDULER_TaskCallback finish_cb,
297 void *finish_cb_cls);
298
299/**
300 * Lists all tickets that have been issued to remote
301 * identites (relying parties)
302 *
303 * @param h the identity provider to use
304 * @param identity the issuing identity
305 * @param error_cb function to call on error (i.e. disconnect),
306 * the handle is afterwards invalid
307 * @param error_cb_cls closure for @a error_cb
308 * @param proc function to call on each ticket; it
309 * will be called repeatedly with a value (if available)
310 * @param proc_cls closure for @a proc
311 * @param finish_cb function to call on completion
312 * the handle is afterwards invalid
313 * @param finish_cb_cls closure for @a finish_cb
314 * @return an iterator handle to use for iteration
201 */ 315 */
202char * 316struct GNUNET_IDENTITY_PROVIDER_TicketIterator *
203GNUNET_IDENTITY_PROVIDER_ticket_to_string (const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket); 317GNUNET_IDENTITY_PROVIDER_ticket_iteration_start_rp (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
318 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
319 GNUNET_SCHEDULER_TaskCallback error_cb,
320 void *error_cb_cls,
321 GNUNET_IDENTITY_PROVIDER_TicketCallback proc,
322 void *proc_cls,
323 GNUNET_SCHEDULER_TaskCallback finish_cb,
324 void *finish_cb_cls);
204 325
205/** 326/**
206 * Created a ticket from a string (Base64 encoded ticket) 327 * Calls the record processor specified in #GNUNET_IDENTITY_PROVIDER_ticket_iteration_start
328 * for the next record.
207 * 329 *
208 * @param input Base64 encoded ticket 330 * @param it the iterator
209 * @param ticket pointer where the ticket is stored
210 * @return GNUNET_OK
211 */ 331 */
212int 332void
213GNUNET_IDENTITY_PROVIDER_string_to_ticket (const char* input, 333GNUNET_IDENTITY_PROVIDER_ticket_iteration_next (struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it);
214 struct GNUNET_IDENTITY_PROVIDER_Ticket **ticket);
215 334
216/** 335/**
217 * Destroys a ticket 336 * Stops iteration and releases the idp handle for further calls. Must
337 * be called on any iteration that has not yet completed prior to calling
338 * #GNUNET_IDENTITY_PROVIDER_disconnect.
218 * 339 *
219 * @param ticket the ticket to destroy 340 * @param it the iterator
220 */ 341 */
221void 342void
222GNUNET_IDENTITY_PROVIDER_ticket_destroy(struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket); 343GNUNET_IDENTITY_PROVIDER_ticket_iteration_stop (struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it);
344
345/**
346 * Disconnect from identity provider service.
347 *
348 * @param h identity provider service to disconnect
349 */
350void
351GNUNET_IDENTITY_PROVIDER_disconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h);
352
353
354/**
355 * Cancel an identity provider operation. Note that the operation MAY still
356 * be executed; this merely cancels the continuation; if the request
357 * was already transmitted, the service may still choose to complete
358 * the operation.
359 *
360 * @param op operation to cancel
361 */
362void
363GNUNET_IDENTITY_PROVIDER_cancel (struct GNUNET_IDENTITY_PROVIDER_Operation *op);
223 364
224#if 0 /* keep Emacsens' auto-indent happy */ 365#if 0 /* keep Emacsens' auto-indent happy */
225{ 366{
diff --git a/src/include/gnunet_jsonapi_lib.h b/src/include/gnunet_jsonapi_lib.h
index f95bff836..2f6b810f0 100644
--- a/src/include/gnunet_jsonapi_lib.h
+++ b/src/include/gnunet_jsonapi_lib.h
@@ -248,7 +248,7 @@ GNUNET_JSONAPI_resource_check_id (const struct GNUNET_JSONAPI_Resource *resource
248 * @param res the JSON resource 248 * @param res the JSON resource
249 * @return the resource id 249 * @return the resource id
250 */ 250 */
251char* 251const char*
252GNUNET_JSONAPI_resource_get_id (const struct GNUNET_JSONAPI_Resource *resource); 252GNUNET_JSONAPI_resource_get_id (const struct GNUNET_JSONAPI_Resource *resource);
253 253
254 254
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 9cfd00e39..436adc5a4 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -2628,13 +2628,47 @@ extern "C"
2628 * 2628 *
2629 * IDENTITY PROVIDER MESSAGE TYPES 2629 * IDENTITY PROVIDER MESSAGE TYPES
2630 */ 2630 */
2631#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE 961 2631#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE 961
2632 2632
2633#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE 962 2633#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE_RESPONSE 962
2634 2634
2635#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_RESULT 963 2635#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_START 963
2636 2636
2637#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_EXCHANGE_RESULT 964 2637#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_STOP 964
2638
2639#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_NEXT 965
2640
2641#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT 966
2642
2643#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_TICKET 967
2644
2645#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT 968
2646
2647#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET 969
2648
2649#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET_RESULT 970
2650
2651#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET 971
2652
2653#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT 972
2654
2655#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_START 973
2656
2657#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_STOP 974
2658
2659#define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_NEXT 975
2660
2661/**************************************************
2662 *
2663 * CREDENTIAL MESSAGE TYPES
2664 */
2665#define GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY 981
2666
2667#define GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT 982
2668
2669#define GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT 983
2670
2671#define GNUNET_MESSAGE_TYPE_CREDENTIAL_COLLECT_RESULT 984
2638 2672
2639/******************************************************************************/ 2673/******************************************************************************/
2640 2674
diff --git a/src/include/gnunet_rest_lib.h b/src/include/gnunet_rest_lib.h
index a4dbb0696..e571eead3 100644
--- a/src/include/gnunet_rest_lib.h
+++ b/src/include/gnunet_rest_lib.h
@@ -89,7 +89,7 @@ typedef void (*GNUNET_REST_ResultProcessor) (void *cls,
89 * 89 *
90 * @param url URL to check 90 * @param url URL to check
91 * @param namespace namespace to check against 91 * @param namespace namespace to check against
92 * @retun GNUNET_YES if namespace matches 92 * @return GNUNET_YES if namespace matches
93 */ 93 */
94int 94int
95GNUNET_REST_namespace_match (const char *url, const char *namespace); 95GNUNET_REST_namespace_match (const char *url, const char *namespace);
@@ -98,7 +98,7 @@ GNUNET_REST_namespace_match (const char *url, const char *namespace);
98 * Create REST MHD response 98 * Create REST MHD response
99 * 99 *
100 * @param data result 100 * @param data result
101 * @retun MHD response 101 * @return MHD response
102 */ 102 */
103 struct MHD_Response* 103 struct MHD_Response*
104GNUNET_REST_create_response (const char *data); 104GNUNET_REST_create_response (const char *data);
diff --git a/src/include/gnunet_rest_plugin.h b/src/include/gnunet_rest_plugin.h
index ecd5f66f1..424dbb1fc 100644
--- a/src/include/gnunet_rest_plugin.h
+++ b/src/include/gnunet_rest_plugin.h
@@ -57,7 +57,7 @@ struct GNUNET_REST_Plugin
57 57
58 /** 58 /**
59 * Plugin name. Used as the namespace for the API. 59 * Plugin name. Used as the namespace for the API.
60 * e.g. http://hostname:port/<name> 60 * e.g. http://hostname:port/name
61 */ 61 */
62 char *name; 62 char *name;
63 63
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h
index c1e0d005c..03bc4575e 100644
--- a/src/include/gnunet_signatures.h
+++ b/src/include/gnunet_signatures.h
@@ -185,6 +185,11 @@ extern "C"
185 */ 185 */
186#define GNUNET_SIGNATURE_PURPOSE_GNUID_TICKET 27 186#define GNUNET_SIGNATURE_PURPOSE_GNUID_TICKET 27
187 187
188/**
189 * Signature for a GNUnet credential
190 */
191#define GNUNET_SIGNATURE_PURPOSE_CREDENTIAL 28
192
188#if 0 /* keep Emacsens' auto-indent happy */ 193#if 0 /* keep Emacsens' auto-indent happy */
189{ 194{
190#endif 195#endif