X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccore%2Fsilcchannel.h;h=385f6807b452361a4821192422600f17fadb663a;hb=d1e71f42379e8b5cd0748a7aeae8561b02cfe53d;hp=fdd8e663850c5bb3838655e841cac4d9587d2bd5;hpb=2dc218143c7859f7529396dc121ae08e2fd78da0;p=silc.git diff --git a/lib/silccore/silcchannel.h b/lib/silccore/silcchannel.h index fdd8e663..385f6807 100644 --- a/lib/silccore/silcchannel.h +++ b/lib/silccore/silcchannel.h @@ -4,12 +4,11 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2001 Pekka Riikonen + Copyright (C) 1997 - 2005 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,18 +17,15 @@ */ -/****h* silccore/SilcChannelAPI +/****h* silccore/SILC Channel Interface * * DESCRIPTION * - * Implementations of the Channel Payload, Channel Message Payload and - * Channel Key Payload. The Channel Payload represents new channel and - * is used to distribute the information of the new channel. The Channel - * Message Payload is used to deliver messages to the channel. The routines - * for Channel Message Payload also handles the encryption and decryption - * of the payload. Last, the Channel Key Payload is used to distribute - * a new key to the channel. It is done for example every time someone - * joins a channel or the old key expires. + * Implementations of the Channel Payload and Channel Key Payload. The + * Channel Payload represents new channel and is used to distribute the + * information of the new channel. The Channel Key Payload is used to + * distribute a new key to the channel. It is done for example every + * time someone joins a channel or the old key expires. * ***/ @@ -54,23 +50,6 @@ ***/ typedef struct SilcChannelPayloadStruct *SilcChannelPayload; -/****s* silccore/SilcChannelAPI/SilcChannelMessagePayload - * - * NAME - * - * typedef struct - * SilcChannelMessagePayloadStruct *SilcChannelMessagePayload; - * - * DESCRIPTION - * - * This context is the actual Channel Message Payload and is allocated - * by silc_channel_message_payload_parse and given as argument usually to - * all silc_channel_message_payload_* functions. It is freed by the - * silc_channel_message_payload_free function. - * - ***/ -typedef struct SilcChannelMessagePayloadStruct *SilcChannelMessagePayload; - /****s* silccore/SilcChannelAPI/SilcChannelKeyPayload * * NAME @@ -87,41 +66,15 @@ typedef struct SilcChannelMessagePayloadStruct *SilcChannelMessagePayload; ***/ typedef struct SilcChannelKeyPayloadStruct *SilcChannelKeyPayload; -/****d* silccore/SilcChannelAPI/SilcMessageFlags - * - * NAME - * - * typedef uint16 SilcMessageFlags; - * - * DESCRIPTION - * - * The message flags type definition and the message flags. The - * message flags are used to indicate some status of the message. - * These flags are also used by the private message interfaces. - * - * SOURCE - */ -typedef uint16 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_NOTICE 0x0008 -#define SILC_MESSAGE_FLAG_REQUEST 0x0010 -#define SILC_MESSAGE_FLAG_SIGNED 0x0020 -#define SILC_MESSAGE_FLAG_RESERVED 0x0040 /* to 0x0200 */ -#define SILC_MESSAGE_FLAG_PRIVATE 0x0400 /* to 0x8000 */ -/***/ - /* Prototypes */ /****f* silccore/SilcChannelAPI/silc_channel_payload_parse * * SYNOPSIS * - * SilcChannelPayload silc_channel_payload_parse(SilcBuffer buffer); + * SilcChannelPayload + * silc_channel_payload_parse(const unsigned char *payload, + * SilcUInt32 payload_len); * * DESCRIPTION * @@ -129,13 +82,16 @@ typedef uint16 SilcMessageFlags; * `buffer' is the raw payload buffer. * ***/ -SilcChannelPayload silc_channel_payload_parse(SilcBuffer buffer); +SilcChannelPayload silc_channel_payload_parse(const unsigned char *payload, + SilcUInt32 payload_len); /****f* silccore/SilcChannelAPI/silc_channel_payload_parse_list * * SYNOPSIS * - * SilcDList silc_channel_payload_parse_list(SilcBuffer buffer); + * SilcDList + * silc_channel_payload_parse_list(const unsigned char *payload, + * SilcUInt32 payload_len); * * DESCRIPTION * @@ -144,28 +100,29 @@ SilcChannelPayload silc_channel_payload_parse(SilcBuffer buffer); * now includes multiple Channel Payloads one after the other. * ***/ -SilcDList silc_channel_payload_parse_list(SilcBuffer buffer); +SilcDList silc_channel_payload_parse_list(const unsigned char *payload, + SilcUInt32 payload_len); /****f* silccore/SilcChannelAPI/silc_channel_payload_encode * * SYNOPSIS * - * SilcBuffer silc_channel_payload_encode(unsigned char *channel_name, - * uint16 channel_name_len, - * unsigned char *channel_id, - * uint32 channel_id_len, - * uint32 mode); + * SilcBuffer silc_channel_payload_encode(const unsigned char *channel_name, + * SilcUInt16 channel_name_len, + * const unsigned char *channel_id, + * SilcUInt32 channel_id_len, + * SilcUInt32 mode); * * DESCRIPTION * * Encode new channel payload and returns it as buffer. * ***/ -SilcBuffer silc_channel_payload_encode(unsigned char *channel_name, - uint16 channel_name_len, - unsigned char *channel_id, - uint32 channel_id_len, - uint32 mode); +SilcBuffer silc_channel_payload_encode(const unsigned char *channel_name, + SilcUInt16 channel_name_len, + const unsigned char *channel_id, + SilcUInt32 channel_id_len, + SilcUInt32 mode); /****f* silccore/SilcChannelAPI/silc_channel_payload_free * @@ -198,7 +155,7 @@ void silc_channel_payload_list_free(SilcDList list); * SYNOPSIS * * unsigned char *silc_channel_get_name(SilcChannelPayload payload, - * uint32 *channel_name_len); + * SilcUInt32 *channel_name_len); * * DESCRIPTION * @@ -206,14 +163,14 @@ void silc_channel_payload_list_free(SilcDList list); * ***/ unsigned char *silc_channel_get_name(SilcChannelPayload payload, - uint32 *channel_name_len); + SilcUInt32 *channel_name_len); /****f* silccore/SilcChannelAPI/silc_channel_get_id * * SYNOPSIS * * unsigned char *silc_channel_get_id(SilcChannelPayload payload, - * uint32 *channel_id_len); + * SilcUInt32 *channel_id_len); * * DESCRIPTION * @@ -221,7 +178,7 @@ unsigned char *silc_channel_get_name(SilcChannelPayload payload, * ***/ unsigned char *silc_channel_get_id(SilcChannelPayload payload, - uint32 *channel_id_len); + SilcUInt32 *channel_id_len); /****f* silccore/SilcChannelAPI/silc_channel_get_id_parse * @@ -242,7 +199,7 @@ SilcChannelID *silc_channel_get_id_parse(SilcChannelPayload payload); * * SYNOPSIS * - * uint32 silc_channel_get_mode(SilcChannelPayload payload); + * SilcUInt32 silc_channel_get_mode(SilcChannelPayload payload); * * DESCRIPTION * @@ -251,175 +208,15 @@ SilcChannelID *silc_channel_get_id_parse(SilcChannelPayload payload); * dictates what the usage of the mode is in different circumstances. * ***/ -uint32 silc_channel_get_mode(SilcChannelPayload payload); - -/****f* silccore/SilcChannelAPI/silc_channel_message_payload_decrypt - * - * SYNOPSIS - * - * int silc_channel_message_payload_decrypt(unsigned char *data, - * size_t data_len, - * SilcCipher cipher, - * SilcHmac hmac); - * - * DESCRIPTION - * - * Decrypt the channel message. First push the IV out of the packet `data'. - * The IV is used in the decryption process. Then decrypt the message. - * After decryption, take the MAC from the decrypted packet, compute MAC - * and compare the MACs. If they match, the decryption was successful - * and we have the channel message ready to be displayed. - * - * This is usually used by the Channel Message interface itself but can - * be called by the appliation if separate decryption process is required. - * For example server might need to call this directly in some - * circumstances. The `cipher' is used to decrypt the payload. - * - * If the `hmac' is no provided then the MAC of the channel message is - * not verified. - * - ***/ -int silc_channel_message_payload_decrypt(unsigned char *data, - size_t data_len, - SilcCipher cipher, - SilcHmac hmac); - -/****f* silccore/SilcChannelAPI/silc_channel_message_payload_parse - * - * SYNOPSIS - * - * SilcChannelMessagePayload - * silc_channel_message_payload_parse(SilcBuffer buffer, - * SilcCipher cipher, - * SilcHmac hmac); - * - * DESCRIPTION - * - * Parses channel message payload returning new channel payload structure. - * This also decrypts it and checks the MAC. The `cipher's is used to - * decrypt the payload. - * - * If the `hmac' is no provided then the MAC of the channel message is - * not verified. - * - ***/ -SilcChannelMessagePayload -silc_channel_message_payload_parse(SilcBuffer buffer, - SilcCipher cipher, - SilcHmac hmac); - -/****f* silccore/SilcChannelAPI/silc_channel_message_payload_encode - * - * SYNOPSIS - * - * SilcBuffer silc_channel_message_payload_encode(uint16 flags, - * uint16 data_len, - * unsigned char *data, - * uint16 iv_len, - * unsigned char *iv, - * SilcCipher cipher, - * SilcHmac hmac); - * - * DESCRIPTION - * - * Encodes channel message payload into a buffer and returns it. This - * is used to add channel message payload into a packet. As the channel - * payload is encrypted separately from other parts of the packet padding - * must be applied to the payload. The function generates the padding - * automatically from random data. The `cipher' is the cipher used - * encrypt the payload and `hmac' is used to compute the MAC for the - * payload. - * - ***/ -SilcBuffer silc_channel_message_payload_encode(uint16 flags, - uint16 data_len, - unsigned char *data, - uint16 iv_len, - unsigned char *iv, - SilcCipher cipher, - SilcHmac hmac); - -/****f* silccore/SilcChannelAPI/silc_channel_message_payload_free - * - * SYNOPSIS - * - * void - * silc_channel_message_payload_free(SilcChannelMessagePayload payload); - * - * DESCRIPTION - * - * Free's Channel Message Payload and all data in it. - * - ***/ -void silc_channel_message_payload_free(SilcChannelMessagePayload payload); - -/****f* silccore/SilcChannelAPI/silc_channel_message_get_flags - * - * SYNOPSIS - * - * SilcMessageFlags - * silc_channel_message_get_flags(SilcChannelMessagePayload payload); - * - * DESCRIPTION - * - * Returns the message flags from the payload. - * - ***/ -SilcMessageFlags -silc_channel_message_get_flags(SilcChannelMessagePayload payload); - -/****f* silccore/SilcChannelAPI/silc_channel_message_get_data - * - * SYNOPSIS - * - * unsigned char * - * silc_channel_message_get_data(SilcChannelMessagePayload payload, - * uint32 *data_len); - * - * DESCRIPTION - * - * Return the data in the payload, that is, the actual channel message. - * The caller must not free it. - * - ***/ -unsigned char *silc_channel_message_get_data(SilcChannelMessagePayload payload, - uint32 *data_len); - -/****f* silccore/SilcChannelAPI/silc_channel_message_get_mac - * - * SYNOPSIS - * - * unsigned char * - * silc_channel_message_get_mac(SilcChannelMessagePayload payload); - * - * DESCRIPTION - * - * Return the MAC of the payload. The caller must already know the - * length of the MAC. The caller must not free the MAC. - * - ***/ -unsigned char *silc_channel_message_get_mac(SilcChannelMessagePayload payload); - -/****f* silccore/SilcChannelAPI/silc_channel_message_get_iv - * - * SYNOPSIS - * - * unsigned char * - * silc_channel_message_get_iv(SilcChannelMessagePayload payload); - * - * DESCRIPTION - * - * Return the IV of the payload. The caller must already know the - * length of the IV. The caller must not free the IV. - * - ***/ -unsigned char *silc_channel_message_get_iv(SilcChannelMessagePayload payload); +SilcUInt32 silc_channel_get_mode(SilcChannelPayload payload); /****f* silccore/SilcChannelAPI/silc_channel_key_payload_parse * * SYNOPSIS * - * SilcChannelKeyPayload silc_channel_key_payload_parse(SilcBuffer buffer); + * SilcChannelKeyPayload + * silc_channel_key_payload_parse(const unsigned char *payload, + * uin32 payload_len); * * DESCRIPTION * @@ -427,18 +224,20 @@ unsigned char *silc_channel_message_get_iv(SilcChannelMessagePayload payload); * structure. * ***/ -SilcChannelKeyPayload silc_channel_key_payload_parse(SilcBuffer buffer); +SilcChannelKeyPayload +silc_channel_key_payload_parse(const unsigned char *payload, + SilcUInt32 payload_len); /****f* silccore/SilcChannelAPI/silc_channel_key_payload_encode * * SYNOPSIS * - * SilcBuffer silc_channel_key_payload_encode(uint16 id_len, - * unsigned char *id, - * uint16 cipher_len, - * unsigned char *cipher, - * uint16 key_len, - * unsigned char *key); + * SilcBuffer silc_channel_key_payload_encode(SilcUInt16 id_len, + * const unsigned char *id, + * SilcUInt16 cipher_len, + * const unsigned char *cipher, + * SilcUInt16 key_len, + * const unsigned char *key); * * DESCRIPTION * @@ -446,12 +245,12 @@ SilcChannelKeyPayload silc_channel_key_payload_parse(SilcBuffer buffer); * to add channel key payload into a packet. * ***/ -SilcBuffer silc_channel_key_payload_encode(uint16 id_len, - unsigned char *id, - uint16 cipher_len, - unsigned char *cipher, - uint16 key_len, - unsigned char *key); +SilcBuffer silc_channel_key_payload_encode(SilcUInt16 id_len, + const unsigned char *id, + SilcUInt16 cipher_len, + const unsigned char *cipher, + SilcUInt16 key_len, + const unsigned char *key); /****f* silccore/SilcChannelAPI/silc_channel_key_payload_free * @@ -471,7 +270,7 @@ void silc_channel_key_payload_free(SilcChannelKeyPayload payload); * SYNOPSIS * * unsigned char *silc_channel_key_get_id(SilcChannelKeyPayload payload, - * uint32 *id_len); + * SilcUInt32 *id_len); * * DESCRIPTION * @@ -480,14 +279,14 @@ void silc_channel_key_payload_free(SilcChannelKeyPayload payload); * ***/ unsigned char *silc_channel_key_get_id(SilcChannelKeyPayload payload, - uint32 *id_len); + SilcUInt32 *id_len); /****f* silccore/SilcChannelAPI/silc_channel_key_get_cipher * * SYNOPSIS * * unsigned char *silc_channel_key_get_cipher(SilcChannelKeyPayload payload, - * uint32 *cipher_len); + * SilcUInt32 *cipher_len); * * DESCRIPTION * @@ -496,14 +295,14 @@ unsigned char *silc_channel_key_get_id(SilcChannelKeyPayload payload, * ***/ unsigned char *silc_channel_key_get_cipher(SilcChannelKeyPayload payload, - uint32 *cipher_len); + SilcUInt32 *cipher_len); /****f* silccore/SilcChannelAPI/silc_channel_key_get_key * * SYNOPSIS * * unsigned char *silc_channel_key_get_key(SilcChannelKeyPayload payload, - * uint32 *key_len); + * SilcUInt32 *key_len); * * DESCRIPTION * @@ -512,6 +311,6 @@ unsigned char *silc_channel_key_get_cipher(SilcChannelKeyPayload payload, * ***/ unsigned char *silc_channel_key_get_key(SilcChannelKeyPayload payload, - uint32 *key_len); + SilcUInt32 *key_len); #endif