aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2017-12-02 22:32:28 +0100
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2017-12-02 22:32:28 +0100
commita9a7ac802811e76e33b54040bf31f00ea9438cea (patch)
tree7f9a22daca2b95e7308d8877c668fc878a39ae4c /src/include
parent14c62ed969ace8843154d10b55d4c3571383dc37 (diff)
downloadgnunet-a9a7ac802811e76e33b54040bf31f00ea9438cea.tar.gz
gnunet-a9a7ac802811e76e33b54040bf31f00ea9438cea.zip
-refactored
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_identity_attribute_lib.h231
-rw-r--r--src/include/gnunet_identity_attribute_plugin.h149
-rw-r--r--src/include/gnunet_identity_provider_plugin.h5
-rw-r--r--src/include/gnunet_identity_provider_service.h109
4 files changed, 386 insertions, 108 deletions
diff --git a/src/include/gnunet_identity_attribute_lib.h b/src/include/gnunet_identity_attribute_lib.h
new file mode 100644
index 000000000..039b50351
--- /dev/null
+++ b/src/include/gnunet_identity_attribute_lib.h
@@ -0,0 +1,231 @@
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 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
218#if 0 /* keep Emacsens' auto-indent happy */
219{
220#endif
221#ifdef __cplusplus
222}
223#endif
224
225
226/* ifndef GNUNET_IDENTITY_ATTRIBUTE_LIB_H */
227#endif
228
229/** @} */ /* end of group identity */
230
231/* 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
index c0a258ab6..4b5098d58 100644
--- a/src/include/gnunet_identity_provider_plugin.h
+++ b/src/include/gnunet_identity_provider_plugin.h
@@ -51,7 +51,7 @@ extern "C"
51 */ 51 */
52typedef void (*GNUNET_IDENTITY_PROVIDER_TicketIterator) (void *cls, 52typedef void (*GNUNET_IDENTITY_PROVIDER_TicketIterator) (void *cls,
53 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, 53 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
54 const struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs); 54 const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
55 55
56 56
57/** 57/**
@@ -74,7 +74,7 @@ struct GNUNET_IDENTITY_PROVIDER_PluginFunctions
74 */ 74 */
75 int (*store_ticket) (void *cls, 75 int (*store_ticket) (void *cls,
76 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, 76 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
77 const struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs); 77 const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs);
78 78
79 /** 79 /**
80 * Delete a ticket from the database. 80 * Delete a ticket from the database.
@@ -111,7 +111,6 @@ struct GNUNET_IDENTITY_PROVIDER_PluginFunctions
111 void *iter_cls); 111 void *iter_cls);
112}; 112};
113 113
114
115#if 0 /* keep Emacsens' auto-indent happy */ 114#if 0 /* keep Emacsens' auto-indent happy */
116{ 115{
117#endif 116#endif
diff --git a/src/include/gnunet_identity_provider_service.h b/src/include/gnunet_identity_provider_service.h
index d17a1cc9c..6bc05d0f4 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.
@@ -82,92 +82,6 @@ struct GNUNET_IDENTITY_PROVIDER_Ticket
82 */ 82 */
83struct GNUNET_IDENTITY_PROVIDER_Operation; 83struct GNUNET_IDENTITY_PROVIDER_Operation;
84 84
85/**
86 * Flags that can be set for an attribute.
87 */
88enum GNUNET_IDENTITY_PROVIDER_AttributeType
89{
90
91 /**
92 * No value attribute.
93 */
94 GNUNET_IDENTITY_PROVIDER_AT_NULL = 0,
95
96 /**
97 * String attribute.
98 */
99 GNUNET_IDENTITY_PROVIDER_AT_STRING = 1,
100
101};
102
103
104
105/**
106 * An attribute.
107 */
108struct GNUNET_IDENTITY_PROVIDER_Attribute
109{
110
111 /**
112 * Type of Attribute.
113 */
114 uint32_t attribute_type;
115
116 /**
117 * Attribute version
118 */
119 uint32_t attribute_version;
120
121 /**
122 * Number of bytes in @e data.
123 */
124 size_t data_size;
125
126 /**
127 * The name of the attribute. Note "name" must never be individually
128 * free'd
129 */
130 const char* name;
131
132 /**
133 * Binary value stored as attribute value. Note: "data" must never
134 * be individually 'malloc'ed, but instead always points into some
135 * existing data area.
136 */
137 const void *data;
138
139};
140
141struct GNUNET_IDENTITY_PROVIDER_AttributeList
142{
143 /**
144 * List head
145 */
146 struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *list_head;
147
148 /**
149 * List tail
150 */
151 struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *list_tail;
152};
153
154struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry
155{
156 /**
157 * DLL
158 */
159 struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *prev;
160
161 /**
162 * DLL
163 */
164 struct GNUNET_IDENTITY_PROVIDER_AttributeListEntry *next;
165
166 /**
167 * The attribute
168 */
169 struct GNUNET_IDENTITY_PROVIDER_Attribute *attribute;
170};
171 85
172/** 86/**
173 * Connect to the identity provider service. 87 * Connect to the identity provider service.
@@ -208,27 +122,12 @@ typedef void
208struct GNUNET_IDENTITY_PROVIDER_Operation * 122struct GNUNET_IDENTITY_PROVIDER_Operation *
209GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle *h, 123GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle *h,
210 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, 124 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
211 const struct GNUNET_IDENTITY_PROVIDER_Attribute *attr, 125 const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr,
212 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cont, 126 GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cont,
213 void *cont_cls); 127 void *cont_cls);
214 128
215 129
216/** 130/**
217 * Create a new attribute.
218 *
219 * @param name the attribute name
220 * @param type the attribute type
221 * @param data the attribute value
222 * @param data_size the attribute value size
223 * @return the new attribute
224 */
225struct GNUNET_IDENTITY_PROVIDER_Attribute *
226GNUNET_IDENTITY_PROVIDER_attribute_new (const char* attr_name,
227 uint32_t attr_type,
228 const void* data,
229 size_t data_size);
230
231/**
232 * Process an attribute that was stored in the idp. 131 * Process an attribute that was stored in the idp.
233 * 132 *
234 * @param cls closure 133 * @param cls closure
@@ -237,7 +136,7 @@ GNUNET_IDENTITY_PROVIDER_attribute_new (const char* attr_name,
237typedef void 136typedef void
238(*GNUNET_IDENTITY_PROVIDER_AttributeResult) (void *cls, 137(*GNUNET_IDENTITY_PROVIDER_AttributeResult) (void *cls,
239 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 138 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
240 const struct GNUNET_IDENTITY_PROVIDER_Attribute *attr); 139 const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr);
241 140
242 141
243 142
@@ -327,7 +226,7 @@ struct GNUNET_IDENTITY_PROVIDER_Operation *
327GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *id, 226GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *id,
328 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, 227 const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss,
329 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, 228 const struct GNUNET_CRYPTO_EcdsaPublicKey *rp,
330 const struct GNUNET_IDENTITY_PROVIDER_AttributeList *attrs, 229 const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs,
331 GNUNET_IDENTITY_PROVIDER_TicketCallback cb, 230 GNUNET_IDENTITY_PROVIDER_TicketCallback cb,
332 void *cb_cls); 231 void *cb_cls);
333 232