mbed client lightswitch demo

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by Austin Blackstone

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 11:cada08fc8a70 1 /**
mbedAustin 11:cada08fc8a70 2 * \file base64.h
mbedAustin 11:cada08fc8a70 3 *
mbedAustin 11:cada08fc8a70 4 * \brief RFC 1521 base64 encoding/decoding
mbedAustin 11:cada08fc8a70 5 *
mbedAustin 11:cada08fc8a70 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
mbedAustin 11:cada08fc8a70 7 * SPDX-License-Identifier: Apache-2.0
mbedAustin 11:cada08fc8a70 8 *
mbedAustin 11:cada08fc8a70 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
mbedAustin 11:cada08fc8a70 10 * not use this file except in compliance with the License.
mbedAustin 11:cada08fc8a70 11 * You may obtain a copy of the License at
mbedAustin 11:cada08fc8a70 12 *
mbedAustin 11:cada08fc8a70 13 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 11:cada08fc8a70 14 *
mbedAustin 11:cada08fc8a70 15 * Unless required by applicable law or agreed to in writing, software
mbedAustin 11:cada08fc8a70 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
mbedAustin 11:cada08fc8a70 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 11:cada08fc8a70 18 * See the License for the specific language governing permissions and
mbedAustin 11:cada08fc8a70 19 * limitations under the License.
mbedAustin 11:cada08fc8a70 20 *
mbedAustin 11:cada08fc8a70 21 * This file is part of mbed TLS (https://tls.mbed.org)
mbedAustin 11:cada08fc8a70 22 */
mbedAustin 11:cada08fc8a70 23 #ifndef MBEDTLS_BASE64_H
mbedAustin 11:cada08fc8a70 24 #define MBEDTLS_BASE64_H
mbedAustin 11:cada08fc8a70 25
mbedAustin 11:cada08fc8a70 26 #include <stddef.h>
mbedAustin 11:cada08fc8a70 27
mbedAustin 11:cada08fc8a70 28 #define MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */
mbedAustin 11:cada08fc8a70 29 #define MBEDTLS_ERR_BASE64_INVALID_CHARACTER -0x002C /**< Invalid character in input. */
mbedAustin 11:cada08fc8a70 30
mbedAustin 11:cada08fc8a70 31 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 32 extern "C" {
mbedAustin 11:cada08fc8a70 33 #endif
mbedAustin 11:cada08fc8a70 34
mbedAustin 11:cada08fc8a70 35 /**
mbedAustin 11:cada08fc8a70 36 * \brief Encode a buffer into base64 format
mbedAustin 11:cada08fc8a70 37 *
mbedAustin 11:cada08fc8a70 38 * \param dst destination buffer
mbedAustin 11:cada08fc8a70 39 * \param dlen size of the destination buffer
mbedAustin 11:cada08fc8a70 40 * \param olen number of bytes written
mbedAustin 11:cada08fc8a70 41 * \param src source buffer
mbedAustin 11:cada08fc8a70 42 * \param slen amount of data to be encoded
mbedAustin 11:cada08fc8a70 43 *
mbedAustin 11:cada08fc8a70 44 * \return 0 if successful, or MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL.
mbedAustin 11:cada08fc8a70 45 * *olen is always updated to reflect the amount
mbedAustin 11:cada08fc8a70 46 * of data that has (or would have) been written.
mbedAustin 11:cada08fc8a70 47 * If that length cannot be represented, then no data is
mbedAustin 11:cada08fc8a70 48 * written to the buffer and *olen is set to the maximum
mbedAustin 11:cada08fc8a70 49 * length representable as a size_t.
mbedAustin 11:cada08fc8a70 50 *
mbedAustin 11:cada08fc8a70 51 * \note Call this function with dlen = 0 to obtain the
mbedAustin 11:cada08fc8a70 52 * required buffer size in *olen
mbedAustin 11:cada08fc8a70 53 */
mbedAustin 11:cada08fc8a70 54 int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen,
mbedAustin 11:cada08fc8a70 55 const unsigned char *src, size_t slen );
mbedAustin 11:cada08fc8a70 56
mbedAustin 11:cada08fc8a70 57 /**
mbedAustin 11:cada08fc8a70 58 * \brief Decode a base64-formatted buffer
mbedAustin 11:cada08fc8a70 59 *
mbedAustin 11:cada08fc8a70 60 * \param dst destination buffer (can be NULL for checking size)
mbedAustin 11:cada08fc8a70 61 * \param dlen size of the destination buffer
mbedAustin 11:cada08fc8a70 62 * \param olen number of bytes written
mbedAustin 11:cada08fc8a70 63 * \param src source buffer
mbedAustin 11:cada08fc8a70 64 * \param slen amount of data to be decoded
mbedAustin 11:cada08fc8a70 65 *
mbedAustin 11:cada08fc8a70 66 * \return 0 if successful, MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL, or
mbedAustin 11:cada08fc8a70 67 * MBEDTLS_ERR_BASE64_INVALID_CHARACTER if the input data is
mbedAustin 11:cada08fc8a70 68 * not correct. *olen is always updated to reflect the amount
mbedAustin 11:cada08fc8a70 69 * of data that has (or would have) been written.
mbedAustin 11:cada08fc8a70 70 *
mbedAustin 11:cada08fc8a70 71 * \note Call this function with *dst = NULL or dlen = 0 to obtain
mbedAustin 11:cada08fc8a70 72 * the required buffer size in *olen
mbedAustin 11:cada08fc8a70 73 */
mbedAustin 11:cada08fc8a70 74 int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen,
mbedAustin 11:cada08fc8a70 75 const unsigned char *src, size_t slen );
mbedAustin 11:cada08fc8a70 76
mbedAustin 11:cada08fc8a70 77 /**
mbedAustin 11:cada08fc8a70 78 * \brief Checkup routine
mbedAustin 11:cada08fc8a70 79 *
mbedAustin 11:cada08fc8a70 80 * \return 0 if successful, or 1 if the test failed
mbedAustin 11:cada08fc8a70 81 */
mbedAustin 11:cada08fc8a70 82 int mbedtls_base64_self_test( int verbose );
mbedAustin 11:cada08fc8a70 83
mbedAustin 11:cada08fc8a70 84 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 85 }
mbedAustin 11:cada08fc8a70 86 #endif
mbedAustin 11:cada08fc8a70 87
mbedAustin 11:cada08fc8a70 88 #endif /* base64.h */