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