]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Labs/Source/mbedtls/include/mbedtls/base64.h
Add the Labs projects provided in the V10.2.1_191129 zip file.
[freertos] / FreeRTOS-Labs / Source / mbedtls / include / mbedtls / base64.h
diff --git a/FreeRTOS-Labs/Source/mbedtls/include/mbedtls/base64.h b/FreeRTOS-Labs/Source/mbedtls/include/mbedtls/base64.h
new file mode 100644 (file)
index 0000000..ed23538
--- /dev/null
@@ -0,0 +1,98 @@
+/**\r
+ * \file base64.h\r
+ *\r
+ * \brief RFC 1521 base64 encoding/decoding\r
+ */\r
+/*\r
+ *  Copyright (C) 2006-2015, ARM Limited, All Rights Reserved\r
+ *  SPDX-License-Identifier: Apache-2.0\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License"); you may\r
+ *  not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *  http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ *\r
+ *  This file is part of mbed TLS (https://tls.mbed.org)\r
+ */\r
+#ifndef MBEDTLS_BASE64_H\r
+#define MBEDTLS_BASE64_H\r
+\r
+#if !defined(MBEDTLS_CONFIG_FILE)\r
+#include "config.h"\r
+#else\r
+#include MBEDTLS_CONFIG_FILE\r
+#endif\r
+\r
+#include <stddef.h>\r
+\r
+#define MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL               -0x002A  /**< Output buffer too small. */\r
+#define MBEDTLS_ERR_BASE64_INVALID_CHARACTER              -0x002C  /**< Invalid character in input. */\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/**\r
+ * \brief          Encode a buffer into base64 format\r
+ *\r
+ * \param dst      destination buffer\r
+ * \param dlen     size of the destination buffer\r
+ * \param olen     number of bytes written\r
+ * \param src      source buffer\r
+ * \param slen     amount of data to be encoded\r
+ *\r
+ * \return         0 if successful, or MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL.\r
+ *                 *olen is always updated to reflect the amount\r
+ *                 of data that has (or would have) been written.\r
+ *                 If that length cannot be represented, then no data is\r
+ *                 written to the buffer and *olen is set to the maximum\r
+ *                 length representable as a size_t.\r
+ *\r
+ * \note           Call this function with dlen = 0 to obtain the\r
+ *                 required buffer size in *olen\r
+ */\r
+int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen,\r
+                   const unsigned char *src, size_t slen );\r
+\r
+/**\r
+ * \brief          Decode a base64-formatted buffer\r
+ *\r
+ * \param dst      destination buffer (can be NULL for checking size)\r
+ * \param dlen     size of the destination buffer\r
+ * \param olen     number of bytes written\r
+ * \param src      source buffer\r
+ * \param slen     amount of data to be decoded\r
+ *\r
+ * \return         0 if successful, MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL, or\r
+ *                 MBEDTLS_ERR_BASE64_INVALID_CHARACTER if the input data is\r
+ *                 not correct. *olen is always updated to reflect the amount\r
+ *                 of data that has (or would have) been written.\r
+ *\r
+ * \note           Call this function with *dst = NULL or dlen = 0 to obtain\r
+ *                 the required buffer size in *olen\r
+ */\r
+int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen,\r
+                   const unsigned char *src, size_t slen );\r
+\r
+#if defined(MBEDTLS_SELF_TEST)\r
+/**\r
+ * \brief          Checkup routine\r
+ *\r
+ * \return         0 if successful, or 1 if the test failed\r
+ */\r
+int mbedtls_base64_self_test( int verbose );\r
+\r
+#endif /* MBEDTLS_SELF_TEST */\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* base64.h */\r