2 This file is part of GNUnet
3 (C) 2008, 2011 Christian Grothoff (and other contributing authors)
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.
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.
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.
23 * @brief support for chat
24 * @author Christian Grothoff
25 * @author Nathan Evans
26 * @author Vitaly Minko
32 #include "gnunet_chat_service.h"
35 * Constant IV since we generate a new session key per each message.
37 #define INITVALUE "InitializationVectorValue"
41 * Client-service messages
44 GNUNET_NETWORK_STRUCT_BEGIN
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
52 struct ReceiveNotificationMessage
55 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION
57 struct GNUNET_MessageHeader header;
60 * Message options, see GNUNET_CHAT_MsgOptions.
62 uint32_t msg_options GNUNET_PACKED;
65 * Sequence number of the message (unique per sender).
67 uint32_t sequence_number GNUNET_PACKED;
70 * For alignment (should be zero).
72 uint32_t reserved GNUNET_PACKED;
75 * Timestamp of the message.
77 struct GNUNET_TIME_AbsoluteNBO timestamp;
80 * Hash of the public key of the pseudonym of the sender of the message.
81 * Should be all zeros for anonymous.
83 struct GNUNET_HashCode sender;
86 * The encrypted session key.
88 struct GNUNET_CRYPTO_RsaEncryptedData encrypted_key;
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.
98 struct TransmitRequestMessage
101 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_TRANSMIT_REQUEST
103 struct GNUNET_MessageHeader header;
106 * For alignment (should be zero).
108 uint32_t reserved GNUNET_PACKED;
111 * Signature confirming receipt. Signature covers everything from header
114 struct GNUNET_CRYPTO_RsaSignature signature;
117 * What is being signed and why?
119 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
122 * Desired message options, see GNUNET_CHAT_MsgOptions.
124 uint32_t msg_options GNUNET_PACKED;
127 * Sequence number of the message (unique per sender).
129 uint32_t sequence_number GNUNET_PACKED;
132 * Timestamp of the message.
134 struct GNUNET_TIME_AbsoluteNBO timestamp;
137 * Who should receive this message? Set to all zeros for "everyone".
139 struct GNUNET_HashCode target;
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.
149 struct ConfirmationReceiptMessage
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.
156 struct GNUNET_MessageHeader header;
159 * For alignment (should be zero).
161 uint32_t reserved GNUNET_PACKED;
164 * Signature confirming receipt. Signature covers everything from header
167 struct GNUNET_CRYPTO_RsaSignature signature;
170 * What is being signed and why?
172 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
175 * Sequence number of the original message.
177 uint32_t sequence_number GNUNET_PACKED;
180 * For alignment (should be zero).
182 uint32_t reserved2 GNUNET_PACKED;
187 struct GNUNET_TIME_AbsoluteNBO timestamp;
190 * Who is confirming the receipt?
192 struct GNUNET_HashCode target;
195 * Who is the author of the chat message?
197 struct GNUNET_HashCode author;
200 * Hash of the (possibly encrypted) content.
202 struct GNUNET_HashCode content;
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.
212 struct JoinRequestMessage
215 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_JOIN_REQUEST
217 struct GNUNET_MessageHeader header;
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.
226 uint32_t msg_options GNUNET_PACKED;
229 * Length of the room name.
231 uint16_t room_name_len GNUNET_PACKED;
234 * For alignment (should be zero).
236 uint16_t reserved GNUNET_PACKED;
237 uint32_t reserved2 GNUNET_PACKED;
240 * Public key of the joining member.
242 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
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
252 struct JoinNotificationMessage
255 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION
257 struct GNUNET_MessageHeader header;
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.
266 uint32_t msg_options GNUNET_PACKED;
269 * Public key of the new user.
271 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
277 * Message send by server to client to indicate leaving of another room member.
279 struct LeaveNotificationMessage
282 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION
284 struct GNUNET_MessageHeader header;
287 * Reserved (for alignment).
289 uint32_t reserved GNUNET_PACKED;
294 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded user;
300 * Peer-to-peer messages
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.
308 struct P2PJoinNotificationMessage
311 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_JOIN_NOTIFICATION
313 struct GNUNET_MessageHeader header;
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.
322 uint32_t msg_options GNUNET_PACKED;
325 * Length of the room name.
327 uint16_t room_name_len GNUNET_PACKED;
330 * Reserved (should be zero).
332 uint16_t reserved GNUNET_PACKED;
333 uint32_t reserved2 GNUNET_PACKED;
336 * Public key of the joining member.
338 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
344 * Message send by one peer to another to indicate leaving of another room
347 struct P2PLeaveNotificationMessage
350 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_LEAVE_NOTIFICATION
352 struct GNUNET_MessageHeader header;
355 * Reserved (for alignment).
357 uint32_t reserved GNUNET_PACKED;
362 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded user;
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.
373 struct P2PReceiveNotificationMessage
376 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_MESSAGE_NOTIFICATION
378 struct GNUNET_MessageHeader header;
381 * Message options, see GNUNET_CHAT_MsgOptions.
383 uint32_t msg_options GNUNET_PACKED;
386 * Sequence number of the message (unique per sender).
388 uint32_t sequence_number GNUNET_PACKED;
391 * Length of the room name. This is only used for anonymous messages.
393 uint16_t room_name_len GNUNET_PACKED;
396 * Reserved (for alignment).
398 uint16_t reserved GNUNET_PACKED;
401 * Timestamp of the message.
403 struct GNUNET_TIME_AbsoluteNBO timestamp;
406 * Hash of the public key of the pseudonym of the sender of the message
407 * Should be all zeros for anonymous.
409 struct GNUNET_HashCode sender;
412 * Who should receive this message? Set to all zeros for "everyone".
414 struct GNUNET_HashCode target;
417 * The encrypted session key.
419 struct GNUNET_CRYPTO_RsaEncryptedData encrypted_key;
425 * Receipt sent from one peer to another to confirm delivery of a chat message.
427 struct P2PConfirmationReceiptMessage
430 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_CONFIRMATION_RECEIPT
432 struct GNUNET_MessageHeader header;
435 * For alignment (should be zero).
437 uint32_t reserved GNUNET_PACKED;
440 * Signature confirming receipt. Signature covers everything from header
443 struct GNUNET_CRYPTO_RsaSignature signature;
446 * What is being signed and why?
448 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
451 * Sequence number of the original message.
453 uint32_t msg_sequence_number GNUNET_PACKED;
456 * Sequence number of the receipt.
458 uint32_t sequence_number GNUNET_PACKED;
463 struct GNUNET_TIME_AbsoluteNBO timestamp;
466 * Who is confirming the receipt?
468 struct GNUNET_HashCode target;
471 * Who is the author of the chat message?
473 struct GNUNET_HashCode author;
476 * Hash of the (possibly encrypted) content.
478 struct GNUNET_HashCode content;
481 GNUNET_NETWORK_STRUCT_END