X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccore%2Fsilcchannel.h;h=5e6ddf6e496ad20ac2315913f0c98df700b8af50;hb=054c9b2c9b21c3cbe87e53c0e0bacb2bff918e68;hp=ea280aa89817cac0779845e6807ce6bdd1ecaaba;hpb=61af85976e943396cf2cbe9bdaee3e4119c74aec;p=crypto.git diff --git a/lib/silccore/silcchannel.h b/lib/silccore/silcchannel.h index ea280aa8..5e6ddf6e 100644 --- a/lib/silccore/silcchannel.h +++ b/lib/silccore/silcchannel.h @@ -22,14 +22,11 @@ * * 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 +51,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,37 +67,6 @@ typedef struct SilcChannelMessagePayloadStruct *SilcChannelMessagePayload; ***/ typedef struct SilcChannelKeyPayloadStruct *SilcChannelKeyPayload; -/****d* silccore/SilcChannelAPI/SilcMessageFlags - * - * NAME - * - * typedef SilcUInt16 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 SilcUInt16 SilcMessageFlags; - -/* The message flags (shared by both channel and private messages) */ -#define SILC_MESSAGE_FLAG_NONE 0x0000 /* No flags */ -#define SILC_MESSAGE_FLAG_AUTOREPLY 0x0001 /* Automatically replied */ -#define SILC_MESSAGE_FLAG_NOREPLY 0x0002 /* Send no reply to this */ -#define SILC_MESSAGE_FLAG_ACTION 0x0004 /* Action message */ -#define SILC_MESSAGE_FLAG_NOTICE 0x0008 /* Notice message */ -#define SILC_MESSAGE_FLAG_REQUEST 0x0010 /* A request */ -#define SILC_MESSAGE_FLAG_SIGNED 0x0020 /* Message is signed */ -#define SILC_MESSAGE_FLAG_REPLY 0x0040 /* A reply */ -#define SILC_MESSAGE_FLAG_DATA 0x0080 /* MIME object */ -#define SILC_MESSAGE_FLAG_UTF8 0x0100 /* UTF-8 string */ -#define SILC_MESSAGE_FLAG_RESERVED 0x0200 /* to 0x0800 */ -#define SILC_MESSAGE_FLAG_PRIVATE 0x1000 /* to 0x8000 */ -/***/ - /* Prototypes */ /****f* silccore/SilcChannelAPI/silc_channel_payload_parse @@ -262,204 +211,6 @@ SilcChannelID *silc_channel_get_id_parse(SilcChannelPayload payload); ***/ SilcUInt32 silc_channel_get_mode(SilcChannelPayload payload); -/****f* silccore/SilcChannelAPI/silc_channel_message_payload_decrypt - * - * SYNOPSIS - * - * bool 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 `check_mac' is FALSE then MAC is not verified. - * - ***/ -bool silc_channel_message_payload_decrypt(unsigned char *data, - size_t data_len, - SilcCipher cipher, - SilcHmac hmac, - bool check_mac); - -/****f* silccore/SilcChannelAPI/silc_channel_message_payload_parse - * - * SYNOPSIS - * - * SilcChannelMessagePayload - * silc_channel_message_payload_parse(const unsigned char *payload, - * SilcUInt32 payload_len, - * 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(unsigned char *payload, - SilcUInt32 payload_len, - SilcCipher cipher, - SilcHmac hmac); - -/****f* silccore/SilcChannelAPI/silc_channel_message_payload_encrypt - * - * SYNOPSIS - * - * bool silc_channel_message_payload_encrypt(unsigned char *data, - * SilcUInt32 data_len, - * unsigned char *iv, - * SilcUInt32 iv_len, - * SilcCipher cipher, - * SilcHmac hmac); - * - * DESCRIPTION - * - * This function is used to encrypt the Channel Messsage Payload which is - * the `data' and `data_len'. The `data_len' is the data length which is - * used to create MAC out of. The `data' MUST have additional space - * after `data_len' bytes for the MAC which is appended to the data. - * - * This is usually used by the Channel Message interface itself but can - * be called by the appliation if separate encryption process is required. - * For example server might need to call this directly in some - * circumstances. The `cipher' is used to encrypt the payload. - * - ***/ -bool silc_channel_message_payload_encrypt(unsigned char *data, - SilcUInt32 data_len, - unsigned char *iv, - SilcUInt32 iv_len, - SilcCipher cipher, - SilcHmac hmac); - -/****f* silccore/SilcChannelAPI/silc_channel_message_payload_encode - * - * SYNOPSIS - * - * SilcBuffer silc_channel_message_payload_encode(SilcMessageFlags flags, - * SilcUInt16 data_len, - * const unsigned char *data, - * SilcUInt16 iv_len, - * unsigned char *iv, - * SilcCipher cipher, - * SilcHmac hmac. - * SilcRng rng); - * - * 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. If `rng' is NULL then global RNG is used, if non-NULL then - * the `rng' is used. - * - ***/ -SilcBuffer silc_channel_message_payload_encode(SilcMessageFlags flags, - SilcUInt16 data_len, - const unsigned char *data, - SilcUInt16 iv_len, - unsigned char *iv, - SilcCipher cipher, - SilcHmac hmac, - SilcRng rng); - -/****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, - * SilcUInt32 *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, - SilcUInt32 *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); - /****f* silccore/SilcChannelAPI/silc_channel_key_payload_parse * * SYNOPSIS