towards better API
[oweals/gnunet.git] / src / reclaim / reclaim.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2016 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14
15      You should have received a copy of the GNU Affero General Public License
16      along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
19  */
20
21 /**
22  * @author Martin Schanzenbach
23  * @file reclaim/reclaim.h
24  *
25  * @brief Common type definitions for the identity provider
26  *        service and API.
27  */
28 #ifndef RECLAIM_H
29 #define RECLAIM_H
30
31 #include "gnunet_common.h"
32
33
34 GNUNET_NETWORK_STRUCT_BEGIN
35
36
37 /**
38  * Use to store an identity attribute
39  */
40 struct AttributeStoreMessage
41 {
42   /**
43    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
44    */
45   struct GNUNET_MessageHeader header;
46
47   /**
48    * Unique identifier for this request (for key collisions).
49    */
50   uint32_t id GNUNET_PACKED;
51
52   /**
53    * The length of the attribute
54    */
55   uint32_t attr_len GNUNET_PACKED;
56
57   /**
58    * The expiration interval of the attribute
59    */
60   uint64_t exp GNUNET_PACKED;
61
62   /**
63    * Identity
64    */
65   struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
66
67   /* followed by the serialized attribute */
68 };
69
70
71 /**
72  * Use to delete an identity attribute
73  */
74 struct AttributeDeleteMessage
75 {
76   /**
77    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
78    */
79   struct GNUNET_MessageHeader header;
80
81   /**
82    * Unique identifier for this request (for key collisions).
83    */
84   uint32_t id GNUNET_PACKED;
85
86   /**
87    * The length of the attribute
88    */
89   uint32_t attr_len GNUNET_PACKED;
90
91   /**
92    * Identity
93    */
94   struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
95
96   /* followed by the serialized attribute */
97 };
98
99
100 /**
101  * Attribute store/delete response message
102  */
103 struct SuccessResultMessage
104 {
105   /**
106    * Message header
107    */
108   struct GNUNET_MessageHeader header;
109
110   /**
111    * Unique identifier for this request (for key collisions).
112    */
113   uint32_t id GNUNET_PACKED;
114
115   /**
116    * #GNUNET_SYSERR on failure, #GNUNET_OK on success
117    */
118   int32_t op_result GNUNET_PACKED;
119 };
120
121 /**
122  * Attribute is returned from the idp.
123  */
124 struct AttributeResultMessage
125 {
126   /**
127    * Message header
128    */
129   struct GNUNET_MessageHeader header;
130
131   /**
132    * Unique identifier for this request (for key collisions).
133    */
134   uint32_t id GNUNET_PACKED;
135
136   /**
137    * Length of serialized attribute data
138    */
139   uint16_t attr_len GNUNET_PACKED;
140
141   /**
142    * Length of serialized attestation data
143    */
144   uint16_t attestation_len GNUNET_PACKED;
145
146   /**
147    * always zero (for alignment)
148    */
149   uint16_t reserved GNUNET_PACKED;
150
151   /**
152    * The public key of the identity.
153    */
154   struct GNUNET_CRYPTO_EcdsaPublicKey identity;
155
156   /* followed by:
157    * serialized attribute data
158    */
159 };
160
161 /**
162  * Attestation is returned from the idp.
163  */
164 struct AttestationResultMessage
165 {
166   /**
167    * Message header
168    */
169   struct GNUNET_MessageHeader header;
170
171   /**
172    * Unique identifier for this request (for key collisions).
173    */
174   uint32_t id GNUNET_PACKED;
175
176   /**
177    * Length of serialized attribute data
178    */
179   uint16_t attestation_len GNUNET_PACKED;
180
181   /**
182    * Length of serialized attribute data
183    */
184   uint16_t attributes_len GNUNET_PACKED;
185
186   /**
187    * always zero (for alignment)
188    */
189   uint16_t reserved GNUNET_PACKED;
190
191   /**
192    * The public key of the identity.
193    */
194   struct GNUNET_CRYPTO_EcdsaPublicKey identity;
195
196   /* followed by:
197    * serialized attestation data
198    */
199 };
200
201
202 /**
203  * Start a attribute iteration for the given identity
204  */
205 struct AttributeIterationStartMessage
206 {
207   /**
208    * Message
209    */
210   struct GNUNET_MessageHeader header;
211
212   /**
213    * Unique identifier for this request (for key collisions).
214    */
215   uint32_t id GNUNET_PACKED;
216
217   /**
218    * Identity.
219    */
220   struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
221 };
222
223
224 /**
225  * Ask for next result of attribute iteration for the given operation
226  */
227 struct AttributeIterationNextMessage
228 {
229   /**
230    * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
231    */
232   struct GNUNET_MessageHeader header;
233
234   /**
235    * Unique identifier for this request (for key collisions).
236    */
237   uint32_t id GNUNET_PACKED;
238 };
239
240
241 /**
242  * Start a attestation iteration for the given identity
243  */
244 struct AttestationIterationStartMessage
245 {
246   /**
247    * Message
248    */
249   struct GNUNET_MessageHeader header;
250
251   /**
252    * Unique identifier for this request (for key collisions).
253    */
254   uint32_t id GNUNET_PACKED;
255
256   /**
257    * Identity.
258    */
259   struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
260 };
261
262
263 /**
264  * Ask for next result of attestation iteration for the given operation
265  */
266 struct AttestationIterationNextMessage
267 {
268   /**
269    * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT
270    */
271   struct GNUNET_MessageHeader header;
272
273   /**
274    * Unique identifier for this request (for key collisions).
275    */
276   uint32_t id GNUNET_PACKED;
277 };
278
279
280 /**
281  * Stop attestation iteration for the given operation
282  */
283 struct AttestationIterationStopMessage
284 {
285   /**
286    * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP
287    */
288   struct GNUNET_MessageHeader header;
289
290   /**
291    * Unique identifier for this request (for key collisions).
292    */
293   uint32_t id GNUNET_PACKED;
294 };
295
296
297 /**
298  * Stop attribute iteration for the given operation
299  */
300 struct AttributeIterationStopMessage
301 {
302   /**
303    * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP
304    */
305   struct GNUNET_MessageHeader header;
306
307   /**
308    * Unique identifier for this request (for key collisions).
309    */
310   uint32_t id GNUNET_PACKED;
311 };
312
313 /**
314  * Start a ticket iteration for the given identity
315  */
316 struct TicketIterationStartMessage
317 {
318   /**
319    * Message
320    */
321   struct GNUNET_MessageHeader header;
322
323   /**
324    * Unique identifier for this request (for key collisions).
325    */
326   uint32_t id GNUNET_PACKED;
327
328   /**
329    * Identity.
330    */
331   struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
332 };
333
334
335 /**
336  * Ask for next result of ticket iteration for the given operation
337  */
338 struct TicketIterationNextMessage
339 {
340   /**
341    * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT
342    */
343   struct GNUNET_MessageHeader header;
344
345   /**
346    * Unique identifier for this request (for key collisions).
347    */
348   uint32_t id GNUNET_PACKED;
349 };
350
351
352 /**
353  * Stop ticket iteration for the given operation
354  */
355 struct TicketIterationStopMessage
356 {
357   /**
358    * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP
359    */
360   struct GNUNET_MessageHeader header;
361
362   /**
363    * Unique identifier for this request (for key collisions).
364    */
365   uint32_t id GNUNET_PACKED;
366 };
367
368
369 /**
370  * Ticket issue message
371  */
372 struct IssueTicketMessage
373 {
374   /**
375    * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET
376    */
377   struct GNUNET_MessageHeader header;
378
379   /**
380    * Unique identifier for this request (for key collisions).
381    */
382   uint32_t id GNUNET_PACKED;
383
384   /**
385    * Identity.
386    */
387   struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
388
389   /**
390    * Requesting party.
391    */
392   struct GNUNET_CRYPTO_EcdsaPublicKey rp;
393
394   /**
395    * length of serialized attribute list
396    */
397   uint32_t attr_len GNUNET_PACKED;
398
399   // Followed by a serialized attribute list
400 };
401
402 /**
403  * Ticket revoke message
404  */
405 struct RevokeTicketMessage
406 {
407   /**
408    * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET
409    */
410   struct GNUNET_MessageHeader header;
411
412   /**
413    * Unique identifier for this request (for key collisions).
414    */
415   uint32_t id GNUNET_PACKED;
416
417   /**
418    * Identity.
419    */
420   struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
421
422   /**
423    * length of serialized attribute list
424    */
425   uint32_t attrs_len GNUNET_PACKED;
426
427   /**
428    * The ticket to revoke
429    */
430   struct GNUNET_RECLAIM_Ticket ticket;
431 };
432
433 /**
434  * Ticket revoke message
435  */
436 struct RevokeTicketResultMessage
437 {
438   /**
439    * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT
440    */
441   struct GNUNET_MessageHeader header;
442
443   /**
444    * Unique identifier for this request (for key collisions).
445    */
446   uint32_t id GNUNET_PACKED;
447
448   /**
449    * Revocation result
450    */
451   uint32_t success GNUNET_PACKED;
452 };
453
454
455 /**
456  * Ticket result message
457  */
458 struct TicketResultMessage
459 {
460   /**
461    * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT
462    */
463   struct GNUNET_MessageHeader header;
464
465   /**
466    * Unique identifier for this request (for key collisions).
467    */
468   uint32_t id GNUNET_PACKED;
469
470   /**
471    * The new ticket
472    */
473   struct GNUNET_RECLAIM_Ticket ticket;
474 };
475
476 /**
477  * Ticket consume message
478  */
479 struct ConsumeTicketMessage
480 {
481   /**
482    * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET
483    */
484   struct GNUNET_MessageHeader header;
485
486   /**
487    * Unique identifier for this request (for key collisions).
488    */
489   uint32_t id GNUNET_PACKED;
490
491   /**
492    * Identity.
493    */
494   struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
495
496   /**
497    * The ticket to consume
498    */
499   struct GNUNET_RECLAIM_Ticket ticket;
500 };
501
502 /**
503  * Attribute list is returned from the idp.
504  */
505 struct ConsumeTicketResultMessage
506 {
507   /**
508    * Message header
509    */
510   struct GNUNET_MessageHeader header;
511
512   /**
513    * Unique identifier for this request (for key collisions).
514    */
515   uint32_t id GNUNET_PACKED;
516
517   /**
518    * Result
519    */
520   uint32_t result GNUNET_PACKED;
521
522   /**
523    * Length of serialized attribute data
524    */
525   uint16_t attrs_len GNUNET_PACKED;
526
527   /**
528    * Length of attestation data
529    */
530   uint16_t attestations_len;
531
532   /**
533    * always zero (for alignment)
534    */
535   uint16_t reserved GNUNET_PACKED;
536
537   /**
538    * The public key of the identity.
539    */
540   struct GNUNET_CRYPTO_EcdsaPublicKey identity;
541
542   /* followed by:
543    * serialized attributes data
544    */
545 };
546
547
548 GNUNET_NETWORK_STRUCT_END
549
550 #endif