]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - common/mbedtls/base64.h
4 * \brief RFC 1521 base64 encoding/decoding
7 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8 * SPDX-License-Identifier: GPL-2.0
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * This file is part of mbed TLS (https://tls.mbed.org)
26 #ifndef MBEDTLS_BASE64_H
27 #define MBEDTLS_BASE64_H
31 #define MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */
32 #define MBEDTLS_ERR_BASE64_INVALID_CHARACTER -0x002C /**< Invalid character in input. */
39 * \brief Encode a buffer into base64 format
41 * \param dst destination buffer
42 * \param dlen size of the destination buffer
43 * \param olen number of bytes written
44 * \param src source buffer
45 * \param slen amount of data to be encoded
47 * \return 0 if successful, or MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL.
48 * *olen is always updated to reflect the amount
49 * of data that has (or would have) been written.
50 * If that length cannot be represented, then no data is
51 * written to the buffer and *olen is set to the maximum
52 * length representable as a size_t.
54 * \note Call this function with dlen = 0 to obtain the
55 * required buffer size in *olen
57 int mbedtls_base64_encode( unsigned char *dst
, size_t dlen
, size_t *olen
,
58 const unsigned char *src
, size_t slen
);
61 * \brief Decode a base64-formatted buffer
63 * \param dst destination buffer (can be NULL for checking size)
64 * \param dlen size of the destination buffer
65 * \param olen number of bytes written
66 * \param src source buffer
67 * \param slen amount of data to be decoded
69 * \return 0 if successful, MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL, or
70 * MBEDTLS_ERR_BASE64_INVALID_CHARACTER if the input data is
71 * not correct. *olen is always updated to reflect the amount
72 * of data that has (or would have) been written.
74 * \note Call this function with *dst = NULL or dlen = 0 to obtain
75 * the required buffer size in *olen
77 int mbedtls_base64_decode( unsigned char *dst
, size_t dlen
, size_t *olen
,
78 const unsigned char *src
, size_t slen
);
81 * \brief Checkup routine
83 * \return 0 if successful, or 1 if the test failed
85 int mbedtls_base64_self_test( int verbose
);