updates.
[silc.git] / lib / silccore / silcchannel.h
index 792c31c83627f2ecc7b02be8b92f40c9ed86f4dc..6d97e1a251a7ae483550910a70bc928ba8ac4268 100644 (file)
@@ -18,7 +18,7 @@
 
 */
 
-/****h* silccore/SilcChannelAPI
+/****h* silccore/SILC Channel Interface
  *
  * DESCRIPTION
  *
@@ -316,6 +316,40 @@ silc_channel_message_payload_parse(unsigned char *payload,
                                   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,
+ *                                              SilcUInt32 true_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 `true_len' is the true length of `data'
+ *    message payload and is used assemble rest of the packet after MAC
+ *    creation. The `true_len' length packet will then be encrypted.
+ *
+ *    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,
+                                         SilcUInt32 true_len,
+                                         unsigned char *iv,
+                                         SilcUInt32 iv_len,
+                                         SilcCipher cipher,
+                                         SilcHmac hmac);
+
 /****f* silccore/SilcChannelAPI/silc_channel_message_payload_encode
  *
  * SYNOPSIS
@@ -326,7 +360,8 @@ silc_channel_message_payload_parse(unsigned char *payload,
  *                                                   SilcUInt16 iv_len,
  *                                                   unsigned char *iv,
  *                                                   SilcCipher cipher,
- *                                                   SilcHmac hmac);
+ *                                                   SilcHmac hmac.
+ *                                                   SilcRng rng);
  *
  * DESCRIPTION
  *
@@ -336,7 +371,8 @@ silc_channel_message_payload_parse(unsigned char *payload,
  *    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.
+ *    payload.  If `rng' is NULL then global RNG is used, if non-NULL then
+ *    the `rng' is used.
  *
  ***/
 SilcBuffer silc_channel_message_payload_encode(SilcUInt16 flags,
@@ -345,7 +381,8 @@ SilcBuffer silc_channel_message_payload_encode(SilcUInt16 flags,
                                               SilcUInt16 iv_len,
                                               unsigned char *iv,
                                               SilcCipher cipher,
-                                              SilcHmac hmac);
+                                              SilcHmac hmac,
+                                              SilcRng rng);
 
 /****f* silccore/SilcChannelAPI/silc_channel_message_payload_free
  *