blob: 0cad8633c2d2ea8abd524f89fc4d6d7ea630c519 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file base64.h
3 */
4#ifndef XYSSL_BASE64_H
5#define XYSSL_BASE64_H
6
7#define XYSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x0010
8#define XYSSL_ERR_BASE64_INVALID_CHARACTER -0x0012
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14/**
15 * \brief Encode a buffer into base64 format
16 *
17 * \param dst destination buffer
18 * \param dlen size of the buffer
19 * \param src source buffer
20 * \param slen amount of data to be encoded
21 *
22 * \return 0 if successful, or XYSSL_ERR_BASE64_BUFFER_TOO_SMALL.
23 * *dlen is always updated to reflect the amount
24 * of data that has (or would have) been written.
25 *
26 * \note Call this function with *dlen = 0 to obtain the
27 * required buffer size in *dlen
28 */
29int base64_encode( unsigned char *dst, int *dlen,
30 unsigned char *src, int slen );
31
32/**
33 * \brief Decode a base64-formatted buffer
34 *
35 * \param dst destination buffer
36 * \param dlen size of the buffer
37 * \param src source buffer
38 * \param slen amount of data to be decoded
39 *
40 * \return 0 if successful, XYSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
41 * XYSSL_ERR_BASE64_INVALID_DATA if the input data is not
42 * correct. *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 */
48int base64_decode( unsigned char *dst, int *dlen,
49 unsigned char *src, int slen );
50
51/**
52 * \brief Checkup routine
53 *
54 * \return 0 if successful, or 1 if the test failed
55 */
56int base64_self_test( int verbose );
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif /* base64.h */