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