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
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
50 struct ReceiveNotificationMessage
53 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION
55 struct GNUNET_MessageHeader header;
58 * Message options, see GNUNET_CHAT_MsgOptions.
60 uint32_t msg_options GNUNET_PACKED;
63 * Sequence number of the message (unique per sender).
65 uint32_t sequence_number GNUNET_PACKED;
68 * For alignment (should be zero).
70 uint32_t reserved GNUNET_PACKED;
73 * Hash of the public key of the pseudonym of the sender of the message.
74 * TBD: Should be all zeros for anonymous.
76 GNUNET_HashCode sender;
79 * The encrypted session key.
81 struct GNUNET_CRYPTO_RsaEncryptedData encrypted_key;
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.
91 struct TransmitRequestMessage
94 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_TRANSMIT_REQUEST
96 struct GNUNET_MessageHeader header;
99 * For alignment (should be zero).
101 uint32_t reserved GNUNET_PACKED;
104 * Signature confirming receipt. Signature covers everything from header
107 struct GNUNET_CRYPTO_RsaSignature signature;
110 * What is being signed and why?
112 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
115 * Desired message options, see GNUNET_CHAT_MsgOptions.
117 uint32_t msg_options GNUNET_PACKED;
120 * Sequence number of the message (unique per sender).
122 uint32_t sequence_number GNUNET_PACKED;
125 * Who should receive this message? Set to all zeros for "everyone".
127 GNUNET_HashCode target;
133 * Receipt sent from a message receiver to the service to confirm delivery of
136 struct ConfirmationReceiptMessage
139 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_RECEIPT
141 struct GNUNET_MessageHeader header;
144 * For alignment (should be zero).
146 uint32_t reserved GNUNET_PACKED;
149 * Signature confirming receipt. Signature covers everything from header
152 struct GNUNET_CRYPTO_RsaSignature signature;
155 * What is being signed and why?
157 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
160 * Sequence number of the original message.
162 uint32_t sequence_number GNUNET_PACKED;
165 * For alignment (should be zero).
167 uint32_t reserved2 GNUNET_PACKED;
172 struct GNUNET_TIME_AbsoluteNBO timestamp;
175 * Who is confirming the receipt?
177 GNUNET_HashCode target;
180 * Who is the author of the chat message?
182 GNUNET_HashCode author;
185 * Hash of the (possibly encrypted) content.
187 GNUNET_HashCode content;
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.
197 struct JoinRequestMessage
200 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_JOIN_REQUEST
202 struct GNUNET_MessageHeader header;
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.
211 uint32_t msg_options GNUNET_PACKED;
214 * Length of the room name.
216 uint16_t room_name_len GNUNET_PACKED;
219 * For alignment (should be zero).
221 uint16_t reserved GNUNET_PACKED;
222 uint32_t reserved2 GNUNET_PACKED;
225 * Public key of the joining member.
227 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
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
237 struct JoinNotificationMessage
240 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION
242 struct GNUNET_MessageHeader header;
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.
251 uint32_t msg_options GNUNET_PACKED;
254 * Public key of the new user.
256 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
262 * Message send by server to client to indicate leaving of another room member.
264 struct LeaveNotificationMessage
267 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION
269 struct GNUNET_MessageHeader header;
272 * Reserved (for alignment).
274 uint32_t reserved GNUNET_PACKED;
279 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded user;
285 * Peer-to-peer messages
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.
293 struct P2PJoinNotificationMessage
296 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_JOIN_NOTIFICATION
298 struct GNUNET_MessageHeader header;
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.
307 uint32_t msg_options GNUNET_PACKED;
310 * Length of the room name.
312 uint16_t room_name_len GNUNET_PACKED;
315 * Reserved (should be zero).
317 uint16_t reserved GNUNET_PACKED;
318 uint32_t reserved2 GNUNET_PACKED;
321 * Public key of the joining member.
323 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
329 * Message send by one peer to another to indicate leaving of another room
332 struct P2PLeaveNotificationMessage
335 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_LEAVE_NOTIFICATION
337 struct GNUNET_MessageHeader header;
340 * Reserved (for alignment).
342 uint32_t reserved GNUNET_PACKED;
347 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded user;
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.
357 struct P2PReceiveNotificationMessage
360 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_MESSAGE_NOTIFICATION
362 struct GNUNET_MessageHeader header;
365 * Message options, see GNUNET_CHAT_MsgOptions.
367 uint32_t msg_options GNUNET_PACKED;
370 * Sequence number of the message (unique per sender).
372 uint32_t sequence_number GNUNET_PACKED;
375 * Reserved (for alignment).
377 uint32_t reserved GNUNET_PACKED;
380 * Hash of the public key of the pseudonym of the sender of the message
381 * TBD: Should be all zeros for anonymous.
383 GNUNET_HashCode sender;
386 * Who should receive this message? Set to all zeros for "everyone".
388 GNUNET_HashCode target;
391 * The encrypted session key.
393 struct GNUNET_CRYPTO_RsaEncryptedData encrypted_key;
399 * Receipt sent from one peer to another to confirm delivery of a chat message.
401 struct P2PConfirmationReceiptMessage
404 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_CONFIRMATION_RECEIPT
406 struct GNUNET_MessageHeader header;
409 * For alignment (should be zero).
411 uint32_t reserved GNUNET_PACKED;
414 * Signature confirming receipt. Signature covers everything from header
417 struct GNUNET_CRYPTO_RsaSignature signature;
420 * What is being signed and why?
422 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
425 * Sequence number of the original message.
427 uint32_t msg_sequence_number GNUNET_PACKED;
430 * Sequence number of the receipt.
432 uint32_t sequence_number GNUNET_PACKED;
437 struct GNUNET_TIME_AbsoluteNBO timestamp;
440 * Who is confirming the receipt?
442 GNUNET_HashCode target;
445 * Who is the author of the chat message?
447 GNUNET_HashCode author;
450 * Hash of the (possibly encrypted) content.
452 GNUNET_HashCode content;