New SILC PKCS API, enabling support for other public keys/certs.
[silc.git] / lib / silccore / silcmessage.h
index 8e1a9f81ec52dbc08e4ab6b86fdf6cfe8d0a11c8..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
@@ -96,21 +96,22 @@ typedef SilcUInt16 SilcMessageFlags;
 #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 */
+#define SILC_MESSAGE_FLAG_ACK         0x0200     /* ACK messages */
+#define SILC_MESSAGE_FLAG_RESERVED    0x0400     /* to 0x1000 */
+#define SILC_MESSAGE_FLAG_PRIVATE     0x2000     /* to 0x8000 */
 /***/
 
 /****f* silccore/SilcMessageAPI/silc_message_payload_decrypt
  *
  * 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
  *
@@ -124,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);
  *
@@ -166,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);
 
@@ -178,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,
@@ -195,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,
@@ -215,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,
@@ -256,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,
@@ -317,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.
  *
  ***/
@@ -332,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.
  *
  ***/
@@ -342,7 +343,7 @@ unsigned char *silc_message_get_iv(SilcMessagePayload payload);
  *
  * SYNOPSIS
  *
- *    const SilcMessageSignedPayload
+ *    SilcMessageSignedPayload
  *    silc_message_get_signature(SilcMessagePayload payload);
  *
  * DESCRIPTION
@@ -353,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
@@ -403,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.
@@ -455,7 +457,9 @@ int silc_message_signed_verify(SilcMessageSignedPayload sig,
  * SYNOPSIS
  *
  *    SilcPublicKey
- *    silc_message_signed_get_public_key(SilcMessageSignedPayload sig);
+ *    silc_message_signed_get_public_key(SilcMessageSignedPayload sig,
+ *                                       const unsigned char **pk_data,
+ *                                       SilcUInt32 *pk_data_len);
  *
  * DESCRIPTION
  *
@@ -468,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 */