mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Externals: Update mbedtls to 2.4.1
The latest version has tons of security fixes (which is expected for a library such as mbedtls). Updating also allows getting rid of a few deprecation warnings.
This commit is contained in:
3
Externals/mbedtls/include/mbedtls/base64.h
vendored
3
Externals/mbedtls/include/mbedtls/base64.h
vendored
@ -44,6 +44,9 @@ extern "C" {
|
||||
* \return 0 if successful, or MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL.
|
||||
* *olen is always updated to reflect the amount
|
||||
* of data that has (or would have) been written.
|
||||
* If that length cannot be represented, then no data is
|
||||
* written to the buffer and *olen is set to the maximum
|
||||
* length representable as a size_t.
|
||||
*
|
||||
* \note Call this function with dlen = 0 to obtain the
|
||||
* required buffer size in *olen
|
||||
|
1
Externals/mbedtls/include/mbedtls/bignum.h
vendored
1
Externals/mbedtls/include/mbedtls/bignum.h
vendored
@ -122,6 +122,7 @@
|
||||
#define MBEDTLS_HAVE_INT64
|
||||
typedef int64_t mbedtls_mpi_sint;
|
||||
typedef uint64_t mbedtls_mpi_uint;
|
||||
/* mbedtls_t_udbl defined as 128-bit unsigned int */
|
||||
typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI)));
|
||||
#define MBEDTLS_HAVE_UDBL
|
||||
#else
|
||||
|
42
Externals/mbedtls/include/mbedtls/bn_mul.h
vendored
42
Externals/mbedtls/include/mbedtls/bn_mul.h
vendored
@ -162,10 +162,6 @@
|
||||
|
||||
#define MULADDC_INIT \
|
||||
asm( \
|
||||
"movq %3, %%rsi \n\t" \
|
||||
"movq %4, %%rdi \n\t" \
|
||||
"movq %5, %%rcx \n\t" \
|
||||
"movq %6, %%rbx \n\t" \
|
||||
"xorq %%r8, %%r8 \n\t"
|
||||
|
||||
#define MULADDC_CORE \
|
||||
@ -181,12 +177,9 @@
|
||||
"addq $8, %%rdi \n\t"
|
||||
|
||||
#define MULADDC_STOP \
|
||||
"movq %%rcx, %0 \n\t" \
|
||||
"movq %%rdi, %1 \n\t" \
|
||||
"movq %%rsi, %2 \n\t" \
|
||||
: "=m" (c), "=m" (d), "=m" (s) \
|
||||
: "m" (s), "m" (d), "m" (c), "m" (b) \
|
||||
: "rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" \
|
||||
: "+c" (c), "+D" (d), "+S" (s) \
|
||||
: "b" (b) \
|
||||
: "rax", "rdx", "r8" \
|
||||
);
|
||||
|
||||
#endif /* AMD64 */
|
||||
@ -412,10 +405,11 @@
|
||||
#endif /* PPC32 */
|
||||
|
||||
/*
|
||||
* The Sparc64 assembly is reported to be broken.
|
||||
* The Sparc(64) assembly is reported to be broken.
|
||||
* Disable it for now, until we're able to fix it.
|
||||
*/
|
||||
#if 0 && defined(__sparc__) && defined(__sparc64__)
|
||||
#if 0 && defined(__sparc__)
|
||||
#if defined(__sparc64__)
|
||||
|
||||
#define MULADDC_INIT \
|
||||
asm( \
|
||||
@ -446,9 +440,8 @@
|
||||
: "g1", "o0", "o1", "o2", "o3", "o4", \
|
||||
"o5" \
|
||||
);
|
||||
#endif /* SPARCv9 */
|
||||
|
||||
#if defined(__sparc__) && !defined(__sparc64__)
|
||||
#else /* __sparc64__ */
|
||||
|
||||
#define MULADDC_INIT \
|
||||
asm( \
|
||||
@ -480,7 +473,8 @@
|
||||
"o5" \
|
||||
);
|
||||
|
||||
#endif /* SPARCv8 */
|
||||
#endif /* __sparc64__ */
|
||||
#endif /* __sparc__ */
|
||||
|
||||
#if defined(__microblaze__) || defined(microblaze)
|
||||
|
||||
@ -562,7 +556,23 @@
|
||||
|
||||
#endif /* TriCore */
|
||||
|
||||
#if defined(__arm__)
|
||||
/*
|
||||
* gcc -O0 by default uses r7 for the frame pointer, so it complains about our
|
||||
* use of r7 below, unless -fomit-frame-pointer is passed. Unfortunately,
|
||||
* passing that option is not easy when building with yotta.
|
||||
*
|
||||
* On the other hand, -fomit-frame-pointer is implied by any -Ox options with
|
||||
* x !=0, which we can detect using __OPTIMIZE__ (which is also defined by
|
||||
* clang and armcc5 under the same conditions).
|
||||
*
|
||||
* So, only use the optimized assembly below for optimized build, which avoids
|
||||
* the build error and is pretty reasonable anyway.
|
||||
*/
|
||||
#if defined(__GNUC__) && !defined(__OPTIMIZE__)
|
||||
#define MULADDC_CANNOT_USE_R7
|
||||
#endif
|
||||
|
||||
#if defined(__arm__) && !defined(MULADDC_CANNOT_USE_R7)
|
||||
|
||||
#if defined(__thumb__) && !defined(__thumb2__)
|
||||
|
||||
|
101
Externals/mbedtls/include/mbedtls/check_config.h
vendored
101
Externals/mbedtls/include/mbedtls/check_config.h
vendored
@ -3,7 +3,7 @@
|
||||
*
|
||||
* \brief Consistency checks for configuration options
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -77,6 +77,11 @@
|
||||
#error "MBEDTLS_DHM_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CMAC_C) && \
|
||||
!defined(MBEDTLS_AES_C) && !defined(MBEDTLS_DES_C)
|
||||
#error "MBEDTLS_CMAC_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECDH_C) && !defined(MBEDTLS_ECP_C)
|
||||
#error "MBEDTLS_ECDH_C defined, but not all prerequisites"
|
||||
#endif
|
||||
@ -88,6 +93,11 @@
|
||||
#error "MBEDTLS_ECDSA_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECJPAKE_C) && \
|
||||
( !defined(MBEDTLS_ECP_C) || !defined(MBEDTLS_MD_C) )
|
||||
#error "MBEDTLS_ECJPAKE_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C)
|
||||
#error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites"
|
||||
#endif
|
||||
@ -125,6 +135,16 @@
|
||||
#error "MBEDTLS_ENTROPY_FORCE_SHA256 defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY) && \
|
||||
( !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) )
|
||||
#error "MBEDTLS_TEST_NULL_ENTROPY defined, but not all prerequisites"
|
||||
#endif
|
||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY) && \
|
||||
( defined(MBEDTLS_ENTROPY_NV_SEED) || defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \
|
||||
defined(MBEDTLS_HAVEGE_C) )
|
||||
#error "MBEDTLS_TEST_NULL_ENTROPY defined, but entropy sources too"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_GCM_C) && ( \
|
||||
!defined(MBEDTLS_AES_C) && !defined(MBEDTLS_CAMELLIA_C) )
|
||||
#error "MBEDTLS_GCM_C defined, but not all prerequisites"
|
||||
@ -187,6 +207,12 @@
|
||||
#error "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) && \
|
||||
( !defined(MBEDTLS_ECJPAKE_C) || !defined(MBEDTLS_SHA256_C) || \
|
||||
!defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) )
|
||||
#error "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
|
||||
( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_PLATFORM_MEMORY) )
|
||||
#error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites"
|
||||
@ -235,6 +261,36 @@
|
||||
#error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\
|
||||
( !defined(MBEDTLS_PLATFORM_C) ||\
|
||||
!defined(MBEDTLS_HAVE_TIME) )
|
||||
#error "MBEDTLS_PLATFORM_TIME_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\
|
||||
( !defined(MBEDTLS_PLATFORM_C) ||\
|
||||
!defined(MBEDTLS_HAVE_TIME) )
|
||||
#error "MBEDTLS_PLATFORM_TIME_MACRO defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
|
||||
( !defined(MBEDTLS_PLATFORM_C) ||\
|
||||
!defined(MBEDTLS_HAVE_TIME) )
|
||||
#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\
|
||||
( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
|
||||
defined(MBEDTLS_PLATFORM_TIME_ALT) )
|
||||
#error "MBEDTLS_PLATFORM_TIME_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
|
||||
( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
|
||||
defined(MBEDTLS_PLATFORM_TIME_ALT) )
|
||||
#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C)
|
||||
#error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
@ -331,6 +387,12 @@
|
||||
#error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_STD_TIME) &&\
|
||||
( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\
|
||||
!defined(MBEDTLS_HAVE_TIME) )
|
||||
#error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\
|
||||
!defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
|
||||
#error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites"
|
||||
@ -346,11 +408,48 @@
|
||||
#error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED) &&\
|
||||
( !defined(MBEDTLS_PLATFORM_C) || !defined(MBEDTLS_ENTROPY_C) )
|
||||
#error "MBEDTLS_ENTROPY_NV_SEED defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) &&\
|
||||
!defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
#error "MBEDTLS_PLATFORM_NV_SEED_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) &&\
|
||||
!defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
|
||||
#error "MBEDTLS_PLATFORM_STD_NV_SEED_READ defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) &&\
|
||||
!defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
|
||||
#error "MBEDTLS_PLATFORM_STD_NV_SEED_WRITE defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) &&\
|
||||
( defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) ||\
|
||||
defined(MBEDTLS_PLATFORM_NV_SEED_ALT) )
|
||||
#error "MBEDTLS_PLATFORM_NV_SEED_READ_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_READ cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) &&\
|
||||
( defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) ||\
|
||||
defined(MBEDTLS_PLATFORM_NV_SEED_ALT) )
|
||||
#error "MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_WRITE cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_BIGNUM_C) || \
|
||||
!defined(MBEDTLS_OID_C) )
|
||||
#error "MBEDTLS_RSA_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_PKCS1_V21) && \
|
||||
!defined(MBEDTLS_PKCS1_V15) )
|
||||
#error "MBEDTLS_RSA_C defined, but none of the PKCS1 versions enabled"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) && \
|
||||
( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_PKCS1_V21) )
|
||||
#error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites"
|
||||
|
14
Externals/mbedtls/include/mbedtls/cipher.h
vendored
14
Externals/mbedtls/include/mbedtls/cipher.h
vendored
@ -46,7 +46,8 @@
|
||||
#define MBEDTLS_CIPHER_MODE_STREAM
|
||||
#endif
|
||||
|
||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && !defined(inline)
|
||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
|
||||
!defined(inline) && !defined(__cplusplus)
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
@ -56,6 +57,7 @@
|
||||
#define MBEDTLS_ERR_CIPHER_INVALID_PADDING -0x6200 /**< Input data contains invalid padding and is rejected. */
|
||||
#define MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED -0x6280 /**< Decryption of block requires a full block. */
|
||||
#define MBEDTLS_ERR_CIPHER_AUTH_FAILED -0x6300 /**< Authentication failed (for AEAD modes). */
|
||||
#define MBEDTLS_ERR_CIPHER_INVALID_CONTEXT -0x6380 /**< The context is invalid, eg because it was free()ed. */
|
||||
|
||||
#define MBEDTLS_CIPHER_VARIABLE_IV_LEN 0x01 /**< Cipher accepts IVs of variable length */
|
||||
#define MBEDTLS_CIPHER_VARIABLE_KEY_LEN 0x02 /**< Cipher accepts keys of variable length */
|
||||
@ -174,6 +176,11 @@ enum {
|
||||
*/
|
||||
typedef struct mbedtls_cipher_base_t mbedtls_cipher_base_t;
|
||||
|
||||
/**
|
||||
* CMAC context (opaque struct).
|
||||
*/
|
||||
typedef struct mbedtls_cmac_context_t mbedtls_cmac_context_t;
|
||||
|
||||
/**
|
||||
* Cipher information. Allows cipher functions to be called in a generic way.
|
||||
*/
|
||||
@ -239,6 +246,11 @@ typedef struct {
|
||||
|
||||
/** Cipher-specific context */
|
||||
void *cipher_ctx;
|
||||
|
||||
#if defined(MBEDTLS_CMAC_C)
|
||||
/** CMAC Specific context */
|
||||
mbedtls_cmac_context_t *cmac_ctx;
|
||||
#endif
|
||||
} mbedtls_cipher_context_t;
|
||||
|
||||
/**
|
||||
|
166
Externals/mbedtls/include/mbedtls/cmac.h
vendored
Normal file
166
Externals/mbedtls/include/mbedtls/cmac.h
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
/**
|
||||
* \file cmac.h
|
||||
*
|
||||
* \brief Cipher-based Message Authentication Code (CMAC) Mode for
|
||||
* Authentication
|
||||
*
|
||||
* Copyright (C) 2015-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
#ifndef MBEDTLS_CMAC_H
|
||||
#define MBEDTLS_CMAC_H
|
||||
|
||||
#include "mbedtls/cipher.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MBEDTLS_AES_BLOCK_SIZE 16
|
||||
#define MBEDTLS_DES3_BLOCK_SIZE 8
|
||||
|
||||
#if defined(MBEDTLS_AES_C)
|
||||
#define MBEDTLS_CIPHER_BLKSIZE_MAX 16 /* longest used by CMAC is AES */
|
||||
#else
|
||||
#define MBEDTLS_CIPHER_BLKSIZE_MAX 8 /* longest used by CMAC is 3DES */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CMAC context structure - Contains internal state information only
|
||||
*/
|
||||
struct mbedtls_cmac_context_t
|
||||
{
|
||||
/** Internal state of the CMAC algorithm */
|
||||
unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX];
|
||||
|
||||
/** Unprocessed data - either data that was not block aligned and is still
|
||||
* pending to be processed, or the final block */
|
||||
unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX];
|
||||
|
||||
/** Length of data pending to be processed */
|
||||
size_t unprocessed_len;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Set the CMAC key and prepare to authenticate the input
|
||||
* data.
|
||||
* Should be called with an initialised cipher context.
|
||||
*
|
||||
* \param ctx Cipher context
|
||||
* \param key CMAC key
|
||||
* \param keybits length of the CMAC key in bits
|
||||
* (must be acceptable by the cipher)
|
||||
*
|
||||
* \return 0 if successful, or a cipher specific error code
|
||||
*/
|
||||
int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx,
|
||||
const unsigned char *key, size_t keybits );
|
||||
|
||||
/**
|
||||
* \brief Generic CMAC process buffer.
|
||||
* Called between mbedtls_cipher_cmac_starts() or
|
||||
* mbedtls_cipher_cmac_reset() and
|
||||
* mbedtls_cipher_cmac_finish().
|
||||
* May be called repeatedly.
|
||||
*
|
||||
* \param ctx CMAC context
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
*
|
||||
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
||||
* verification fails.
|
||||
*/
|
||||
int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx,
|
||||
const unsigned char *input, size_t ilen );
|
||||
|
||||
/**
|
||||
* \brief Output CMAC.
|
||||
* Called after mbedtls_cipher_cmac_update().
|
||||
* Usually followed by mbedtls_cipher_cmac_reset(), then
|
||||
* mbedtls_cipher_cmac_starts(), or mbedtls_cipher_free().
|
||||
*
|
||||
* \param ctx CMAC context
|
||||
* \param output Generic CMAC checksum result
|
||||
*
|
||||
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
||||
* verification fails.
|
||||
*/
|
||||
int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx,
|
||||
unsigned char *output );
|
||||
|
||||
/**
|
||||
* \brief Prepare to authenticate a new message with the same key.
|
||||
* Called after mbedtls_cipher_cmac_finish() and before
|
||||
* mbedtls_cipher_cmac_update().
|
||||
*
|
||||
* \param ctx CMAC context to be reset
|
||||
*
|
||||
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
||||
* verification fails.
|
||||
*/
|
||||
int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx );
|
||||
|
||||
/**
|
||||
* \brief Output = Generic_CMAC( hmac key, input buffer )
|
||||
*
|
||||
* \param cipher_info message digest info
|
||||
* \param key CMAC key
|
||||
* \param keylen length of the CMAC key in bits
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
* \param output Generic CMAC-result
|
||||
*
|
||||
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
|
||||
* verification fails.
|
||||
*/
|
||||
int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info,
|
||||
const unsigned char *key, size_t keylen,
|
||||
const unsigned char *input, size_t ilen,
|
||||
unsigned char *output );
|
||||
|
||||
#if defined(MBEDTLS_AES_C)
|
||||
/**
|
||||
* \brief AES-CMAC-128-PRF
|
||||
* Implementation of (AES-CMAC-PRF-128), as defined in RFC 4615
|
||||
*
|
||||
* \param key PRF key
|
||||
* \param key_len PRF key length in bytes
|
||||
* \param input buffer holding the input data
|
||||
* \param in_len length of the input data in bytes
|
||||
* \param output buffer holding the generated pseudorandom output (16 bytes)
|
||||
*
|
||||
* \return 0 if successful
|
||||
*/
|
||||
int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len,
|
||||
const unsigned char *input, size_t in_len,
|
||||
unsigned char output[16] );
|
||||
#endif /* MBEDTLS_AES_C */
|
||||
|
||||
#if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) )
|
||||
/**
|
||||
* \brief Checkup routine
|
||||
*
|
||||
* \return 0 if successful, or 1 if the test failed
|
||||
*/
|
||||
int mbedtls_cmac_self_test( int verbose );
|
||||
#endif /* MBEDTLS_SELF_TEST && ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MBEDTLS_CMAC_H */
|
@ -1,7 +1,8 @@
|
||||
/**
|
||||
* \file config.h
|
||||
* \file compat-1.3.h
|
||||
*
|
||||
* \brief Compatibility names (set of defines)
|
||||
* \brief Compatibility definitions for using mbed TLS with client code written
|
||||
* for the PolarSSL naming conventions.
|
||||
*
|
||||
* \deprecated Use the new names directly instead
|
||||
*
|
||||
|
228
Externals/mbedtls/include/mbedtls/config.h
vendored
228
Externals/mbedtls/include/mbedtls/config.h
vendored
@ -3,6 +3,10 @@
|
||||
*
|
||||
* \brief Configuration options (set of defines)
|
||||
*
|
||||
* This set of compile-time options may be used to enable
|
||||
* or disable features selectively, and reduce the global
|
||||
* memory footprint.
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@ -21,11 +25,6 @@
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
|
||||
/*
|
||||
* This set of compile-time options may be used to enable
|
||||
* or disable features selectively, and reduce the global
|
||||
* memory footprint.
|
||||
*/
|
||||
#ifndef MBEDTLS_CONFIG_H
|
||||
#define MBEDTLS_CONFIG_H
|
||||
|
||||
@ -72,6 +71,10 @@
|
||||
* The time does not need to be correct, only time differences are used,
|
||||
* by contrast with MBEDTLS_HAVE_TIME_DATE
|
||||
*
|
||||
* Defining MBEDTLS_HAVE_TIME allows you to specify MBEDTLS_PLATFORM_TIME_ALT,
|
||||
* MBEDTLS_PLATFORM_TIME_MACRO, MBEDTLS_PLATFORM_TIME_TYPE_MACRO and
|
||||
* MBEDTLS_PLATFORM_STD_TIME.
|
||||
*
|
||||
* Comment if your system does not support time functions
|
||||
*/
|
||||
#define MBEDTLS_HAVE_TIME
|
||||
@ -132,10 +135,10 @@
|
||||
//#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_PLATFORM_XXX_ALT
|
||||
* \def MBEDTLS_PLATFORM_EXIT_ALT
|
||||
*
|
||||
* Uncomment a macro to let mbed TLS support the function in the platform
|
||||
* abstraction layer.
|
||||
* MBEDTLS_PLATFORM_XXX_ALT: Uncomment a macro to let mbed TLS support the
|
||||
* function in the platform abstraction layer.
|
||||
*
|
||||
* Example: In case you uncomment MBEDTLS_PLATFORM_PRINTF_ALT, mbed TLS will
|
||||
* provide a function "mbedtls_platform_set_printf()" that allows you to set an
|
||||
@ -149,13 +152,17 @@
|
||||
* \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as
|
||||
* MBEDTLS_PLATFORM_XXX_MACRO!
|
||||
*
|
||||
* Requires: MBEDTLS_PLATFORM_TIME_ALT requires MBEDTLS_HAVE_TIME
|
||||
*
|
||||
* Uncomment a macro to enable alternate implementation of specific base
|
||||
* platform function
|
||||
*/
|
||||
//#define MBEDTLS_PLATFORM_EXIT_ALT
|
||||
//#define MBEDTLS_PLATFORM_TIME_ALT
|
||||
//#define MBEDTLS_PLATFORM_FPRINTF_ALT
|
||||
//#define MBEDTLS_PLATFORM_PRINTF_ALT
|
||||
//#define MBEDTLS_PLATFORM_SNPRINTF_ALT
|
||||
//#define MBEDTLS_PLATFORM_NV_SEED_ALT
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_DEPRECATED_WARNING
|
||||
@ -208,12 +215,12 @@
|
||||
//#define MBEDTLS_TIMING_ALT
|
||||
|
||||
/**
|
||||
* \def MBEDTLS__MODULE_NAME__ALT
|
||||
* \def MBEDTLS_AES_ALT
|
||||
*
|
||||
* Uncomment a macro to let mbed TLS use your alternate core implementation of
|
||||
* a symmetric crypto or hash module (e.g. platform specific assembly
|
||||
* optimized implementations). Keep in mind that the function prototypes
|
||||
* should remain the same.
|
||||
* MBEDTLS__MODULE_NAME__ALT: Uncomment a macro to let mbed TLS use your
|
||||
* alternate core implementation of a symmetric crypto or hash module (e.g.
|
||||
* platform specific assembly optimized implementations). Keep in mind that
|
||||
* the function prototypes should remain the same.
|
||||
*
|
||||
* This replaces the whole module. If you only want to replace one of the
|
||||
* functions, use one of the MBEDTLS__FUNCTION_NAME__ALT flags.
|
||||
@ -241,11 +248,11 @@
|
||||
//#define MBEDTLS_SHA512_ALT
|
||||
|
||||
/**
|
||||
* \def MBEDTLS__FUNCTION_NAME__ALT
|
||||
* \def MBEDTLS_MD2_PROCESS_ALT
|
||||
*
|
||||
* Uncomment a macro to let mbed TLS use you alternate core implementation of
|
||||
* symmetric crypto or hash function. Keep in mind that function prototypes
|
||||
* should remain the same.
|
||||
* MBEDTLS__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use you
|
||||
* alternate core implementation of symmetric crypto or hash function. Keep in
|
||||
* mind that function prototypes should remain the same.
|
||||
*
|
||||
* This replaces only one function. The header file from mbed TLS is still
|
||||
* used, in contrast to the MBEDTLS__MODULE_NAME__ALT flags.
|
||||
@ -278,6 +285,23 @@
|
||||
//#define MBEDTLS_AES_ENCRYPT_ALT
|
||||
//#define MBEDTLS_AES_DECRYPT_ALT
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_TEST_NULL_ENTROPY
|
||||
*
|
||||
* Enables testing and use of mbed TLS without any configured entropy sources.
|
||||
* This permits use of the library on platforms before an entropy source has
|
||||
* been integrated (see for example the MBEDTLS_ENTROPY_HARDWARE_ALT or the
|
||||
* MBEDTLS_ENTROPY_NV_SEED switches).
|
||||
*
|
||||
* WARNING! This switch MUST be disabled in production builds, and is suitable
|
||||
* only for development.
|
||||
* Enabling the switch negates any security provided by the library.
|
||||
*
|
||||
* Requires MBEDTLS_ENTROPY_C, MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
|
||||
*
|
||||
*/
|
||||
//#define MBEDTLS_TEST_NULL_ENTROPY
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_ENTROPY_HARDWARE_ALT
|
||||
*
|
||||
@ -364,10 +388,11 @@
|
||||
//#define MBEDTLS_CIPHER_NULL_CIPHER
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_CIPHER_PADDING_XXX
|
||||
* \def MBEDTLS_CIPHER_PADDING_PKCS7
|
||||
*
|
||||
* Uncomment or comment macros to add support for specific padding modes
|
||||
* in the cipher layer with cipher modes that support padding (e.g. CBC)
|
||||
* MBEDTLS_CIPHER_PADDING_XXX: Uncomment or comment macros to add support for
|
||||
* specific padding modes in the cipher layer with cipher modes that support
|
||||
* padding (e.g. CBC)
|
||||
*
|
||||
* If you disable all padding modes, only full blocks can be used with CBC.
|
||||
*
|
||||
@ -407,10 +432,10 @@
|
||||
#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_ECP_XXXX_ENABLED
|
||||
* \def MBEDTLS_ECP_DP_SECP192R1_ENABLED
|
||||
*
|
||||
* Enables specific curves within the Elliptic Curve module.
|
||||
* By default all supported curves are enabled.
|
||||
* MBEDTLS_ECP_XXXX_ENABLED: Enables specific curves within the Elliptic Curve
|
||||
* module. By default all supported curves are enabled.
|
||||
*
|
||||
* Comment macros to disable the curve and functions for it
|
||||
*/
|
||||
@ -694,6 +719,25 @@
|
||||
*/
|
||||
#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
|
||||
*
|
||||
* Enable the ECJPAKE based ciphersuite modes in SSL / TLS.
|
||||
*
|
||||
* \warning This is currently experimental. EC J-PAKE support is based on the
|
||||
* Thread v1.0.0 specification; incompatible changes to the specification
|
||||
* might still happen. For this reason, this is disabled by default.
|
||||
*
|
||||
* Requires: MBEDTLS_ECJPAKE_C
|
||||
* MBEDTLS_SHA256_C
|
||||
* MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
*
|
||||
* This enables the following ciphersuites (if other requisites are
|
||||
* enabled as well):
|
||||
* MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
|
||||
*/
|
||||
//#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_PK_PARSE_EC_EXTENDED
|
||||
*
|
||||
@ -779,6 +823,34 @@
|
||||
*/
|
||||
//#define MBEDTLS_ENTROPY_FORCE_SHA256
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_ENTROPY_NV_SEED
|
||||
*
|
||||
* Enable the non-volatile (NV) seed file-based entropy source.
|
||||
* (Also enables the NV seed read/write functions in the platform layer)
|
||||
*
|
||||
* This is crucial (if not required) on systems that do not have a
|
||||
* cryptographic entropy source (in hardware or kernel) available.
|
||||
*
|
||||
* Requires: MBEDTLS_ENTROPY_C, MBEDTLS_PLATFORM_C
|
||||
*
|
||||
* \note The read/write functions that are used by the entropy source are
|
||||
* determined in the platform layer, and can be modified at runtime and/or
|
||||
* compile-time depending on the flags (MBEDTLS_PLATFORM_NV_SEED_*) used.
|
||||
*
|
||||
* \note If you use the default implementation functions that read a seedfile
|
||||
* with regular fopen(), please make sure you make a seedfile with the
|
||||
* proper name (defined in MBEDTLS_PLATFORM_STD_NV_SEED_FILE) and at
|
||||
* least MBEDTLS_ENTROPY_BLOCK_SIZE bytes in size that can be read from
|
||||
* and written to or you will get an entropy source error! The default
|
||||
* implementation will only use the first MBEDTLS_ENTROPY_BLOCK_SIZE
|
||||
* bytes from the file.
|
||||
*
|
||||
* \note The entropy collector will write to the seed file before entropy is
|
||||
* given to an external source, to update it.
|
||||
*/
|
||||
//#define MBEDTLS_ENTROPY_NV_SEED
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_MEMORY_DEBUG
|
||||
*
|
||||
@ -868,18 +940,6 @@
|
||||
*/
|
||||
//#define MBEDTLS_SHA256_SMALLER
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_SSL_AEAD_RANDOM_IV
|
||||
*
|
||||
* Generate a random IV rather than using the record sequence number as a
|
||||
* nonce for ciphersuites using and AEAD algorithm (GCM or CCM).
|
||||
*
|
||||
* Using the sequence number is generally recommended.
|
||||
*
|
||||
* Uncomment this macro to always use random IVs with AEAD ciphersuites.
|
||||
*/
|
||||
//#define MBEDTLS_SSL_AEAD_RANDOM_IV
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_SSL_ALL_ALERT_MESSAGES
|
||||
*
|
||||
@ -1039,7 +1099,7 @@
|
||||
*
|
||||
* Comment this macro to disable support for SSL 3.0
|
||||
*/
|
||||
#define MBEDTLS_SSL_PROTO_SSL3
|
||||
//#define MBEDTLS_SSL_PROTO_SSL3
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_SSL_PROTO_TLS1
|
||||
@ -1175,6 +1235,16 @@
|
||||
*/
|
||||
#define MBEDTLS_SSL_SESSION_TICKETS
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_SSL_EXPORT_KEYS
|
||||
*
|
||||
* Enable support for exporting key block and master secret.
|
||||
* This is required for certain users of TLS, e.g. EAP-TLS.
|
||||
*
|
||||
* Comment this macro to disable support for key export
|
||||
*/
|
||||
#define MBEDTLS_SSL_EXPORT_KEYS
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_SSL_SERVER_NAME_INDICATION
|
||||
*
|
||||
@ -1246,6 +1316,8 @@
|
||||
* If set, the X509 parser will not break-off when parsing an X509 certificate
|
||||
* and encountering an unknown critical extension.
|
||||
*
|
||||
* \warning Depending on your PKI use, enabling this can be a security risk!
|
||||
*
|
||||
* Uncomment to prevent an error.
|
||||
*/
|
||||
//#define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
|
||||
@ -1587,6 +1659,19 @@
|
||||
*/
|
||||
#define MBEDTLS_CIPHER_C
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_CMAC_C
|
||||
*
|
||||
* Enable the CMAC (Cipher-based Message Authentication Code) mode for block
|
||||
* ciphers.
|
||||
*
|
||||
* Module: library/cmac.c
|
||||
*
|
||||
* Requires: MBEDTLS_AES_C or MBEDTLS_DES_C
|
||||
*
|
||||
*/
|
||||
//#define MBEDTLS_CMAC_C
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_CTR_DRBG_C
|
||||
*
|
||||
@ -1686,6 +1771,25 @@
|
||||
*/
|
||||
#define MBEDTLS_ECDSA_C
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_ECJPAKE_C
|
||||
*
|
||||
* Enable the elliptic curve J-PAKE library.
|
||||
*
|
||||
* \warning This is currently experimental. EC J-PAKE support is based on the
|
||||
* Thread v1.0.0 specification; incompatible changes to the specification
|
||||
* might still happen. For this reason, this is disabled by default.
|
||||
*
|
||||
* Module: library/ecjpake.c
|
||||
* Caller:
|
||||
*
|
||||
* This module is used by the following key exchanges:
|
||||
* ECJPAKE
|
||||
*
|
||||
* Requires: MBEDTLS_ECP_C, MBEDTLS_MD_C
|
||||
*/
|
||||
//#define MBEDTLS_ECJPAKE_C
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_ECP_C
|
||||
*
|
||||
@ -1694,6 +1798,7 @@
|
||||
* Module: library/ecp.c
|
||||
* Caller: library/ecdh.c
|
||||
* library/ecdsa.c
|
||||
* library/ecjpake.c
|
||||
*
|
||||
* Requires: MBEDTLS_BIGNUM_C and at least one MBEDTLS_ECP_DP_XXX_ENABLED
|
||||
*/
|
||||
@ -1846,11 +1951,19 @@
|
||||
/**
|
||||
* \def MBEDTLS_NET_C
|
||||
*
|
||||
* Enable the TCP/IP networking routines.
|
||||
* Enable the TCP and UDP over IPv6/IPv4 networking routines.
|
||||
*
|
||||
* Module: library/net.c
|
||||
* \note This module only works on POSIX/Unix (including Linux, BSD and OS X)
|
||||
* and Windows. For other platforms, you'll want to disable it, and write your
|
||||
* own networking callbacks to be passed to \c mbedtls_ssl_set_bio().
|
||||
*
|
||||
* This module provides TCP/IP networking routines.
|
||||
* \note See also our Knowledge Base article about porting to a new
|
||||
* environment:
|
||||
* https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS
|
||||
*
|
||||
* Module: library/net_sockets.c
|
||||
*
|
||||
* This module provides networking routines.
|
||||
*/
|
||||
#define MBEDTLS_NET_C
|
||||
|
||||
@ -2196,7 +2309,8 @@
|
||||
* By default mbed TLS assumes it is used in a non-threaded environment or that
|
||||
* contexts are not shared between threads. If you do intend to use contexts
|
||||
* between threads, you will need to enable this layer to prevent race
|
||||
* conditions.
|
||||
* conditions. See also our Knowledge Base article about threading:
|
||||
* https://tls.mbed.org/kb/development/thread-safety-and-multi-threading
|
||||
*
|
||||
* Module: library/threading.c
|
||||
*
|
||||
@ -2213,7 +2327,18 @@
|
||||
/**
|
||||
* \def MBEDTLS_TIMING_C
|
||||
*
|
||||
* Enable the portable timing interface.
|
||||
* Enable the semi-portable timing interface.
|
||||
*
|
||||
* \note The provided implementation only works on POSIX/Unix (including Linux,
|
||||
* BSD and OS X) and Windows. On other platforms, you can either disable that
|
||||
* module and provide your own implementations of the callbacks needed by
|
||||
* \c mbedtls_ssl_set_timer_cb() for DTLS, or leave it enabled and provide
|
||||
* your own implementation of the whole module by setting
|
||||
* \c MBEDTLS_TIMING_ALT in the current file.
|
||||
*
|
||||
* \note See also our Knowledge Base article about porting to a new
|
||||
* environment:
|
||||
* https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS
|
||||
*
|
||||
* Module: library/timing.c
|
||||
* Caller: library/havege.c
|
||||
@ -2385,6 +2510,7 @@
|
||||
/* Entropy options */
|
||||
//#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */
|
||||
//#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */
|
||||
//#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Default minimum number of bytes required for the hardware entropy source mbedtls_hardware_poll() before entropy is released */
|
||||
|
||||
/* Memory buffer allocator options */
|
||||
//#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */
|
||||
@ -2394,20 +2520,30 @@
|
||||
//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
||||
//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
|
||||
/* Note: your snprintf must correclty zero-terminate the buffer! */
|
||||
//#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 0 /**< Default exit value to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE 1 /**< Default exit value to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" /**< Seed file to read/write with default implementation */
|
||||
|
||||
/* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */
|
||||
/* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */
|
||||
//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
||||
//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
||||
//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */
|
||||
/* Note: your snprintf must correclty zero-terminate the buffer! */
|
||||
//#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf /**< Default snprintf macro to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */
|
||||
|
||||
/* SSL Cache options */
|
||||
//#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */
|
||||
@ -2435,11 +2571,15 @@
|
||||
|
||||
/* X509 options */
|
||||
//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */
|
||||
//#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the null terminator character ('\0'). */
|
||||
|
||||
/* \} name SECTION: Module configuration options */
|
||||
/* \} name SECTION: Customisation configuration options */
|
||||
|
||||
#if defined(TARGET_LIKE_MBED)
|
||||
#include "mbedtls/target_config.h"
|
||||
/* Target and application specific configurations */
|
||||
//#define YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE "mbedtls/target_config.h"
|
||||
|
||||
#if defined(TARGET_LIKE_MBED) && defined(YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE)
|
||||
#include YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
2
Externals/mbedtls/include/mbedtls/ctr_drbg.h
vendored
2
Externals/mbedtls/include/mbedtls/ctr_drbg.h
vendored
@ -111,7 +111,7 @@ mbedtls_ctr_drbg_context;
|
||||
|
||||
/**
|
||||
* \brief CTR_DRBG context initialization
|
||||
* Makes the context ready for mbetls_ctr_drbg_seed() or
|
||||
* Makes the context ready for mbedtls_ctr_drbg_seed() or
|
||||
* mbedtls_ctr_drbg_free().
|
||||
*
|
||||
* \param ctx CTR_DRBG context to be initialized
|
||||
|
113
Externals/mbedtls/include/mbedtls/debug.h
vendored
113
Externals/mbedtls/include/mbedtls/debug.h
vendored
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* \file debug.h
|
||||
*
|
||||
* \brief Debug functions
|
||||
* \brief Functions for controlling and providing debug output from the library.
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
@ -80,39 +80,141 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Set the level threshold to handle globally. Messages that have a
|
||||
* level over the threshold value are ignored.
|
||||
* (Default value: 0 (No debug))
|
||||
* \brief Set the threshold error level to handle globally all debug output.
|
||||
* Debug messages that have a level over the threshold value are
|
||||
* discarded.
|
||||
* (Default value: 0 = No debug )
|
||||
*
|
||||
* \param threshold maximum level of messages to pass on
|
||||
* \param threshold theshold level of messages to filter on. Messages at a
|
||||
* higher level will be discarded.
|
||||
* - Debug levels
|
||||
* - 0 No debug
|
||||
* - 1 Error
|
||||
* - 2 State change
|
||||
* - 3 Informational
|
||||
* - 4 Verbose
|
||||
*/
|
||||
void mbedtls_debug_set_threshold( int threshold );
|
||||
|
||||
/**
|
||||
* \brief Print a message to the debug output. This function is always used
|
||||
* through the MBEDTLS_SSL_DEBUG_MSG() macro, which supplies the ssl
|
||||
* context, file and line number parameters.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param level error level of the debug message
|
||||
* \param file file the message has occurred in
|
||||
* \param line line number the message has occurred at
|
||||
* \param format format specifier, in printf format
|
||||
* \param ... variables used by the format specifier
|
||||
*
|
||||
* \attention This function is intended for INTERNAL usage within the
|
||||
* library only.
|
||||
*/
|
||||
void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line,
|
||||
const char *format, ... );
|
||||
|
||||
/**
|
||||
* \brief Print the return value of a function to the debug output. This
|
||||
* function is always used through the MBEDTLS_SSL_DEBUG_RET() macro,
|
||||
* which supplies the ssl context, file and line number parameters.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param level error level of the debug message
|
||||
* \param file file the error has occurred in
|
||||
* \param line line number the error has occurred in
|
||||
* \param text the name of the function that returned the error
|
||||
* \param ret the return code value
|
||||
*
|
||||
* \attention This function is intended for INTERNAL usage within the
|
||||
* library only.
|
||||
*/
|
||||
void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line,
|
||||
const char *text, int ret );
|
||||
|
||||
/**
|
||||
* \brief Output a buffer of size len bytes to the debug output. This function
|
||||
* is always used through the MBEDTLS_SSL_DEBUG_BUF() macro,
|
||||
* which supplies the ssl context, file and line number parameters.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param level error level of the debug message
|
||||
* \param file file the error has occurred in
|
||||
* \param line line number the error has occurred in
|
||||
* \param text a name or label for the buffer being dumped. Normally the
|
||||
* variable or buffer name
|
||||
* \param buf the buffer to be outputted
|
||||
* \param len length of the buffer
|
||||
*
|
||||
* \attention This function is intended for INTERNAL usage within the
|
||||
* library only.
|
||||
*/
|
||||
void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line, const char *text,
|
||||
const unsigned char *buf, size_t len );
|
||||
|
||||
#if defined(MBEDTLS_BIGNUM_C)
|
||||
/**
|
||||
* \brief Print a MPI variable to the debug output. This function is always
|
||||
* used through the MBEDTLS_SSL_DEBUG_MPI() macro, which supplies the
|
||||
* ssl context, file and line number parameters.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param level error level of the debug message
|
||||
* \param file file the error has occurred in
|
||||
* \param line line number the error has occurred in
|
||||
* \param text a name or label for the MPI being output. Normally the
|
||||
* variable name
|
||||
* \param X the MPI variable
|
||||
*
|
||||
* \attention This function is intended for INTERNAL usage within the
|
||||
* library only.
|
||||
*/
|
||||
void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line,
|
||||
const char *text, const mbedtls_mpi *X );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
/**
|
||||
* \brief Print an ECP point to the debug output. This function is always
|
||||
* used through the MBEDTLS_SSL_DEBUG_ECP() macro, which supplies the
|
||||
* ssl context, file and line number parameters.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param level error level of the debug message
|
||||
* \param file file the error has occurred in
|
||||
* \param line line number the error has occurred in
|
||||
* \param text a name or label for the ECP point being output. Normally the
|
||||
* variable name
|
||||
* \param X the ECP point
|
||||
*
|
||||
* \attention This function is intended for INTERNAL usage within the
|
||||
* library only.
|
||||
*/
|
||||
void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line,
|
||||
const char *text, const mbedtls_ecp_point *X );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
/**
|
||||
* \brief Print a X.509 certificate structure to the debug output. This
|
||||
* function is always used through the MBEDTLS_SSL_DEBUG_CRT() macro,
|
||||
* which supplies the ssl context, file and line number parameters.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param level error level of the debug message
|
||||
* \param file file the error has occurred in
|
||||
* \param line line number the error has occurred in
|
||||
* \param text a name or label for the certificate being output
|
||||
* \param crt X.509 certificate structure
|
||||
*
|
||||
* \attention This function is intended for INTERNAL usage within the
|
||||
* library only.
|
||||
*/
|
||||
void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
|
||||
const char *file, int line,
|
||||
const char *text, const mbedtls_x509_crt *crt );
|
||||
@ -123,3 +225,4 @@ void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
|
||||
#endif
|
||||
|
||||
#endif /* debug.h */
|
||||
|
||||
|
2
Externals/mbedtls/include/mbedtls/dhm.h
vendored
2
Externals/mbedtls/include/mbedtls/dhm.h
vendored
@ -221,7 +221,7 @@ int mbedtls_dhm_read_public( mbedtls_dhm_context *ctx,
|
||||
* \param ctx DHM context
|
||||
* \param x_size private value size in bytes
|
||||
* \param output destination buffer
|
||||
* \param olen must be equal to ctx->P.len
|
||||
* \param olen must be at least equal to the size of P, ctx->len
|
||||
* \param f_rng RNG function
|
||||
* \param p_rng RNG parameter
|
||||
*
|
||||
|
238
Externals/mbedtls/include/mbedtls/ecjpake.h
vendored
Normal file
238
Externals/mbedtls/include/mbedtls/ecjpake.h
vendored
Normal file
@ -0,0 +1,238 @@
|
||||
/**
|
||||
* \file ecjpake.h
|
||||
*
|
||||
* \brief Elliptic curve J-PAKE
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
#ifndef MBEDTLS_ECJPAKE_H
|
||||
#define MBEDTLS_ECJPAKE_H
|
||||
|
||||
/*
|
||||
* J-PAKE is a password-authenticated key exchange that allows deriving a
|
||||
* strong shared secret from a (potentially low entropy) pre-shared
|
||||
* passphrase, with forward secrecy and mutual authentication.
|
||||
* https://en.wikipedia.org/wiki/Password_Authenticated_Key_Exchange_by_Juggling
|
||||
*
|
||||
* This file implements the Elliptic Curve variant of J-PAKE,
|
||||
* as defined in Chapter 7.4 of the Thread v1.0 Specification,
|
||||
* available to members of the Thread Group http://threadgroup.org/
|
||||
*
|
||||
* As the J-PAKE algorithm is inherently symmetric, so is our API.
|
||||
* Each party needs to send its first round message, in any order, to the
|
||||
* other party, then each sends its second round message, in any order.
|
||||
* The payloads are serialized in a way suitable for use in TLS, but could
|
||||
* also be use outside TLS.
|
||||
*/
|
||||
|
||||
#include "ecp.h"
|
||||
#include "md.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Roles in the EC J-PAKE exchange
|
||||
*/
|
||||
typedef enum {
|
||||
MBEDTLS_ECJPAKE_CLIENT = 0, /**< Client */
|
||||
MBEDTLS_ECJPAKE_SERVER, /**< Server */
|
||||
} mbedtls_ecjpake_role;
|
||||
|
||||
/**
|
||||
* EC J-PAKE context structure.
|
||||
*
|
||||
* J-PAKE is a symmetric protocol, except for the identifiers used in
|
||||
* Zero-Knowledge Proofs, and the serialization of the second message
|
||||
* (KeyExchange) as defined by the Thread spec.
|
||||
*
|
||||
* In order to benefit from this symmetry, we choose a different naming
|
||||
* convetion from the Thread v1.0 spec. Correspondance is indicated in the
|
||||
* description as a pair C: client name, S: server name
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const mbedtls_md_info_t *md_info; /**< Hash to use */
|
||||
mbedtls_ecp_group grp; /**< Elliptic curve */
|
||||
mbedtls_ecjpake_role role; /**< Are we client or server? */
|
||||
int point_format; /**< Format for point export */
|
||||
|
||||
mbedtls_ecp_point Xm1; /**< My public key 1 C: X1, S: X3 */
|
||||
mbedtls_ecp_point Xm2; /**< My public key 2 C: X2, S: X4 */
|
||||
mbedtls_ecp_point Xp1; /**< Peer public key 1 C: X3, S: X1 */
|
||||
mbedtls_ecp_point Xp2; /**< Peer public key 2 C: X4, S: X2 */
|
||||
mbedtls_ecp_point Xp; /**< Peer public key C: Xs, S: Xc */
|
||||
|
||||
mbedtls_mpi xm1; /**< My private key 1 C: x1, S: x3 */
|
||||
mbedtls_mpi xm2; /**< My private key 2 C: x2, S: x4 */
|
||||
|
||||
mbedtls_mpi s; /**< Pre-shared secret (passphrase) */
|
||||
} mbedtls_ecjpake_context;
|
||||
|
||||
/**
|
||||
* \brief Initialize a context
|
||||
* (just makes it ready for setup() or free()).
|
||||
*
|
||||
* \param ctx context to initialize
|
||||
*/
|
||||
void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Set up a context for use
|
||||
*
|
||||
* \note Currently the only values for hash/curve allowed by the
|
||||
* standard are MBEDTLS_MD_SHA256/MBEDTLS_ECP_DP_SECP256R1.
|
||||
*
|
||||
* \param ctx context to set up
|
||||
* \param role Our role: client or server
|
||||
* \param hash hash function to use (MBEDTLS_MD_XXX)
|
||||
* \param curve elliptic curve identifier (MBEDTLS_ECP_DP_XXX)
|
||||
* \param secret pre-shared secret (passphrase)
|
||||
* \param len length of the shared secret
|
||||
*
|
||||
* \return 0 if successfull,
|
||||
* a negative error code otherwise
|
||||
*/
|
||||
int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx,
|
||||
mbedtls_ecjpake_role role,
|
||||
mbedtls_md_type_t hash,
|
||||
mbedtls_ecp_group_id curve,
|
||||
const unsigned char *secret,
|
||||
size_t len );
|
||||
|
||||
/*
|
||||
* \brief Check if a context is ready for use
|
||||
*
|
||||
* \param ctx Context to check
|
||||
*
|
||||
* \return 0 if the context is ready for use,
|
||||
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise
|
||||
*/
|
||||
int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Generate and write the first round message
|
||||
* (TLS: contents of the Client/ServerHello extension,
|
||||
* excluding extension type and length bytes)
|
||||
*
|
||||
* \param ctx Context to use
|
||||
* \param buf Buffer to write the contents to
|
||||
* \param len Buffer size
|
||||
* \param olen Will be updated with the number of bytes written
|
||||
* \param f_rng RNG function
|
||||
* \param p_rng RNG parameter
|
||||
*
|
||||
* \return 0 if successfull,
|
||||
* a negative error code otherwise
|
||||
*/
|
||||
int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx,
|
||||
unsigned char *buf, size_t len, size_t *olen,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng );
|
||||
|
||||
/**
|
||||
* \brief Read and process the first round message
|
||||
* (TLS: contents of the Client/ServerHello extension,
|
||||
* excluding extension type and length bytes)
|
||||
*
|
||||
* \param ctx Context to use
|
||||
* \param buf Pointer to extension contents
|
||||
* \param len Extension length
|
||||
*
|
||||
* \return 0 if successfull,
|
||||
* a negative error code otherwise
|
||||
*/
|
||||
int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx,
|
||||
const unsigned char *buf,
|
||||
size_t len );
|
||||
|
||||
/**
|
||||
* \brief Generate and write the second round message
|
||||
* (TLS: contents of the Client/ServerKeyExchange)
|
||||
*
|
||||
* \param ctx Context to use
|
||||
* \param buf Buffer to write the contents to
|
||||
* \param len Buffer size
|
||||
* \param olen Will be updated with the number of bytes written
|
||||
* \param f_rng RNG function
|
||||
* \param p_rng RNG parameter
|
||||
*
|
||||
* \return 0 if successfull,
|
||||
* a negative error code otherwise
|
||||
*/
|
||||
int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx,
|
||||
unsigned char *buf, size_t len, size_t *olen,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng );
|
||||
|
||||
/**
|
||||
* \brief Read and process the second round message
|
||||
* (TLS: contents of the Client/ServerKeyExchange)
|
||||
*
|
||||
* \param ctx Context to use
|
||||
* \param buf Pointer to the message
|
||||
* \param len Message length
|
||||
*
|
||||
* \return 0 if successfull,
|
||||
* a negative error code otherwise
|
||||
*/
|
||||
int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx,
|
||||
const unsigned char *buf,
|
||||
size_t len );
|
||||
|
||||
/**
|
||||
* \brief Derive the shared secret
|
||||
* (TLS: Pre-Master Secret)
|
||||
*
|
||||
* \param ctx Context to use
|
||||
* \param buf Buffer to write the contents to
|
||||
* \param len Buffer size
|
||||
* \param olen Will be updated with the number of bytes written
|
||||
* \param f_rng RNG function
|
||||
* \param p_rng RNG parameter
|
||||
*
|
||||
* \return 0 if successfull,
|
||||
* a negative error code otherwise
|
||||
*/
|
||||
int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx,
|
||||
unsigned char *buf, size_t len, size_t *olen,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng );
|
||||
|
||||
/**
|
||||
* \brief Free a context's content
|
||||
*
|
||||
* \param ctx context to free
|
||||
*/
|
||||
void mbedtls_ecjpake_free( mbedtls_ecjpake_context *ctx );
|
||||
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
/**
|
||||
* \brief Checkup routine
|
||||
*
|
||||
* \return 0 if successful, or 1 if a test failed
|
||||
*/
|
||||
int mbedtls_ecjpake_self_test( int verbose );
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ecjpake.h */
|
38
Externals/mbedtls/include/mbedtls/ecp.h
vendored
38
Externals/mbedtls/include/mbedtls/ecp.h
vendored
@ -346,6 +346,21 @@ int mbedtls_ecp_set_zero( mbedtls_ecp_point *pt );
|
||||
*/
|
||||
int mbedtls_ecp_is_zero( mbedtls_ecp_point *pt );
|
||||
|
||||
/**
|
||||
* \brief Compare two points
|
||||
*
|
||||
* \note This assumes the points are normalized. Otherwise,
|
||||
* they may compare as "not equal" even if they are.
|
||||
*
|
||||
* \param P First point to compare
|
||||
* \param Q Second point to compare
|
||||
*
|
||||
* \return 0 if the points are equal,
|
||||
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise
|
||||
*/
|
||||
int mbedtls_ecp_point_cmp( const mbedtls_ecp_point *P,
|
||||
const mbedtls_ecp_point *Q );
|
||||
|
||||
/**
|
||||
* \brief Import a non-zero point from two ASCII strings
|
||||
*
|
||||
@ -569,6 +584,29 @@ int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, const mbedtls_ecp_po
|
||||
*/
|
||||
int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi *d );
|
||||
|
||||
/**
|
||||
* \brief Generate a keypair with configurable base point
|
||||
*
|
||||
* \param grp ECP group
|
||||
* \param G Chosen base point
|
||||
* \param d Destination MPI (secret part)
|
||||
* \param Q Destination point (public part)
|
||||
* \param f_rng RNG function
|
||||
* \param p_rng RNG parameter
|
||||
*
|
||||
* \return 0 if successful,
|
||||
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
|
||||
*
|
||||
* \note Uses bare components rather than an mbedtls_ecp_keypair structure
|
||||
* in order to ease use with other structures such as
|
||||
* mbedtls_ecdh_context of mbedtls_ecdsa_context.
|
||||
*/
|
||||
int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp,
|
||||
const mbedtls_ecp_point *G,
|
||||
mbedtls_mpi *d, mbedtls_ecp_point *Q,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng );
|
||||
|
||||
/**
|
||||
* \brief Generate a keypair
|
||||
*
|
||||
|
37
Externals/mbedtls/include/mbedtls/entropy.h
vendored
37
Externals/mbedtls/include/mbedtls/entropy.h
vendored
@ -3,7 +3,7 @@
|
||||
*
|
||||
* \brief Entropy accumulator implementation
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -134,6 +134,9 @@ typedef struct
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
mbedtls_threading_mutex_t mutex; /*!< mutex */
|
||||
#endif
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
int initial_entropy_run;
|
||||
#endif
|
||||
}
|
||||
mbedtls_entropy_context;
|
||||
|
||||
@ -208,6 +211,18 @@ int mbedtls_entropy_func( void *data, unsigned char *output, size_t len );
|
||||
int mbedtls_entropy_update_manual( mbedtls_entropy_context *ctx,
|
||||
const unsigned char *data, size_t len );
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
/**
|
||||
* \brief Trigger an update of the seed file in NV by using the
|
||||
* current entropy pool.
|
||||
*
|
||||
* \param ctx Entropy context
|
||||
*
|
||||
* \return 0 if successful
|
||||
*/
|
||||
int mbedtls_entropy_update_nv_seed( mbedtls_entropy_context *ctx );
|
||||
#endif /* MBEDTLS_ENTROPY_NV_SEED */
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
/**
|
||||
* \brief Write a seed file
|
||||
@ -240,9 +255,29 @@ int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *
|
||||
/**
|
||||
* \brief Checkup routine
|
||||
*
|
||||
* This module self-test also calls the entropy self-test,
|
||||
* mbedtls_entropy_source_self_test();
|
||||
*
|
||||
* \return 0 if successful, or 1 if a test failed
|
||||
*/
|
||||
int mbedtls_entropy_self_test( int verbose );
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
||||
/**
|
||||
* \brief Checkup routine
|
||||
*
|
||||
* Verifies the integrity of the hardware entropy source
|
||||
* provided by the function 'mbedtls_hardware_poll()'.
|
||||
*
|
||||
* Note this is the only hardware entropy source that is known
|
||||
* at link time, and other entropy sources configured
|
||||
* dynamically at runtime by the function
|
||||
* mbedtls_entropy_add_source() will not be tested.
|
||||
*
|
||||
* \return 0 if successful, or 1 if a test failed
|
||||
*/
|
||||
int mbedtls_entropy_source_self_test( int verbose );
|
||||
#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */
|
||||
#endif /* MBEDTLS_SELF_TEST */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
22
Externals/mbedtls/include/mbedtls/entropy_poll.h
vendored
22
Externals/mbedtls/include/mbedtls/entropy_poll.h
vendored
@ -3,7 +3,7 @@
|
||||
*
|
||||
* \brief Platform-specific and custom entropy polling functions
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -41,7 +41,17 @@ extern "C" {
|
||||
#define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
|
||||
#define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */
|
||||
#define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */
|
||||
#if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
|
||||
#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Entropy poll callback that provides 0 entropy.
|
||||
*/
|
||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||
int mbedtls_null_entropy_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen );
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
|
||||
/**
|
||||
@ -82,6 +92,16 @@ int mbedtls_hardware_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
/**
|
||||
* \brief Entropy poll callback for a non-volatile seed file
|
||||
*
|
||||
* \note This must accept NULL as its first argument.
|
||||
*/
|
||||
int mbedtls_nv_seed_poll( void *data,
|
||||
unsigned char *output, size_t len, size_t *olen );
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
2
Externals/mbedtls/include/mbedtls/error.h
vendored
2
Externals/mbedtls/include/mbedtls/error.h
vendored
@ -79,7 +79,7 @@
|
||||
* ECP 4 8 (Started from top)
|
||||
* MD 5 4
|
||||
* CIPHER 6 6
|
||||
* SSL 6 16 (Started from top)
|
||||
* SSL 6 17 (Started from top)
|
||||
* SSL 7 31
|
||||
*
|
||||
* Module dependent error code (5 bits 0x.00.-0x.F8.)
|
||||
|
4
Externals/mbedtls/include/mbedtls/gcm.h
vendored
4
Externals/mbedtls/include/mbedtls/gcm.h
vendored
@ -190,8 +190,8 @@ int mbedtls_gcm_update( mbedtls_gcm_context *ctx,
|
||||
* 16 bytes.
|
||||
*
|
||||
* \param ctx GCM context
|
||||
* \param tag buffer for holding the tag (may be NULL if tag_len is 0)
|
||||
* \param tag_len length of the tag to generate
|
||||
* \param tag buffer for holding the tag
|
||||
* \param tag_len length of the tag to generate (must be at least 4)
|
||||
*
|
||||
* \return 0 if successful or MBEDTLS_ERR_GCM_BAD_INPUT
|
||||
*/
|
||||
|
@ -98,7 +98,7 @@ typedef struct
|
||||
|
||||
/**
|
||||
* \brief HMAC_DRBG context initialization
|
||||
* Makes the context ready for mbetls_hmac_drbg_seed(),
|
||||
* Makes the context ready for mbedtls_hmac_drbg_seed(),
|
||||
* mbedtls_hmac_drbg_seed_buf() or
|
||||
* mbedtls_hmac_drbg_free().
|
||||
*
|
||||
|
13
Externals/mbedtls/include/mbedtls/md.h
vendored
13
Externals/mbedtls/include/mbedtls/md.h
vendored
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file mbedtls_md.h
|
||||
* \file md.h
|
||||
*
|
||||
* \brief Generic message digest wrapper
|
||||
*
|
||||
@ -27,10 +27,6 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && !defined(inline)
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080 /**< The selected feature is not available. */
|
||||
#define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */
|
||||
#define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180 /**< Failed to allocate memory. */
|
||||
@ -308,8 +304,8 @@ int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *inpu
|
||||
/**
|
||||
* \brief Output HMAC.
|
||||
* Called after mbedtls_md_hmac_update().
|
||||
* Usually followed my mbedtls_md_hmac_reset(), mbedtls_md_hmac_starts(),
|
||||
* or mbedtls_md_free().
|
||||
* Usually followed by mbedtls_md_hmac_reset(),
|
||||
* mbedtls_md_hmac_starts(), or mbedtls_md_free().
|
||||
*
|
||||
* \param ctx HMAC context
|
||||
* \param output Generic HMAC checksum result
|
||||
@ -321,7 +317,8 @@ int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
|
||||
|
||||
/**
|
||||
* \brief Prepare to authenticate a new message with the same key.
|
||||
* Called after mbedtls_md_hmac_finish() and before mbedtls_md_hmac_update().
|
||||
* Called after mbedtls_md_hmac_finish() and before
|
||||
* mbedtls_md_hmac_update().
|
||||
*
|
||||
* \param ctx HMAC context to be reset
|
||||
*
|
||||
|
2
Externals/mbedtls/include/mbedtls/md2.h
vendored
2
Externals/mbedtls/include/mbedtls/md2.h
vendored
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file mbedtls_md2.h
|
||||
* \file md2.h
|
||||
*
|
||||
* \brief MD2 message digest algorithm (hash function)
|
||||
*
|
||||
|
2
Externals/mbedtls/include/mbedtls/md4.h
vendored
2
Externals/mbedtls/include/mbedtls/md4.h
vendored
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file mbedtls_md4.h
|
||||
* \file md4.h
|
||||
*
|
||||
* \brief MD4 message digest algorithm (hash function)
|
||||
*
|
||||
|
2
Externals/mbedtls/include/mbedtls/md5.h
vendored
2
Externals/mbedtls/include/mbedtls/md5.h
vendored
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file mbedtls_md5.h
|
||||
* \file md5.h
|
||||
*
|
||||
* \brief MD5 message digest algorithm (hash function)
|
||||
*
|
||||
|
@ -98,8 +98,10 @@ void mbedtls_memory_buffer_alloc_status( void );
|
||||
/**
|
||||
* \brief Get the peak heap usage so far
|
||||
*
|
||||
* \param max_used Peak number of bytes reauested by the application
|
||||
* \param max_blocks Peak number of blocks reauested by the application
|
||||
* \param max_used Peak number of bytes in use or committed. This
|
||||
* includes bytes in allocated blocks too small to split
|
||||
* into smaller blocks but larger than the requested size.
|
||||
* \param max_blocks Peak number of blocks in use, including free and used
|
||||
*/
|
||||
void mbedtls_memory_buffer_alloc_max_get( size_t *max_used, size_t *max_blocks );
|
||||
|
||||
@ -111,8 +113,10 @@ void mbedtls_memory_buffer_alloc_max_reset( void );
|
||||
/**
|
||||
* \brief Get the current heap usage
|
||||
*
|
||||
* \param cur_used Number of bytes reauested by the application
|
||||
* \param cur_blocks Number of blocks reauested by the application
|
||||
* \param cur_used Current number of bytes in use or committed. This
|
||||
* includes bytes in allocated blocks too small to split
|
||||
* into smaller blocks but larger than the requested size.
|
||||
* \param cur_blocks Current number of blocks in use, including free and used
|
||||
*/
|
||||
void mbedtls_memory_buffer_alloc_cur_get( size_t *cur_used, size_t *cur_blocks );
|
||||
#endif /* MBEDTLS_MEMORY_DEBUG */
|
||||
|
214
Externals/mbedtls/include/mbedtls/net.h
vendored
214
Externals/mbedtls/include/mbedtls/net.h
vendored
@ -1,9 +1,9 @@
|
||||
/**
|
||||
* \file net.h
|
||||
*
|
||||
* \brief Network communication functions
|
||||
* \brief Deprecated header file that includes mbedtls/net_sockets.h
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -19,207 +19,13 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*
|
||||
* \deprecated Superseded by mbedtls/net_sockets.h
|
||||
*/
|
||||
#ifndef MBEDTLS_NET_H
|
||||
#define MBEDTLS_NET_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "ssl.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042 /**< Failed to open a socket. */
|
||||
#define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044 /**< The connection to the given server / port failed. */
|
||||
#define MBEDTLS_ERR_NET_BIND_FAILED -0x0046 /**< Binding of the socket failed. */
|
||||
#define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048 /**< Could not listen on the socket. */
|
||||
#define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A /**< Could not accept the incoming connection. */
|
||||
#define MBEDTLS_ERR_NET_RECV_FAILED -0x004C /**< Reading information from the socket failed. */
|
||||
#define MBEDTLS_ERR_NET_SEND_FAILED -0x004E /**< Sending information through the socket failed. */
|
||||
#define MBEDTLS_ERR_NET_CONN_RESET -0x0050 /**< Connection was reset by peer. */
|
||||
#define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052 /**< Failed to get an IP address for the given hostname. */
|
||||
#define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043 /**< Buffer is too small to hold the data. */
|
||||
#define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045 /**< The context is invalid, eg because it was free()ed. */
|
||||
|
||||
#define MBEDTLS_NET_LISTEN_BACKLOG 10 /**< The backlog that listen() should use. */
|
||||
|
||||
#define MBEDTLS_NET_PROTO_TCP 0 /**< The TCP transport protocol */
|
||||
#define MBEDTLS_NET_PROTO_UDP 1 /**< The UDP transport protocol */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Wrapper type for sockets.
|
||||
*
|
||||
* Currently backed by just a file descriptor, but might be more in the future
|
||||
* (eg two file descriptors for combined IPv4 + IPv6 support, or additional
|
||||
* structures for hand-made UDP demultiplexing).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int fd; /**< The underlying file descriptor */
|
||||
}
|
||||
mbedtls_net_context;
|
||||
|
||||
/**
|
||||
* \brief Initialize a context
|
||||
* Just makes the context ready to be used or freed safely.
|
||||
*
|
||||
* \param ctx Context to initialize
|
||||
*/
|
||||
void mbedtls_net_init( mbedtls_net_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Initiate a connection with host:port in the given protocol
|
||||
*
|
||||
* \param ctx Socket to use
|
||||
* \param host Host to connect to
|
||||
* \param port Port to connect to
|
||||
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
|
||||
*
|
||||
* \return 0 if successful, or one of:
|
||||
* MBEDTLS_ERR_NET_SOCKET_FAILED,
|
||||
* MBEDTLS_ERR_NET_UNKNOWN_HOST,
|
||||
* MBEDTLS_ERR_NET_CONNECT_FAILED
|
||||
*
|
||||
* \note Sets the socket in connected mode even with UDP.
|
||||
*/
|
||||
int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto );
|
||||
|
||||
/**
|
||||
* \brief Create a receiving socket on bind_ip:port in the chosen
|
||||
* protocol. If bind_ip == NULL, all interfaces are bound.
|
||||
*
|
||||
* \param ctx Socket to use
|
||||
* \param bind_ip IP to bind to, can be NULL
|
||||
* \param port Port number to use
|
||||
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
|
||||
*
|
||||
* \return 0 if successful, or one of:
|
||||
* MBEDTLS_ERR_NET_SOCKET_FAILED,
|
||||
* MBEDTLS_ERR_NET_BIND_FAILED,
|
||||
* MBEDTLS_ERR_NET_LISTEN_FAILED
|
||||
*
|
||||
* \note Regardless of the protocol, opens the sockets and binds it.
|
||||
* In addition, make the socket listening if protocol is TCP.
|
||||
*/
|
||||
int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto );
|
||||
|
||||
/**
|
||||
* \brief Accept a connection from a remote client
|
||||
*
|
||||
* \param bind_ctx Relevant socket
|
||||
* \param client_ctx Will contain the connected client socket
|
||||
* \param client_ip Will contain the client IP address
|
||||
* \param buf_size Size of the client_ip buffer
|
||||
* \param ip_len Will receive the size of the client IP written
|
||||
*
|
||||
* \return 0 if successful, or
|
||||
* MBEDTLS_ERR_NET_ACCEPT_FAILED, or
|
||||
* MBEDTLS_ERR_NET_BUFFER_TOO_SMALL if buf_size is too small,
|
||||
* MBEDTLS_ERR_SSL_WANT_READ if bind_fd was set to
|
||||
* non-blocking and accept() would block.
|
||||
*/
|
||||
int mbedtls_net_accept( mbedtls_net_context *bind_ctx,
|
||||
mbedtls_net_context *client_ctx,
|
||||
void *client_ip, size_t buf_size, size_t *ip_len );
|
||||
|
||||
/**
|
||||
* \brief Set the socket blocking
|
||||
*
|
||||
* \param ctx Socket to set
|
||||
*
|
||||
* \return 0 if successful, or a non-zero error code
|
||||
*/
|
||||
int mbedtls_net_set_block( mbedtls_net_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Set the socket non-blocking
|
||||
*
|
||||
* \param ctx Socket to set
|
||||
*
|
||||
* \return 0 if successful, or a non-zero error code
|
||||
*/
|
||||
int mbedtls_net_set_nonblock( mbedtls_net_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Portable usleep helper
|
||||
*
|
||||
* \param usec Amount of microseconds to sleep
|
||||
*
|
||||
* \note Real amount of time slept will not be less than
|
||||
* select()'s timeout granularity (typically, 10ms).
|
||||
*/
|
||||
void mbedtls_net_usleep( unsigned long usec );
|
||||
|
||||
/**
|
||||
* \brief Read at most 'len' characters. If no error occurs,
|
||||
* the actual amount read is returned.
|
||||
*
|
||||
* \param ctx Socket
|
||||
* \param buf The buffer to write to
|
||||
* \param len Maximum length of the buffer
|
||||
*
|
||||
* \return the number of bytes received,
|
||||
* or a non-zero error code; with a non-blocking socket,
|
||||
* MBEDTLS_ERR_SSL_WANT_READ indicates read() would block.
|
||||
*/
|
||||
int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len );
|
||||
|
||||
/**
|
||||
* \brief Write at most 'len' characters. If no error occurs,
|
||||
* the actual amount read is returned.
|
||||
*
|
||||
* \param ctx Socket
|
||||
* \param buf The buffer to read from
|
||||
* \param len The length of the buffer
|
||||
*
|
||||
* \return the number of bytes sent,
|
||||
* or a non-zero error code; with a non-blocking socket,
|
||||
* MBEDTLS_ERR_SSL_WANT_WRITE indicates write() would block.
|
||||
*/
|
||||
int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len );
|
||||
|
||||
/**
|
||||
* \brief Read at most 'len' characters, blocking for at most
|
||||
* 'timeout' seconds. If no error occurs, the actual amount
|
||||
* read is returned.
|
||||
*
|
||||
* \param ctx Socket
|
||||
* \param buf The buffer to write to
|
||||
* \param len Maximum length of the buffer
|
||||
* \param timeout Maximum number of milliseconds to wait for data
|
||||
* 0 means no timeout (wait forever)
|
||||
*
|
||||
* \return the number of bytes received,
|
||||
* or a non-zero error code:
|
||||
* MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out,
|
||||
* MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal.
|
||||
*
|
||||
* \note This function will block (until data becomes available or
|
||||
* timeout is reached) even if the socket is set to
|
||||
* non-blocking. Handling timeouts with non-blocking reads
|
||||
* requires a different strategy.
|
||||
*/
|
||||
int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
|
||||
uint32_t timeout );
|
||||
|
||||
/**
|
||||
* \brief Gracefully shutdown the connection and free associated data
|
||||
*
|
||||
* \param ctx The context to free
|
||||
*/
|
||||
void mbedtls_net_free( mbedtls_net_context *ctx );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* net.h */
|
||||
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#if defined(MBEDTLS_DEPRECATED_WARNING)
|
||||
#warning "Deprecated header file: Superseded by mbedtls/net_sockets.h"
|
||||
#endif /* MBEDTLS_DEPRECATED_WARNING */
|
||||
#endif /* !MBEDTLS_DEPRECATED_REMOVED */
|
||||
|
225
Externals/mbedtls/include/mbedtls/net_sockets.h
vendored
Normal file
225
Externals/mbedtls/include/mbedtls/net_sockets.h
vendored
Normal file
@ -0,0 +1,225 @@
|
||||
/**
|
||||
* \file net_sockets.h
|
||||
*
|
||||
* \brief Network communication functions
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
#ifndef MBEDTLS_NET_SOCKETS_H
|
||||
#define MBEDTLS_NET_SOCKETS_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "ssl.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042 /**< Failed to open a socket. */
|
||||
#define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044 /**< The connection to the given server / port failed. */
|
||||
#define MBEDTLS_ERR_NET_BIND_FAILED -0x0046 /**< Binding of the socket failed. */
|
||||
#define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048 /**< Could not listen on the socket. */
|
||||
#define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A /**< Could not accept the incoming connection. */
|
||||
#define MBEDTLS_ERR_NET_RECV_FAILED -0x004C /**< Reading information from the socket failed. */
|
||||
#define MBEDTLS_ERR_NET_SEND_FAILED -0x004E /**< Sending information through the socket failed. */
|
||||
#define MBEDTLS_ERR_NET_CONN_RESET -0x0050 /**< Connection was reset by peer. */
|
||||
#define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052 /**< Failed to get an IP address for the given hostname. */
|
||||
#define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043 /**< Buffer is too small to hold the data. */
|
||||
#define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045 /**< The context is invalid, eg because it was free()ed. */
|
||||
|
||||
#define MBEDTLS_NET_LISTEN_BACKLOG 10 /**< The backlog that listen() should use. */
|
||||
|
||||
#define MBEDTLS_NET_PROTO_TCP 0 /**< The TCP transport protocol */
|
||||
#define MBEDTLS_NET_PROTO_UDP 1 /**< The UDP transport protocol */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Wrapper type for sockets.
|
||||
*
|
||||
* Currently backed by just a file descriptor, but might be more in the future
|
||||
* (eg two file descriptors for combined IPv4 + IPv6 support, or additional
|
||||
* structures for hand-made UDP demultiplexing).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int fd; /**< The underlying file descriptor */
|
||||
}
|
||||
mbedtls_net_context;
|
||||
|
||||
/**
|
||||
* \brief Initialize a context
|
||||
* Just makes the context ready to be used or freed safely.
|
||||
*
|
||||
* \param ctx Context to initialize
|
||||
*/
|
||||
void mbedtls_net_init( mbedtls_net_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Initiate a connection with host:port in the given protocol
|
||||
*
|
||||
* \param ctx Socket to use
|
||||
* \param host Host to connect to
|
||||
* \param port Port to connect to
|
||||
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
|
||||
*
|
||||
* \return 0 if successful, or one of:
|
||||
* MBEDTLS_ERR_NET_SOCKET_FAILED,
|
||||
* MBEDTLS_ERR_NET_UNKNOWN_HOST,
|
||||
* MBEDTLS_ERR_NET_CONNECT_FAILED
|
||||
*
|
||||
* \note Sets the socket in connected mode even with UDP.
|
||||
*/
|
||||
int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto );
|
||||
|
||||
/**
|
||||
* \brief Create a receiving socket on bind_ip:port in the chosen
|
||||
* protocol. If bind_ip == NULL, all interfaces are bound.
|
||||
*
|
||||
* \param ctx Socket to use
|
||||
* \param bind_ip IP to bind to, can be NULL
|
||||
* \param port Port number to use
|
||||
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
|
||||
*
|
||||
* \return 0 if successful, or one of:
|
||||
* MBEDTLS_ERR_NET_SOCKET_FAILED,
|
||||
* MBEDTLS_ERR_NET_BIND_FAILED,
|
||||
* MBEDTLS_ERR_NET_LISTEN_FAILED
|
||||
*
|
||||
* \note Regardless of the protocol, opens the sockets and binds it.
|
||||
* In addition, make the socket listening if protocol is TCP.
|
||||
*/
|
||||
int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto );
|
||||
|
||||
/**
|
||||
* \brief Accept a connection from a remote client
|
||||
*
|
||||
* \param bind_ctx Relevant socket
|
||||
* \param client_ctx Will contain the connected client socket
|
||||
* \param client_ip Will contain the client IP address
|
||||
* \param buf_size Size of the client_ip buffer
|
||||
* \param ip_len Will receive the size of the client IP written
|
||||
*
|
||||
* \return 0 if successful, or
|
||||
* MBEDTLS_ERR_NET_ACCEPT_FAILED, or
|
||||
* MBEDTLS_ERR_NET_BUFFER_TOO_SMALL if buf_size is too small,
|
||||
* MBEDTLS_ERR_SSL_WANT_READ if bind_fd was set to
|
||||
* non-blocking and accept() would block.
|
||||
*/
|
||||
int mbedtls_net_accept( mbedtls_net_context *bind_ctx,
|
||||
mbedtls_net_context *client_ctx,
|
||||
void *client_ip, size_t buf_size, size_t *ip_len );
|
||||
|
||||
/**
|
||||
* \brief Set the socket blocking
|
||||
*
|
||||
* \param ctx Socket to set
|
||||
*
|
||||
* \return 0 if successful, or a non-zero error code
|
||||
*/
|
||||
int mbedtls_net_set_block( mbedtls_net_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Set the socket non-blocking
|
||||
*
|
||||
* \param ctx Socket to set
|
||||
*
|
||||
* \return 0 if successful, or a non-zero error code
|
||||
*/
|
||||
int mbedtls_net_set_nonblock( mbedtls_net_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Portable usleep helper
|
||||
*
|
||||
* \param usec Amount of microseconds to sleep
|
||||
*
|
||||
* \note Real amount of time slept will not be less than
|
||||
* select()'s timeout granularity (typically, 10ms).
|
||||
*/
|
||||
void mbedtls_net_usleep( unsigned long usec );
|
||||
|
||||
/**
|
||||
* \brief Read at most 'len' characters. If no error occurs,
|
||||
* the actual amount read is returned.
|
||||
*
|
||||
* \param ctx Socket
|
||||
* \param buf The buffer to write to
|
||||
* \param len Maximum length of the buffer
|
||||
*
|
||||
* \return the number of bytes received,
|
||||
* or a non-zero error code; with a non-blocking socket,
|
||||
* MBEDTLS_ERR_SSL_WANT_READ indicates read() would block.
|
||||
*/
|
||||
int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len );
|
||||
|
||||
/**
|
||||
* \brief Write at most 'len' characters. If no error occurs,
|
||||
* the actual amount read is returned.
|
||||
*
|
||||
* \param ctx Socket
|
||||
* \param buf The buffer to read from
|
||||
* \param len The length of the buffer
|
||||
*
|
||||
* \return the number of bytes sent,
|
||||
* or a non-zero error code; with a non-blocking socket,
|
||||
* MBEDTLS_ERR_SSL_WANT_WRITE indicates write() would block.
|
||||
*/
|
||||
int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len );
|
||||
|
||||
/**
|
||||
* \brief Read at most 'len' characters, blocking for at most
|
||||
* 'timeout' seconds. If no error occurs, the actual amount
|
||||
* read is returned.
|
||||
*
|
||||
* \param ctx Socket
|
||||
* \param buf The buffer to write to
|
||||
* \param len Maximum length of the buffer
|
||||
* \param timeout Maximum number of milliseconds to wait for data
|
||||
* 0 means no timeout (wait forever)
|
||||
*
|
||||
* \return the number of bytes received,
|
||||
* or a non-zero error code:
|
||||
* MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out,
|
||||
* MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal.
|
||||
*
|
||||
* \note This function will block (until data becomes available or
|
||||
* timeout is reached) even if the socket is set to
|
||||
* non-blocking. Handling timeouts with non-blocking reads
|
||||
* requires a different strategy.
|
||||
*/
|
||||
int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
|
||||
uint32_t timeout );
|
||||
|
||||
/**
|
||||
* \brief Gracefully shutdown the connection and free associated data
|
||||
*
|
||||
* \param ctx The context to free
|
||||
*/
|
||||
void mbedtls_net_free( mbedtls_net_context *ctx );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* net_sockets.h */
|
17
Externals/mbedtls/include/mbedtls/pk.h
vendored
17
Externals/mbedtls/include/mbedtls/pk.h
vendored
@ -44,6 +44,11 @@
|
||||
#include "ecdsa.h"
|
||||
#endif
|
||||
|
||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
|
||||
!defined(inline) && !defined(__cplusplus)
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#define MBEDTLS_ERR_PK_ALLOC_FAILED -0x3F80 /**< Memory allocation failed. */
|
||||
#define MBEDTLS_ERR_PK_TYPE_MISMATCH -0x3F00 /**< Type mismatch, eg attempt to encrypt with an ECDSA key */
|
||||
#define MBEDTLS_ERR_PK_BAD_INPUT_DATA -0x3E80 /**< Bad input parameters to function. */
|
||||
@ -59,7 +64,6 @@
|
||||
#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980 /**< Unavailable feature, e.g. RSA disabled for RSA key. */
|
||||
#define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900 /**< The signature is valid but its length is less than expected. */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -317,7 +321,7 @@ int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options,
|
||||
/**
|
||||
* \brief Make signature, including padding if relevant.
|
||||
*
|
||||
* \param ctx PK context to use
|
||||
* \param ctx PK context to use - must hold a private key
|
||||
* \param md_alg Hash algorithm used (see notes)
|
||||
* \param hash Hash of the message to sign
|
||||
* \param hash_len Hash length or 0 (see notes)
|
||||
@ -346,7 +350,7 @@ int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
|
||||
/**
|
||||
* \brief Decrypt message (including padding if relevant).
|
||||
*
|
||||
* \param ctx PK context to use
|
||||
* \param ctx PK context to use - must hold a private key
|
||||
* \param input Input to decrypt
|
||||
* \param ilen Input size
|
||||
* \param output Decrypted output
|
||||
@ -492,11 +496,12 @@ int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx,
|
||||
* \brief Load and parse a public key
|
||||
*
|
||||
* \param ctx key to be initialized
|
||||
* \param path filename to read the private key from
|
||||
* \param path filename to read the public key from
|
||||
*
|
||||
* \note On entry, ctx must be empty, either freshly initialised
|
||||
* with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a
|
||||
* specific key type, check the result with mbedtls_pk_can_do().
|
||||
* with mbedtls_pk_init() or reset with mbedtls_pk_free(). If
|
||||
* you need a specific key type, check the result with
|
||||
* mbedtls_pk_can_do().
|
||||
*
|
||||
* \note The key is also checked for correctness.
|
||||
*
|
||||
|
5
Externals/mbedtls/include/mbedtls/pkcs11.h
vendored
5
Externals/mbedtls/include/mbedtls/pkcs11.h
vendored
@ -37,7 +37,8 @@
|
||||
|
||||
#include <pkcs11-helper-1.0/pkcs11h-certificate.h>
|
||||
|
||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && !defined(inline)
|
||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
|
||||
!defined(inline) && !defined(__cplusplus)
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
@ -54,7 +55,7 @@ typedef struct {
|
||||
} mbedtls_pkcs11_context;
|
||||
|
||||
/**
|
||||
* Initialize a mbetls_pkcs11_context.
|
||||
* Initialize a mbedtls_pkcs11_context.
|
||||
* (Just making memory references valid.)
|
||||
*/
|
||||
void mbedtls_pkcs11_init( mbedtls_pkcs11_context *ctx );
|
||||
|
85
Externals/mbedtls/include/mbedtls/platform.h
vendored
85
Externals/mbedtls/include/mbedtls/platform.h
vendored
@ -3,7 +3,7 @@
|
||||
*
|
||||
* \brief mbed TLS Platform abstraction layer
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -29,6 +29,10 @@
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
#include "mbedtls/platform_time.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -44,6 +48,7 @@ extern "C" {
|
||||
#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF)
|
||||
#if defined(_WIN32)
|
||||
#define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf /**< Default snprintf to use */
|
||||
@ -64,14 +69,35 @@ extern "C" {
|
||||
#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use */
|
||||
#endif
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_EXIT)
|
||||
#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default free to use */
|
||||
#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use */
|
||||
#endif
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_TIME)
|
||||
#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use */
|
||||
#endif
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS)
|
||||
#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS /**< Default exit value to use */
|
||||
#endif
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE)
|
||||
#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE /**< Default exit value to use */
|
||||
#endif
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ)
|
||||
#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read
|
||||
#endif
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE)
|
||||
#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write
|
||||
#endif
|
||||
#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_FILE)
|
||||
#define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile"
|
||||
#endif
|
||||
#endif /* MBEDTLS_FS_IO */
|
||||
#else /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */
|
||||
#if defined(MBEDTLS_PLATFORM_STD_MEM_HDR)
|
||||
#include MBEDTLS_PLATFORM_STD_MEM_HDR
|
||||
#endif
|
||||
#endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */
|
||||
|
||||
|
||||
/* \} name SECTION: Module settings */
|
||||
|
||||
/*
|
||||
@ -207,6 +233,61 @@ int mbedtls_platform_set_exit( void (*exit_func)( int status ) );
|
||||
#endif /* MBEDTLS_PLATFORM_EXIT_MACRO */
|
||||
#endif /* MBEDTLS_PLATFORM_EXIT_ALT */
|
||||
|
||||
/*
|
||||
* The default exit values
|
||||
*/
|
||||
#if defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS)
|
||||
#define MBEDTLS_EXIT_SUCCESS MBEDTLS_PLATFORM_STD_EXIT_SUCCESS
|
||||
#else
|
||||
#define MBEDTLS_EXIT_SUCCESS 0
|
||||
#endif
|
||||
#if defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE)
|
||||
#define MBEDTLS_EXIT_FAILURE MBEDTLS_PLATFORM_STD_EXIT_FAILURE
|
||||
#else
|
||||
#define MBEDTLS_EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The function pointers for reading from and writing a seed file to
|
||||
* Non-Volatile storage (NV) in a platform-independent way
|
||||
*
|
||||
* Only enabled when the NV seed entropy source is enabled
|
||||
*/
|
||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||
#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO)
|
||||
/* Internal standard platform definitions */
|
||||
int mbedtls_platform_std_nv_seed_read( unsigned char *buf, size_t buf_len );
|
||||
int mbedtls_platform_std_nv_seed_write( unsigned char *buf, size_t buf_len );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
|
||||
extern int (*mbedtls_nv_seed_read)( unsigned char *buf, size_t buf_len );
|
||||
extern int (*mbedtls_nv_seed_write)( unsigned char *buf, size_t buf_len );
|
||||
|
||||
/**
|
||||
* \brief Set your own seed file writing/reading functions
|
||||
*
|
||||
* \param nv_seed_read_func the seed reading function implementation
|
||||
* \param nv_seed_write_func the seed writing function implementation
|
||||
*
|
||||
* \return 0
|
||||
*/
|
||||
int mbedtls_platform_set_nv_seed(
|
||||
int (*nv_seed_read_func)( unsigned char *buf, size_t buf_len ),
|
||||
int (*nv_seed_write_func)( unsigned char *buf, size_t buf_len )
|
||||
);
|
||||
#else
|
||||
#if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) && \
|
||||
defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO)
|
||||
#define mbedtls_nv_seed_read MBEDTLS_PLATFORM_NV_SEED_READ_MACRO
|
||||
#define mbedtls_nv_seed_write MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO
|
||||
#else
|
||||
#define mbedtls_nv_seed_read mbedtls_platform_std_nv_seed_read
|
||||
#define mbedtls_nv_seed_write mbedtls_platform_std_nv_seed_write
|
||||
#endif
|
||||
#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */
|
||||
#endif /* MBEDTLS_ENTROPY_NV_SEED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
81
Externals/mbedtls/include/mbedtls/platform_time.h
vendored
Normal file
81
Externals/mbedtls/include/mbedtls/platform_time.h
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/**
|
||||
* \file platform_time.h
|
||||
*
|
||||
* \brief mbed TLS Platform time abstraction
|
||||
*
|
||||
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
#ifndef MBEDTLS_PLATFORM_TIME_H
|
||||
#define MBEDTLS_PLATFORM_TIME_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name SECTION: Module settings
|
||||
*
|
||||
* The configuration options you can set for this module are in this section.
|
||||
* Either change them in config.h or define them on the compiler command line.
|
||||
* \{
|
||||
*/
|
||||
|
||||
/*
|
||||
* The time_t datatype
|
||||
*/
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO)
|
||||
typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t;
|
||||
#else
|
||||
/* For time_t */
|
||||
#include <time.h>
|
||||
typedef time_t mbedtls_time_t;
|
||||
#endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */
|
||||
|
||||
/*
|
||||
* The function pointers for time
|
||||
*/
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
|
||||
extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time );
|
||||
|
||||
/**
|
||||
* \brief Set your own time function pointer
|
||||
*
|
||||
* \param time_func the time function implementation
|
||||
*
|
||||
* \return 0
|
||||
*/
|
||||
int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) );
|
||||
#else
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_MACRO)
|
||||
#define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO
|
||||
#else
|
||||
#define mbedtls_time time
|
||||
#endif /* MBEDTLS_PLATFORM_TIME_MACRO */
|
||||
#endif /* MBEDTLS_PLATFORM_TIME_ALT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* platform_time.h */
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file mbedtls_ripemd160.h
|
||||
* \file ripemd160.h
|
||||
*
|
||||
* \brief RIPE MD-160 message digest
|
||||
*
|
||||
|
2
Externals/mbedtls/include/mbedtls/rsa.h
vendored
2
Externals/mbedtls/include/mbedtls/rsa.h
vendored
@ -99,7 +99,7 @@ typedef struct
|
||||
mbedtls_mpi Vf; /*!< cached un-blinding value */
|
||||
|
||||
int padding; /*!< MBEDTLS_RSA_PKCS_V15 for 1.5 padding and
|
||||
RSA_PKCS_v21 for OAEP/PSS */
|
||||
MBEDTLS_RSA_PKCS_v21 for OAEP/PSS */
|
||||
int hash_id; /*!< Hash identifier of mbedtls_md_type_t as
|
||||
specified in the mbedtls_md.h header file
|
||||
for the EME-OAEP and EMSA-PSS
|
||||
|
2
Externals/mbedtls/include/mbedtls/sha1.h
vendored
2
Externals/mbedtls/include/mbedtls/sha1.h
vendored
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file mbedtls_sha1.h
|
||||
* \file sha1.h
|
||||
*
|
||||
* \brief SHA-1 cryptographic hash function
|
||||
*
|
||||
|
2
Externals/mbedtls/include/mbedtls/sha256.h
vendored
2
Externals/mbedtls/include/mbedtls/sha256.h
vendored
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file mbedtls_sha256.h
|
||||
* \file sha256.h
|
||||
*
|
||||
* \brief SHA-224 and SHA-256 cryptographic hash function
|
||||
*
|
||||
|
2
Externals/mbedtls/include/mbedtls/sha512.h
vendored
2
Externals/mbedtls/include/mbedtls/sha512.h
vendored
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file mbedtls_sha512.h
|
||||
* \file sha512.h
|
||||
*
|
||||
* \brief SHA-384 and SHA-512 cryptographic hash function
|
||||
*
|
||||
|
436
Externals/mbedtls/include/mbedtls/ssl.h
vendored
436
Externals/mbedtls/include/mbedtls/ssl.h
vendored
@ -52,27 +52,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
/* For convenience below and in programs */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
|
||||
#define MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
|
||||
#define MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||
#define MBEDTLS_KEY_EXCHANGE__SOME__SIGNATURE_ENABLED
|
||||
#include "mbedtls/platform_time.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -126,6 +106,9 @@
|
||||
#define MBEDTLS_ERR_SSL_WANT_WRITE -0x6880 /**< Connection requires a write call. */
|
||||
#define MBEDTLS_ERR_SSL_TIMEOUT -0x6800 /**< The operation timed out. */
|
||||
#define MBEDTLS_ERR_SSL_CLIENT_RECONNECT -0x6780 /**< The client initiated a reconnect from the same port. */
|
||||
#define MBEDTLS_ERR_SSL_UNEXPECTED_RECORD -0x6700 /**< Record header looks valid but is not expected. */
|
||||
#define MBEDTLS_ERR_SSL_NON_FATAL -0x6680 /**< The alert message received indicates a non-fatal error. */
|
||||
#define MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH -0x6600 /**< Couldn't set the hash for verifying CertificateVerify */
|
||||
|
||||
/*
|
||||
* Various constants
|
||||
@ -139,6 +122,8 @@
|
||||
#define MBEDTLS_SSL_TRANSPORT_STREAM 0 /*!< TLS */
|
||||
#define MBEDTLS_SSL_TRANSPORT_DATAGRAM 1 /*!< DTLS */
|
||||
|
||||
#define MBEDTLS_SSL_MAX_HOST_NAME_LEN 255 /*!< Maximum host name defined in RFC 1035 */
|
||||
|
||||
/* RFC 6066 section 4, see also mfl_code_to_length in ssl_tls.c
|
||||
* NONE must be zero so that memset()ing structure to zero works */
|
||||
#define MBEDTLS_SSL_MAX_FRAG_LEN_NONE 0 /*!< don't use this extension */
|
||||
@ -249,7 +234,7 @@
|
||||
* Signaling ciphersuite values (SCSV)
|
||||
*/
|
||||
#define MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO 0xFF /**< renegotiation info ext */
|
||||
#define MBEDTLS_SSL_FALLBACK_SCSV_VALUE 0x5600 /**< draft-ietf-tls-downgrade-scsv-00 */
|
||||
#define MBEDTLS_SSL_FALLBACK_SCSV_VALUE 0x5600 /**< RFC 7507 section 2 */
|
||||
|
||||
/*
|
||||
* Supported Signature and Hash algorithms (For TLS 1.2)
|
||||
@ -350,6 +335,8 @@
|
||||
|
||||
#define MBEDTLS_TLS_EXT_SESSION_TICKET 35
|
||||
|
||||
#define MBEDTLS_TLS_EXT_ECJPAKE_KKPP 256 /* experimental */
|
||||
|
||||
#define MBEDTLS_TLS_EXT_RENEGOTIATION_INFO 0xFF01
|
||||
|
||||
/*
|
||||
@ -388,6 +375,9 @@ union mbedtls_ssl_premaster_secret
|
||||
unsigned char _pms_ecdhe_psk[4 + MBEDTLS_ECP_MAX_BYTES
|
||||
+ MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */
|
||||
#endif
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
unsigned char _pms_ecjpake[32]; /* Thread spec: SHA-256 output */
|
||||
#endif
|
||||
};
|
||||
|
||||
#define MBEDTLS_PREMASTER_SIZE sizeof( union mbedtls_ssl_premaster_secret )
|
||||
@ -423,6 +413,116 @@ typedef enum
|
||||
}
|
||||
mbedtls_ssl_states;
|
||||
|
||||
/**
|
||||
* \brief Callback type: send data on the network.
|
||||
*
|
||||
* \note That callback may be either blocking or non-blocking.
|
||||
*
|
||||
* \param ctx Context for the send callback (typically a file descriptor)
|
||||
* \param buf Buffer holding the data to send
|
||||
* \param len Length of the data to send
|
||||
*
|
||||
* \return The callback must return the number of bytes sent if any,
|
||||
* or a non-zero error code.
|
||||
* If performing non-blocking I/O, \c MBEDTLS_ERR_SSL_WANT_WRITE
|
||||
* must be returned when the operation would block.
|
||||
*
|
||||
* \note The callback is allowed to send fewer bytes than requested.
|
||||
* It must always return the number of bytes actually sent.
|
||||
*/
|
||||
typedef int mbedtls_ssl_send_t( void *ctx,
|
||||
const unsigned char *buf,
|
||||
size_t len );
|
||||
|
||||
/**
|
||||
* \brief Callback type: receive data from the network.
|
||||
*
|
||||
* \note That callback may be either blocking or non-blocking.
|
||||
*
|
||||
* \param ctx Context for the receive callback (typically a file
|
||||
* descriptor)
|
||||
* \param buf Buffer to write the received data to
|
||||
* \param len Length of the receive buffer
|
||||
*
|
||||
* \return The callback must return the number of bytes received,
|
||||
* or a non-zero error code.
|
||||
* If performing non-blocking I/O, \c MBEDTLS_ERR_SSL_WANT_READ
|
||||
* must be returned when the operation would block.
|
||||
*
|
||||
* \note The callback may receive fewer bytes than the length of the
|
||||
* buffer. It must always return the number of bytes actually
|
||||
* received and written to the buffer.
|
||||
*/
|
||||
typedef int mbedtls_ssl_recv_t( void *ctx,
|
||||
unsigned char *buf,
|
||||
size_t len );
|
||||
|
||||
/**
|
||||
* \brief Callback type: receive data from the network, with timeout
|
||||
*
|
||||
* \note That callback must block until data is received, or the
|
||||
* timeout delay expires, or the operation is interrupted by a
|
||||
* signal.
|
||||
*
|
||||
* \param ctx Context for the receive callback (typically a file descriptor)
|
||||
* \param buf Buffer to write the received data to
|
||||
* \param len Length of the receive buffer
|
||||
* \param timeout Maximum nomber of millisecondes to wait for data
|
||||
* 0 means no timeout (potentially waiting forever)
|
||||
*
|
||||
* \return The callback must return the number of bytes received,
|
||||
* or a non-zero error code:
|
||||
* \c MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out,
|
||||
* \c MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal.
|
||||
*
|
||||
* \note The callback may receive fewer bytes than the length of the
|
||||
* buffer. It must always return the number of bytes actually
|
||||
* received and written to the buffer.
|
||||
*/
|
||||
typedef int mbedtls_ssl_recv_timeout_t( void *ctx,
|
||||
unsigned char *buf,
|
||||
size_t len,
|
||||
uint32_t timeout );
|
||||
/**
|
||||
* \brief Callback type: set a pair of timers/delays to watch
|
||||
*
|
||||
* \param ctx Context pointer
|
||||
* \param int_ms Intermediate delay in milliseconds
|
||||
* \param fin_ms Final delay in milliseconds
|
||||
* 0 cancels the current timer.
|
||||
*
|
||||
* \note This callback must at least store the necessary information
|
||||
* for the associated \c mbedtls_ssl_get_timer_t callback to
|
||||
* return correct information.
|
||||
*
|
||||
* \note If using a event-driven style of programming, an event must
|
||||
* be generated when the final delay is passed. The event must
|
||||
* cause a call to \c mbedtls_ssl_handshake() with the proper
|
||||
* SSL context to be scheduled. Care must be taken to ensure
|
||||
* that at most one such call happens at a time.
|
||||
*
|
||||
* \note Only one timer at a time must be running. Calling this
|
||||
* function while a timer is running must cancel it. Cancelled
|
||||
* timers must not generate any event.
|
||||
*/
|
||||
typedef void mbedtls_ssl_set_timer_t( void * ctx,
|
||||
uint32_t int_ms,
|
||||
uint32_t fin_ms );
|
||||
|
||||
/**
|
||||
* \brief Callback type: get status of timers/delays
|
||||
*
|
||||
* \param ctx Context pointer
|
||||
*
|
||||
* \return This callback must return:
|
||||
* -1 if cancelled (fin_ms == 0),
|
||||
* 0 if none of the delays have passed,
|
||||
* 1 if only the intermediate delay has passed,
|
||||
* 2 if the final delay has passed.
|
||||
*/
|
||||
typedef int mbedtls_ssl_get_timer_t( void * ctx );
|
||||
|
||||
|
||||
/* Defined below */
|
||||
typedef struct mbedtls_ssl_session mbedtls_ssl_session;
|
||||
typedef struct mbedtls_ssl_context mbedtls_ssl_context;
|
||||
@ -444,7 +544,7 @@ typedef struct mbedtls_ssl_flight_item mbedtls_ssl_flight_item;
|
||||
struct mbedtls_ssl_session
|
||||
{
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
time_t start; /*!< starting time */
|
||||
mbedtls_time_t start; /*!< starting time */
|
||||
#endif
|
||||
int ciphersuite; /*!< chosen ciphersuite */
|
||||
int compression; /*!< chosen compression */
|
||||
@ -540,6 +640,13 @@ struct mbedtls_ssl_config
|
||||
void *p_ticket; /*!< context for the ticket callbacks */
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_EXPORT_KEYS)
|
||||
/** Callback to export key block and master secret */
|
||||
int (*f_export_keys)( void *, const unsigned char *,
|
||||
const unsigned char *, size_t, size_t, size_t );
|
||||
void *p_export_keys; /*!< context for key export callback */
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
const mbedtls_x509_crt_profile *cert_profile; /*!< verification profile */
|
||||
mbedtls_ssl_key_cert *key_cert; /*!< own certificate/key pair(s) */
|
||||
@ -547,7 +654,7 @@ struct mbedtls_ssl_config
|
||||
mbedtls_x509_crl *ca_crl; /*!< trusted CAs CRLs */
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__SIGNATURE_ENABLED)
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
|
||||
const int *sig_hashes; /*!< allowed signature hashes */
|
||||
#endif
|
||||
|
||||
@ -667,12 +774,11 @@ struct mbedtls_ssl_context
|
||||
unsigned badmac_seen; /*!< records with a bad MAC received */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Callbacks
|
||||
*/
|
||||
int (*f_send)(void *, const unsigned char *, size_t);
|
||||
int (*f_recv)(void *, unsigned char *, size_t);
|
||||
int (*f_recv_timeout)(void *, unsigned char *, size_t, uint32_t);
|
||||
mbedtls_ssl_send_t *f_send; /*!< Callback for network send */
|
||||
mbedtls_ssl_recv_t *f_recv; /*!< Callback for network receive */
|
||||
mbedtls_ssl_recv_timeout_t *f_recv_timeout;
|
||||
/*!< Callback for network receive with timeout */
|
||||
|
||||
void *p_bio; /*!< context for I/O operations */
|
||||
|
||||
/*
|
||||
@ -698,8 +804,9 @@ struct mbedtls_ssl_context
|
||||
* Timers
|
||||
*/
|
||||
void *p_timer; /*!< context for the timer callbacks */
|
||||
void (*f_set_timer)(void *, uint32_t, uint32_t); /*!< set timer callback */
|
||||
int (*f_get_timer)(void *); /*!< get timer callback */
|
||||
|
||||
mbedtls_ssl_set_timer_t *f_set_timer; /*!< set timer callback */
|
||||
mbedtls_ssl_get_timer_t *f_get_timer; /*!< get timer callback */
|
||||
|
||||
/*
|
||||
* Record layer (incoming data)
|
||||
@ -840,7 +947,7 @@ int mbedtls_ssl_get_ciphersuite_id( const char *ciphersuite_name );
|
||||
|
||||
/**
|
||||
* \brief Initialize an SSL context
|
||||
* Just makes the context ready for mbetls_ssl_setup() or
|
||||
* Just makes the context ready for mbedtls_ssl_setup() or
|
||||
* mbedtls_ssl_free()
|
||||
*
|
||||
* \param ssl SSL context
|
||||
@ -853,7 +960,7 @@ void mbedtls_ssl_init( mbedtls_ssl_context *ssl );
|
||||
* \note No copy of the configuration context is made, it can be
|
||||
* shared by many mbedtls_ssl_context structures.
|
||||
*
|
||||
* \warning Modifying the conf structure after is has been used in this
|
||||
* \warning Modifying the conf structure after it has been used in this
|
||||
* function is unsupported!
|
||||
*
|
||||
* \param ssl SSL context
|
||||
@ -871,7 +978,7 @@ int mbedtls_ssl_setup( mbedtls_ssl_context *ssl,
|
||||
* pointers and data.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \return 0 if successful, or POLASSL_ERR_SSL_MALLOC_FAILED,
|
||||
* \return 0 if successful, or MBEDTLS_ERR_SSL_ALLOC_FAILED,
|
||||
MBEDTLS_ERR_SSL_HW_ACCEL_FAILED or
|
||||
* MBEDTLS_ERR_SSL_COMPRESSION_FAILED
|
||||
*/
|
||||
@ -919,6 +1026,7 @@ void mbedtls_ssl_conf_transport( mbedtls_ssl_config *conf, int transport );
|
||||
*
|
||||
* MBEDTLS_SSL_VERIFY_REQUIRED: peer *must* present a valid certificate,
|
||||
* handshake is aborted if verification failed.
|
||||
* (default on client)
|
||||
*
|
||||
* \note On client, MBEDTLS_SSL_VERIFY_REQUIRED is the recommended mode.
|
||||
* With MBEDTLS_SSL_VERIFY_OPTIONAL, the user needs to call mbedtls_ssl_get_verify_result() at
|
||||
@ -983,8 +1091,6 @@ void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf,
|
||||
* \param f_send write callback
|
||||
* \param f_recv read callback
|
||||
* \param f_recv_timeout blocking read callback with timeout.
|
||||
* The last argument is the timeout in milliseconds,
|
||||
* 0 means no timeout (block forever until a message comes)
|
||||
*
|
||||
* \note One of f_recv or f_recv_timeout can be NULL, in which case
|
||||
* the other is used. If both are non-NULL, f_recv_timeout is
|
||||
@ -996,12 +1102,21 @@ void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf,
|
||||
*
|
||||
* \note For DTLS, you need to provide either a non-NULL
|
||||
* f_recv_timeout callback, or a f_recv that doesn't block.
|
||||
*
|
||||
* \note See the documentations of \c mbedtls_ssl_sent_t,
|
||||
* \c mbedtls_ssl_recv_t and \c mbedtls_ssl_recv_timeout_t for
|
||||
* the conventions those callbacks must follow.
|
||||
*
|
||||
* \note On some platforms, net_sockets.c provides
|
||||
* \c mbedtls_net_send(), \c mbedtls_net_recv() and
|
||||
* \c mbedtls_net_recv_timeout() that are suitable to be used
|
||||
* here.
|
||||
*/
|
||||
void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl,
|
||||
void *p_bio,
|
||||
int (*f_send)(void *, const unsigned char *, size_t),
|
||||
int (*f_recv)(void *, unsigned char *, size_t),
|
||||
int (*f_recv_timeout)(void *, unsigned char *, size_t, uint32_t) );
|
||||
void *p_bio,
|
||||
mbedtls_ssl_send_t *f_send,
|
||||
mbedtls_ssl_recv_t *f_recv,
|
||||
mbedtls_ssl_recv_timeout_t *f_recv_timeout );
|
||||
|
||||
/**
|
||||
* \brief Set the timeout period for mbedtls_ssl_read()
|
||||
@ -1022,37 +1137,42 @@ void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl,
|
||||
void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout );
|
||||
|
||||
/**
|
||||
* \brief Set the timer callbacks
|
||||
* (Mandatory for DTLS.)
|
||||
* \brief Set the timer callbacks (Mandatory for DTLS.)
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param p_timer parameter (context) shared by timer callback
|
||||
* \param p_timer parameter (context) shared by timer callbacks
|
||||
* \param f_set_timer set timer callback
|
||||
* Accepts an intermediate and a final delay in milliseconcs
|
||||
* If the final delay is 0, cancels the running timer.
|
||||
* \param f_get_timer get timer callback. Must return:
|
||||
* -1 if cancelled
|
||||
* 0 if none of the delays is expired
|
||||
* 1 if the intermediate delay only is expired
|
||||
* 2 if the final delay is expired
|
||||
*
|
||||
* \note See the documentation of \c mbedtls_ssl_set_timer_t and
|
||||
* \c mbedtls_ssl_get_timer_t for the conventions this pair of
|
||||
* callbacks must fallow.
|
||||
*
|
||||
* \note On some platforms, timing.c provides
|
||||
* \c mbedtls_timing_set_delay() and
|
||||
* \c mbedtls_timing_get_delay() that are suitable for using
|
||||
* here, except if using an event-driven style.
|
||||
*
|
||||
* \note See also the "DTLS tutorial" article in our knowledge base.
|
||||
* https://tls.mbed.org/kb/how-to/dtls-tutorial
|
||||
*/
|
||||
void mbedtls_ssl_set_timer_cb( mbedtls_ssl_context *ssl,
|
||||
void *p_timer,
|
||||
void (*f_set_timer)(void *, uint32_t int_ms, uint32_t fin_ms),
|
||||
int (*f_get_timer)(void *) );
|
||||
mbedtls_ssl_set_timer_t *f_set_timer,
|
||||
mbedtls_ssl_get_timer_t *f_get_timer );
|
||||
|
||||
/**
|
||||
* \brief Callback type: generate and write session ticket
|
||||
*
|
||||
* \note This describes what a callback implementation should do.
|
||||
* This callback should generate and encrypted and
|
||||
* This callback should generate an encrypted and
|
||||
* authenticated ticket for the session and write it to the
|
||||
* output buffer. Here, ticket means the opaque ticket part
|
||||
* of the NewSessionTicket structure of RFC 5077.
|
||||
*
|
||||
* \param p_ticket Context for the callback
|
||||
* \param session SSL session to bo written in the ticket
|
||||
* \param start Start of the outpur buffer
|
||||
* \param session SSL session to be written in the ticket
|
||||
* \param start Start of the output buffer
|
||||
* \param end End of the output buffer
|
||||
* \param tlen On exit, holds the length written
|
||||
* \param lifetime On exit, holds the lifetime of the ticket in seconds
|
||||
@ -1067,6 +1187,35 @@ typedef int mbedtls_ssl_ticket_write_t( void *p_ticket,
|
||||
size_t *tlen,
|
||||
uint32_t *lifetime );
|
||||
|
||||
#if defined(MBEDTLS_SSL_EXPORT_KEYS)
|
||||
/**
|
||||
* \brief Callback type: Export key block and master secret
|
||||
*
|
||||
* \note This is required for certain uses of TLS, e.g. EAP-TLS
|
||||
* (RFC 5216) and Thread. The key pointers are ephemeral and
|
||||
* therefore must not be stored. The master secret and keys
|
||||
* should not be used directly except as an input to a key
|
||||
* derivation function.
|
||||
*
|
||||
* \param p_expkey Context for the callback
|
||||
* \param ms Pointer to master secret (fixed length: 48 bytes)
|
||||
* \param kb Pointer to key block, see RFC 5246 section 6.3
|
||||
* (variable length: 2 * maclen + 2 * keylen + 2 * ivlen).
|
||||
* \param maclen MAC length
|
||||
* \param keylen Key length
|
||||
* \param ivlen IV length
|
||||
*
|
||||
* \return 0 if successful, or
|
||||
* a specific MBEDTLS_ERR_XXX code.
|
||||
*/
|
||||
typedef int mbedtls_ssl_export_keys_t( void *p_expkey,
|
||||
const unsigned char *ms,
|
||||
const unsigned char *kb,
|
||||
size_t maclen,
|
||||
size_t keylen,
|
||||
size_t ivlen );
|
||||
#endif /* MBEDTLS_SSL_EXPORT_KEYS */
|
||||
|
||||
/**
|
||||
* \brief Callback type: parse and load session ticket
|
||||
*
|
||||
@ -1116,6 +1265,22 @@ void mbedtls_ssl_conf_session_tickets_cb( mbedtls_ssl_config *conf,
|
||||
void *p_ticket );
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_SSL_SRV_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_EXPORT_KEYS)
|
||||
/**
|
||||
* \brief Configure key export callback.
|
||||
* (Default: none.)
|
||||
*
|
||||
* \note See \c mbedtls_ssl_export_keys_t.
|
||||
*
|
||||
* \param conf SSL configuration context
|
||||
* \param f_export_keys Callback for exporting keys
|
||||
* \param p_export_keys Context for the callback
|
||||
*/
|
||||
void mbedtls_ssl_conf_export_keys_cb( mbedtls_ssl_config *conf,
|
||||
mbedtls_ssl_export_keys_t *f_export_keys,
|
||||
void *p_export_keys );
|
||||
#endif /* MBEDTLS_SSL_EXPORT_KEYS */
|
||||
|
||||
/**
|
||||
* \brief Callback type: generate a cookie
|
||||
*
|
||||
@ -1258,7 +1423,7 @@ void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limi
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
/**
|
||||
* \brief Set retransmit timeout values for the DTLS handshale.
|
||||
* \brief Set retransmit timeout values for the DTLS handshake.
|
||||
* (DTLS only, no effect on TLS.)
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
@ -1269,9 +1434,24 @@ void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limi
|
||||
*
|
||||
* \note Default values are from RFC 6347 section 4.2.4.1.
|
||||
*
|
||||
* \note Higher values for initial timeout may increase average
|
||||
* handshake latency. Lower values may increase the risk of
|
||||
* network congestion by causing more retransmissions.
|
||||
* \note The 'min' value should typically be slightly above the
|
||||
* expected round-trip time to your peer, plus whatever time
|
||||
* it takes for the peer to process the message. For example,
|
||||
* if your RTT is about 600ms and you peer needs up to 1s to
|
||||
* do the cryptographic operations in the handshake, then you
|
||||
* should set 'min' slightly above 1600. Lower values of 'min'
|
||||
* might cause spurious resends which waste network resources,
|
||||
* while larger value of 'min' will increase overall latency
|
||||
* on unreliable network links.
|
||||
*
|
||||
* \note The more unreliable your network connection is, the larger
|
||||
* your max / min ratio needs to be in order to achieve
|
||||
* reliable handshakes.
|
||||
*
|
||||
* \note Messages are retransmitted up to log2(ceil(max/min)) times.
|
||||
* For example, if min = 1s and max = 5s, the retransmit plan
|
||||
* goes: send ... 1s -> resend ... 2s -> resend ... 4s ->
|
||||
* resend ... 5s -> give up and return a timeout error.
|
||||
*/
|
||||
void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *conf, uint32_t min, uint32_t max );
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
@ -1341,7 +1521,7 @@ int mbedtls_ssl_set_session( mbedtls_ssl_context *ssl, const mbedtls_ssl_session
|
||||
/**
|
||||
* \brief Set the list of allowed ciphersuites and the preference
|
||||
* order. First in the list has the highest preference.
|
||||
* (Overrides all version specific lists)
|
||||
* (Overrides all version-specific lists)
|
||||
*
|
||||
* The ciphersuites array is not copied, and must remain
|
||||
* valid for the lifetime of the ssl_config.
|
||||
@ -1383,6 +1563,10 @@ void mbedtls_ssl_conf_ciphersuites_for_version( mbedtls_ssl_config *conf,
|
||||
/**
|
||||
* \brief Set the X.509 security profile used for verification
|
||||
*
|
||||
* \note The restrictions are enforced for all certificates in the
|
||||
* chain. However, signatures in the handshake are not covered
|
||||
* by this setting but by \b mbedtls_ssl_conf_sig_hashes().
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param profile Profile to use
|
||||
*/
|
||||
@ -1415,7 +1599,12 @@ void mbedtls_ssl_conf_ca_chain( mbedtls_ssl_config *conf,
|
||||
* adequate, preference is given to the one set by the first
|
||||
* call to this function, then second, etc.
|
||||
*
|
||||
* \note On client, only the first call has any effect.
|
||||
* \note On client, only the first call has any effect. That is,
|
||||
* only one client certificate can be provisioned. The
|
||||
* server's preferences in its CertficateRequest message will
|
||||
* be ignored and our only cert will be sent regardless of
|
||||
* whether it matches those preferences - the server can then
|
||||
* decide what it wants to do with it.
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param own_cert own public certificate chain
|
||||
@ -1435,6 +1624,12 @@ int mbedtls_ssl_conf_own_cert( mbedtls_ssl_config *conf,
|
||||
* \note This is mainly useful for clients. Servers will usually
|
||||
* want to use \c mbedtls_ssl_conf_psk_cb() instead.
|
||||
*
|
||||
* \note Currently clients can only register one pre-shared key.
|
||||
* In other words, the servers' identity hint is ignored.
|
||||
* Support for setting multiple PSKs on clients and selecting
|
||||
* one based on the identity hint is not a planned feature but
|
||||
* feedback is welcomed.
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param psk pointer to the pre-shared key
|
||||
* \param psk_len pre-shared key length
|
||||
@ -1544,16 +1739,14 @@ void mbedtls_ssl_conf_dhm_min_bitlen( mbedtls_ssl_config *conf,
|
||||
* On client: this affects the list of curves offered for any
|
||||
* use. The server can override our preference order.
|
||||
*
|
||||
* Both sides: limits the set of curves used by peer to the
|
||||
* listed curves for any use ECDHE and the end-entity
|
||||
* certificate.
|
||||
* Both sides: limits the set of curves accepted for use in
|
||||
* ECDHE and in the peer's end-entity certificate.
|
||||
*
|
||||
* \note This has no influence on which curve are allowed inside the
|
||||
* \note This has no influence on which curves are allowed inside the
|
||||
* certificate chains, see \c mbedtls_ssl_conf_cert_profile()
|
||||
* for that. For example, if the peer's certificate chain is
|
||||
* EE -> CA_int -> CA_root, then the allowed curves for EE are
|
||||
* controlled by \c mbedtls_ssl_conf_curves() but for CA_int
|
||||
* and CA_root it's \c mbedtls_ssl_conf_cert_profile().
|
||||
* for that. For the end-entity certificate however, the key
|
||||
* will be accepted only if it is allowed both by this list
|
||||
* and by the cert profile.
|
||||
*
|
||||
* \note This list should be ordered by decreasing preference
|
||||
* (preferred curve first).
|
||||
@ -1566,10 +1759,10 @@ void mbedtls_ssl_conf_curves( mbedtls_ssl_config *conf,
|
||||
const mbedtls_ecp_group_id *curves );
|
||||
#endif /* MBEDTLS_ECP_C */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__SIGNATURE_ENABLED)
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
|
||||
/**
|
||||
* \brief Set the allowed hashes for signatures during the handshake.
|
||||
* (Default: all available hashes.)
|
||||
* (Default: all available hashes except MD5.)
|
||||
*
|
||||
* \note This only affects which hashes are offered and can be used
|
||||
* for signatures during the handshake. Hashes for message
|
||||
@ -1587,14 +1780,15 @@ void mbedtls_ssl_conf_curves( mbedtls_ssl_config *conf,
|
||||
*/
|
||||
void mbedtls_ssl_conf_sig_hashes( mbedtls_ssl_config *conf,
|
||||
const int *hashes );
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE__SOME__SIGNATURE_ENABLED */
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
/**
|
||||
* \brief Set hostname for ServerName TLS extension
|
||||
* \brief Set the hostname to check against the received server
|
||||
* certificate. It sets the ServerName TLS extension too,
|
||||
* if the extension is enabled.
|
||||
* (client-side only)
|
||||
*
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param hostname the server hostname
|
||||
*
|
||||
@ -1677,13 +1871,39 @@ void mbedtls_ssl_conf_sni( mbedtls_ssl_config *conf,
|
||||
void *p_sni );
|
||||
#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
/**
|
||||
* \brief Set the EC J-PAKE password for current handshake.
|
||||
*
|
||||
* \note An internal copy is made, and destroyed as soon as the
|
||||
* handshake is completed, or when the SSL context is reset or
|
||||
* freed.
|
||||
*
|
||||
* \note The SSL context needs to be already set up. The right place
|
||||
* to call this function is between \c mbedtls_ssl_setup() or
|
||||
* \c mbedtls_ssl_reset() and \c mbedtls_ssl_handshake().
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param pw EC J-PAKE password (pre-shared secret)
|
||||
* \param pw_len length of pw in bytes
|
||||
*
|
||||
* \return 0 on success, or a negative error code.
|
||||
*/
|
||||
int mbedtls_ssl_set_hs_ecjpake_password( mbedtls_ssl_context *ssl,
|
||||
const unsigned char *pw,
|
||||
size_t pw_len );
|
||||
#endif /*MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_SSL_ALPN)
|
||||
/**
|
||||
* \brief Set the supported Application Layer Protocols.
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param protos NULL-terminated list of supported protocols,
|
||||
* in decreasing preference order.
|
||||
* \param protos Pointer to a NULL-terminated list of supported protocols,
|
||||
* in decreasing preference order. The pointer to the list is
|
||||
* recorded by the library for later reference as required, so
|
||||
* the lifetime of the table must be atleast as long as the
|
||||
* lifetime of the SSL configuration structure.
|
||||
*
|
||||
* \return 0 on success, or MBEDTLS_ERR_SSL_BAD_INPUT_DATA.
|
||||
*/
|
||||
@ -1797,11 +2017,13 @@ void mbedtls_ssl_conf_extended_master_secret( mbedtls_ssl_config *conf, char ems
|
||||
* \brief Disable or enable support for RC4
|
||||
* (Default: MBEDTLS_SSL_ARC4_DISABLED)
|
||||
*
|
||||
* \warning Use of RC4 in (D)TLS has been prohibited by RFC ????
|
||||
* for security reasons. Use at your own risks.
|
||||
* \warning Use of RC4 in DTLS/TLS has been prohibited by RFC 7465
|
||||
* for security reasons. Use at your own risk.
|
||||
*
|
||||
* \note This function will likely be removed in future versions as
|
||||
* RC4 will then be disabled by default at compile time.
|
||||
* \note This function is deprecated and will likely be removed in
|
||||
* a future version of the library.
|
||||
* RC4 is disabled by default at compile time and needs to be
|
||||
* actively enabled for use with legacy systems.
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param arc4 MBEDTLS_SSL_ARC4_ENABLED or MBEDTLS_SSL_ARC4_DISABLED
|
||||
@ -1877,7 +2099,7 @@ void mbedtls_ssl_conf_session_tickets( mbedtls_ssl_config *conf, int use_tickets
|
||||
*
|
||||
* \warning It is recommended to always disable renegotation unless you
|
||||
* know you need it and you know what you're doing. In the
|
||||
* past, there has been several issues associated with
|
||||
* past, there have been several issues associated with
|
||||
* renegotiation or a poor understanding of its properties.
|
||||
*
|
||||
* \note Server-side, enabling renegotiation also makes the server
|
||||
@ -2103,7 +2325,8 @@ int mbedtls_ssl_get_session( const mbedtls_ssl_context *ssl, mbedtls_ssl_session
|
||||
* \note If this function returns something other than 0 or
|
||||
* MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context
|
||||
* becomes unusable, and you should either free it or call
|
||||
* \c mbedtls_ssl_session_reset() on it before re-using it.
|
||||
* \c mbedtls_ssl_session_reset() on it before re-using it for
|
||||
* a new connection; the current connection must be closed.
|
||||
*
|
||||
* \note If DTLS is in use, then you may choose to handle
|
||||
* MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED specially for logging
|
||||
@ -2116,8 +2339,14 @@ int mbedtls_ssl_handshake( mbedtls_ssl_context *ssl );
|
||||
* \brief Perform a single step of the SSL handshake
|
||||
*
|
||||
* \note The state of the context (ssl->state) will be at
|
||||
* the following state after execution of this function.
|
||||
* Do not call this function if state is MBEDTLS_SSL_HANDSHAKE_OVER.
|
||||
* the next state after execution of this function. Do not
|
||||
* call this function if state is MBEDTLS_SSL_HANDSHAKE_OVER.
|
||||
*
|
||||
* \note If this function returns something other than 0 or
|
||||
* MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context
|
||||
* becomes unusable, and you should either free it or call
|
||||
* \c mbedtls_ssl_session_reset() on it before re-using it for
|
||||
* a new connection; the current connection must be closed.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
@ -2132,11 +2361,19 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl );
|
||||
* \brief Initiate an SSL renegotiation on the running connection.
|
||||
* Client: perform the renegotiation right now.
|
||||
* Server: request renegotiation, which will be performed
|
||||
* during the next call to mbedtls_ssl_read() if honored by client.
|
||||
* during the next call to mbedtls_ssl_read() if honored by
|
||||
* client.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return 0 if successful, or any mbedtls_ssl_handshake() return value.
|
||||
* \return 0 if successful, or any mbedtls_ssl_handshake() return
|
||||
* value.
|
||||
*
|
||||
* \note If this function returns something other than 0 or
|
||||
* MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context
|
||||
* becomes unusable, and you should either free it or call
|
||||
* \c mbedtls_ssl_session_reset() on it before re-using it for
|
||||
* a new connection; the current connection must be closed.
|
||||
*/
|
||||
int mbedtls_ssl_renegotiate( mbedtls_ssl_context *ssl );
|
||||
#endif /* MBEDTLS_SSL_RENEGOTIATION */
|
||||
@ -2154,6 +2391,13 @@ int mbedtls_ssl_renegotiate( mbedtls_ssl_context *ssl );
|
||||
* MBEDTLS_ERR_SSL_CLIENT_RECONNECT (see below), or
|
||||
* another negative error code.
|
||||
*
|
||||
* \note If this function returns something other than a positive
|
||||
* value or MBEDTLS_ERR_SSL_WANT_READ/WRITE or
|
||||
* MBEDTLS_ERR_SSL_CLIENT_RECONNECT, then the ssl context
|
||||
* becomes unusable, and you should either free it or call
|
||||
* \c mbedtls_ssl_session_reset() on it before re-using it for
|
||||
* a new connection; the current connection must be closed.
|
||||
*
|
||||
* \note When this function return MBEDTLS_ERR_SSL_CLIENT_RECONNECT
|
||||
* (which can only happen server-side), it means that a client
|
||||
* is initiating a new connection using the same source port.
|
||||
@ -2187,6 +2431,12 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )
|
||||
* or MBEDTLS_ERR_SSL_WANT_WRITE of MBEDTLS_ERR_SSL_WANT_READ,
|
||||
* or another negative error code.
|
||||
*
|
||||
* \note If this function returns something other than a positive
|
||||
* value or MBEDTLS_ERR_SSL_WANT_READ/WRITE, the ssl context
|
||||
* becomes unusable, and you should either free it or call
|
||||
* \c mbedtls_ssl_session_reset() on it before re-using it for
|
||||
* a new connection; the current connection must be closed.
|
||||
*
|
||||
* \note When this function returns MBEDTLS_ERR_SSL_WANT_WRITE/READ,
|
||||
* it must be called later with the *same* arguments,
|
||||
* until it returns a positive value.
|
||||
@ -2210,6 +2460,12 @@ int mbedtls_ssl_write( mbedtls_ssl_context *ssl, const unsigned char *buf, size_
|
||||
* \param message The alert message (SSL_ALERT_MSG_*)
|
||||
*
|
||||
* \return 0 if successful, or a specific SSL error code.
|
||||
*
|
||||
* \note If this function returns something other than 0 or
|
||||
* MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context
|
||||
* becomes unusable, and you should either free it or call
|
||||
* \c mbedtls_ssl_session_reset() on it before re-using it for
|
||||
* a new connection; the current connection must be closed.
|
||||
*/
|
||||
int mbedtls_ssl_send_alert_message( mbedtls_ssl_context *ssl,
|
||||
unsigned char level,
|
||||
@ -2218,6 +2474,14 @@ int mbedtls_ssl_send_alert_message( mbedtls_ssl_context *ssl,
|
||||
* \brief Notify the peer that the connection is being closed
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return 0 if successful, or a specific SSL error code.
|
||||
*
|
||||
* \note If this function returns something other than 0 or
|
||||
* MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context
|
||||
* becomes unusable, and you should either free it or call
|
||||
* \c mbedtls_ssl_session_reset() on it before re-using it for
|
||||
* a new connection; the current connection must be closed.
|
||||
*/
|
||||
int mbedtls_ssl_close_notify( mbedtls_ssl_context *ssl );
|
||||
|
||||
|
@ -60,7 +60,7 @@ typedef struct mbedtls_ssl_cache_entry mbedtls_ssl_cache_entry;
|
||||
struct mbedtls_ssl_cache_entry
|
||||
{
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
time_t timestamp; /*!< entry timestamp */
|
||||
mbedtls_time_t timestamp; /*!< entry timestamp */
|
||||
#endif
|
||||
mbedtls_ssl_session session; /*!< entry session */
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
@ -121,7 +121,7 @@ void mbedtls_ssl_cache_set_timeout( mbedtls_ssl_cache_context *cache, int timeou
|
||||
#endif /* MBEDTLS_HAVE_TIME */
|
||||
|
||||
/**
|
||||
* \brief Set the cache timeout
|
||||
* \brief Set the maximum number of cache entries
|
||||
* (Default: MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES (50))
|
||||
*
|
||||
* \param cache SSL cache context
|
||||
|
@ -229,8 +229,10 @@ extern "C" {
|
||||
#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 0xC0AE /**< TLS 1.2 */
|
||||
#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 0xC0AF /**< TLS 1.2 */
|
||||
|
||||
#define MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 0xC0FF /**< experimental */
|
||||
|
||||
/* Reminder: update mbedtls_ssl_premaster_secret when adding a new key exchange.
|
||||
* Reminder: update MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED below.
|
||||
* Reminder: update MBEDTLS_KEY_EXCHANGE__xxx below
|
||||
*/
|
||||
typedef enum {
|
||||
MBEDTLS_KEY_EXCHANGE_NONE = 0,
|
||||
@ -244,19 +246,35 @@ typedef enum {
|
||||
MBEDTLS_KEY_EXCHANGE_ECDHE_PSK,
|
||||
MBEDTLS_KEY_EXCHANGE_ECDH_RSA,
|
||||
MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA,
|
||||
MBEDTLS_KEY_EXCHANGE_ECJPAKE,
|
||||
} mbedtls_key_exchange_type_t;
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
|
||||
/* Key exchanges using a certificate */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
|
||||
#define MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED
|
||||
#endif
|
||||
|
||||
/* Key exchanges using a PSK */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
|
||||
#define MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED
|
||||
#endif
|
||||
|
||||
/* Key exchanges using a ECDHE */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
|
||||
#define MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED
|
||||
#endif
|
||||
|
||||
typedef struct mbedtls_ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t;
|
||||
|
||||
#define MBEDTLS_CIPHERSUITE_WEAK 0x01 /**< Weak ciphersuite flag */
|
||||
|
27
Externals/mbedtls/include/mbedtls/ssl_internal.h
vendored
27
Externals/mbedtls/include/mbedtls/ssl_internal.h
vendored
@ -41,7 +41,12 @@
|
||||
#include "sha512.h"
|
||||
#endif
|
||||
|
||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && !defined(inline)
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
#include "ecjpake.h"
|
||||
#endif
|
||||
|
||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
|
||||
!defined(inline) && !defined(__cplusplus)
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
@ -146,6 +151,7 @@
|
||||
* of state of the renegotiation flag, so no indicator is required)
|
||||
*/
|
||||
#define MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS_PRESENT (1 << 0)
|
||||
#define MBEDTLS_TLS_EXT_ECJPAKE_KKPP_OK (1 << 1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -160,7 +166,6 @@ struct mbedtls_ssl_handshake_params
|
||||
* Handshake specific crypto variables
|
||||
*/
|
||||
int sig_alg; /*!< Hash algorithm for signature */
|
||||
int cert_type; /*!< Requested cert type */
|
||||
int verify_sig_alg; /*!< Signature algorithm for verify */
|
||||
#if defined(MBEDTLS_DHM_C)
|
||||
mbedtls_dhm_context dhm_ctx; /*!< DHM key exchange */
|
||||
@ -168,7 +173,15 @@ struct mbedtls_ssl_handshake_params
|
||||
#if defined(MBEDTLS_ECDH_C)
|
||||
mbedtls_ecdh_context ecdh_ctx; /*!< ECDH key exchange */
|
||||
#endif
|
||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
mbedtls_ecjpake_context ecjpake_ctx; /*!< EC J-PAKE key exchange */
|
||||
#if defined(MBEDTLS_SSL_CLI_C)
|
||||
unsigned char *ecjpake_cache; /*!< Cache for ClientHello ext */
|
||||
size_t ecjpake_cache_len; /*!< Length of cached data */
|
||||
#endif
|
||||
#endif
|
||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
const mbedtls_ecp_curve_info **curves; /*!< Supported elliptic curves */
|
||||
#endif
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
|
||||
@ -342,6 +355,11 @@ int mbedtls_ssl_send_fatal_handshake_failure( mbedtls_ssl_context *ssl );
|
||||
void mbedtls_ssl_reset_checksum( mbedtls_ssl_context *ssl );
|
||||
int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl );
|
||||
|
||||
int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl );
|
||||
int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl );
|
||||
int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl );
|
||||
void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl );
|
||||
|
||||
int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl );
|
||||
int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want );
|
||||
|
||||
@ -371,12 +389,13 @@ mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig( unsigned char sig );
|
||||
|
||||
mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash( unsigned char hash );
|
||||
unsigned char mbedtls_ssl_hash_from_md_alg( int md );
|
||||
int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md );
|
||||
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
int mbedtls_ssl_check_curve( const mbedtls_ssl_context *ssl, mbedtls_ecp_group_id grp_id );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__SIGNATURE_ENABLED)
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
|
||||
int mbedtls_ssl_check_sig_hash( const mbedtls_ssl_context *ssl,
|
||||
mbedtls_md_type_t md );
|
||||
#endif
|
||||
|
@ -81,6 +81,7 @@ void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t *
|
||||
void mbedtls_threading_free_alt( void );
|
||||
#endif /* MBEDTLS_THREADING_ALT */
|
||||
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
/*
|
||||
* The function pointers for mutex_init, mutex_free, mutex_ and mutex_unlock
|
||||
*
|
||||
@ -96,6 +97,7 @@ extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex );
|
||||
*/
|
||||
extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex;
|
||||
extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex;
|
||||
#endif /* MBEDTLS_THREADING_C */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
4
Externals/mbedtls/include/mbedtls/timing.h
vendored
4
Externals/mbedtls/include/mbedtls/timing.h
vendored
@ -92,7 +92,7 @@ void mbedtls_set_alarm( int seconds );
|
||||
* (See \c mbedtls_timing_get_delay().)
|
||||
*
|
||||
* \param data Pointer to timing data
|
||||
* Must point to a valid \c mbetls_timing_delay_context struct.
|
||||
* Must point to a valid \c mbedtls_timing_delay_context struct.
|
||||
* \param int_ms First (intermediate) delay in milliseconds.
|
||||
* \param fin_ms Second (final) delay in milliseconds.
|
||||
* Pass 0 to cancel the current delay.
|
||||
@ -104,7 +104,7 @@ void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms );
|
||||
* (Memory helper: number of delays passed.)
|
||||
*
|
||||
* \param data Pointer to timing data
|
||||
* Must point to a valid \c mbetls_timing_delay_context struct.
|
||||
* Must point to a valid \c mbedtls_timing_delay_context struct.
|
||||
*
|
||||
* \return -1 if cancelled (fin_ms = 0)
|
||||
* 0 if none of the delays are passed,
|
||||
|
8
Externals/mbedtls/include/mbedtls/version.h
vendored
8
Externals/mbedtls/include/mbedtls/version.h
vendored
@ -38,7 +38,7 @@
|
||||
* Major, Minor, Patchlevel
|
||||
*/
|
||||
#define MBEDTLS_VERSION_MAJOR 2
|
||||
#define MBEDTLS_VERSION_MINOR 1
|
||||
#define MBEDTLS_VERSION_MINOR 4
|
||||
#define MBEDTLS_VERSION_PATCH 1
|
||||
|
||||
/**
|
||||
@ -46,9 +46,9 @@
|
||||
* MMNNPP00
|
||||
* Major version | Minor version | Patch version
|
||||
*/
|
||||
#define MBEDTLS_VERSION_NUMBER 0x02010100
|
||||
#define MBEDTLS_VERSION_STRING "2.1.1"
|
||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.1.1"
|
||||
#define MBEDTLS_VERSION_NUMBER 0x02040100
|
||||
#define MBEDTLS_VERSION_STRING "2.4.1"
|
||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.4.1"
|
||||
|
||||
#if defined(MBEDTLS_VERSION_C)
|
||||
|
||||
|
3
Externals/mbedtls/include/mbedtls/x509_crl.h
vendored
3
Externals/mbedtls/include/mbedtls/x509_crl.h
vendored
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file mbedtls_x509_crl.h
|
||||
* \file x509_crl.h
|
||||
*
|
||||
* \brief X.509 certificate revocation list parsing
|
||||
*
|
||||
@ -100,6 +100,7 @@ mbedtls_x509_crl;
|
||||
*
|
||||
* \param chain points to the start of the chain
|
||||
* \param buf buffer holding the CRL data in DER format
|
||||
* \param buflen size of the buffer
|
||||
* (including the terminating null byte for PEM data)
|
||||
*
|
||||
* \return 0 if successful, or a specific X509 or PEM error code
|
||||
|
27
Externals/mbedtls/include/mbedtls/x509_crt.h
vendored
27
Externals/mbedtls/include/mbedtls/x509_crt.h
vendored
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file mbedtls_x509_crt.h
|
||||
* \file x509_crt.h
|
||||
*
|
||||
* \brief X.509 certificate parsing and writing
|
||||
*
|
||||
@ -120,6 +120,10 @@ mbedtls_x509_crt_profile;
|
||||
#define MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN 32
|
||||
#define MBEDTLS_X509_RFC5280_UTC_TIME_LEN 15
|
||||
|
||||
#if !defined( MBEDTLS_X509_MAX_FILE_PATH_LEN )
|
||||
#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Container for writing a certificate (CRT)
|
||||
*/
|
||||
@ -271,9 +275,14 @@ int mbedtls_x509_crt_verify_info( char *buf, size_t size, const char *prefix,
|
||||
* \note Same as \c mbedtls_x509_crt_verify_with_profile() with the
|
||||
* default security profile.
|
||||
*
|
||||
* \param crt a certificate to be verified
|
||||
* \param trust_ca the trusted CA chain
|
||||
* \param ca_crl the CRL chain for trusted CA's
|
||||
* \note It is your responsibility to provide up-to-date CRLs for
|
||||
* all trusted CAs. If no CRL is provided for the CA that was
|
||||
* used to sign the certificate, CRL verification is skipped
|
||||
* silently, that is *without* setting any flag.
|
||||
*
|
||||
* \param crt a certificate (chain) to be verified
|
||||
* \param trust_ca the list of trusted CAs
|
||||
* \param ca_crl the list of CRLs for trusted CAs (see note above)
|
||||
* \param cn expected Common Name (can be set to
|
||||
* NULL if the CN must not be verified)
|
||||
* \param flags result of the verification
|
||||
@ -301,12 +310,12 @@ int mbedtls_x509_crt_verify( mbedtls_x509_crt *crt,
|
||||
* security profile.
|
||||
*
|
||||
* \note The restrictions on keys (RSA minimum size, allowed curves
|
||||
* for ECDSA) only applys to (intermediate) CAs, not to the
|
||||
* end-entity certificate.
|
||||
* for ECDSA) apply to all certificates: trusted root,
|
||||
* intermediate CAs if any, and end entity certificate.
|
||||
*
|
||||
* \param crt a certificate to be verified
|
||||
* \param trust_ca the trusted CA chain
|
||||
* \param ca_crl the CRL chain for trusted CA's
|
||||
* \param crt a certificate (chain) to be verified
|
||||
* \param trust_ca the list of trusted CAs
|
||||
* \param ca_crl the list of CRLs for trusted CAs
|
||||
* \param profile security profile for verification
|
||||
* \param cn expected Common Name (can be set to
|
||||
* NULL if the CN must not be verified)
|
||||
|
10
Externals/mbedtls/include/mbedtls/x509_csr.h
vendored
10
Externals/mbedtls/include/mbedtls/x509_csr.h
vendored
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file mbedtls_x509_csr.h
|
||||
* \file x509_csr.h
|
||||
*
|
||||
* \brief X.509 certificate signing request parsing and writing
|
||||
*
|
||||
@ -83,6 +83,8 @@ mbedtls_x509write_csr;
|
||||
/**
|
||||
* \brief Load a Certificate Signing Request (CSR) in DER format
|
||||
*
|
||||
* \note CSR attributes (if any) are currently silently ignored.
|
||||
*
|
||||
* \param csr CSR context to fill
|
||||
* \param buf buffer holding the CRL data
|
||||
* \param buflen size of the buffer
|
||||
@ -95,6 +97,8 @@ int mbedtls_x509_csr_parse_der( mbedtls_x509_csr *csr,
|
||||
/**
|
||||
* \brief Load a Certificate Signing Request (CSR), DER or PEM format
|
||||
*
|
||||
* \note See notes for \c mbedtls_x509_csr_parse_der()
|
||||
*
|
||||
* \param csr CSR context to fill
|
||||
* \param buf buffer holding the CRL data
|
||||
* \param buflen size of the buffer
|
||||
@ -108,6 +112,8 @@ int mbedtls_x509_csr_parse( mbedtls_x509_csr *csr, const unsigned char *buf, siz
|
||||
/**
|
||||
* \brief Load a Certificate Signing Request (CSR)
|
||||
*
|
||||
* \note See notes for \c mbedtls_x509_csr_parse()
|
||||
*
|
||||
* \param csr CSR context to fill
|
||||
* \param path filename to read the CSR from
|
||||
*
|
||||
@ -276,7 +282,7 @@ int mbedtls_x509write_csr_der( mbedtls_x509write_csr *ctx, unsigned char *buf, s
|
||||
*
|
||||
* \note f_rng may be NULL if RSA is used for signature and the
|
||||
* signature is made offline (otherwise f_rng is desirable
|
||||
* for couermeasures against timing attacks).
|
||||
* for countermeasures against timing attacks).
|
||||
* ECDSA signatures always require a non-NULL f_rng.
|
||||
*/
|
||||
int mbedtls_x509write_csr_pem( mbedtls_x509write_csr *ctx, unsigned char *buf, size_t size,
|
||||
|
Reference in New Issue
Block a user