![]() |
|
|||
File indexing completed on 2025-08-27 09:37:29
0001 /** 0002 * \file base64.h 0003 * 0004 * \brief RFC 1521 base64 encoding/decoding 0005 */ 0006 /* 0007 * Copyright The Mbed TLS Contributors 0008 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 0009 */ 0010 #ifndef MBEDTLS_BASE64_H 0011 #define MBEDTLS_BASE64_H 0012 0013 #include "mbedtls/build_info.h" 0014 0015 #include <stddef.h> 0016 0017 /** Output buffer too small. */ 0018 #define MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL -0x002A 0019 /** Invalid character in input. */ 0020 #define MBEDTLS_ERR_BASE64_INVALID_CHARACTER -0x002C 0021 0022 #ifdef __cplusplus 0023 extern "C" { 0024 #endif 0025 0026 /** 0027 * \brief Encode a buffer into base64 format 0028 * 0029 * \param dst destination buffer 0030 * \param dlen size of the destination buffer 0031 * \param olen number of bytes written 0032 * \param src source buffer 0033 * \param slen amount of data to be encoded 0034 * 0035 * \return 0 if successful, or MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL. 0036 * *olen is always updated to reflect the amount 0037 * of data that has (or would have) been written. 0038 * If that length cannot be represented, then no data is 0039 * written to the buffer and *olen is set to the maximum 0040 * length representable as a size_t. 0041 * 0042 * \note Call this function with dlen = 0 to obtain the 0043 * required buffer size in *olen 0044 */ 0045 int mbedtls_base64_encode(unsigned char *dst, size_t dlen, size_t *olen, 0046 const unsigned char *src, size_t slen); 0047 0048 /** 0049 * \brief Decode a base64-formatted buffer 0050 * 0051 * \param dst destination buffer (can be NULL for checking size) 0052 * \param dlen size of the destination buffer 0053 * \param olen number of bytes written 0054 * \param src source buffer 0055 * \param slen amount of data to be decoded 0056 * 0057 * \return 0 if successful, MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL, or 0058 * MBEDTLS_ERR_BASE64_INVALID_CHARACTER if the input data is 0059 * not correct. *olen is always updated to reflect the amount 0060 * of data that has (or would have) been written. 0061 * 0062 * \note Call this function with *dst = NULL or dlen = 0 to obtain 0063 * the required buffer size in *olen 0064 */ 0065 int mbedtls_base64_decode(unsigned char *dst, size_t dlen, size_t *olen, 0066 const unsigned char *src, size_t slen); 0067 0068 #if defined(MBEDTLS_SELF_TEST) 0069 /** 0070 * \brief Checkup routine 0071 * 0072 * \return 0 if successful, or 1 if the test failed 0073 */ 0074 int mbedtls_base64_self_test(int verbose); 0075 0076 #endif /* MBEDTLS_SELF_TEST */ 0077 0078 #ifdef __cplusplus 0079 } 0080 #endif 0081 0082 #endif /* base64.h */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |