]> git.zerfleddert.de Git - proxmark3-svn/blame - common/mbedtls/base64.h
Update cmdlft55xx.c
[proxmark3-svn] / common / mbedtls / base64.h
CommitLineData
700d8687
OM
1/**
2 * \file base64.h
3 *
4 * \brief RFC 1521 base64 encoding/decoding
5 */
6/*
7 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8 * SPDX-License-Identifier: GPL-2.0
9 *
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.
14 *
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.
19 *
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.
23 *
24 * This file is part of mbed TLS (https://tls.mbed.org)
25 */
26#ifndef MBEDTLS_BASE64_H
27#define MBEDTLS_BASE64_H
28
29#include <stddef.h>
30
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. */
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 destination buffer
43 * \param olen number of bytes written
44 * \param src source buffer
45 * \param slen amount of data to be encoded
46 *
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.
53 *
54 * \note Call this function with dlen = 0 to obtain the
55 * required buffer size in *olen
56 */
57int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen,
58 const unsigned char *src, size_t slen );
59
60/**
61 * \brief Decode a base64-formatted buffer
62 *
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
68 *
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.
73 *
74 * \note Call this function with *dst = NULL or dlen = 0 to obtain
75 * the required buffer size in *olen
76 */
77int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen,
78 const unsigned char *src, size_t slen );
79
80/**
81 * \brief Checkup routine
82 *
83 * \return 0 if successful, or 1 if the test failed
84 */
85int mbedtls_base64_self_test( int verbose );
86
87#ifdef __cplusplus
88}
89#endif
90
91#endif /* base64.h */
Impressum, Datenschutz