BA
/
BaBoRo1
Embed:
(wiki syntax)
Show/hide line numbers
base64.h
Go to the documentation of this file.
00001 /** 00002 * \file base64.h 00003 * 00004 * \brief RFC 1521 base64 encoding/decoding 00005 */ 00006 /* 00007 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 00008 * SPDX-License-Identifier: Apache-2.0 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00011 * not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00018 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 * 00022 * This file is part of mbed TLS (https://tls.mbed.org) 00023 */ 00024 #ifndef MBEDTLS_BASE64_H 00025 #define MBEDTLS_BASE64_H 00026 00027 #include <stddef.h> 00028 00029 #define MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */ 00030 #define MBEDTLS_ERR_BASE64_INVALID_CHARACTER -0x002C /**< Invalid character in input. */ 00031 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif 00035 00036 /** 00037 * \brief Encode a buffer into base64 format 00038 * 00039 * \param dst destination buffer 00040 * \param dlen size of the destination buffer 00041 * \param olen number of bytes written 00042 * \param src source buffer 00043 * \param slen amount of data to be encoded 00044 * 00045 * \return 0 if successful, or MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL. 00046 * *olen is always updated to reflect the amount 00047 * of data that has (or would have) been written. 00048 * If that length cannot be represented, then no data is 00049 * written to the buffer and *olen is set to the maximum 00050 * length representable as a size_t. 00051 * 00052 * \note Call this function with dlen = 0 to obtain the 00053 * required buffer size in *olen 00054 */ 00055 int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, 00056 const unsigned char *src, size_t slen ); 00057 00058 /** 00059 * \brief Decode a base64-formatted buffer 00060 * 00061 * \param dst destination buffer (can be NULL for checking size) 00062 * \param dlen size of the destination buffer 00063 * \param olen number of bytes written 00064 * \param src source buffer 00065 * \param slen amount of data to be decoded 00066 * 00067 * \return 0 if successful, MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL, or 00068 * MBEDTLS_ERR_BASE64_INVALID_CHARACTER if the input data is 00069 * not correct. *olen is always updated to reflect the amount 00070 * of data that has (or would have) been written. 00071 * 00072 * \note Call this function with *dst = NULL or dlen = 0 to obtain 00073 * the required buffer size in *olen 00074 */ 00075 int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, 00076 const unsigned char *src, size_t slen ); 00077 00078 /** 00079 * \brief Checkup routine 00080 * 00081 * \return 0 if successful, or 1 if the test failed 00082 */ 00083 int mbedtls_base64_self_test( int verbose ); 00084 00085 #ifdef __cplusplus 00086 } 00087 #endif 00088 00089 #endif /* base64.h */
Generated on Tue Jul 12 2022 12:21:43 by
