Bugzilla #1097: PDKIM: Update embedded PolarSSL code to 0.14.2, thanks to Andreas...
[exim.git] / src / src / pdkim / base64.h
CommitLineData
80a47a2c
TK
1/**
2 * \file base64.h
3 *
62d3e98d
TK
4 * Copyright (C) 2006-2010, Brainspark B.V.
5 *
6 * This file is part of PolarSSL (http://www.polarssl.org)
7 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
80a47a2c 8 *
62d3e98d 9 * All rights reserved.
80a47a2c
TK
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 */
25
67932e54 26/* $Cambridge: exim/src/src/pdkim/base64.h,v 1.3 2009/12/07 13:05:07 tom Exp $ */
80a47a2c
TK
27
28#ifndef POLARSSL_BASE64_H
29#define POLARSSL_BASE64_H
30
67932e54
TK
31#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL 0x0010
32#define POLARSSL_ERR_BASE64_INVALID_CHARACTER 0x0012
80a47a2c
TK
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38/**
39 * \brief Encode a buffer into base64 format
40 *
41 * \param dst destination buffer
42 * \param dlen size of the buffer
43 * \param src source buffer
44 * \param slen amount of data to be encoded
45 *
46 * \return 0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL.
47 * *dlen is always updated to reflect the amount
48 * of data that has (or would have) been written.
49 *
50 * \note Call this function with *dlen = 0 to obtain the
51 * required buffer size in *dlen
52 */
53int base64_encode( unsigned char *dst, int *dlen,
62d3e98d 54 const unsigned char *src, int slen );
80a47a2c
TK
55
56/**
57 * \brief Decode a base64-formatted buffer
58 *
59 * \param dst destination buffer
60 * \param dlen size of the buffer
61 * \param src source buffer
62 * \param slen amount of data to be decoded
63 *
64 * \return 0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
65 * POLARSSL_ERR_BASE64_INVALID_DATA if the input data is not
66 * correct. *dlen is always updated to reflect the amount
67 * of data that has (or would have) been written.
68 *
69 * \note Call this function with *dlen = 0 to obtain the
70 * required buffer size in *dlen
71 */
72int base64_decode( unsigned char *dst, int *dlen,
62d3e98d 73 const unsigned char *src, int slen );
80a47a2c
TK
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif /* base64.h */