mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-01 04:50:58 +02:00
Update IDF to a0468b2 (#2108)
* Update IDF to a0468b2 * add missing ld file * Fix PIO builds and change coex policy
This commit is contained in:
4
tools/sdk/include/mbedtls/.gitignore
vendored
4
tools/sdk/include/mbedtls/.gitignore
vendored
@ -1,4 +0,0 @@
|
||||
Makefile
|
||||
*.sln
|
||||
*.vcxproj
|
||||
mbedtls/check_config
|
@ -1,16 +0,0 @@
|
||||
option(INSTALL_MBEDTLS_HEADERS "Install mbed TLS headers." ON)
|
||||
|
||||
if(INSTALL_MBEDTLS_HEADERS)
|
||||
|
||||
file(GLOB headers "mbedtls/*.h")
|
||||
|
||||
install(FILES ${headers}
|
||||
DESTINATION include/mbedtls
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
|
||||
|
||||
endif(INSTALL_MBEDTLS_HEADERS)
|
||||
|
||||
# Make config.h available in an out-of-source build. ssl-opt.sh requires it.
|
||||
if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
link_to_source(mbedtls)
|
||||
endif()
|
66
tools/sdk/include/mbedtls/aes_alt.h
Normal file
66
tools/sdk/include/mbedtls/aes_alt.h
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* \file aes_alt.h
|
||||
*
|
||||
* \brief AES block cipher
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#ifndef AES_ALT_H
|
||||
#define AES_ALT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_AES_ALT)
|
||||
#include "hwcrypto/aes.h"
|
||||
|
||||
typedef esp_aes_context mbedtls_aes_context;
|
||||
|
||||
#define mbedtls_aes_init esp_aes_init
|
||||
#define mbedtls_aes_free esp_aes_free
|
||||
#define mbedtls_aes_setkey_enc esp_aes_setkey
|
||||
#define mbedtls_aes_setkey_dec esp_aes_setkey
|
||||
#define mbedtls_aes_crypt_ecb esp_aes_crypt_ecb
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
#define mbedtls_aes_crypt_cbc esp_aes_crypt_cbc
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
#define mbedtls_aes_crypt_cfb128 esp_aes_crypt_cfb128
|
||||
#define mbedtls_aes_crypt_cfb8 esp_aes_crypt_cfb8
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
#define mbedtls_aes_crypt_ctr esp_aes_crypt_ctr
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
typedef esp_aes_xts_context mbedtls_aes_xts_context;
|
||||
#define mbedtls_aes_xts_init esp_aes_xts_init
|
||||
#define mbedtls_aes_xts_free esp_aes_xts_free
|
||||
#define mbedtls_aes_xts_setkey_enc esp_aes_xts_setkey_enc
|
||||
#define mbedtls_aes_xts_setkey_dec esp_aes_xts_setkey_dec
|
||||
#define mbedtls_aes_crypt_xts esp_aes_crypt_xts
|
||||
#endif
|
||||
#define mbedtls_internal_aes_encrypt esp_internal_aes_encrypt
|
||||
#define mbedtls_internal_aes_decrypt esp_internal_aes_decrypt
|
||||
#endif /* MBEDTLS_AES_ALT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
20
tools/sdk/include/mbedtls/esp_mem.h
Normal file
20
tools/sdk/include/mbedtls/esp_mem.h
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void *esp_mbedtls_mem_calloc(size_t n, size_t size);
|
||||
void esp_mbedtls_mem_free(void *ptr);
|
@ -79,7 +79,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief The AES context-type definition.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_aes_context
|
||||
{
|
||||
int nr; /*!< The number of rounds. */
|
||||
uint32_t *rk; /*!< AES round keys. */
|
||||
@ -98,7 +98,7 @@ mbedtls_aes_context;
|
||||
/**
|
||||
* \brief The AES XTS context-type definition.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_aes_xts_context
|
||||
{
|
||||
mbedtls_aes_context crypt; /*!< The AES context to use for AES block
|
||||
encryption or decryption. */
|
||||
|
@ -53,7 +53,7 @@ extern "C" {
|
||||
* security risk. We recommend considering stronger ciphers instead.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_arc4_context
|
||||
{
|
||||
int x; /*!< permutation index */
|
||||
int y; /*!< permutation index */
|
||||
|
@ -62,7 +62,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief The ARIA context-type definition.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_aria_context
|
||||
{
|
||||
unsigned char nr; /*!< The number of rounds (12, 14 or 16) */
|
||||
/*! The ARIA round keys. */
|
||||
|
@ -179,7 +179,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief MPI structure
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_mpi
|
||||
{
|
||||
int s; /*!< integer sign */
|
||||
size_t n; /*!< total # of limbs */
|
||||
|
@ -55,7 +55,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief Blowfish context structure
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_blowfish_context
|
||||
{
|
||||
uint32_t P[MBEDTLS_BLOWFISH_ROUNDS + 2]; /*!< Blowfish round keys */
|
||||
uint32_t S[4][256]; /*!< key dependent S-boxes */
|
||||
|
@ -51,7 +51,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief CAMELLIA context structure
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_camellia_context
|
||||
{
|
||||
int nr; /*!< number of rounds */
|
||||
uint32_t rk[68]; /*!< CAMELLIA round keys */
|
||||
|
@ -68,7 +68,8 @@ extern "C" {
|
||||
* \brief The CCM context-type definition. The CCM context is passed
|
||||
* to the APIs called.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct mbedtls_ccm_context
|
||||
{
|
||||
mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */
|
||||
}
|
||||
mbedtls_ccm_context;
|
||||
|
@ -52,7 +52,7 @@ extern "C" {
|
||||
|
||||
#if !defined(MBEDTLS_CHACHA20_ALT)
|
||||
|
||||
typedef struct
|
||||
typedef struct mbedtls_chacha20_context
|
||||
{
|
||||
uint32_t state[16]; /*! The state (before round operations). */
|
||||
uint8_t keystream8[64]; /*! Leftover keystream bytes. */
|
||||
|
@ -60,7 +60,7 @@ mbedtls_chachapoly_mode_t;
|
||||
|
||||
#include "chacha20.h"
|
||||
|
||||
typedef struct
|
||||
typedef struct mbedtls_chachapoly_context
|
||||
{
|
||||
mbedtls_chacha20_context chacha20_ctx; /**< The ChaCha20 context. */
|
||||
mbedtls_poly1305_context poly1305_ctx; /**< The Poly1305 context. */
|
||||
|
@ -45,7 +45,8 @@
|
||||
#define MBEDTLS_CIPHER_MODE_WITH_PADDING
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER)
|
||||
#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) || \
|
||||
defined(MBEDTLS_CHACHA20_C)
|
||||
#define MBEDTLS_CIPHER_MODE_STREAM
|
||||
#endif
|
||||
|
||||
@ -235,7 +236,8 @@ typedef struct mbedtls_cmac_context_t mbedtls_cmac_context_t;
|
||||
* Cipher information. Allows calling cipher functions
|
||||
* in a generic way.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct mbedtls_cipher_info_t
|
||||
{
|
||||
/** Full cipher identifier. For example,
|
||||
* MBEDTLS_CIPHER_AES_256_CBC.
|
||||
*/
|
||||
@ -276,7 +278,8 @@ typedef struct {
|
||||
/**
|
||||
* Generic cipher context.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct mbedtls_cipher_context_t
|
||||
{
|
||||
/** Information about the associated cipher. */
|
||||
const mbedtls_cipher_info_t *cipher_info;
|
||||
|
||||
|
@ -137,12 +137,21 @@
|
||||
/**
|
||||
* \def MBEDTLS_HAVE_TIME_DATE
|
||||
*
|
||||
* System has time.h and time(), gmtime() and the clock is correct.
|
||||
* System has time.h, time(), and an implementation for
|
||||
* mbedtls_platform_gmtime_r() (see below).
|
||||
* The time needs to be correct (not necesarily very accurate, but at least
|
||||
* the date should be correct). This is used to verify the validity period of
|
||||
* X.509 certificates.
|
||||
*
|
||||
* Comment if your system does not have a correct clock.
|
||||
*
|
||||
* \note mbedtls_platform_gmtime_r() is an abstraction in platform_util.h that
|
||||
* behaves similarly to the gmtime_r() function from the C standard. Refer to
|
||||
* the documentation for mbedtls_platform_gmtime_r() for more information.
|
||||
*
|
||||
* \note It is possible to configure an implementation for
|
||||
* mbedtls_platform_gmtime_r() at compile-time by using the macro
|
||||
* MBEDTLS_PLATFORM_GMTIME_R_ALT.
|
||||
*/
|
||||
#define MBEDTLS_HAVE_TIME_DATE
|
||||
|
||||
@ -3010,6 +3019,23 @@
|
||||
*/
|
||||
//#define MBEDTLS_SSL_OUT_CONTENT_LEN 16384
|
||||
|
||||
/** \def MBEDTLS_SSL_DTLS_MAX_BUFFERING
|
||||
*
|
||||
* Maximum number of heap-allocated bytes for the purpose of
|
||||
* DTLS handshake message reassembly and future message buffering.
|
||||
*
|
||||
* This should be at least 9/8 * MBEDTLSSL_IN_CONTENT_LEN
|
||||
* to account for a reassembled handshake message of maximum size,
|
||||
* together with its reassembly bitmap.
|
||||
*
|
||||
* A value of 2 * MBEDTLS_SSL_IN_CONTENT_LEN (32768 by default)
|
||||
* should be sufficient for all practical situations as it allows
|
||||
* to reassembly a large handshake message (such as a certificate)
|
||||
* while buffering multiple smaller handshake messages.
|
||||
*
|
||||
*/
|
||||
//#define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768
|
||||
|
||||
//#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */
|
||||
//#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */
|
||||
//#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */
|
||||
@ -3083,6 +3109,25 @@
|
||||
*/
|
||||
//#define MBEDTLS_PLATFORM_ZEROIZE_ALT
|
||||
|
||||
/**
|
||||
* Uncomment the macro to let Mbed TLS use your alternate implementation of
|
||||
* mbedtls_platform_gmtime_r(). This replaces the default implementation in
|
||||
* platform_util.c.
|
||||
*
|
||||
* gmtime() is not a thread-safe function as defined in the C standard. The
|
||||
* library will try to use safer implementations of this function, such as
|
||||
* gmtime_r() when available. However, if Mbed TLS cannot identify the target
|
||||
* system, the implementation of mbedtls_platform_gmtime_r() will default to
|
||||
* using the standard gmtime(). In this case, calls from the library to
|
||||
* gmtime() will be guarded by the global mutex mbedtls_threading_gmtime_mutex
|
||||
* if MBEDTLS_THREADING_C is enabled. We recommend that calls from outside the
|
||||
* library are also guarded with this mutex to avoid race conditions. However,
|
||||
* if the macro MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, Mbed TLS will
|
||||
* unconditionally use the implementation for mbedtls_platform_gmtime_r()
|
||||
* supplied at compile time.
|
||||
*/
|
||||
//#define MBEDTLS_PLATFORM_GMTIME_R_ALT
|
||||
|
||||
/* \} name SECTION: Customisation configuration options */
|
||||
|
||||
/* Target and application specific configurations */
|
||||
|
@ -108,7 +108,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief The CTR_DRBG context structure.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_ctr_drbg_context
|
||||
{
|
||||
unsigned char counter[16]; /*!< The counter (V). */
|
||||
int reseed_counter; /*!< The reseed counter. */
|
||||
|
@ -61,7 +61,7 @@ extern "C" {
|
||||
* security risk. We recommend considering stronger ciphers
|
||||
* instead.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_des_context
|
||||
{
|
||||
uint32_t sk[32]; /*!< DES subkeys */
|
||||
}
|
||||
@ -70,7 +70,7 @@ mbedtls_des_context;
|
||||
/**
|
||||
* \brief Triple-DES context structure
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_des3_context
|
||||
{
|
||||
uint32_t sk[96]; /*!< 3DES subkeys */
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief The DHM context structure.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_dhm_context
|
||||
{
|
||||
size_t len; /*!< The size of \p P in Bytes. */
|
||||
mbedtls_mpi P; /*!< The prime modulus. */
|
||||
|
@ -52,7 +52,7 @@ typedef enum
|
||||
/**
|
||||
* \brief The ECDH context structure.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_ecdh_context
|
||||
{
|
||||
mbedtls_ecp_group grp; /*!< The elliptic curve used. */
|
||||
mbedtls_mpi d; /*!< The private key. */
|
||||
|
@ -68,7 +68,7 @@ typedef enum {
|
||||
* convetion from the Thread v1.0 spec. Correspondance is indicated in the
|
||||
* description as a pair C: client name, S: server name
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_ecjpake_context
|
||||
{
|
||||
const mbedtls_md_info_t *md_info; /**< Hash to use */
|
||||
mbedtls_ecp_group grp; /**< Elliptic curve */
|
||||
|
@ -92,7 +92,7 @@ typedef enum
|
||||
/**
|
||||
* Curve information, for use by other modules.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_ecp_curve_info
|
||||
{
|
||||
mbedtls_ecp_group_id grp_id; /*!< An internal identifier. */
|
||||
uint16_t tls_id; /*!< The TLS NamedCurve identifier. */
|
||||
@ -111,7 +111,7 @@ typedef struct
|
||||
* Otherwise, \p X and \p Y are its standard (affine)
|
||||
* coordinates.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_ecp_point
|
||||
{
|
||||
mbedtls_mpi X; /*!< The X coordinate of the ECP point. */
|
||||
mbedtls_mpi Y; /*!< The Y coordinate of the ECP point. */
|
||||
@ -156,7 +156,7 @@ mbedtls_ecp_point;
|
||||
* reduction. It must return 0 on success and non-zero on failure.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_ecp_group
|
||||
{
|
||||
mbedtls_ecp_group_id id; /*!< An internal group identifier. */
|
||||
mbedtls_mpi P; /*!< The prime modulus of the base field. */
|
||||
@ -251,7 +251,7 @@ mbedtls_ecp_group;
|
||||
* \note Members are deliberately in the same order as in the
|
||||
* ::mbedtls_ecdsa_context structure.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_ecp_keypair
|
||||
{
|
||||
mbedtls_ecp_group grp; /*!< Elliptic curve and base point */
|
||||
mbedtls_mpi d; /*!< our secret value */
|
||||
|
@ -107,7 +107,7 @@ typedef int (*mbedtls_entropy_f_source_ptr)(void *data, unsigned char *output, s
|
||||
/**
|
||||
* \brief Entropy source state
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_entropy_source_state
|
||||
{
|
||||
mbedtls_entropy_f_source_ptr f_source; /**< The entropy source callback */
|
||||
void * p_source; /**< The callback data pointer */
|
||||
@ -120,7 +120,7 @@ mbedtls_entropy_source_state;
|
||||
/**
|
||||
* \brief Entropy context structure
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_entropy_context
|
||||
{
|
||||
int accumulator_started;
|
||||
#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
|
||||
|
2719
tools/sdk/include/mbedtls/mbedtls/esp_config.h
Normal file
2719
tools/sdk/include/mbedtls/mbedtls/esp_config.h
Normal file
File diff suppressed because it is too large
Load Diff
57
tools/sdk/include/mbedtls/mbedtls/esp_debug.h
Normal file
57
tools/sdk/include/mbedtls/mbedtls/esp_debug.h
Normal file
@ -0,0 +1,57 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// 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.
|
||||
#ifndef _ESP_DEBUG_H_
|
||||
#define _ESP_DEBUG_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_MBEDTLS_DEBUG
|
||||
|
||||
/** @brief Enable mbedTLS debug logging via the esp_log mechanism.
|
||||
*
|
||||
* mbedTLS internal debugging is filtered from a specified mbedTLS
|
||||
* threshold level to esp_log level at runtime:
|
||||
*
|
||||
* - 1 - Warning
|
||||
* - 2 - Info
|
||||
* - 3 - Debug
|
||||
* - 4 - Verbose
|
||||
*
|
||||
* (Note that mbedTLS debug thresholds are not always consistently used.)
|
||||
*
|
||||
* This function will set the esp log level for "mbedtls" to the specified mbedTLS
|
||||
* threshold level that matches. However, the overall max ESP log level must be set high
|
||||
* enough in menuconfig, or some messages may be filtered at compile time.
|
||||
*
|
||||
* @param conf mbedtls_ssl_config structure
|
||||
* @param mbedTLS debug threshold, 0-4. Messages are filtered at runtime.
|
||||
*/
|
||||
void mbedtls_esp_enable_debug_log(mbedtls_ssl_config *conf, int threshold);
|
||||
|
||||
/** @brief Disable mbedTLS debug logging via the esp_log mechanism.
|
||||
*
|
||||
*/
|
||||
void mbedtls_esp_disable_debug_log(mbedtls_ssl_config *conf);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_DEBUG_H__ */
|
@ -53,7 +53,8 @@ extern "C" {
|
||||
/**
|
||||
* \brief The GCM context structure.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct mbedtls_gcm_context
|
||||
{
|
||||
mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */
|
||||
uint64_t HL[16]; /*!< Precalculated HTable low. */
|
||||
uint64_t HH[16]; /*!< Precalculated HTable high. */
|
||||
|
@ -35,7 +35,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief HAVEGE state structure
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_havege_state
|
||||
{
|
||||
int PT1, PT2, offset[2];
|
||||
int pool[MBEDTLS_HAVEGE_COLLECT_SIZE];
|
||||
|
@ -73,6 +73,11 @@ int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt,
|
||||
* \brief Take the input keying material \p ikm and extract from it a
|
||||
* fixed-length pseudorandom key \p prk.
|
||||
*
|
||||
* \warning This function should only be used if the security of it has been
|
||||
* studied and established in that particular context (eg. TLS 1.3
|
||||
* key schedule). For standard HKDF security guarantees use
|
||||
* \c mbedtls_hkdf instead.
|
||||
*
|
||||
* \param md A hash function; md.size denotes the length of the
|
||||
* hash function output in bytes.
|
||||
* \param salt An optional salt value (a non-secret random value);
|
||||
@ -97,10 +102,15 @@ int mbedtls_hkdf_extract( const mbedtls_md_info_t *md,
|
||||
* \brief Expand the supplied \p prk into several additional pseudorandom
|
||||
* keys, which is the output of the HKDF.
|
||||
*
|
||||
* \warning This function should only be used if the security of it has been
|
||||
* studied and established in that particular context (eg. TLS 1.3
|
||||
* key schedule). For standard HKDF security guarantees use
|
||||
* \c mbedtls_hkdf instead.
|
||||
*
|
||||
* \param md A hash function; md.size denotes the length of the hash
|
||||
* function output in bytes.
|
||||
* \param prk A pseudorandom key of at least md.size bytes. \p prk is usually,
|
||||
* the output from the HKDF extract step.
|
||||
* \param prk A pseudorandom key of at least md.size bytes. \p prk is
|
||||
* usually the output from the HKDF extract step.
|
||||
* \param prk_len The length in bytes of \p prk.
|
||||
* \param info An optional context and application specific information
|
||||
* string. This can be a zero-length string.
|
||||
|
@ -74,7 +74,7 @@ extern "C" {
|
||||
/**
|
||||
* HMAC_DRBG context.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_hmac_drbg_context
|
||||
{
|
||||
/* Working state: the key K is not stored explicitely,
|
||||
* but is implied by the HMAC context */
|
||||
|
@ -80,7 +80,8 @@ typedef struct mbedtls_md_info_t mbedtls_md_info_t;
|
||||
/**
|
||||
* The generic message-digest context.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct mbedtls_md_context_t
|
||||
{
|
||||
/** Information about the associated message digest. */
|
||||
const mbedtls_md_info_t *md_info;
|
||||
|
||||
|
@ -55,7 +55,7 @@ extern "C" {
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_md2_context
|
||||
{
|
||||
unsigned char cksum[16]; /*!< checksum of the data block */
|
||||
unsigned char state[48]; /*!< intermediate digest state */
|
||||
|
@ -56,7 +56,7 @@ extern "C" {
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_md4_context
|
||||
{
|
||||
uint32_t total[2]; /*!< number of bytes processed */
|
||||
uint32_t state[4]; /*!< intermediate digest state */
|
||||
|
@ -55,7 +55,7 @@ extern "C" {
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_md5_context
|
||||
{
|
||||
uint32_t total[2]; /*!< number of bytes processed */
|
||||
uint32_t state[4]; /*!< intermediate digest state */
|
||||
|
@ -84,7 +84,7 @@ extern "C" {
|
||||
* (eg two file descriptors for combined IPv4 + IPv6 support, or additional
|
||||
* structures for hand-made UDP demultiplexing).
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_net_context
|
||||
{
|
||||
int fd; /**< The underlying file descriptor */
|
||||
}
|
||||
|
@ -403,7 +403,8 @@ extern "C" {
|
||||
/**
|
||||
* \brief Base OID descriptor structure
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct mbedtls_oid_descriptor_t
|
||||
{
|
||||
const char *asn1; /*!< OID ASN.1 representation */
|
||||
size_t asn1_len; /*!< length of asn1 */
|
||||
const char *name; /*!< official name (e.g. from RFC) */
|
||||
|
@ -51,7 +51,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief PEM context structure
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_pem_context
|
||||
{
|
||||
unsigned char *buf; /*!< buffer for decoded data */
|
||||
size_t buflen; /*!< length of the buffer */
|
||||
|
@ -87,7 +87,7 @@ typedef enum {
|
||||
* \brief Options for RSASSA-PSS signature verification.
|
||||
* See \c mbedtls_rsa_rsassa_pss_verify_ext()
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_pk_rsassa_pss_options
|
||||
{
|
||||
mbedtls_md_type_t mgf1_hash_id;
|
||||
int expected_salt_len;
|
||||
@ -107,7 +107,7 @@ typedef enum
|
||||
/**
|
||||
* \brief Item to send to the debug module
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_pk_debug_item
|
||||
{
|
||||
mbedtls_pk_debug_type type;
|
||||
const char *name;
|
||||
@ -125,7 +125,7 @@ typedef struct mbedtls_pk_info_t mbedtls_pk_info_t;
|
||||
/**
|
||||
* \brief Public key container
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_pk_context
|
||||
{
|
||||
const mbedtls_pk_info_t * pk_info; /**< Public key informations */
|
||||
void * pk_ctx; /**< Underlying public key context */
|
||||
|
@ -50,7 +50,8 @@ extern "C" {
|
||||
/**
|
||||
* Context for PKCS #11 private keys.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct mbedtls_pkcs11_context
|
||||
{
|
||||
pkcs11h_certificate_t pkcs11h_cert;
|
||||
int len;
|
||||
} mbedtls_pkcs11_context;
|
||||
|
@ -315,7 +315,8 @@ int mbedtls_platform_set_nv_seed(
|
||||
* \note This structure may be used to assist platform-specific
|
||||
* setup or teardown operations.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct mbedtls_platform_context
|
||||
{
|
||||
char dummy; /**< A placeholder member, as empty structs are not portable. */
|
||||
}
|
||||
mbedtls_platform_context;
|
||||
|
@ -25,7 +25,17 @@
|
||||
#ifndef MBEDTLS_PLATFORM_UTIL_H
|
||||
#define MBEDTLS_PLATFORM_UTIL_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE)
|
||||
#include "mbedtls/platform_time.h"
|
||||
#include <time.h>
|
||||
#endif /* MBEDTLS_HAVE_TIME_DATE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -55,6 +65,37 @@ extern "C" {
|
||||
*/
|
||||
void mbedtls_platform_zeroize( void *buf, size_t len );
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE)
|
||||
/**
|
||||
* \brief Platform-specific implementation of gmtime_r()
|
||||
*
|
||||
* The function is a thread-safe abstraction that behaves
|
||||
* similarly to the gmtime_r() function from Unix/POSIX.
|
||||
*
|
||||
* Mbed TLS will try to identify the underlying platform and
|
||||
* make use of an appropriate underlying implementation (e.g.
|
||||
* gmtime_r() for POSIX and gmtime_s() for Windows). If this is
|
||||
* not possible, then gmtime() will be used. In this case, calls
|
||||
* from the library to gmtime() will be guarded by the mutex
|
||||
* mbedtls_threading_gmtime_mutex if MBEDTLS_THREADING_C is
|
||||
* enabled. It is recommended that calls from outside the library
|
||||
* are also guarded by this mutex.
|
||||
*
|
||||
* If MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, then Mbed TLS will
|
||||
* unconditionally use the alternative implementation for
|
||||
* mbedtls_platform_gmtime_r() supplied by the user at compile time.
|
||||
*
|
||||
* \param tt Pointer to an object containing time (in seconds) since the
|
||||
* epoch to be converted
|
||||
* \param tm_buf Pointer to an object where the results will be stored
|
||||
*
|
||||
* \return Pointer to an object of type struct tm on success, otherwise
|
||||
* NULL
|
||||
*/
|
||||
struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt,
|
||||
struct tm *tm_buf );
|
||||
#endif /* MBEDTLS_HAVE_TIME_DATE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -52,7 +52,7 @@ extern "C" {
|
||||
|
||||
#if !defined(MBEDTLS_POLY1305_ALT)
|
||||
|
||||
typedef struct
|
||||
typedef struct mbedtls_poly1305_context
|
||||
{
|
||||
uint32_t r[4]; /** The value for 'r' (low 128 bits of the key). */
|
||||
uint32_t s[4]; /** The value for 's' (high 128 bits of the key). */
|
||||
|
@ -46,7 +46,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief RIPEMD-160 context structure
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_ripemd160_context
|
||||
{
|
||||
uint32_t total[2]; /*!< number of bytes processed */
|
||||
uint32_t state[5]; /*!< intermediate digest state */
|
||||
|
@ -92,7 +92,7 @@ extern "C" {
|
||||
* is deprecated. All manipulation should instead be done through
|
||||
* the public interface functions.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_rsa_context
|
||||
{
|
||||
int ver; /*!< Always 0.*/
|
||||
size_t len; /*!< The size of \p N in Bytes. */
|
||||
|
@ -58,7 +58,7 @@ extern "C" {
|
||||
* stronger message digests instead.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_sha1_context
|
||||
{
|
||||
uint32_t total[2]; /*!< The number of Bytes processed. */
|
||||
uint32_t state[5]; /*!< The intermediate digest state. */
|
||||
|
@ -53,7 +53,7 @@ extern "C" {
|
||||
* checksum calculations. The choice between these two is
|
||||
* made in the call to mbedtls_sha256_starts_ret().
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_sha256_context
|
||||
{
|
||||
uint32_t total[2]; /*!< The number of Bytes processed. */
|
||||
uint32_t state[8]; /*!< The intermediate digest state. */
|
||||
|
@ -52,7 +52,7 @@ extern "C" {
|
||||
* checksum calculations. The choice between these two is
|
||||
* made in the call to mbedtls_sha512_starts_ret().
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_sha512_context
|
||||
{
|
||||
uint64_t total[2]; /*!< The number of Bytes processed. */
|
||||
uint64_t state[8]; /*!< The intermediate digest state. */
|
||||
|
@ -121,6 +121,7 @@
|
||||
#define MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH -0x6600 /**< Couldn't set the hash for verifying CertificateVerify */
|
||||
#define MBEDTLS_ERR_SSL_CONTINUE_PROCESSING -0x6580 /**< Internal-only message signaling that further message-processing should be done */
|
||||
#define MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS -0x6500 /**< The asynchronous operation is not completed yet. */
|
||||
#define MBEDTLS_ERR_SSL_EARLY_MESSAGE -0x6480 /**< Internal-only message signaling that a message arrived early. */
|
||||
|
||||
/*
|
||||
* Various constants
|
||||
@ -242,6 +243,14 @@
|
||||
#define MBEDTLS_SSL_OUT_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Maximum number of heap-allocated bytes for the purpose of
|
||||
* DTLS handshake message reassembly and future message buffering.
|
||||
*/
|
||||
#if !defined(MBEDTLS_SSL_DTLS_MAX_BUFFERING)
|
||||
#define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768
|
||||
#endif
|
||||
|
||||
/* \} name SECTION: Module settings */
|
||||
|
||||
/*
|
||||
@ -1022,14 +1031,14 @@ struct mbedtls_ssl_context
|
||||
int renego_records_seen; /*!< Records since renego request, or with DTLS,
|
||||
number of retransmissions of request if
|
||||
renego_max_records is < 0 */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_RENEGOTIATION */
|
||||
|
||||
int major_ver; /*!< equal to MBEDTLS_SSL_MAJOR_VERSION_3 */
|
||||
int minor_ver; /*!< either 0 (SSL3) or 1 (TLS1.0) */
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
|
||||
unsigned badmac_seen; /*!< records with a bad MAC received */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
|
||||
|
||||
mbedtls_ssl_send_t *f_send; /*!< Callback for network send */
|
||||
mbedtls_ssl_recv_t *f_recv; /*!< Callback for network receive */
|
||||
@ -1085,11 +1094,11 @@ struct mbedtls_ssl_context
|
||||
uint16_t in_epoch; /*!< DTLS epoch for incoming records */
|
||||
size_t next_record_offset; /*!< offset of the next record in datagram
|
||||
(equal to in_left if none) */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
|
||||
uint64_t in_window_top; /*!< last validated record seq_num */
|
||||
uint64_t in_window; /*!< bitmask for replay detection */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
|
||||
|
||||
size_t in_hslen; /*!< current handshake message length,
|
||||
including the handshake header */
|
||||
@ -1098,6 +1107,11 @@ struct mbedtls_ssl_context
|
||||
int keep_current_message; /*!< drop or reuse current message
|
||||
on next call to record layer? */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
uint8_t disable_datagram_packing; /*!< Disable packing multiple records
|
||||
* within a single datagram. */
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
/*
|
||||
* Record layer (outgoing data)
|
||||
*/
|
||||
@ -1112,12 +1126,18 @@ struct mbedtls_ssl_context
|
||||
size_t out_msglen; /*!< record header: message length */
|
||||
size_t out_left; /*!< amount of data not yet written */
|
||||
|
||||
unsigned char cur_out_ctr[8]; /*!< Outgoing record sequence number. */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
uint16_t mtu; /*!< path mtu, used to fragment outgoing messages */
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
#if defined(MBEDTLS_ZLIB_SUPPORT)
|
||||
unsigned char *compress_buf; /*!< zlib data buffer */
|
||||
#endif
|
||||
#endif /* MBEDTLS_ZLIB_SUPPORT */
|
||||
#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
|
||||
signed char split_done; /*!< current record already splitted? */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
|
||||
|
||||
/*
|
||||
* PKI layer
|
||||
@ -1130,11 +1150,11 @@ struct mbedtls_ssl_context
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
char *hostname; /*!< expected peer CN for verification
|
||||
(and SNI if available) */
|
||||
#endif
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_ALPN)
|
||||
const char *alpn_chosen; /*!< negotiated protocol */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_ALPN */
|
||||
|
||||
/*
|
||||
* Information for DTLS hello verify
|
||||
@ -1142,7 +1162,7 @@ struct mbedtls_ssl_context
|
||||
#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
|
||||
unsigned char *cli_id; /*!< transport-level ID of the client */
|
||||
size_t cli_id_len; /*!< length of cli_id */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */
|
||||
|
||||
/*
|
||||
* Secure renegotiation
|
||||
@ -1154,7 +1174,7 @@ struct mbedtls_ssl_context
|
||||
size_t verify_data_len; /*!< length of verify data stored */
|
||||
char own_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]; /*!< previous handshake verify data */
|
||||
char peer_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]; /*!< previous handshake verify data */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_RENEGOTIATION */
|
||||
};
|
||||
|
||||
#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
|
||||
@ -1374,6 +1394,52 @@ void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl,
|
||||
mbedtls_ssl_recv_t *f_recv,
|
||||
mbedtls_ssl_recv_timeout_t *f_recv_timeout );
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
/**
|
||||
* \brief Set the Maximum Tranport Unit (MTU).
|
||||
* Special value: 0 means unset (no limit).
|
||||
* This represents the maximum size of a datagram payload
|
||||
* handled by the transport layer (usually UDP) as determined
|
||||
* by the network link and stack. In practice, this controls
|
||||
* the maximum size datagram the DTLS layer will pass to the
|
||||
* \c f_send() callback set using \c mbedtls_ssl_set_bio().
|
||||
*
|
||||
* \note The limit on datagram size is converted to a limit on
|
||||
* record payload by subtracting the current overhead of
|
||||
* encapsulation and encryption/authentication if any.
|
||||
*
|
||||
* \note This can be called at any point during the connection, for
|
||||
* example when a Path Maximum Transfer Unit (PMTU)
|
||||
* estimate becomes available from other sources,
|
||||
* such as lower (or higher) protocol layers.
|
||||
*
|
||||
* \note This setting only controls the size of the packets we send,
|
||||
* and does not restrict the size of the datagrams we're
|
||||
* willing to receive. Client-side, you can request the
|
||||
* server to use smaller records with \c
|
||||
* mbedtls_ssl_conf_max_frag_len().
|
||||
*
|
||||
* \note If both a MTU and a maximum fragment length have been
|
||||
* configured (or negotiated with the peer), the resulting
|
||||
* lower limit on record payload (see first note) is used.
|
||||
*
|
||||
* \note This can only be used to decrease the maximum size
|
||||
* of datagrams (hence records, see first note) sent. It
|
||||
* cannot be used to increase the maximum size of records over
|
||||
* the limit set by #MBEDTLS_SSL_OUT_CONTENT_LEN.
|
||||
*
|
||||
* \note Values lower than the current record layer expansion will
|
||||
* result in an error when trying to send data.
|
||||
*
|
||||
* \note Using record compression together with a non-zero MTU value
|
||||
* will result in an error when trying to send data.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param mtu Value of the path MTU in bytes
|
||||
*/
|
||||
void mbedtls_ssl_set_mtu( mbedtls_ssl_context *ssl, uint16_t mtu );
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
/**
|
||||
* \brief Set the timeout period for mbedtls_ssl_read()
|
||||
* (Default: no timeout.)
|
||||
@ -1757,6 +1823,38 @@ void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limi
|
||||
#endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
|
||||
/**
|
||||
* \brief Allow or disallow packing of multiple handshake records
|
||||
* within a single datagram.
|
||||
*
|
||||
* \param ssl The SSL context to configure.
|
||||
* \param allow_packing This determines whether datagram packing may
|
||||
* be used or not. A value of \c 0 means that every
|
||||
* record will be sent in a separate datagram; a
|
||||
* value of \c 1 means that, if space permits,
|
||||
* multiple handshake messages (including CCS) belonging to
|
||||
* a single flight may be packed within a single datagram.
|
||||
*
|
||||
* \note This is enabled by default and should only be disabled
|
||||
* for test purposes, or if datagram packing causes
|
||||
* interoperability issues with peers that don't support it.
|
||||
*
|
||||
* \note Allowing datagram packing reduces the network load since
|
||||
* there's less overhead if multiple messages share the same
|
||||
* datagram. Also, it increases the handshake efficiency
|
||||
* since messages belonging to a single datagram will not
|
||||
* be reordered in transit, and so future message buffering
|
||||
* or flight retransmission (if no buffering is used) as
|
||||
* means to deal with reordering are needed less frequently.
|
||||
*
|
||||
* \note Application records are not affected by this option and
|
||||
* are currently always sent in separate datagrams.
|
||||
*
|
||||
*/
|
||||
void mbedtls_ssl_set_datagram_packing( mbedtls_ssl_context *ssl,
|
||||
unsigned allow_packing );
|
||||
|
||||
/**
|
||||
* \brief Set retransmit timeout values for the DTLS handshake.
|
||||
* (DTLS only, no effect on TLS.)
|
||||
@ -2433,6 +2531,18 @@ void mbedtls_ssl_conf_cert_req_ca_list( mbedtls_ssl_config *conf,
|
||||
* (Client: set maximum fragment length to emit *and*
|
||||
* negotiate with the server during handshake)
|
||||
*
|
||||
* \note With TLS, this currently only affects ApplicationData (sent
|
||||
* with \c mbedtls_ssl_read()), not handshake messages.
|
||||
* With DTLS, this affects both ApplicationData and handshake.
|
||||
*
|
||||
* \note This sets the maximum length for a record's payload,
|
||||
* excluding record overhead that will be added to it, see
|
||||
* \c mbedtls_ssl_get_record_expansion().
|
||||
*
|
||||
* \note For DTLS, it is also possible to set a limit for the total
|
||||
* size of daragrams passed to the transport layer, including
|
||||
* record overhead, see \c mbedtls_ssl_set_mtu().
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param mfl_code Code for maximum fragment length (allowed values:
|
||||
* MBEDTLS_SSL_MAX_FRAG_LEN_512, MBEDTLS_SSL_MAX_FRAG_LEN_1024,
|
||||
@ -2695,6 +2805,9 @@ const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl );
|
||||
* \brief Return the (maximum) number of bytes added by the record
|
||||
* layer: header + encryption/MAC overhead (inc. padding)
|
||||
*
|
||||
* \note This function is not available (always returns an error)
|
||||
* when record compression is enabled.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return Current maximum record expansion in bytes, or
|
||||
@ -2709,12 +2822,8 @@ int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl );
|
||||
* This is the value negotiated with peer if any,
|
||||
* or the locally configured value.
|
||||
*
|
||||
* \note With DTLS, \c mbedtls_ssl_write() will return an error if
|
||||
* called with a larger length value.
|
||||
* With TLS, \c mbedtls_ssl_write() will fragment the input if
|
||||
* necessary and return the number of bytes written; it is up
|
||||
* to the caller to call \c mbedtls_ssl_write() again in
|
||||
* order to send the remaining bytes if any.
|
||||
* \sa mbedtls_ssl_conf_max_frag_len()
|
||||
* \sa mbedtls_ssl_get_max_record_payload()
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
@ -2723,6 +2832,34 @@ int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl );
|
||||
size_t mbedtls_ssl_get_max_frag_len( const mbedtls_ssl_context *ssl );
|
||||
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
|
||||
|
||||
/**
|
||||
* \brief Return the current maximum outgoing record payload in bytes.
|
||||
* This takes into account the config.h setting \c
|
||||
* MBEDTLS_SSL_OUT_CONTENT_LEN, the configured and negotiated
|
||||
* max fragment length extension if used, and for DTLS the
|
||||
* path MTU as configured and current record expansion.
|
||||
*
|
||||
* \note With DTLS, \c mbedtls_ssl_write() will return an error if
|
||||
* called with a larger length value.
|
||||
* With TLS, \c mbedtls_ssl_write() will fragment the input if
|
||||
* necessary and return the number of bytes written; it is up
|
||||
* to the caller to call \c mbedtls_ssl_write() again in
|
||||
* order to send the remaining bytes if any.
|
||||
*
|
||||
* \note This function is not available (always returns an error)
|
||||
* when record compression is enabled.
|
||||
*
|
||||
* \sa mbedtls_ssl_set_mtu()
|
||||
* \sa mbedtls_ssl_get_max_frag_len()
|
||||
* \sa mbedtls_ssl_get_record_expansion()
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return Current maximum payload for an outgoing record,
|
||||
* or a negative error code.
|
||||
*/
|
||||
int mbedtls_ssl_get_max_out_record_payload( const mbedtls_ssl_context *ssl );
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
/**
|
||||
* \brief Return the peer certificate from the current connection
|
||||
|
@ -50,7 +50,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief Context for the default cookie functions.
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_ssl_cookie_ctx
|
||||
{
|
||||
mbedtls_md_context_t hmac_ctx; /*!< context for the HMAC portion */
|
||||
#if !defined(MBEDTLS_HAVE_TIME)
|
||||
|
@ -155,6 +155,9 @@
|
||||
#define MBEDTLS_SSL_OUT_PAYLOAD_LEN ( MBEDTLS_SSL_PAYLOAD_OVERHEAD + \
|
||||
( MBEDTLS_SSL_OUT_CONTENT_LEN ) )
|
||||
|
||||
/* The maximum number of buffered handshake messages. */
|
||||
#define MBEDTLS_SSL_MAX_BUFFERED_HS 4
|
||||
|
||||
/* Maximum length we can advertise as our max content length for
|
||||
RFC 6066 max_fragment_length extension negotiation purposes
|
||||
(the lesser of both sizes, if they are unequal.)
|
||||
@ -294,18 +297,45 @@ struct mbedtls_ssl_handshake_params
|
||||
unsigned char verify_cookie_len; /*!< Cli: cookie length
|
||||
Srv: flag for sending a cookie */
|
||||
|
||||
unsigned char *hs_msg; /*!< Reassembled handshake message */
|
||||
|
||||
uint32_t retransmit_timeout; /*!< Current value of timeout */
|
||||
unsigned char retransmit_state; /*!< Retransmission state */
|
||||
mbedtls_ssl_flight_item *flight; /*!< Current outgoing flight */
|
||||
mbedtls_ssl_flight_item *cur_msg; /*!< Current message in flight */
|
||||
mbedtls_ssl_flight_item *flight; /*!< Current outgoing flight */
|
||||
mbedtls_ssl_flight_item *cur_msg; /*!< Current message in flight */
|
||||
unsigned char *cur_msg_p; /*!< Position in current message */
|
||||
unsigned int in_flight_start_seq; /*!< Minimum message sequence in the
|
||||
flight being received */
|
||||
mbedtls_ssl_transform *alt_transform_out; /*!< Alternative transform for
|
||||
resending messages */
|
||||
unsigned char alt_out_ctr[8]; /*!< Alternative record epoch/counter
|
||||
for resending messages */
|
||||
|
||||
struct
|
||||
{
|
||||
size_t total_bytes_buffered; /*!< Cumulative size of heap allocated
|
||||
* buffers used for message buffering. */
|
||||
|
||||
uint8_t seen_ccs; /*!< Indicates if a CCS message has
|
||||
* been seen in the current flight. */
|
||||
|
||||
struct mbedtls_ssl_hs_buffer
|
||||
{
|
||||
unsigned is_valid : 1;
|
||||
unsigned is_fragmented : 1;
|
||||
unsigned is_complete : 1;
|
||||
unsigned char *data;
|
||||
size_t data_len;
|
||||
} hs[MBEDTLS_SSL_MAX_BUFFERED_HS];
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned char *data;
|
||||
size_t len;
|
||||
unsigned epoch;
|
||||
} future_record;
|
||||
|
||||
} buffering;
|
||||
|
||||
uint16_t mtu; /*!< Handshake mtu, used to fragment outgoing messages */
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
/*
|
||||
@ -364,6 +394,8 @@ struct mbedtls_ssl_handshake_params
|
||||
#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
|
||||
};
|
||||
|
||||
typedef struct mbedtls_ssl_hs_buffer mbedtls_ssl_hs_buffer;
|
||||
|
||||
/*
|
||||
* This structure contains a full set of runtime transform parameters
|
||||
* either in negotiation or active.
|
||||
@ -478,7 +510,6 @@ 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 );
|
||||
@ -490,7 +521,10 @@ void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl );
|
||||
* of the logic of (D)TLS from the implementation
|
||||
* of the secure transport.
|
||||
*
|
||||
* \param ssl SSL context to use
|
||||
* \param ssl The SSL context to use.
|
||||
* \param update_hs_digest This indicates if the handshake digest
|
||||
* should be automatically updated in case
|
||||
* a handshake message is found.
|
||||
*
|
||||
* \return 0 or non-zero error code.
|
||||
*
|
||||
@ -556,10 +590,12 @@ void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl );
|
||||
* following the above definition.
|
||||
*
|
||||
*/
|
||||
int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl );
|
||||
int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl,
|
||||
unsigned update_hs_digest );
|
||||
int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want );
|
||||
|
||||
int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl );
|
||||
int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl );
|
||||
int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush );
|
||||
int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl );
|
||||
|
||||
int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl );
|
||||
@ -668,6 +704,7 @@ static inline size_t mbedtls_ssl_hs_hdr_len( const mbedtls_ssl_context *ssl )
|
||||
void mbedtls_ssl_send_flight_completed( mbedtls_ssl_context *ssl );
|
||||
void mbedtls_ssl_recv_flight_completed( mbedtls_ssl_context *ssl );
|
||||
int mbedtls_ssl_resend( mbedtls_ssl_context *ssl );
|
||||
int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl );
|
||||
#endif
|
||||
|
||||
/* Visible for testing purposes only */
|
||||
|
@ -44,7 +44,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief Information for session ticket protection
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_ssl_ticket_key
|
||||
{
|
||||
unsigned char name[4]; /*!< random key identifier */
|
||||
uint32_t generation_time; /*!< key generation timestamp (seconds) */
|
||||
@ -55,7 +55,7 @@ mbedtls_ssl_ticket_key;
|
||||
/**
|
||||
* \brief Context for session ticket handling functions
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_ssl_ticket_context
|
||||
{
|
||||
mbedtls_ssl_ticket_key keys[2]; /*!< ticket protection keys */
|
||||
unsigned char active; /*!< index of the currently active key */
|
||||
|
@ -42,7 +42,7 @@ extern "C" {
|
||||
|
||||
#if defined(MBEDTLS_THREADING_PTHREAD)
|
||||
#include <pthread.h>
|
||||
typedef struct
|
||||
typedef struct mbedtls_threading_mutex_t
|
||||
{
|
||||
pthread_mutex_t mutex;
|
||||
char is_valid;
|
||||
@ -99,6 +99,17 @@ extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex );
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex;
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
|
||||
/* This mutex may or may not be used in the default definition of
|
||||
* mbedtls_platform_gmtime_r(), but in order to determine that,
|
||||
* we need to check POSIX features, hence modify _POSIX_C_SOURCE.
|
||||
* With the current approach, this declaration is orphaned, lacking
|
||||
* an accompanying definition, in case mbedtls_platform_gmtime_r()
|
||||
* doesn't need it, but that's not a problem. */
|
||||
extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex;
|
||||
#endif /* MBEDTLS_HAVE_TIME_DATE && !MBEDTLS_PLATFORM_GMTIME_R_ALT */
|
||||
|
||||
#endif /* MBEDTLS_THREADING_C */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -51,7 +51,7 @@ struct mbedtls_timing_hr_time
|
||||
/**
|
||||
* \brief Context for mbedtls_timing_set/get_delay()
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_timing_delay_context
|
||||
{
|
||||
struct mbedtls_timing_hr_time timer;
|
||||
uint32_t int_ms;
|
||||
|
@ -39,17 +39,17 @@
|
||||
* Major, Minor, Patchlevel
|
||||
*/
|
||||
#define MBEDTLS_VERSION_MAJOR 2
|
||||
#define MBEDTLS_VERSION_MINOR 12
|
||||
#define MBEDTLS_VERSION_PATCH 0
|
||||
#define MBEDTLS_VERSION_MINOR 13
|
||||
#define MBEDTLS_VERSION_PATCH 1
|
||||
|
||||
/**
|
||||
* The single version number has the following structure:
|
||||
* MMNNPP00
|
||||
* Major version | Minor version | Patch version
|
||||
*/
|
||||
#define MBEDTLS_VERSION_NUMBER 0x020C0000
|
||||
#define MBEDTLS_VERSION_STRING "2.12.0"
|
||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.12.0"
|
||||
#define MBEDTLS_VERSION_NUMBER 0x020D0100
|
||||
#define MBEDTLS_VERSION_STRING "2.13.1"
|
||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.13.1"
|
||||
|
||||
#if defined(MBEDTLS_VERSION_C)
|
||||
|
||||
|
@ -105,7 +105,7 @@ mbedtls_x509_crt;
|
||||
*
|
||||
* All lists are bitfields, built by ORing flags from MBEDTLS_X509_ID_FLAG().
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_x509_crt_profile
|
||||
{
|
||||
uint32_t allowed_mds; /**< MDs for signatures */
|
||||
uint32_t allowed_pks; /**< PK algs for signatures */
|
||||
|
@ -50,7 +50,7 @@ extern "C" {
|
||||
/**
|
||||
* \brief XTEA context structure
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct mbedtls_xtea_context
|
||||
{
|
||||
uint32_t k[4]; /*!< key */
|
||||
}
|
||||
|
57
tools/sdk/include/mbedtls/sha1_alt.h
Normal file
57
tools/sdk/include/mbedtls/sha1_alt.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* SHA-1 implementation with hardware ESP32 support added.
|
||||
* Uses mbedTLS software implementation for failover when concurrent
|
||||
* SHA operations are in use.
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* Additions Copyright (C) 2016, Espressif Systems (Shanghai) PTE LTD
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef _SHA1_ALT_H_
|
||||
#define _SHA1_ALT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA1_ALT)
|
||||
|
||||
typedef enum {
|
||||
ESP_MBEDTLS_SHA1_UNUSED, /* first block hasn't been processed yet */
|
||||
ESP_MBEDTLS_SHA1_HARDWARE, /* using hardware SHA engine */
|
||||
ESP_MBEDTLS_SHA1_SOFTWARE, /* using software SHA */
|
||||
} esp_mbedtls_sha1_mode;
|
||||
|
||||
/**
|
||||
* \brief SHA-1 context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t total[2]; /*!< number of bytes processed */
|
||||
uint32_t state[5]; /*!< intermediate digest state */
|
||||
unsigned char buffer[64]; /*!< data block being processed */
|
||||
esp_mbedtls_sha1_mode mode;
|
||||
}
|
||||
mbedtls_sha1_context;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
57
tools/sdk/include/mbedtls/sha256_alt.h
Normal file
57
tools/sdk/include/mbedtls/sha256_alt.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* SHA-256 implementation with hardware ESP32 support added.
|
||||
* Uses mbedTLS software implementation for failover when concurrent
|
||||
* SHA operations are in use.
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* Additions Copyright (C) 2016, Espressif Systems (Shanghai) PTE LTD
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef _SHA256_ALT_H_
|
||||
#define _SHA256_ALT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA256_ALT)
|
||||
|
||||
typedef enum {
|
||||
ESP_MBEDTLS_SHA256_UNUSED, /* first block hasn't been processed yet */
|
||||
ESP_MBEDTLS_SHA256_HARDWARE, /* using hardware SHA engine */
|
||||
ESP_MBEDTLS_SHA256_SOFTWARE, /* using software SHA */
|
||||
} esp_mbedtls_sha256_mode;
|
||||
|
||||
/**
|
||||
* \brief SHA-256 context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t total[2]; /*!< number of bytes processed */
|
||||
uint32_t state[8]; /*!< intermediate digest state */
|
||||
unsigned char buffer[64]; /*!< data block being processed */
|
||||
int is224; /*!< 0 => SHA-256, else SHA-224 */
|
||||
esp_mbedtls_sha256_mode mode;
|
||||
}
|
||||
mbedtls_sha256_context;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
57
tools/sdk/include/mbedtls/sha512_alt.h
Normal file
57
tools/sdk/include/mbedtls/sha512_alt.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* SHA-512 implementation with hardware ESP32 support added.
|
||||
* Uses mbedTLS software implementation for failover when concurrent
|
||||
* SHA operations are in use.
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* Additions Copyright (C) 2016, Espressif Systems (Shanghai) PTE LTD
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef _SHA512_ALT_H_
|
||||
#define _SHA512_ALT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA512_ALT)
|
||||
|
||||
typedef enum {
|
||||
ESP_MBEDTLS_SHA512_UNUSED, /* first block hasn't been processed yet */
|
||||
ESP_MBEDTLS_SHA512_HARDWARE, /* using hardware SHA engine */
|
||||
ESP_MBEDTLS_SHA512_SOFTWARE, /* using software SHA */
|
||||
} esp_mbedtls_sha512_mode;
|
||||
|
||||
/**
|
||||
* \brief SHA-512 context structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t total[2]; /*!< number of bytes processed */
|
||||
uint64_t state[8]; /*!< intermediate digest state */
|
||||
unsigned char buffer[128]; /*!< data block being processed */
|
||||
int is384; /*!< 0 => SHA-512, else SHA-384 */
|
||||
esp_mbedtls_sha512_mode mode;
|
||||
}
|
||||
mbedtls_sha512_context;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user