New SILC PKCS API, enabling support for other public keys/certs.
[crypto.git] / lib / silccore / silcmessage.h
index ff139decbd61af9d43be8b9e33cec22ea6f8721c..356a2ad81a742ca5785a9dce2258f2c6d68850f4 100644 (file)
@@ -1,10 +1,10 @@
 /*
 
-  silcmessage.h 
+  silcmessage.h
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2002 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
@@ -26,7 +26,7 @@
  *
  * This interface defines also the SILC_MESSAGE_FLAG_SIGNED Payload,
  * which defines how channel messages and private messages can be digitally
- * signed.  This interface provides the payload parsing, encoding, 
+ * signed.  This interface provides the payload parsing, encoding,
  * signature computing and signature verification routines.
  *
  ***/
@@ -37,7 +37,7 @@
 /****s* silccore/SilcMessageAPI/SilcMessagePayload
  *
  * NAME
- * 
+ *
  *    typedef struct SilcMessagePayloadStruct *SilcMessagePayload;
  *
  *
@@ -54,7 +54,7 @@ typedef struct SilcMessagePayloadStruct *SilcMessagePayload;
 /****s* silccore/SilcMessageAPI/SilcMessageSignedPayload
  *
  * NAME
- * 
+ *
  *    typedef struct SilcMessageSignedPayloadStruct *SilcMessageSignedPayload;
  *
  *
@@ -73,12 +73,12 @@ typedef struct SilcMessageSignedPayloadStruct *SilcMessageSignedPayload;
 /****d* silccore/SilcMessageAPI/SilcMessageFlags
  *
  * NAME
- * 
+ *
  *    typedef SilcUInt16 SilcMessageFlags;
  *
  * DESCRIPTION
  *
- *    The message flags type definition and the message flags.  The 
+ *    The message flags type definition and the message flags.  The
  *    message flags are used to indicate some status of the message.
  *
  * SOURCE
@@ -105,13 +105,13 @@ typedef SilcUInt16 SilcMessageFlags;
  *
  * SYNOPSIS
  *
- *    bool silc_message_payload_decrypt(unsigned char *data,
+ *    SilcBool silc_message_payload_decrypt(unsigned char *data,
  *                                      size_t data_len,
- *                                      bool private_message,
- *                                      bool static_key,
+ *                                      SilcBool private_message,
+ *                                      SilcBool static_key,
  *                                      SilcCipher cipher,
  *                                      SilcHmac hmac,
- *                                      bool check_mac);
+ *                                      SilcBool check_mac);
  *
  * DESCRIPTION
  *
@@ -125,28 +125,28 @@ typedef SilcUInt16 SilcMessageFlags;
  *
  *    This is usually used by the Message Payload 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 
+ *    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_message_payload_decrypt(unsigned char *data,
+SilcBool silc_message_payload_decrypt(unsigned char *data,
                                  size_t data_len,
-                                 bool private_message,
-                                 bool static_key,
+                                 SilcBool private_message,
+                                 SilcBool static_key,
                                  SilcCipher cipher,
                                  SilcHmac hmac,
-                                 bool check_mac);
+                                 SilcBool check_mac);
 
 /****f* silccore/SilcMessageAPI/silc_message_payload_parse
  *
  * SYNOPSIS
  *
- *    SilcMessagePayload 
+ *    SilcMessagePayload
  *    silc_message_payload_parse(unsigned char *payload,
  *                               SilcUInt32 payload_len,
- *                               bool private_message,
- *                               bool static_key,
+ *                               SilcBool private_message,
+ *                               SilcBool static_key,
  *                               SilcCipher cipher,
  *                               SilcHmac hmac);
  *
@@ -167,11 +167,11 @@ bool silc_message_payload_decrypt(unsigned char *data,
  *    (no private message key) and this merely decodes the payload.
  *
  ***/
-SilcMessagePayload 
+SilcMessagePayload
 silc_message_payload_parse(unsigned char *payload,
                           SilcUInt32 payload_len,
-                          bool private_message,
-                          bool static_key,
+                          SilcBool private_message,
+                          SilcBool static_key,
                           SilcCipher cipher,
                           SilcHmac hmac);
 
