-consistently use struct GNUNET_HashCode
[oweals/gnunet.git] / src / chat / chat.h
1 /*
2      This file is part of GNUnet
3      (C) 2008, 2011 Christian Grothoff (and other contributing authors)
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 2, 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., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file chat/chat.h
23  * @brief support for chat
24  * @author Christian Grothoff
25  * @author Nathan Evans
26  * @author Vitaly Minko
27  */
28
29 #ifndef CHAT_H
30 #define CHAT_H
31
32 #include "gnunet_chat_service.h"
33
34 /**
35  * Constant IV since we generate a new session key per each message.
36  */
37 #define INITVALUE "InitializationVectorValue"
38
39
40 /**
41  * Client-service messages
42  */
43
44 GNUNET_NETWORK_STRUCT_BEGIN
45
46 /**
47  * Notification sent by service to client indicating that we've received a chat
48  * message.  After this struct, the remaining bytes are the actual text message.
49  * If the mesasge is private, then the text is encrypted, otherwise it's
50  * plaintext.
51  */
52 struct ReceiveNotificationMessage
53 {
54   /**
55    * Message type will be GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION
56    */
57   struct GNUNET_MessageHeader header;
58
59   /**
60    * Message options, see GNUNET_CHAT_MsgOptions.
61    */
62   uint32_t msg_options GNUNET_PACKED;
63
64   /**
65    * Sequence number of the message (unique per sender).
66    */
67   uint32_t sequence_number GNUNET_PACKED;
68
69   /**
70    * For alignment (should be zero).
71    */
72   uint32_t reserved GNUNET_PACKED;
73
74   /**
75    * Timestamp of the message.
76    */
77   struct GNUNET_TIME_AbsoluteNBO timestamp;
78
79   /**
80    * Hash of the public key of the pseudonym of the sender of the message.
81    * Should be all zeros for anonymous.
82    */
83   struct GNUNET_HashCode sender;
84
85   /**
86    * The encrypted session key.
87    */
88   struct GNUNET_CRYPTO_RsaEncryptedData encrypted_key;
89
90 };
91
92
93 /**
94  * Request sent by client to transmit a chat message to another room members.
95  * After this struct, the remaining bytes are the actual message in plaintext.
96  * Private messages are encrypted on the service side.
97  */
98 struct TransmitRequestMessage
99 {
100   /**
101    * Message type will be GNUNET_MESSAGE_TYPE_CHAT_TRANSMIT_REQUEST
102    */
103   struct GNUNET_MessageHeader header;
104
105   /**
106    * For alignment (should be zero).
107    */
108   uint32_t reserved GNUNET_PACKED;
109
110   /**
111    * Signature confirming receipt.  Signature covers everything from header
112    * through content.
113    */
114   struct GNUNET_CRYPTO_RsaSignature signature;
115
116   /**
117    * What is being signed and why?
118    */
119   struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
120
121   /**
122    * Desired message options, see GNUNET_CHAT_MsgOptions.
123    */
124   uint32_t msg_options GNUNET_PACKED;
125
126   /**
127    * Sequence number of the message (unique per sender).
128    */
129   uint32_t sequence_number GNUNET_PACKED;
130
131   /**
132    * Timestamp of the message.
133    */
134   struct GNUNET_TIME_AbsoluteNBO timestamp;
135
136   /**
137    * Who should receive this message?  Set to all zeros for "everyone".
138    */
139   struct GNUNET_HashCode target;
140
141 };
142
143
144 /**
145  * Receipt sent from a message receiver to the service to confirm delivery of
146  * a chat message and from the service to sender of the original message to
147  * acknowledge delivery.
148  */
149 struct ConfirmationReceiptMessage
150 {
151   /**
152    * Message type will be
153    * GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_RECEIPT when sending from client,
154    * GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_NOTIFICATION when sending to client.
155    */
156   struct GNUNET_MessageHeader header;
157
158   /**
159    * For alignment (should be zero).
160    */
161   uint32_t reserved GNUNET_PACKED;
162
163   /**
164    * Signature confirming receipt.  Signature covers everything from header
165    * through content.
166    */
167   struct GNUNET_CRYPTO_RsaSignature signature;
168
169   /**
170    * What is being signed and why?
171    */
172   struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
173
174   /**
175    * Sequence number of the original message.
176    */
177   uint32_t sequence_number GNUNET_PACKED;
178
179   /**
180    * For alignment (should be zero).
181    */
182   uint32_t reserved2 GNUNET_PACKED;
183
184   /**
185    * Time of receipt.
186    */
187   struct GNUNET_TIME_AbsoluteNBO timestamp;
188
189   /**
190    * Who is confirming the receipt?
191    */
192   struct GNUNET_HashCode target;
193
194   /**
195    * Who is the author of the chat message?
196    */
197   struct GNUNET_HashCode author;
198
199   /**
200    * Hash of the (possibly encrypted) content.
201    */
202   struct GNUNET_HashCode content;
203
204 };
205
206
207 /**
208  * Message send from client to daemon to join a chat room.
209  * This struct is followed by the room name and then
210  * the serialized ECRS meta data describing the new member.
211  */
212 struct JoinRequestMessage
213 {
214   /**
215    * Message type will be GNUNET_MESSAGE_TYPE_CHAT_JOIN_REQUEST
216    */
217   struct GNUNET_MessageHeader header;
218
219   /**
220    * Options.  Set all options that this client is willing to receive.
221    * For example, if the client does not want to receive anonymous or
222    * OTR messages but is willing to generate acknowledgements and
223    * receive private messages, this should be set to
224    * GNUNET_CHAT_MSG_PRIVATE | GNUNET_CHAT_MSG_ACKNOWLEDGED.
225    */
226   uint32_t msg_options GNUNET_PACKED;
227
228   /**
229    * Length of the room name.
230    */
231   uint16_t room_name_len GNUNET_PACKED;
232
233   /**
234    * For alignment (should be zero).
235    */
236   uint16_t reserved GNUNET_PACKED;
237   uint32_t reserved2 GNUNET_PACKED;
238
239   /**
240    * Public key of the joining member.
241    */
242   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
243
244 };
245
246
247 /**
248  * Message send by server to client to indicate joining of another room member.
249  * This struct is followed by the serialized ECRS MetaData describing the new
250  * member.
251  */
252 struct JoinNotificationMessage
253 {
254   /**
255    * Message type will be GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION
256    */
257   struct GNUNET_MessageHeader header;
258
259   /**
260    * Options.  Set to all options that the new user is willing to
261    * process.  For example, if the client does not want to receive
262    * anonymous or OTR messages but is willing to generate
263    * acknowledgements and receive private messages, this should be set
264    * to GNUNET_CHAT_MSG_PRIVATE | GNUNET_CHAT_MSG_ACKNOWLEDGED.
265    */
266   uint32_t msg_options GNUNET_PACKED;
267
268   /**
269    * Public key of the new user.
270    */
271   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
272
273 };
274
275
276 /**
277  * Message send by server to client to indicate leaving of another room member.
278  */
279 struct LeaveNotificationMessage
280 {
281   /**
282    * Message type will be GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION
283    */
284   struct GNUNET_MessageHeader header;
285
286   /**
287    * Reserved (for alignment).
288    */
289   uint32_t reserved GNUNET_PACKED;
290
291   /**
292    * Who is leaving?
293    */
294   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded user;
295
296 };
297
298
299 /**
300  * Peer-to-peer messages
301  */
302
303 /**
304  * Message send by one peer to another to indicate joining of another room
305  * member.  This struct is followed by the room name and then the serialized
306  * ECRS MetaData describing the new member.
307  */
308 struct P2PJoinNotificationMessage
309 {
310   /**
311    * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_JOIN_NOTIFICATION
312    */
313   struct GNUNET_MessageHeader header;
314
315   /**
316    * Options.  Set all options that this client is willing to receive.
317    * For example, if the client does not want to receive anonymous or
318    * OTR messages but is willing to generate acknowledgements and
319    * receive private messages, this should be set to
320    * GNUNET_CHAT_MSG_PRIVATE | GNUNET_CHAT_MSG_ACKNOWLEDGED.
321    */
322   uint32_t msg_options GNUNET_PACKED;
323
324   /**
325    * Length of the room name.
326    */
327   uint16_t room_name_len GNUNET_PACKED;
328
329   /**
330    * Reserved (should be zero).
331    */
332   uint16_t reserved GNUNET_PACKED;
333   uint32_t reserved2 GNUNET_PACKED;
334
335   /**
336    * Public key of the joining member.
337    */
338   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
339
340 };
341
342
343 /**
344  * Message send by one peer to another to indicate leaving of another room
345  * member.
346  */
347 struct P2PLeaveNotificationMessage
348 {
349   /**
350    * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_LEAVE_NOTIFICATION
351    */
352   struct GNUNET_MessageHeader header;
353
354   /**
355    * Reserved (for alignment).
356    */
357   uint32_t reserved GNUNET_PACKED;
358
359   /**
360    * Who is leaving?
361    */
362   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded user;
363
364 };
365
366
367 /**
368  * Message send by one peer to another to indicate receiving of a chat message.
369  * This struct is followed by the room name (only if the message is anonymous)
370  * and then the remaining bytes are the actual text message.  If the mesasge is
371  * private, then the text is encrypted, otherwise it's plaintext.
372  */
373 struct P2PReceiveNotificationMessage
374 {
375   /**
376    * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_MESSAGE_NOTIFICATION
377    */
378   struct GNUNET_MessageHeader header;
379
380   /**
381    * Message options, see GNUNET_CHAT_MsgOptions.
382    */
383   uint32_t msg_options GNUNET_PACKED;
384
385   /**
386    * Sequence number of the message (unique per sender).
387    */
388   uint32_t sequence_number GNUNET_PACKED;
389
390   /**
391    * Length of the room name. This is only used for anonymous messages.
392    */
393   uint16_t room_name_len GNUNET_PACKED;
394
395   /**
396    * Reserved (for alignment).
397    */
398   uint16_t reserved GNUNET_PACKED;
399
400   /**
401    * Timestamp of the message.
402    */
403   struct GNUNET_TIME_AbsoluteNBO timestamp;
404
405   /**
406    * Hash of the public key of the pseudonym of the sender of the message
407    * Should be all zeros for anonymous.
408    */
409   struct GNUNET_HashCode sender;
410
411   /**
412    * Who should receive this message?  Set to all zeros for "everyone".
413    */
414   struct GNUNET_HashCode target;
415
416   /**
417    * The encrypted session key.
418    */
419   struct GNUNET_CRYPTO_RsaEncryptedData encrypted_key;
420
421 };
422
423
424 /**
425  * Receipt sent from one peer to another to confirm delivery of a chat message.
426  */
427 struct P2PConfirmationReceiptMessage
428 {
429   /**
430    * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_CONFIRMATION_RECEIPT
431    */
432   struct GNUNET_MessageHeader header;
433
434   /**
435    * For alignment (should be zero).
436    */
437   uint32_t reserved GNUNET_PACKED;
438
439   /**
440    * Signature confirming receipt.  Signature covers everything from header
441    * through content.
442    */
443   struct GNUNET_CRYPTO_RsaSignature signature;
444
445   /**
446    * What is being signed and why?
447    */
448   struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
449
450   /**
451    * Sequence number of the original message.
452    */
453   uint32_t msg_sequence_number GNUNET_PACKED;
454
455   /**
456    * Sequence number of the receipt.
457    */
458   uint32_t sequence_number GNUNET_PACKED;
459
460   /**
461    * Time of receipt.
462    */
463   struct GNUNET_TIME_AbsoluteNBO timestamp;
464
465   /**
466    * Who is confirming the receipt?
467    */
468   struct GNUNET_HashCode target;
469
470   /**
471    * Who is the author of the chat message?
472    */
473   struct GNUNET_HashCode author;
474
475   /**
476    * Hash of the (possibly encrypted) content.
477    */
478   struct GNUNET_HashCode content;
479
480 };
481 GNUNET_NETWORK_STRUCT_END
482
483 #endif
484
485 /* end of chat.h */