1 /* $Cambridge: exim/src/src/pdkim/base64.h,v 1.1.2.1 2009/02/24 13:13:47 tom Exp $ */
5 * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
7 * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
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.
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.
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.
23 #ifndef POLARSSL_BASE64_H
24 #define POLARSSL_BASE64_H
26 #define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x0010
27 #define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x0012
34 * \brief Encode a buffer into base64 format
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
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.
45 * \note Call this function with *dlen = 0 to obtain the
46 * required buffer size in *dlen
48 int base64_encode( unsigned char *dst, int *dlen,
49 unsigned char *src, int slen );
52 * \brief Decode a base64-formatted buffer
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
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.
64 * \note Call this function with *dlen = 0 to obtain the
65 * required buffer size in *dlen
67 int base64_decode( unsigned char *dst, int *dlen,
68 unsigned char *src, int slen );