@@ -179,7 +179,7 @@ silc_message_payload_parse(unsigned char *payload,
  *
  * SYNOPSIS
  *
- *    bool silc_message_payload_encrypt(unsigned char *data,
+ *    SilcBool silc_message_payload_encrypt(unsigned char *data,
  *                                      SilcUInt32 data_len,
  *                                      SilcUInt32 true_len,
  *                                      unsigned char *iv,
@@ -196,12 +196,12 @@ silc_message_payload_parse(unsigned char *payload,
  *
  *    This is usually used by the Message Payload 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 
+ *    For example server might need to call this directly in some
  *    circumstances. The `cipher' is used to encrypt the payload and `hmac'
  *    to compute the MAC for the payload.
  *
  ***/
-bool silc_message_payload_encrypt(unsigned char *data,
+SilcBool silc_message_payload_encrypt(unsigned char *data,
                                  SilcUInt32 data_len,
                                  SilcUInt32 true_len,
                                  unsigned char *iv,
@@ -216,8 +216,8 @@ bool silc_message_payload_encrypt(unsigned char *data,
  *    SilcBuffer silc_message_payload_encode(SilcMessageFlags flags,
  *                                           const unsigned char *data,
  *                                           SilcUInt32 data_len,
- *                                           bool generate_iv,
- *                                           bool private_message,
+ *                                           SilcBool generate_iv,
+ *                                           SilcBool private_message,
  *                                           SilcCipher cipher,
  *                                           SilcHmac hmac,
  *                                           SilcRng rng,
@@ -257,8 +257,8 @@ bool silc_message_payload_encrypt(unsigned char *data,
 SilcBuffer silc_message_payload_encode(SilcMessageFlags flags,
                                       const unsigned char *data,
                                       SilcUInt32 data_len,
-                                      bool generate_iv,
-                                      bool private_message,
+                                      SilcBool generate_iv,
+                                      SilcBool private_message,
                                       SilcCipher cipher,
                                       SilcHmac hmac,
                                       SilcRng rng,
@@ -318,7 +318,7 @@ unsigned char *silc_message_get_data(SilcMessagePayload payload,
  *
  * DESCRIPTION
  *
- *    Return the MAC of the payload. The caller must already know the 
+ *    Return the MAC of the payload. The caller must already know the
  *    length of the MAC. The caller must not free the MAC.
  *
  ***/
@@ -333,7 +333,7 @@ unsigned char *silc_message_get_mac(SilcMessagePayload payload);
  *
  * DESCRIPTION
  *
- *    Return the IV of the payload. The caller must already know the 
+ *    Return the IV of the payload. The caller must already know the
  *    length of the IV. The caller must not free the IV.
  *
  ***/
@@ -343,7 +343,7 @@ unsigned char *silc_message_get_iv(SilcMessagePayload payload);
  *
  * SYNOPSIS
  *
- *    const SilcMessageSignedPayload
+ *    SilcMessageSignedPayload
  *    silc_message_get_signature(SilcMessagePayload payload);
  *
  * DESCRIPTION
@@ -354,10 +354,11 @@ unsigned char *silc_message_get_iv(SilcMessagePayload payload);
  *    could not be retrieved from the message.
  *
  *    The caller SHOULD verify the signature by calling the
- *    silc_message_signed_verify function.
+ *    silc_message_signed_verify function.  Caller must not free the
+ *    returned payload pointer.
  *
  ***/
-const SilcMessageSignedPayload
+SilcMessageSignedPayload
 silc_message_get_signature(SilcMessagePayload payload);
 
 /****f* silccore/SilcMessageAPI/silc_message_signed_payload_parse
@@ -404,7 +405,7 @@ silc_message_signed_payload_parse(const unsigned char *data,
  *    is used to produce the signature.  This function returns the encoded
  *    payload with the signature or NULL on error.  Caller must free the
  *    returned buffer.  The `hash' SHOULD be SHA-1 hash function.
- *    
+ *
  *    Application usually does not need to call this since the function
  *    silc_message_payload_encode calls this automatically if the caller
  *    wants to sign the message.
@@ -457,7 +458,7 @@ int silc_message_signed_verify(SilcMessageSignedPayload sig,
  *
  *    SilcPublicKey
  *    silc_message_signed_get_public_key(SilcMessageSignedPayload sig,
- *                                       unsigned char **pk_data,
+ *                                       const unsigned char **pk_data,
  *                                       SilcUInt32 *pk_data_len);
  *
  * DESCRIPTION
@@ -471,7 +472,7 @@ int silc_message_signed_verify(SilcMessageSignedPayload sig,
  ***/
 SilcPublicKey
 silc_message_signed_get_public_key(SilcMessageSignedPayload sig,
-                                  unsigned char **pk_data,
+                                  const unsigned char **pk_data,
                                   SilcUInt32 *pk_data_len);
 
 #endif /* SILCMESSAGE_H */