Adding self-contained DKIM support
[users/jgh/exim.git] / src / src / pdkim / base64.h
1 /* $Cambridge: exim/src/src/pdkim/base64.h,v 1.1.2.1 2009/02/24 13:13:47 tom Exp $ */
2 /**
3  * \file base64.h
4  *
5  *  Based on XySSL: Copyright (C) 2006-2008  Christophe Devine
6  *
7  *  Copyright (C) 2009  Paul Bakker <polarssl_maintainer at polarssl dot org>
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  *  You should have received a copy of the GNU General Public License along
20  *  with this program; if not, write to the Free Software Foundation, Inc.,
21  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 #ifndef POLARSSL_BASE64_H
24 #define POLARSSL_BASE64_H
25
26 #define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL               -0x0010
27 #define POLARSSL_ERR_BASE64_INVALID_CHARACTER              -0x0012
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /**
34  * \brief          Encode a buffer into base64 format
35  *
36  * \param dst      destination buffer
37  * \param dlen     size of the buffer
38  * \param src      source buffer
39  * \param slen     amount of data to be encoded
40  *
41  * \return         0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL.
42  *                 *dlen is always updated to reflect the amount
43  *                 of data that has (or would have) been written.
44  *
45  * \note           Call this function with *dlen = 0 to obtain the
46  *                 required buffer size in *dlen
47  */
48 int base64_encode( unsigned char *dst, int *dlen,
49                    unsigned char *src, int  slen );
50
51 /**
52  * \brief          Decode a base64-formatted buffer
53  *
54  * \param dst      destination buffer
55  * \param dlen     size of the buffer
56  * \param src      source buffer
57  * \param slen     amount of data to be decoded
58  *
59  * \return         0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
60  *                 POLARSSL_ERR_BASE64_INVALID_DATA if the input data is not
61  *                 correct. *dlen is always updated to reflect the amount
62  *                 of data that has (or would have) been written.
63  *
64  * \note           Call this function with *dlen = 0 to obtain the
65  *                 required buffer size in *dlen
66  */
67 int base64_decode( unsigned char *dst, int *dlen,
68                    unsigned char *src, int  slen );
69
70 #ifdef __cplusplus
71 }
72 #endif
73
74 #endif /* base64.h */