bede78e2f3dd23d388175672223fa48be2c8fae7
[silc.git] / lib / silccore / silcprivate.h
1 /*
2  
3   silcprivate.h
4  
5   Author: Pekka Riikonen <priikone@silcnet.org>
6  
7   Copyright (C) 1997 - 2001 Pekka Riikonen
8  
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13  
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18
19 */
20
21 /****h* silccore/SILC Private Message Interface
22  *
23  * DESCRIPTION
24  *
25  * Implementation of the SILC Private Message Payload that is used to
26  * deliver private messages.
27  *
28  ***/
29
30 #ifndef SILCPRIVATE_H
31 #define SILCPRIVATE_H
32
33 /****s* silccore/SilcPrivateAPI/SilcPrivateMessagePayload
34  *
35  * NAME
36  * 
37  *    typedef struct SilcPrivateMessagePayloadStruct 
38  *                     *SilcPrivateMessagePayload;
39  *
40  *
41  * DESCRIPTION
42  *
43  *    This context is the actual Private Message Payload and is allocated
44  *    by silc_private_message_payload_parse and given as argument usually
45  *    to all silc_private_message_* functions.  It is freed by the
46  *    silc_private_message_payload_free function.
47  *
48  ***/
49 typedef struct SilcPrivateMessagePayloadStruct *SilcPrivateMessagePayload;
50
51 /* Prototypes */
52
53 /****f* silccore/SilcPrivateAPI/silc_private_message_payload_parse
54  *
55  * SYNOPSIS
56  *
57  *    SilcPrivateMessagePayload 
58  *    silc_private_message_payload_parse(unsigned char *payload,
59  *                                       SilcUInt32 payload_len,
60  *                                       SilcCipher cipher);
61  *
62  * DESCRIPTION
63  *
64  *    Parses private message payload returning new private mesage payload 
65  *    structure. This also decrypts the message if the `cipher' is provided.
66  *
67  ***/
68 SilcPrivateMessagePayload 
69 silc_private_message_payload_parse(unsigned char *payload,
70                                    SilcUInt32 payload_len,
71                                    SilcCipher cipher);
72
73 /****f* silccore/SilcPrivateAPI/silc_private_message_payload_encode
74  *
75  * SYNOPSIS
76  *
77  *    SilcBuffer silc_private_message_payload_encode(SilcUInt16 flags,
78  *                                                   SilcUInt16 data_len,
79  *                                                   const unsigned char *data,
80  *                                                   SilcCipher cipher,
81  *                                                   SilcRng rng);
82  *
83  * DESCRIPTION
84  *
85  *    Encodes private message payload into a buffer and returns it.  If
86  *    the cipher is provided the packet is also encrypted here.  It is provided
87  *    if the private message private keys are used.  If the `rng' is NULL
88  *    then global RNG is used, if non-NULL then `rng' is used.
89  *
90  ***/
91 SilcBuffer silc_private_message_payload_encode(SilcUInt16 flags,
92                                                SilcUInt16 data_len,
93                                                const unsigned char *data,
94                                                SilcCipher cipher,
95                                                SilcRng rng);
96
97 /****f* silccore/SilcPrivateAPI/silc_private_message_payload_free
98  *
99  * SYNOPSIS
100  *
101  *    void 
102  *    silc_private_message_payload_free(SilcPrivateMessagePayload payload);
103  *
104  * DESCRIPTION
105  *
106  *    Frees Private Message Payload
107  *
108  ***/
109 void silc_private_message_payload_free(SilcPrivateMessagePayload payload);
110
111 /****f* silccore/SilcPrivateAPI/silc_private_message_get_flags
112  *
113  * SYNOPSIS
114  *
115  *    SilcUInt16 
116  *    silc_private_message_get_flags(SilcPrivateMessagePayload payload);
117  *
118  * DESCRIPTION
119  *
120  *    Returns flags from the payload. Message flags may indicate some
121  *    status of the message. Private message flags are equivalent to the
122  *    channel message flags.
123  *
124  ***/
125 SilcUInt16 
126 silc_private_message_get_flags(SilcPrivateMessagePayload payload);
127
128 /****f* silccore/SilcPrivateAPI/silc_private_message_get_message
129  *
130  * SYNOPSIS
131  *
132  *    unsigned char *
133  *    silc_private_message_get_message(SilcPrivateMessagePayload payload,
134  *                                     SilcUInt32 *message_len);
135  *
136  * DESCRIPTION
137  *
138  *    Returns the actual private message. The caller must not free it.
139  *
140  ***/
141 unsigned char *
142 silc_private_message_get_message(SilcPrivateMessagePayload payload,
143                                  SilcUInt32 *message_len);
144
145 #endif