Added SILC Thread Queue API
[silc.git] / lib / silcutil / silcbase64.h
1 /*
2
3   silcbase64.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2007 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; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 /****h* silcutil/SILC Base64 API
21  *
22  * DESCRIPTION
23  *
24  * This interface provides Base64 encoding and decoding routines.
25  *
26  ***/
27
28 #ifndef SILCBASE64_H
29 #define SILCBASE64_H
30
31 /****f* silcutil/SilcBase64API/silc_base64_encode
32  *
33  * SYNOPSIS
34  *
35  *    char *silc_base64_encode(SilcStack stack,
36  *                             unsigned char *data, SilcUInt32 len);
37  *
38  * DESCRIPTION
39  *
40  *    Encodes data into Base 64 (PEM) encoding. Returns NULL terminated
41  *    Base 64 encoded data string.  Returns NULL if system is out of memory.
42  *
43  *    If `stack' is non-NULL the returned buffer is allocated from `stack'.
44  *
45  ***/
46 char *silc_base64_encode(SilcStack stack, unsigned char *data, SilcUInt32 len);
47
48 /****f* silcutil/SilcBase64API/silc_base64_encode_file
49  *
50  * SYNOPSIS
51  *
52  *    char *silc_base64_encode_file(SilcStack stack,
53  *                                  unsigned char *data, SilcUInt32 data_len);
54  *
55  * DESCRIPTION
56  *
57  *    Same as silc_base64_encode() but puts newline ('\n') every 72
58  *    characters.  Returns NULL if system is out of memory.
59  *
60  *    If `stack' is non-NULL the returned buffer is allocated from `stack'.
61  *
62  ***/
63 char *silc_base64_encode_file(SilcStack stack,
64                               unsigned char *data, SilcUInt32 data_len);
65
66 /****f* silcutil/SilcBase64API/silc_base_decode
67  *
68  * SYNOPSIS
69  *
70  *    unsigned char *silc_base_decode(SilcStack stack,
71  *                                    unsigned char *base64,
72  *                                    SilcUInt32 base64_len,
73  *                                    SilcUInt32 *ret_len);
74  *
75  * DESCRIPTION
76  *
77  *    Decodes Base 64 (PEM) into data. Returns the decoded data.  Returns
78  *    NULL if the data is not valid Base 64 encoded data.
79  *
80  *    If `stack' is non-NULL the returned buffer is allocated from `stack'.
81  *
82  ***/
83 unsigned char *silc_base64_decode(SilcStack stack,
84                                   unsigned char *base64,
85                                   SilcUInt32 base64_len,
86                                   SilcUInt32 *ret_len);
87
88 #endif /* SILCBASE64_H */