96550bdf2f2f61d77fa54048bc25e2d103f92853
[oweals/gnunet.git] / src / identity / identity.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2013 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 Christian Grothoff
23  * @file identity/identity.h
24  *
25  * @brief Common type definitions for the identity
26  *        service and API.
27  */
28 #ifndef IDENTITY_H
29 #define IDENTITY_H
30
31 #include "gnunet_common.h"
32
33
34 GNUNET_NETWORK_STRUCT_BEGIN
35
36
37 /**
38  * Answer from service to client about last operation;
39  * GET_DEFAULT maybe answered with this message on failure;
40  * CREATE and RENAME will always be answered with this message.
41  */
42 struct ResultCodeMessage
43 {
44   /**
45    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
46    */
47   struct GNUNET_MessageHeader header;
48
49   /**
50    * Status code for the last operation, in NBO.
51    * (currently not used).
52    */
53   uint32_t result_code GNUNET_PACKED;
54
55   /* followed by 0-terminated error message (on error) */
56 };
57
58
59 /**
60  * Client informs service about desire to lookup a (single) pseudonym.
61  */
62 struct LookupMessage
63 {
64   /**
65    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP
66    */
67   struct GNUNET_MessageHeader header;
68
69   /* followed by 0-terminated ego name */
70 };
71
72
73 /**
74  * Service informs client about status of a pseudonym.
75  */
76 struct UpdateMessage
77 {
78   /**
79    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
80    */
81   struct GNUNET_MessageHeader header;
82
83   /**
84    * Number of bytes in ego name string including 0-termination, in NBO;
85    * 0 if the ego was deleted.
86    */
87   uint16_t name_len GNUNET_PACKED;
88
89   /**
90    * Usually #GNUNET_NO, #GNUNET_YES to signal end of list.
91    */
92   uint16_t end_of_list GNUNET_PACKED;
93
94   /**
95    * The private key
96    */
97   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
98
99   /* followed by 0-terminated ego name */
100 };
101
102
103 /**
104  * Client requests knowledge about default identity for
105  * a subsystem from identity service.
106  */
107 struct GetDefaultMessage
108 {
109   /**
110    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT
111    */
112   struct GNUNET_MessageHeader header;
113
114   /**
115    * Number of bytes in service name string including 0-termination, in NBO.
116    */
117   uint16_t name_len GNUNET_PACKED;
118
119   /**
120    * Always zero.
121    */
122   uint16_t reserved GNUNET_PACKED;
123
124
125   /* followed by 0-terminated service name */
126 };
127
128
129 /**
130  * Used from service to client as a result to the GET_DEFAULT
131  * message, used from client to service to SET_DEFAULT.
132  */
133 struct SetDefaultMessage
134 {
135   /**
136    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
137    */
138   struct GNUNET_MessageHeader header;
139
140   /**
141    * Number of bytes in service name string including 0-termination, in NBO.
142    */
143   uint16_t name_len GNUNET_PACKED;
144
145   /**
146    * Always zero.
147    */
148   uint16_t reserved GNUNET_PACKED;
149
150   /**
151    * The private key
152    */
153   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
154
155   /* followed by 0-terminated service name */
156 };
157
158
159 /**
160  * Client requests creation of an identity.  Service
161  * will respond with a result code.
162  */
163 struct CreateRequestMessage
164 {
165   /**
166    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
167    */
168   struct GNUNET_MessageHeader header;
169
170   /**
171    * Number of bytes in identity name string including 0-termination, in NBO.
172    */
173   uint16_t name_len GNUNET_PACKED;
174
175   /**
176    * Always zero.
177    */
178   uint16_t reserved GNUNET_PACKED;
179
180   /**
181    * The private key
182    */
183   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
184
185   /* followed by 0-terminated identity name */
186 };
187
188
189 /**
190  * Client requests renaming of an identity.  Service
191  * will respond with a result code.
192  */
193 struct RenameMessage
194 {
195   /**
196    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
197    */
198   struct GNUNET_MessageHeader header;
199
200   /**
201    * Number of characters in the old name including 0-termination, in NBO.
202    */
203   uint16_t old_name_len GNUNET_PACKED;
204
205   /**
206    * Number of characters in the new name including 0-termination, in NBO.
207    */
208   uint16_t new_name_len GNUNET_PACKED;
209
210   /* followed by 0-terminated old name */
211   /* followed by 0-terminated new name */
212 };
213
214
215 /**
216  * Client requests deletion of an identity.  Service
217  * will respond with a result code.
218  */
219 struct DeleteMessage
220 {
221   /**
222    * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
223    */
224   struct GNUNET_MessageHeader header;
225
226   /**
227    * Number of characters in the name including 0-termination, in NBO.
228    */
229   uint16_t name_len GNUNET_PACKED;
230
231   /**
232    * Always zero.
233    */
234   uint16_t reserved GNUNET_PACKED;
235
236   /* followed by 0-terminated name */
237 };
238
239 GNUNET_NETWORK_STRUCT_END
240
241 /**
242  * Handle for an ego.
243  */
244 struct GNUNET_IDENTITY_Ego
245 {
246   /**
247    * Private key associated with this ego.
248    */
249   struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
250
251   /**
252    * Current name associated with this ego.
253    */
254   char *name;
255
256   /**
257    * Client context associated with this ego.
258    */
259   void *ctx;
260
261   /**
262    * Hash of the public key of this ego.
263    */
264   struct GNUNET_HashCode id;
265 };
266
267
268 #endif