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