PDKIM: Upgrade PolarSSL files to upstream version 0.12.1. Thanks to Andreas Metzler...
[exim.git] / src / src / pdkim / base64.h
1 /**
2  * \file base64.h
3  *
4  *  Copyright (C) 2006-2009, Paul Bakker <polarssl_maintainer at polarssl.org>
5  *  All rights reserved.
6  *
7  *  Joined copyright on original XySSL code with: Christophe Devine
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
24 /* $Cambridge: exim/src/src/pdkim/base64.h,v 1.3 2009/12/07 13:05:07 tom Exp $ */
25
26 #ifndef POLARSSL_BASE64_H
27 #define POLARSSL_BASE64_H
28
29 #define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL               0x0010
30 #define POLARSSL_ERR_BASE64_INVALID_CHARACTER              0x0012
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /**
37  * \brief          Encode a buffer into base64 format
38  *
39  * \param dst      destination buffer
40  * \param dlen     size of the buffer
41  * \param src      source buffer
42  * \param slen     amount of data to be encoded
43  *
44  * \return         0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL.
45  *                 *dlen is always updated to reflect the amount
46  *                 of data that has (or would have) been written.
47  *
48  * \note           Call this function with *dlen = 0 to obtain the
49  *                 required buffer size in *dlen
50  */
51 int base64_encode( unsigned char *dst, int *dlen,
52                    unsigned char *src, int  slen );
53
54 /**
55  * \brief          Decode a base64-formatted buffer
56  *
57  * \param dst      destination buffer
58  * \param dlen     size of the buffer
59  * \param src      source buffer
60  * \param slen     amount of data to be decoded
61  *
62  * \return         0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
63  *                 POLARSSL_ERR_BASE64_INVALID_DATA if the input data is not
64  *                 correct. *dlen is always updated to reflect the amount
65  *                 of data that has (or would have) been written.
66  *
67  * \note           Call this function with *dlen = 0 to obtain the
68  *                 required buffer size in *dlen
69  */
70 int base64_decode( unsigned char *dst, int *dlen,
71                    unsigned char *src, int  slen );
72
73 #ifdef __cplusplus
74 }
75 #endif
76
77 #endif /* base64.h */