4 * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine
6 * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
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.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 /* $Cambridge: exim/src/src/pdkim/base64.h,v 1.2 2009/06/10 07:34:05 tom Exp $ */
25 #ifndef POLARSSL_BASE64_H
26 #define POLARSSL_BASE64_H
28 #define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x0010
29 #define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x0012
36 * \brief Encode a buffer into base64 format
38 * \param dst destination buffer
39 * \param dlen size of the buffer
40 * \param src source buffer
41 * \param slen amount of data to be encoded
43 * \return 0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL.
44 * *dlen is always updated to reflect the amount
45 * of data that has (or would have) been written.
47 * \note Call this function with *dlen = 0 to obtain the
48 * required buffer size in *dlen
50 int base64_encode( unsigned char *dst, int *dlen,
51 unsigned char *src, int slen );
54 * \brief Decode a base64-formatted buffer
56 * \param dst destination buffer
57 * \param dlen size of the buffer
58 * \param src source buffer
59 * \param slen amount of data to be decoded
61 * \return 0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
62 * POLARSSL_ERR_BASE64_INVALID_DATA if the input data is not
63 * correct. *dlen is always updated to reflect the amount
64 * of data that has (or would have) been written.
66 * \note Call this function with *dlen = 0 to obtain the
67 * required buffer size in *dlen
69 int base64_decode( unsigned char *dst, int *dlen,
70 unsigned char *src, int slen );