* Redefined the Private Message Payload to support private message
keys and to support the new private message flags. Updated
- the protocol specs.
+ the protocol specs. Flags makes it possible to have for example
+ CTCP style messages.
* Added new type SilcPrivateMessagePayload and defined an API
for it in the lib/silcclient/silcprivate.[ch].
private message key set, unset and list commands with the new
KEY command.
+ * Redefined the Channel Message Payload to include the channel
+ message flags (equal with private message flags) to support
+ for example CTCP style messages.
+
+ * Defined some of the message (for channel and private message)
+ flags. Updated the protocol specs and added the flags to the
+ lib/silccore/silcchannel.h.
+
Wed Mar 28 15:52:36 EEST 2001 Pekka Riikonen <priikone@poseidon.pspt.fi>
* Added SilcKeyAgreementStatus type to the key agreement routines
silc_hash_make(client->md5hash, channel->iv, iv_len, channel->iv);
/* Encode the channel payload. This also encrypts the message payload. */
- payload = silc_channel_message_payload_encode(data_len, data, iv_len,
- channel->iv, cipher, hmac,
- client->rng);
+ payload = silc_channel_message_payload_encode(0, data_len, data, iv_len,
+ channel->iv, cipher, hmac);
/* Get data used in packet header encryption, keys and stuff. */
cipher = conn->send_key;
SILC_LOG_DEBUG(("Sending private message"));
/* Encode private message payload */
- buffer = silc_private_message_payload_encode(strlen(conn->nickname),
- conn->nickname, 0,
+ buffer = silc_private_message_payload_encode(0, strlen(conn->nickname),
+ conn->nickname,
data_len, data,
client_entry->send_key);
/* Channel Message Payload structure. Contents of this structure is parsed
from SILC packets. */
struct SilcChannelMessagePayloadStruct {
+ unsigned short flags;
unsigned short data_len;
unsigned char *data;
unsigned char *mac;
/* Parse the Channel Message Payload. Ignore the padding. */
ret = silc_buffer_unformat(buffer,
+ SILC_STR_UI_SHORT(&new->flags),
SILC_STR_UI16_NSTRING_ALLOC(&new->data,
&new->data_len),
SILC_STR_UI16_NSTRING(NULL, NULL),
encrypted separately from other parts of the packet padding must
be applied to the payload. */
-SilcBuffer silc_channel_message_payload_encode(unsigned short data_len,
+SilcBuffer silc_channel_message_payload_encode(unsigned short flags,
+ unsigned short data_len,
unsigned char *data,
unsigned short iv_len,
unsigned char *iv,
SilcCipher cipher,
- SilcHmac hmac,
- SilcRng rng)
+ SilcHmac hmac)
{
int i;
SilcBuffer buffer;
/* Calculate length of padding. IV is not included into the calculation
since it is not encrypted. */
mac_len = silc_hmac_len(hmac);
- len = 4 + data_len + mac_len;
+ len = 6 + data_len + mac_len;
pad_len = SILC_PACKET_PADLEN((len + 2));
/* Allocate channel payload buffer */
buffer = silc_buffer_alloc(len);
/* Generate padding */
- for (i = 0; i < pad_len; i++) pad[i] = silc_rng_get_byte(rng);
+ for (i = 0; i < pad_len; i++) pad[i] = silc_rng_global_get_byte();
/* Encode the Channel Message Payload */
- silc_buffer_pull_tail(buffer, 4 + data_len + pad_len);
+ silc_buffer_pull_tail(buffer, 6 + data_len + pad_len);
silc_buffer_format(buffer,
+ SILC_STR_UI_SHORT(flags),
SILC_STR_UI_SHORT(data_len),
SILC_STR_UI_XNSTRING(data, data_len),
SILC_STR_UI_SHORT(pad_len),
/* Put rest of the data to the payload */
silc_buffer_pull_tail(buffer, mac_len + iv_len);
- silc_buffer_pull(buffer, 4 + data_len + pad_len);
+ silc_buffer_pull(buffer, 6 + data_len + pad_len);
silc_buffer_format(buffer,
SILC_STR_UI_XNSTRING(mac, mac_len),
SILC_STR_UI_XNSTRING(iv, iv_len),
SILC_STR_END);
- silc_buffer_push(buffer, 4 + data_len + pad_len);
+ silc_buffer_push(buffer, 6 + data_len + pad_len);
/* Encrypt payload of the packet. This is encrypted with the channel key. */
silc_cipher_encrypt(cipher, buffer->data, buffer->data,
actual structure is defined in source file and is private data. */
typedef struct SilcChannelKeyPayloadStruct *SilcChannelKeyPayload;
+/* The Message flag type */
+typedef unsigned short SilcMessageFlags;
+
+/* The message flags (shared by both channel and private messages) */
+#define SILC_MESSAGE_FLAG_NONE 0x0000
+#define SILC_MESSAGE_FLAG_AUTOREPLY 0x0001
+#define SILC_MESSAGE_FLAG_NOREPLY 0x0002
+#define SILC_MESSAGE_FLAG_ACTION 0x0004
+#define SILC_MESSAGE_FLAG_RESERVED 0x0008 /* to 0x0200 */
+#define SILC_MESSAGE_FLAG_PRIVATE 0x0400 /* to 0x8000 */
+
/* Prototypes */
SilcChannelPayload silc_channel_payload_parse(SilcBuffer buffer);
SilcDList silc_channel_payload_parse_list(SilcBuffer buffer);
silc_channel_message_payload_parse(SilcBuffer buffer,
SilcCipher cipher,
SilcHmac hmac);
-SilcBuffer silc_channel_message_payload_encode(unsigned short data_len,
+SilcBuffer silc_channel_message_payload_encode(unsigned short flags,
+ unsigned short data_len,
unsigned char *data,
unsigned short iv_len,
unsigned char *iv,
SilcCipher cipher,
- SilcHmac hmac,
- SilcRng rng);
+ SilcHmac hmac);
void silc_channel_message_payload_free(SilcChannelMessagePayload payload);
unsigned char *silc_channel_message_get_data(SilcChannelMessagePayload payload,
unsigned int *data_len);