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 * Timestamp of the message.
75 struct GNUNET_TIME_AbsoluteNBO timestamp;
78 * Hash of the public key of the pseudonym of the sender of the message.
79 * Should be all zeros for anonymous.
81 GNUNET_HashCode sender;
84 * The encrypted session key.
86 struct GNUNET_CRYPTO_RsaEncryptedData encrypted_key;
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.
96 struct TransmitRequestMessage
99 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_TRANSMIT_REQUEST
101 struct GNUNET_MessageHeader header;
104 * For alignment (should be zero).
106 uint32_t reserved GNUNET_PACKED;
109 * Signature confirming receipt. Signature covers everything from header
112 struct GNUNET_CRYPTO_RsaSignature signature;
115 * What is being signed and why?
117 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
120 * Desired message options, see GNUNET_CHAT_MsgOptions.
122 uint32_t msg_options GNUNET_PACKED;
125 * Sequence number of the message (unique per sender).
127 uint32_t sequence_number GNUNET_PACKED;
130 * Timestamp of the message.
132 struct GNUNET_TIME_AbsoluteNBO timestamp;
135 * Who should receive this message? Set to all zeros for "everyone".
137 GNUNET_HashCode target;
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.
147 struct ConfirmationReceiptMessage
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.
154 struct GNUNET_MessageHeader header;
157 * For alignment (should be zero).
159 uint32_t reserved GNUNET_PACKED;
162 * Signature confirming receipt. Signature covers everything from header
165 struct GNUNET_CRYPTO_RsaSignature signature;
168 * What is being signed and why?
170 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
173 * Sequence number of the original message.
175 uint32_t sequence_number GNUNET_PACKED;
178 * For alignment (should be zero).
180 uint32_t reserved2 GNUNET_PACKED;
185 struct GNUNET_TIME_AbsoluteNBO timestamp;
188 * Who is confirming the receipt?
190 GNUNET_HashCode target;
193 * Who is the author of the chat message?
195 GNUNET_HashCode author;
198 * Hash of the (possibly encrypted) content.
200 GNUNET_HashCode content;
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.
210 struct JoinRequestMessage
213 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_JOIN_REQUEST
215 struct GNUNET_MessageHeader header;
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.
224 uint32_t msg_options GNUNET_PACKED;
227 * Length of the room name.
229 uint16_t room_name_len GNUNET_PACKED;
232 * For alignment (should be zero).
234 uint16_t reserved GNUNET_PACKED;
235 uint32_t reserved2 GNUNET_PACKED;
238 * Public key of the joining member.
240 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
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
250 struct JoinNotificationMessage
253 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION
255 struct GNUNET_MessageHeader header;
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.
264 uint32_t msg_options GNUNET_PACKED;
267 * Public key of the new user.
269 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
275 * Message send by server to client to indicate leaving of another room member.
277 struct LeaveNotificationMessage
280 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION
282 struct GNUNET_MessageHeader header;
285 * Reserved (for alignment).
287 uint32_t reserved GNUNET_PACKED;
292 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded user;
298 * Peer-to-peer messages
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.
306 struct P2PJoinNotificationMessage
309 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_JOIN_NOTIFICATION
311 struct GNUNET_MessageHeader header;
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.
320 uint32_t msg_options GNUNET_PACKED;
323 * Length of the room name.
325 uint16_t room_name_len GNUNET_PACKED;
328 * Reserved (should be zero).
330 uint16_t reserved GNUNET_PACKED;
331 uint32_t reserved2 GNUNET_PACKED;
334 * Public key of the joining member.
336 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
342 * Message send by one peer to another to indicate leaving of another room
345 struct P2PLeaveNotificationMessage
348 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_LEAVE_NOTIFICATION
350 struct GNUNET_MessageHeader header;
353 * Reserved (for alignment).
355 uint32_t reserved GNUNET_PACKED;
360 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded user;
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.
371 struct P2PReceiveNotificationMessage
374 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_MESSAGE_NOTIFICATION
376 struct GNUNET_MessageHeader header;
379 * Message options, see GNUNET_CHAT_MsgOptions.
381 uint32_t msg_options GNUNET_PACKED;
384 * Sequence number of the message (unique per sender).
386 uint32_t sequence_number GNUNET_PACKED;
389 * Length of the room name. This is only used for anonymous messages.
391 uint16_t room_name_len GNUNET_PACKED;
394 * Reserved (for alignment).
396 uint16_t reserved GNUNET_PACKED;
399 * Timestamp of the message.
401 struct GNUNET_TIME_AbsoluteNBO timestamp;
404 * Hash of the public key of the pseudonym of the sender of the message
405 * Should be all zeros for anonymous.
407 GNUNET_HashCode sender;
410 * Who should receive this message? Set to all zeros for "everyone".
412 GNUNET_HashCode target;
415 * The encrypted session key.
417 struct GNUNET_CRYPTO_RsaEncryptedData encrypted_key;
423 * Receipt sent from one peer to another to confirm delivery of a chat message.
425 struct P2PConfirmationReceiptMessage
428 * Message type will be GNUNET_MESSAGE_TYPE_CHAT_P2P_CONFIRMATION_RECEIPT
430 struct GNUNET_MessageHeader header;
433 * For alignment (should be zero).
435 uint32_t reserved GNUNET_PACKED;
438 * Signature confirming receipt. Signature covers everything from header
441 struct GNUNET_CRYPTO_RsaSignature signature;
444 * What is being signed and why?
446 struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
449 * Sequence number of the original message.
451 uint32_t msg_sequence_number GNUNET_PACKED;
454 * Sequence number of the receipt.
456 uint32_t sequence_number GNUNET_PACKED;
461 struct GNUNET_TIME_AbsoluteNBO timestamp;
464 * Who is confirming the receipt?
466 GNUNET_HashCode target;
469 * Who is the author of the chat message?
471 GNUNET_HashCode author;
474 * Hash of the (possibly encrypted) content.
476 GNUNET_HashCode content;