mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-01 04:50:58 +02:00
Update IDF to 9a26296
This commit is contained in:
@ -39,6 +39,11 @@
|
||||
#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */
|
||||
#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */
|
||||
|
||||
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
|
||||
!defined(inline) && !defined(__cplusplus)
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_AES_ALT)
|
||||
// Regular implementation
|
||||
//
|
||||
@ -253,10 +258,12 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
|
||||
* \param ctx AES context
|
||||
* \param input Plaintext block
|
||||
* \param output Output (ciphertext) block
|
||||
*
|
||||
* \return 0 if successful
|
||||
*/
|
||||
void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
|
||||
const unsigned char input[16],
|
||||
unsigned char output[16] );
|
||||
int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
|
||||
const unsigned char input[16],
|
||||
unsigned char output[16] );
|
||||
|
||||
/**
|
||||
* \brief Internal AES block decryption function
|
||||
@ -266,10 +273,49 @@ void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
|
||||
* \param ctx AES context
|
||||
* \param input Ciphertext block
|
||||
* \param output Output (plaintext) block
|
||||
*
|
||||
* \return 0 if successful
|
||||
*/
|
||||
void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
|
||||
const unsigned char input[16],
|
||||
unsigned char output[16] );
|
||||
int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
|
||||
const unsigned char input[16],
|
||||
unsigned char output[16] );
|
||||
|
||||
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
|
||||
#if defined(MBEDTLS_DEPRECATED_WARNING)
|
||||
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
|
||||
#else
|
||||
#define MBEDTLS_DEPRECATED
|
||||
#endif
|
||||
/**
|
||||
* \brief Deprecated internal AES block encryption function
|
||||
* without return value.
|
||||
*
|
||||
* \deprecated Superseded by mbedtls_aes_encrypt_ext() in 2.5.0
|
||||
*
|
||||
* \param ctx AES context
|
||||
* \param input Plaintext block
|
||||
* \param output Output (ciphertext) block
|
||||
*/
|
||||
MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
|
||||
const unsigned char input[16],
|
||||
unsigned char output[16] );
|
||||
|
||||
/**
|
||||
* \brief Deprecated internal AES block decryption function
|
||||
* without return value.
|
||||
*
|
||||
* \deprecated Superseded by mbedtls_aes_decrypt_ext() in 2.5.0
|
||||
*
|
||||
* \param ctx AES context
|
||||
* \param input Ciphertext block
|
||||
* \param output Output (plaintext) block
|
||||
*/
|
||||
MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
|
||||
const unsigned char input[16],
|
||||
unsigned char output[16] );
|
||||
|
||||
#undef MBEDTLS_DEPRECATED
|
||||
#endif /* !MBEDTLS_DEPRECATED_REMOVED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -105,36 +105,71 @@
|
||||
/*
|
||||
* Define the base integer type, architecture-wise.
|
||||
*
|
||||
* 32-bit integers can be forced on 64-bit arches (eg. for testing purposes)
|
||||
* by defining MBEDTLS_HAVE_INT32 and undefining MBEDTLS_HAVE_ASM
|
||||
* 32 or 64-bit integer types can be forced regardless of the underlying
|
||||
* architecture by defining MBEDTLS_HAVE_INT32 or MBEDTLS_HAVE_INT64
|
||||
* respectively and undefining MBEDTLS_HAVE_ASM.
|
||||
*
|
||||
* Double-width integers (e.g. 128-bit in 64-bit architectures) can be
|
||||
* disabled by defining MBEDTLS_NO_UDBL_DIVISION.
|
||||
*/
|
||||
#if ( ! defined(MBEDTLS_HAVE_INT32) && \
|
||||
defined(_MSC_VER) && defined(_M_AMD64) )
|
||||
#define MBEDTLS_HAVE_INT64
|
||||
typedef int64_t mbedtls_mpi_sint;
|
||||
typedef uint64_t mbedtls_mpi_uint;
|
||||
#else
|
||||
#if ( ! defined(MBEDTLS_HAVE_INT32) && \
|
||||
defined(__GNUC__) && ( \
|
||||
defined(__amd64__) || defined(__x86_64__) || \
|
||||
defined(__ppc64__) || defined(__powerpc64__) || \
|
||||
defined(__ia64__) || defined(__alpha__) || \
|
||||
(defined(__sparc__) && defined(__arch64__)) || \
|
||||
defined(__s390x__) || defined(__mips64) ) )
|
||||
#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
|
||||
#define MBEDTLS_HAVE_INT32
|
||||
typedef int32_t mbedtls_mpi_sint;
|
||||
typedef uint32_t mbedtls_mpi_uint;
|
||||
typedef uint64_t mbedtls_t_udbl;
|
||||
#define MBEDTLS_HAVE_UDBL
|
||||
#endif /* !MBEDTLS_HAVE_INT32 && __GNUC__ && 64-bit platform */
|
||||
#endif /* !MBEDTLS_HAVE_INT32 && _MSC_VER && _M_AMD64 */
|
||||
#if !defined(MBEDTLS_HAVE_INT32)
|
||||
#if defined(_MSC_VER) && defined(_M_AMD64)
|
||||
/* Always choose 64-bit when using MSC */
|
||||
#if !defined(MBEDTLS_HAVE_INT64)
|
||||
#define MBEDTLS_HAVE_INT64
|
||||
#endif /* !MBEDTLS_HAVE_INT64 */
|
||||
typedef int64_t mbedtls_mpi_sint;
|
||||
typedef uint64_t mbedtls_mpi_uint;
|
||||
#elif defined(__GNUC__) && ( \
|
||||
defined(__amd64__) || defined(__x86_64__) || \
|
||||
defined(__ppc64__) || defined(__powerpc64__) || \
|
||||
defined(__ia64__) || defined(__alpha__) || \
|
||||
( defined(__sparc__) && defined(__arch64__) ) || \
|
||||
defined(__s390x__) || defined(__mips64) )
|
||||
#if !defined(MBEDTLS_HAVE_INT64)
|
||||
#define MBEDTLS_HAVE_INT64
|
||||
#endif /* MBEDTLS_HAVE_INT64 */
|
||||
typedef int64_t mbedtls_mpi_sint;
|
||||
typedef uint64_t mbedtls_mpi_uint;
|
||||
#if !defined(MBEDTLS_NO_UDBL_DIVISION)
|
||||
/* mbedtls_t_udbl defined as 128-bit unsigned int */
|
||||
typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI)));
|
||||
#define MBEDTLS_HAVE_UDBL
|
||||
#endif /* !MBEDTLS_NO_UDBL_DIVISION */
|
||||
#elif defined(__ARMCC_VERSION) && defined(__aarch64__)
|
||||
/*
|
||||
* __ARMCC_VERSION is defined for both armcc and armclang and
|
||||
* __aarch64__ is only defined by armclang when compiling 64-bit code
|
||||
*/
|
||||
#if !defined(MBEDTLS_HAVE_INT64)
|
||||
#define MBEDTLS_HAVE_INT64
|
||||
#endif /* !MBEDTLS_HAVE_INT64 */
|
||||
typedef int64_t mbedtls_mpi_sint;
|
||||
typedef uint64_t mbedtls_mpi_uint;
|
||||
#if !defined(MBEDTLS_NO_UDBL_DIVISION)
|
||||
/* mbedtls_t_udbl defined as 128-bit unsigned int */
|
||||
typedef __uint128_t mbedtls_t_udbl;
|
||||
#define MBEDTLS_HAVE_UDBL
|
||||
#endif /* !MBEDTLS_NO_UDBL_DIVISION */
|
||||
#elif defined(MBEDTLS_HAVE_INT64)
|
||||
/* Force 64-bit integers with unknown compiler */
|
||||
typedef int64_t mbedtls_mpi_sint;
|
||||
typedef uint64_t mbedtls_mpi_uint;
|
||||
#endif
|
||||
#endif /* !MBEDTLS_HAVE_INT32 */
|
||||
|
||||
#if !defined(MBEDTLS_HAVE_INT64)
|
||||
/* Default to 32-bit compilation */
|
||||
#if !defined(MBEDTLS_HAVE_INT32)
|
||||
#define MBEDTLS_HAVE_INT32
|
||||
#endif /* !MBEDTLS_HAVE_INT32 */
|
||||
typedef int32_t mbedtls_mpi_sint;
|
||||
typedef uint32_t mbedtls_mpi_uint;
|
||||
#if !defined(MBEDTLS_NO_UDBL_DIVISION)
|
||||
typedef uint64_t mbedtls_t_udbl;
|
||||
#define MBEDTLS_HAVE_UDBL
|
||||
#endif /* !MBEDTLS_NO_UDBL_DIVISION */
|
||||
#endif /* !MBEDTLS_HAVE_INT64 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -342,7 +377,7 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix,
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
/**
|
||||
* \brief Read X from an opened file
|
||||
* \brief Read MPI from a line in an opened file
|
||||
*
|
||||
* \param X Destination MPI
|
||||
* \param radix Input numeric base
|
||||
@ -351,6 +386,15 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix,
|
||||
* \return 0 if successful, MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if
|
||||
* the file read buffer is too small or a
|
||||
* MBEDTLS_ERR_MPI_XXX error code
|
||||
*
|
||||
* \note On success, this function advances the file stream
|
||||
* to the end of the current line or to EOF.
|
||||
*
|
||||
* The function returns 0 on an empty line.
|
||||
*
|
||||
* Leading whitespaces are ignored, as is a
|
||||
* '0x' prefix for radix 16.
|
||||
*
|
||||
*/
|
||||
int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin );
|
||||
|
||||
@ -667,8 +711,8 @@ int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B
|
||||
*
|
||||
* \return 0 if successful,
|
||||
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
|
||||
* MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is negative or nil
|
||||
MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N
|
||||
* MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is <= 1,
|
||||
MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N.
|
||||
*/
|
||||
int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N );
|
||||
|
||||
|
@ -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
|
||||
@ -145,6 +150,38 @@
|
||||
#error "MBEDTLS_GCM_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
|
||||
#error "MBEDTLS_ECP_RANDOMIZE_JAC_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_ADD_MIXED_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
|
||||
#error "MBEDTLS_ECP_ADD_MIXED_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
|
||||
#error "MBEDTLS_ECP_DOUBLE_JAC_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
|
||||
#error "MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
|
||||
#error "MBEDTLS_ECP_NORMALIZE_JAC_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
|
||||
#error "MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
|
||||
#error "MBEDTLS_ECP_RANDOMIZE_MXZ_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
|
||||
#error "MBEDTLS_ECP_NORMALIZE_MXZ_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVEGE_C) && !defined(MBEDTLS_TIMING_C)
|
||||
#error "MBEDTLS_HAVEGE_C defined, but not all prerequisites"
|
||||
#endif
|
||||
@ -256,6 +293,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
|
||||
@ -352,6 +419,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"
|
||||
@ -577,6 +650,15 @@
|
||||
#error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_INT32) && defined(MBEDTLS_HAVE_INT64)
|
||||
#error "MBEDTLS_HAVE_INT32 and MBEDTLS_HAVE_INT64 cannot be defined simultaneously"
|
||||
#endif /* MBEDTLS_HAVE_INT32 && MBEDTLS_HAVE_INT64 */
|
||||
|
||||
#if ( defined(MBEDTLS_HAVE_INT32) || defined(MBEDTLS_HAVE_INT64) ) && \
|
||||
defined(MBEDTLS_HAVE_ASM)
|
||||
#error "MBEDTLS_HAVE_INT32/MBEDTLS_HAVE_INT64 and MBEDTLS_HAVE_ASM cannot be defined simultaneously"
|
||||
#endif /* (MBEDTLS_HAVE_INT32 || MBEDTLS_HAVE_INT64) && MBEDTLS_HAVE_ASM */
|
||||
|
||||
/*
|
||||
* Avoid warning from -pedantic. This is a convenient place for this
|
||||
* workaround since this is included by every single file before the
|
||||
|
@ -176,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.
|
||||
*/
|
||||
@ -241,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;
|
||||
|
||||
/**
|
||||
|
170
tools/sdk/include/mbedtls/mbedtls/cmac.h
Normal file
170
tools/sdk/include/mbedtls/mbedtls/cmac.h
Normal file
@ -0,0 +1,170 @@
|
||||
/**
|
||||
* \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 initialized cipher context.
|
||||
*
|
||||
* \param ctx Cipher context. This should be a cipher context,
|
||||
* initialized to be one of the following types:
|
||||
* MBEDTLS_CIPHER_AES_128_ECB, MBEDTLS_CIPHER_AES_192_ECB,
|
||||
* MBEDTLS_CIPHER_AES_256_ECB or
|
||||
* MBEDTLS_CIPHER_DES_EDE3_ECB.
|
||||
* \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( cmac 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 */
|
@ -207,9 +207,6 @@
|
||||
#if defined MBEDTLS_ERROR_C
|
||||
#define POLARSSL_ERROR_C MBEDTLS_ERROR_C
|
||||
#endif
|
||||
#if defined MBEDTLS_ERROR_STRERROR_BC
|
||||
#define POLARSSL_ERROR_STRERROR_BC MBEDTLS_ERROR_STRERROR_BC
|
||||
#endif
|
||||
#if defined MBEDTLS_ERROR_STRERROR_DUMMY
|
||||
#define POLARSSL_ERROR_STRERROR_DUMMY MBEDTLS_ERROR_STRERROR_DUMMY
|
||||
#endif
|
||||
@ -318,9 +315,6 @@
|
||||
#if defined MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
#define POLARSSL_MEMORY_BUFFER_ALLOC_C MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
#endif
|
||||
#if defined MBEDTLS_MEMORY_C
|
||||
#define POLARSSL_MEMORY_C MBEDTLS_MEMORY_C
|
||||
#endif
|
||||
#if defined MBEDTLS_MEMORY_DEBUG
|
||||
#define POLARSSL_MEMORY_DEBUG MBEDTLS_MEMORY_DEBUG
|
||||
#endif
|
||||
@ -345,9 +339,6 @@
|
||||
#if defined MBEDTLS_PADLOCK_C
|
||||
#define POLARSSL_PADLOCK_C MBEDTLS_PADLOCK_C
|
||||
#endif
|
||||
#if defined MBEDTLS_PBKDF2_C
|
||||
#define POLARSSL_PBKDF2_C MBEDTLS_PBKDF2_C
|
||||
#endif
|
||||
#if defined MBEDTLS_PEM_PARSE_C
|
||||
#define POLARSSL_PEM_PARSE_C MBEDTLS_PEM_PARSE_C
|
||||
#endif
|
||||
@ -429,9 +420,6 @@
|
||||
#if defined MBEDTLS_PLATFORM_STD_FREE
|
||||
#define POLARSSL_PLATFORM_STD_FREE MBEDTLS_PLATFORM_STD_FREE
|
||||
#endif
|
||||
#if defined MBEDTLS_PLATFORM_STD_MALLOC
|
||||
#define POLARSSL_PLATFORM_STD_MALLOC MBEDTLS_PLATFORM_STD_MALLOC
|
||||
#endif
|
||||
#if defined MBEDTLS_PLATFORM_STD_MEM_HDR
|
||||
#define POLARSSL_PLATFORM_STD_MEM_HDR MBEDTLS_PLATFORM_STD_MEM_HDR
|
||||
#endif
|
||||
@ -492,12 +480,6 @@
|
||||
#if defined MBEDTLS_SHA512_PROCESS_ALT
|
||||
#define POLARSSL_SHA512_PROCESS_ALT MBEDTLS_SHA512_PROCESS_ALT
|
||||
#endif
|
||||
#if defined MBEDTLS_SSL_AEAD_RANDOM_IV
|
||||
#define POLARSSL_SSL_AEAD_RANDOM_IV MBEDTLS_SSL_AEAD_RANDOM_IV
|
||||
#endif
|
||||
#if defined MBEDTLS_SSL_ALERT_MESSAGES
|
||||
#define POLARSSL_SSL_ALERT_MESSAGES MBEDTLS_SSL_ALERT_MESSAGES
|
||||
#endif
|
||||
#if defined MBEDTLS_SSL_ALL_ALERT_MESSAGES
|
||||
#define POLARSSL_SSL_ALL_ALERT_MESSAGES MBEDTLS_SSL_ALL_ALERT_MESSAGES
|
||||
#endif
|
||||
@ -522,9 +504,6 @@
|
||||
#if defined MBEDTLS_SSL_DEBUG_ALL
|
||||
#define POLARSSL_SSL_DEBUG_ALL MBEDTLS_SSL_DEBUG_ALL
|
||||
#endif
|
||||
#if defined MBEDTLS_SSL_DISABLE_RENEGOTIATION
|
||||
#define POLARSSL_SSL_DISABLE_RENEGOTIATION MBEDTLS_SSL_DISABLE_RENEGOTIATION
|
||||
#endif
|
||||
#if defined MBEDTLS_SSL_DTLS_ANTI_REPLAY
|
||||
#define POLARSSL_SSL_DTLS_ANTI_REPLAY MBEDTLS_SSL_DTLS_ANTI_REPLAY
|
||||
#endif
|
||||
@ -752,7 +731,6 @@
|
||||
#define KU_KEY_ENCIPHERMENT MBEDTLS_X509_KU_KEY_ENCIPHERMENT
|
||||
#define KU_NON_REPUDIATION MBEDTLS_X509_KU_NON_REPUDIATION
|
||||
#define LN_2_DIV_LN_10_SCALE100 MBEDTLS_LN_2_DIV_LN_10_SCALE100
|
||||
#define MD_CONTEXT_T_INIT MBEDTLS_MD_CONTEXT_T_INIT
|
||||
#define MEMORY_VERIFY_ALLOC MBEDTLS_MEMORY_VERIFY_ALLOC
|
||||
#define MEMORY_VERIFY_ALWAYS MBEDTLS_MEMORY_VERIFY_ALWAYS
|
||||
#define MEMORY_VERIFY_FREE MBEDTLS_MEMORY_VERIFY_FREE
|
||||
@ -1017,19 +995,13 @@
|
||||
#define POLARSSL_CONFIG_H MBEDTLS_CONFIG_H
|
||||
#define POLARSSL_CTR_DRBG_H MBEDTLS_CTR_DRBG_H
|
||||
#define POLARSSL_DEBUG_H MBEDTLS_DEBUG_H
|
||||
#define POLARSSL_DEBUG_LOG_FULL MBEDTLS_DEBUG_LOG_FULL
|
||||
#define POLARSSL_DEBUG_LOG_RAW MBEDTLS_DEBUG_LOG_RAW
|
||||
#define POLARSSL_DECRYPT MBEDTLS_DECRYPT
|
||||
#define POLARSSL_DES_H MBEDTLS_DES_H
|
||||
#define POLARSSL_DHM_H MBEDTLS_DHM_H
|
||||
#define POLARSSL_DHM_RFC2409_MODP_1024_G MBEDTLS_DHM_RFC2409_MODP_1024_G
|
||||
#define POLARSSL_DHM_RFC2409_MODP_1024_P MBEDTLS_DHM_RFC2409_MODP_1024_P
|
||||
#define POLARSSL_DHM_RFC3526_MODP_2048_G MBEDTLS_DHM_RFC3526_MODP_2048_G
|
||||
#define POLARSSL_DHM_RFC3526_MODP_2048_P MBEDTLS_DHM_RFC3526_MODP_2048_P
|
||||
#define POLARSSL_DHM_RFC3526_MODP_3072_G MBEDTLS_DHM_RFC3526_MODP_3072_G
|
||||
#define POLARSSL_DHM_RFC3526_MODP_3072_P MBEDTLS_DHM_RFC3526_MODP_3072_P
|
||||
#define POLARSSL_DHM_RFC5114_MODP_1024_G MBEDTLS_DHM_RFC5114_MODP_1024_G
|
||||
#define POLARSSL_DHM_RFC5114_MODP_1024_P MBEDTLS_DHM_RFC5114_MODP_1024_P
|
||||
#define POLARSSL_DHM_RFC5114_MODP_2048_G MBEDTLS_DHM_RFC5114_MODP_2048_G
|
||||
#define POLARSSL_DHM_RFC5114_MODP_2048_P MBEDTLS_DHM_RFC5114_MODP_2048_P
|
||||
#define POLARSSL_ECDH_H MBEDTLS_ECDH_H
|
||||
@ -1117,9 +1089,6 @@
|
||||
#define POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR
|
||||
#define POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG
|
||||
#define POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG
|
||||
#define POLARSSL_ERR_MD2_FILE_IO_ERROR MBEDTLS_ERR_MD2_FILE_IO_ERROR
|
||||
#define POLARSSL_ERR_MD4_FILE_IO_ERROR MBEDTLS_ERR_MD4_FILE_IO_ERROR
|
||||
#define POLARSSL_ERR_MD5_FILE_IO_ERROR MBEDTLS_ERR_MD5_FILE_IO_ERROR
|
||||
#define POLARSSL_ERR_MD_ALLOC_FAILED MBEDTLS_ERR_MD_ALLOC_FAILED
|
||||
#define POLARSSL_ERR_MD_BAD_INPUT_DATA MBEDTLS_ERR_MD_BAD_INPUT_DATA
|
||||
#define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE
|
||||
@ -1147,7 +1116,6 @@
|
||||
#define POLARSSL_ERR_OID_BUF_TOO_SMALL MBEDTLS_ERR_OID_BUF_TOO_SMALL
|
||||
#define POLARSSL_ERR_OID_NOT_FOUND MBEDTLS_ERR_OID_NOT_FOUND
|
||||
#define POLARSSL_ERR_PADLOCK_DATA_MISALIGNED MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED
|
||||
#define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA MBEDTLS_ERR_PBKDF2_BAD_INPUT_DATA
|
||||
#define POLARSSL_ERR_PEM_BAD_INPUT_DATA MBEDTLS_ERR_PEM_BAD_INPUT_DATA
|
||||
#define POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE
|
||||
#define POLARSSL_ERR_PEM_INVALID_DATA MBEDTLS_ERR_PEM_INVALID_DATA
|
||||
@ -1179,7 +1147,6 @@
|
||||
#define POLARSSL_ERR_PK_TYPE_MISMATCH MBEDTLS_ERR_PK_TYPE_MISMATCH
|
||||
#define POLARSSL_ERR_PK_UNKNOWN_NAMED_CURVE MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE
|
||||
#define POLARSSL_ERR_PK_UNKNOWN_PK_ALG MBEDTLS_ERR_PK_UNKNOWN_PK_ALG
|
||||
#define POLARSSL_ERR_RIPEMD160_FILE_IO_ERROR MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR
|
||||
#define POLARSSL_ERR_RSA_BAD_INPUT_DATA MBEDTLS_ERR_RSA_BAD_INPUT_DATA
|
||||
#define POLARSSL_ERR_RSA_INVALID_PADDING MBEDTLS_ERR_RSA_INVALID_PADDING
|
||||
#define POLARSSL_ERR_RSA_KEY_CHECK_FAILED MBEDTLS_ERR_RSA_KEY_CHECK_FAILED
|
||||
@ -1189,9 +1156,6 @@
|
||||
#define POLARSSL_ERR_RSA_PUBLIC_FAILED MBEDTLS_ERR_RSA_PUBLIC_FAILED
|
||||
#define POLARSSL_ERR_RSA_RNG_FAILED MBEDTLS_ERR_RSA_RNG_FAILED
|
||||
#define POLARSSL_ERR_RSA_VERIFY_FAILED MBEDTLS_ERR_RSA_VERIFY_FAILED
|
||||
#define POLARSSL_ERR_SHA1_FILE_IO_ERROR MBEDTLS_ERR_SHA1_FILE_IO_ERROR
|
||||
#define POLARSSL_ERR_SHA256_FILE_IO_ERROR MBEDTLS_ERR_SHA256_FILE_IO_ERROR
|
||||
#define POLARSSL_ERR_SHA512_FILE_IO_ERROR MBEDTLS_ERR_SHA512_FILE_IO_ERROR
|
||||
#define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE
|
||||
#define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST
|
||||
#define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY
|
||||
@ -1305,7 +1269,6 @@
|
||||
#define POLARSSL_MD_SHA512 MBEDTLS_MD_SHA512
|
||||
#define POLARSSL_MD_WRAP_H MBEDTLS_MD_WRAP_H
|
||||
#define POLARSSL_MEMORY_BUFFER_ALLOC_H MBEDTLS_MEMORY_BUFFER_ALLOC_H
|
||||
#define POLARSSL_MEMORY_H MBEDTLS_MEMORY_H
|
||||
#define POLARSSL_MODE_CBC MBEDTLS_MODE_CBC
|
||||
#define POLARSSL_MODE_CCM MBEDTLS_MODE_CCM
|
||||
#define POLARSSL_MODE_CFB MBEDTLS_MODE_CFB
|
||||
@ -1319,7 +1282,7 @@
|
||||
#define POLARSSL_MPI_MAX_BITS_SCALE100 MBEDTLS_MPI_MAX_BITS_SCALE100
|
||||
#define POLARSSL_MPI_MAX_LIMBS MBEDTLS_MPI_MAX_LIMBS
|
||||
#define POLARSSL_MPI_RW_BUFFER_SIZE MBEDTLS_MPI_RW_BUFFER_SIZE
|
||||
#define POLARSSL_NET_H MBEDTLS_NET_H
|
||||
#define POLARSSL_NET_H MBEDTLS_NET_SOCKETS_H
|
||||
#define POLARSSL_NET_LISTEN_BACKLOG MBEDTLS_NET_LISTEN_BACKLOG
|
||||
#define POLARSSL_OID_H MBEDTLS_OID_H
|
||||
#define POLARSSL_OPERATION_NONE MBEDTLS_OPERATION_NONE
|
||||
@ -1329,7 +1292,6 @@
|
||||
#define POLARSSL_PADDING_ZEROS MBEDTLS_PADDING_ZEROS
|
||||
#define POLARSSL_PADDING_ZEROS_AND_LEN MBEDTLS_PADDING_ZEROS_AND_LEN
|
||||
#define POLARSSL_PADLOCK_H MBEDTLS_PADLOCK_H
|
||||
#define POLARSSL_PBKDF2_H MBEDTLS_PBKDF2_H
|
||||
#define POLARSSL_PEM_H MBEDTLS_PEM_H
|
||||
#define POLARSSL_PKCS11_H MBEDTLS_PKCS11_H
|
||||
#define POLARSSL_PKCS12_H MBEDTLS_PKCS12_H
|
||||
@ -1712,7 +1674,6 @@
|
||||
#define TLS_RSA_WITH_NULL_SHA256 MBEDTLS_TLS_RSA_WITH_NULL_SHA256
|
||||
#define TLS_RSA_WITH_RC4_128_MD5 MBEDTLS_TLS_RSA_WITH_RC4_128_MD5
|
||||
#define TLS_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_RSA_WITH_RC4_128_SHA
|
||||
#define UL64 MBEDTLS_UL64
|
||||
#define X509_CRT_VERSION_1 MBEDTLS_X509_CRT_VERSION_1
|
||||
#define X509_CRT_VERSION_2 MBEDTLS_X509_CRT_VERSION_2
|
||||
#define X509_CRT_VERSION_3 MBEDTLS_X509_CRT_VERSION_3
|
||||
@ -1736,7 +1697,6 @@
|
||||
#define _ssl_key_cert mbedtls_ssl_key_cert
|
||||
#define _ssl_premaster_secret mbedtls_ssl_premaster_secret
|
||||
#define _ssl_session mbedtls_ssl_session
|
||||
#define _ssl_ticket_keys mbedtls_ssl_ticket_keys
|
||||
#define _ssl_transform mbedtls_ssl_transform
|
||||
#define _x509_crl mbedtls_x509_crl
|
||||
#define _x509_crl_entry mbedtls_x509_crl_entry
|
||||
@ -1836,7 +1796,6 @@
|
||||
#define cipher_definitions mbedtls_cipher_definitions
|
||||
#define cipher_finish mbedtls_cipher_finish
|
||||
#define cipher_free mbedtls_cipher_free
|
||||
#define cipher_free_ctx mbedtls_cipher_free_ctx
|
||||
#define cipher_get_block_size mbedtls_cipher_get_block_size
|
||||
#define cipher_get_cipher_mode mbedtls_cipher_get_cipher_mode
|
||||
#define cipher_get_iv_size mbedtls_cipher_get_iv_size
|
||||
@ -1855,7 +1814,6 @@
|
||||
#define cipher_mode_t mbedtls_cipher_mode_t
|
||||
#define cipher_padding_t mbedtls_cipher_padding_t
|
||||
#define cipher_reset mbedtls_cipher_reset
|
||||
#define cipher_self_test mbedtls_cipher_self_test
|
||||
#define cipher_set_iv mbedtls_cipher_set_iv
|
||||
#define cipher_set_padding_mode mbedtls_cipher_set_padding_mode
|
||||
#define cipher_setkey mbedtls_cipher_setkey
|
||||
@ -1866,7 +1824,6 @@
|
||||
#define ctr_drbg_context mbedtls_ctr_drbg_context
|
||||
#define ctr_drbg_free mbedtls_ctr_drbg_free
|
||||
#define ctr_drbg_init mbedtls_ctr_drbg_init
|
||||
#define ctr_drbg_init_entropy_len mbedtls_ctr_drbg_init_entropy_len
|
||||
#define ctr_drbg_random mbedtls_ctr_drbg_random
|
||||
#define ctr_drbg_random_with_add mbedtls_ctr_drbg_random_with_add
|
||||
#define ctr_drbg_reseed mbedtls_ctr_drbg_reseed
|
||||
@ -1877,14 +1834,12 @@
|
||||
#define ctr_drbg_update mbedtls_ctr_drbg_update
|
||||
#define ctr_drbg_update_seed_file mbedtls_ctr_drbg_update_seed_file
|
||||
#define ctr_drbg_write_seed_file mbedtls_ctr_drbg_write_seed_file
|
||||
#define debug_fmt mbedtls_debug_fmt
|
||||
#define debug_print_buf mbedtls_debug_print_buf
|
||||
#define debug_print_crt mbedtls_debug_print_crt
|
||||
#define debug_print_ecp mbedtls_debug_print_ecp
|
||||
#define debug_print_mpi mbedtls_debug_print_mpi
|
||||
#define debug_print_msg mbedtls_debug_print_msg
|
||||
#define debug_print_ret mbedtls_debug_print_ret
|
||||
#define debug_set_log_mode mbedtls_debug_set_log_mode
|
||||
#define debug_set_threshold mbedtls_debug_set_threshold
|
||||
#define des3_context mbedtls_des3_context
|
||||
#define des3_crypt_cbc mbedtls_des3_crypt_cbc
|
||||
@ -1928,7 +1883,6 @@
|
||||
#define ecdh_make_public mbedtls_ecdh_make_public
|
||||
#define ecdh_read_params mbedtls_ecdh_read_params
|
||||
#define ecdh_read_public mbedtls_ecdh_read_public
|
||||
#define ecdh_self_test mbedtls_ecdh_self_test
|
||||
#define ecdh_side mbedtls_ecdh_side
|
||||
#define ecdsa_context mbedtls_ecdsa_context
|
||||
#define ecdsa_free mbedtls_ecdsa_free
|
||||
@ -1937,7 +1891,6 @@
|
||||
#define ecdsa_info mbedtls_ecdsa_info
|
||||
#define ecdsa_init mbedtls_ecdsa_init
|
||||
#define ecdsa_read_signature mbedtls_ecdsa_read_signature
|
||||
#define ecdsa_self_test mbedtls_ecdsa_self_test
|
||||
#define ecdsa_sign mbedtls_ecdsa_sign
|
||||
#define ecdsa_sign_det mbedtls_ecdsa_sign_det
|
||||
#define ecdsa_verify mbedtls_ecdsa_verify
|
||||
@ -1945,7 +1898,6 @@
|
||||
#define ecdsa_write_signature_det mbedtls_ecdsa_write_signature_det
|
||||
#define eckey_info mbedtls_eckey_info
|
||||
#define eckeydh_info mbedtls_eckeydh_info
|
||||
#define ecp_add mbedtls_ecp_add
|
||||
#define ecp_check_privkey mbedtls_ecp_check_privkey
|
||||
#define ecp_check_pub_priv mbedtls_ecp_check_pub_priv
|
||||
#define ecp_check_pubkey mbedtls_ecp_check_pubkey
|
||||
@ -1962,7 +1914,6 @@
|
||||
#define ecp_group_free mbedtls_ecp_group_free
|
||||
#define ecp_group_id mbedtls_ecp_group_id
|
||||
#define ecp_group_init mbedtls_ecp_group_init
|
||||
#define ecp_group_read_string mbedtls_ecp_group_read_string
|
||||
#define ecp_grp_id_list mbedtls_ecp_grp_id_list
|
||||
#define ecp_is_zero mbedtls_ecp_is_zero
|
||||
#define ecp_keypair mbedtls_ecp_keypair
|
||||
@ -1977,7 +1928,6 @@
|
||||
#define ecp_point_write_binary mbedtls_ecp_point_write_binary
|
||||
#define ecp_self_test mbedtls_ecp_self_test
|
||||
#define ecp_set_zero mbedtls_ecp_set_zero
|
||||
#define ecp_sub mbedtls_ecp_sub
|
||||
#define ecp_tls_read_group mbedtls_ecp_tls_read_group
|
||||
#define ecp_tls_read_point mbedtls_ecp_tls_read_point
|
||||
#define ecp_tls_write_group mbedtls_ecp_tls_write_group
|
||||
@ -2015,7 +1965,6 @@
|
||||
#define hmac_drbg_context mbedtls_hmac_drbg_context
|
||||
#define hmac_drbg_free mbedtls_hmac_drbg_free
|
||||
#define hmac_drbg_init mbedtls_hmac_drbg_init
|
||||
#define hmac_drbg_init_buf mbedtls_hmac_drbg_init_buf
|
||||
#define hmac_drbg_random mbedtls_hmac_drbg_random
|
||||
#define hmac_drbg_random_with_add mbedtls_hmac_drbg_random_with_add
|
||||
#define hmac_drbg_reseed mbedtls_hmac_drbg_reseed
|
||||
@ -2031,14 +1980,8 @@
|
||||
#define md mbedtls_md
|
||||
#define md2 mbedtls_md2
|
||||
#define md2_context mbedtls_md2_context
|
||||
#define md2_file mbedtls_md2_file
|
||||
#define md2_finish mbedtls_md2_finish
|
||||
#define md2_free mbedtls_md2_free
|
||||
#define md2_hmac mbedtls_md2_hmac
|
||||
#define md2_hmac_finish mbedtls_md2_hmac_finish
|
||||
#define md2_hmac_reset mbedtls_md2_hmac_reset
|
||||
#define md2_hmac_starts mbedtls_md2_hmac_starts
|
||||
#define md2_hmac_update mbedtls_md2_hmac_update
|
||||
#define md2_info mbedtls_md2_info
|
||||
#define md2_init mbedtls_md2_init
|
||||
#define md2_process mbedtls_md2_process
|
||||
@ -2047,14 +1990,8 @@
|
||||
#define md2_update mbedtls_md2_update
|
||||
#define md4 mbedtls_md4
|
||||
#define md4_context mbedtls_md4_context
|
||||
#define md4_file mbedtls_md4_file
|
||||
#define md4_finish mbedtls_md4_finish
|
||||
#define md4_free mbedtls_md4_free
|
||||
#define md4_hmac mbedtls_md4_hmac
|
||||
#define md4_hmac_finish mbedtls_md4_hmac_finish
|
||||
#define md4_hmac_reset mbedtls_md4_hmac_reset
|
||||
#define md4_hmac_starts mbedtls_md4_hmac_starts
|
||||
#define md4_hmac_update mbedtls_md4_hmac_update
|
||||
#define md4_info mbedtls_md4_info
|
||||
#define md4_init mbedtls_md4_init
|
||||
#define md4_process mbedtls_md4_process
|
||||
@ -2063,14 +2000,8 @@
|
||||
#define md4_update mbedtls_md4_update
|
||||
#define md5 mbedtls_md5
|
||||
#define md5_context mbedtls_md5_context
|
||||
#define md5_file mbedtls_md5_file
|
||||
#define md5_finish mbedtls_md5_finish
|
||||
#define md5_free mbedtls_md5_free
|
||||
#define md5_hmac mbedtls_md5_hmac
|
||||
#define md5_hmac_finish mbedtls_md5_hmac_finish
|
||||
#define md5_hmac_reset mbedtls_md5_hmac_reset
|
||||
#define md5_hmac_starts mbedtls_md5_hmac_starts
|
||||
#define md5_hmac_update mbedtls_md5_hmac_update
|
||||
#define md5_info mbedtls_md5_info
|
||||
#define md5_init mbedtls_md5_init
|
||||
#define md5_process mbedtls_md5_process
|
||||
@ -2081,7 +2012,6 @@
|
||||
#define md_file mbedtls_md_file
|
||||
#define md_finish mbedtls_md_finish
|
||||
#define md_free mbedtls_md_free
|
||||
#define md_free_ctx mbedtls_md_free_ctx
|
||||
#define md_get_name mbedtls_md_get_name
|
||||
#define md_get_size mbedtls_md_get_size
|
||||
#define md_get_type mbedtls_md_get_type
|
||||
@ -2109,7 +2039,6 @@
|
||||
#define memory_buffer_alloc_status mbedtls_memory_buffer_alloc_status
|
||||
#define memory_buffer_alloc_verify mbedtls_memory_buffer_alloc_verify
|
||||
#define memory_buffer_set_verify mbedtls_memory_buffer_set_verify
|
||||
#define memory_set_own mbedtls_memory_set_own
|
||||
#define mpi mbedtls_mpi
|
||||
#define mpi_add_abs mbedtls_mpi_add_abs
|
||||
#define mpi_add_int mbedtls_mpi_add_int
|
||||
@ -2185,8 +2114,6 @@
|
||||
#define padlock_supports mbedtls_padlock_has_support
|
||||
#define padlock_xcryptcbc mbedtls_padlock_xcryptcbc
|
||||
#define padlock_xcryptecb mbedtls_padlock_xcryptecb
|
||||
#define pbkdf2_hmac mbedtls_pbkdf2_hmac
|
||||
#define pbkdf2_self_test mbedtls_pbkdf2_self_test
|
||||
#define pem_context mbedtls_pem_context
|
||||
#define pem_free mbedtls_pem_free
|
||||
#define pem_init mbedtls_pem_init
|
||||
@ -2246,13 +2173,11 @@
|
||||
#define platform_entropy_poll mbedtls_platform_entropy_poll
|
||||
#define platform_set_exit mbedtls_platform_set_exit
|
||||
#define platform_set_fprintf mbedtls_platform_set_fprintf
|
||||
#define platform_set_malloc_free mbedtls_platform_set_malloc_free
|
||||
#define platform_set_printf mbedtls_platform_set_printf
|
||||
#define platform_set_snprintf mbedtls_platform_set_snprintf
|
||||
#define polarssl_exit mbedtls_exit
|
||||
#define polarssl_fprintf mbedtls_fprintf
|
||||
#define polarssl_free mbedtls_free
|
||||
#define polarssl_malloc mbedtls_malloc
|
||||
#define polarssl_mutex_free mbedtls_mutex_free
|
||||
#define polarssl_mutex_init mbedtls_mutex_init
|
||||
#define polarssl_mutex_lock mbedtls_mutex_lock
|
||||
@ -2262,14 +2187,8 @@
|
||||
#define polarssl_strerror mbedtls_strerror
|
||||
#define ripemd160 mbedtls_ripemd160
|
||||
#define ripemd160_context mbedtls_ripemd160_context
|
||||
#define ripemd160_file mbedtls_ripemd160_file
|
||||
#define ripemd160_finish mbedtls_ripemd160_finish
|
||||
#define ripemd160_free mbedtls_ripemd160_free
|
||||
#define ripemd160_hmac mbedtls_ripemd160_hmac
|
||||
#define ripemd160_hmac_finish mbedtls_ripemd160_hmac_finish
|
||||
#define ripemd160_hmac_reset mbedtls_ripemd160_hmac_reset
|
||||
#define ripemd160_hmac_starts mbedtls_ripemd160_hmac_starts
|
||||
#define ripemd160_hmac_update mbedtls_ripemd160_hmac_update
|
||||
#define ripemd160_info mbedtls_ripemd160_info
|
||||
#define ripemd160_init mbedtls_ripemd160_init
|
||||
#define ripemd160_process mbedtls_ripemd160_process
|
||||
@ -2283,12 +2202,10 @@
|
||||
#define rsa_check_pubkey mbedtls_rsa_check_pubkey
|
||||
#define rsa_context mbedtls_rsa_context
|
||||
#define rsa_copy mbedtls_rsa_copy
|
||||
#define rsa_decrypt_func mbedtls_rsa_decrypt_func
|
||||
#define rsa_free mbedtls_rsa_free
|
||||
#define rsa_gen_key mbedtls_rsa_gen_key
|
||||
#define rsa_info mbedtls_rsa_info
|
||||
#define rsa_init mbedtls_rsa_init
|
||||
#define rsa_key_len_func mbedtls_rsa_key_len_func
|
||||
#define rsa_pkcs1_decrypt mbedtls_rsa_pkcs1_decrypt
|
||||
#define rsa_pkcs1_encrypt mbedtls_rsa_pkcs1_encrypt
|
||||
#define rsa_pkcs1_sign mbedtls_rsa_pkcs1_sign
|
||||
@ -2306,19 +2223,12 @@
|
||||
#define rsa_rsassa_pss_verify_ext mbedtls_rsa_rsassa_pss_verify_ext
|
||||
#define rsa_self_test mbedtls_rsa_self_test
|
||||
#define rsa_set_padding mbedtls_rsa_set_padding
|
||||
#define rsa_sign_func mbedtls_rsa_sign_func
|
||||
#define safer_memcmp mbedtls_ssl_safer_memcmp
|
||||
#define set_alarm mbedtls_set_alarm
|
||||
#define sha1 mbedtls_sha1
|
||||
#define sha1_context mbedtls_sha1_context
|
||||
#define sha1_file mbedtls_sha1_file
|
||||
#define sha1_finish mbedtls_sha1_finish
|
||||
#define sha1_free mbedtls_sha1_free
|
||||
#define sha1_hmac mbedtls_sha1_hmac
|
||||
#define sha1_hmac_finish mbedtls_sha1_hmac_finish
|
||||
#define sha1_hmac_reset mbedtls_sha1_hmac_reset
|
||||
#define sha1_hmac_starts mbedtls_sha1_hmac_starts
|
||||
#define sha1_hmac_update mbedtls_sha1_hmac_update
|
||||
#define sha1_info mbedtls_sha1_info
|
||||
#define sha1_init mbedtls_sha1_init
|
||||
#define sha1_process mbedtls_sha1_process
|
||||
@ -2328,14 +2238,8 @@
|
||||
#define sha224_info mbedtls_sha224_info
|
||||
#define sha256 mbedtls_sha256
|
||||
#define sha256_context mbedtls_sha256_context
|
||||
#define sha256_file mbedtls_sha256_file
|
||||
#define sha256_finish mbedtls_sha256_finish
|
||||
#define sha256_free mbedtls_sha256_free
|
||||
#define sha256_hmac mbedtls_sha256_hmac
|
||||
#define sha256_hmac_finish mbedtls_sha256_hmac_finish
|
||||
#define sha256_hmac_reset mbedtls_sha256_hmac_reset
|
||||
#define sha256_hmac_starts mbedtls_sha256_hmac_starts
|
||||
#define sha256_hmac_update mbedtls_sha256_hmac_update
|
||||
#define sha256_info mbedtls_sha256_info
|
||||
#define sha256_init mbedtls_sha256_init
|
||||
#define sha256_process mbedtls_sha256_process
|
||||
@ -2345,14 +2249,8 @@
|
||||
#define sha384_info mbedtls_sha384_info
|
||||
#define sha512 mbedtls_sha512
|
||||
#define sha512_context mbedtls_sha512_context
|
||||
#define sha512_file mbedtls_sha512_file
|
||||
#define sha512_finish mbedtls_sha512_finish
|
||||
#define sha512_free mbedtls_sha512_free
|
||||
#define sha512_hmac mbedtls_sha512_hmac
|
||||
#define sha512_hmac_finish mbedtls_sha512_hmac_finish
|
||||
#define sha512_hmac_reset mbedtls_sha512_hmac_reset
|
||||
#define sha512_hmac_starts mbedtls_sha512_hmac_starts
|
||||
#define sha512_hmac_update mbedtls_sha512_hmac_update
|
||||
#define sha512_info mbedtls_sha512_info
|
||||
#define sha512_init mbedtls_sha512_init
|
||||
#define sha512_process mbedtls_sha512_process
|
||||
@ -2385,7 +2283,6 @@
|
||||
#define ssl_cookie_setup mbedtls_ssl_cookie_setup
|
||||
#define ssl_cookie_write mbedtls_ssl_cookie_write
|
||||
#define ssl_cookie_write_t mbedtls_ssl_cookie_write_t
|
||||
#define ssl_curve_is_acceptable mbedtls_ssl_curve_is_acceptable
|
||||
#define ssl_derive_keys mbedtls_ssl_derive_keys
|
||||
#define ssl_dtls_replay_check mbedtls_ssl_dtls_replay_check
|
||||
#define ssl_dtls_replay_update mbedtls_ssl_dtls_replay_update
|
||||
@ -2453,7 +2350,6 @@
|
||||
#define ssl_set_arc4_support mbedtls_ssl_conf_arc4_support
|
||||
#define ssl_set_authmode mbedtls_ssl_conf_authmode
|
||||
#define ssl_set_bio mbedtls_ssl_set_bio
|
||||
#define ssl_set_bio mbedtls_ssl_set_bio_timeout
|
||||
#define ssl_set_ca_chain mbedtls_ssl_conf_ca_chain
|
||||
#define ssl_set_cbc_record_splitting mbedtls_ssl_conf_cbc_record_splitting
|
||||
#define ssl_set_ciphersuites mbedtls_ssl_conf_ciphersuites
|
||||
@ -2476,8 +2372,6 @@
|
||||
#define ssl_set_max_version mbedtls_ssl_conf_max_version
|
||||
#define ssl_set_min_version mbedtls_ssl_conf_min_version
|
||||
#define ssl_set_own_cert mbedtls_ssl_conf_own_cert
|
||||
#define ssl_set_own_cert_alt mbedtls_ssl_set_own_cert_alt
|
||||
#define ssl_set_own_cert_rsa mbedtls_ssl_set_own_cert_rsa
|
||||
#define ssl_set_psk mbedtls_ssl_conf_psk
|
||||
#define ssl_set_psk_cb mbedtls_ssl_conf_psk_cb
|
||||
#define ssl_set_renegotiation mbedtls_ssl_conf_renegotiation
|
||||
@ -2486,7 +2380,6 @@
|
||||
#define ssl_set_rng mbedtls_ssl_conf_rng
|
||||
#define ssl_set_session mbedtls_ssl_set_session
|
||||
#define ssl_set_session_cache mbedtls_ssl_conf_session_cache
|
||||
#define ssl_set_session_ticket_lifetime mbedtls_ssl_conf_session_ticket_lifetime
|
||||
#define ssl_set_session_tickets mbedtls_ssl_conf_session_tickets
|
||||
#define ssl_set_sni mbedtls_ssl_conf_sni
|
||||
#define ssl_set_transport mbedtls_ssl_conf_transport
|
||||
@ -2494,7 +2387,6 @@
|
||||
#define ssl_set_verify mbedtls_ssl_conf_verify
|
||||
#define ssl_sig_from_pk mbedtls_ssl_sig_from_pk
|
||||
#define ssl_states mbedtls_ssl_states
|
||||
#define ssl_ticket_keys mbedtls_ssl_ticket_keys
|
||||
#define ssl_transform mbedtls_ssl_transform
|
||||
#define ssl_transform_free mbedtls_ssl_transform_free
|
||||
#define ssl_write mbedtls_ssl_write
|
||||
@ -2523,7 +2415,6 @@
|
||||
#define test_cli_key mbedtls_test_cli_key
|
||||
#define test_cli_key_ec mbedtls_test_cli_key_ec
|
||||
#define test_cli_key_rsa mbedtls_test_cli_key_rsa
|
||||
#define test_dhm_params mbedtls_test_dhm_params
|
||||
#define test_srv_crt mbedtls_test_srv_crt
|
||||
#define test_srv_crt_ec mbedtls_test_srv_crt_ec
|
||||
#define test_srv_crt_rsa mbedtls_test_srv_crt_rsa
|
||||
@ -2578,8 +2469,6 @@
|
||||
#define x509_get_time mbedtls_x509_get_time
|
||||
#define x509_key_size_helper mbedtls_x509_key_size_helper
|
||||
#define x509_name mbedtls_x509_name
|
||||
#define x509_oid_get_description mbedtls_x509_oid_get_description
|
||||
#define x509_oid_get_numeric_string mbedtls_x509_oid_get_numeric_string
|
||||
#define x509_self_test mbedtls_x509_self_test
|
||||
#define x509_sequence mbedtls_x509_sequence
|
||||
#define x509_serial_gets mbedtls_x509_serial_gets
|
||||
|
@ -55,6 +55,34 @@
|
||||
*/
|
||||
#define MBEDTLS_HAVE_ASM
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_NO_UDBL_DIVISION
|
||||
*
|
||||
* The platform lacks support for double-width integer division (64-bit
|
||||
* division on a 32-bit platform, 128-bit division on a 64-bit platform).
|
||||
*
|
||||
* Used in:
|
||||
* include/mbedtls/bignum.h
|
||||
* library/bignum.c
|
||||
*
|
||||
* The bignum code uses double-width division to speed up some operations.
|
||||
* Double-width division is often implemented in software that needs to
|
||||
* be linked with the program. The presence of a double-width integer
|
||||
* type is usually detected automatically through preprocessor macros,
|
||||
* but the automatic detection cannot know whether the code needs to
|
||||
* and can be linked with an implementation of division for that type.
|
||||
* By default division is assumed to be usable if the type is present.
|
||||
* Uncomment this option to prevent the use of double-width division.
|
||||
*
|
||||
* Note that division for the native integer type is always required.
|
||||
* Furthermore, a 64-bit type is always required even on a 32-bit
|
||||
* platform, but it need not support multiplication or division. In some
|
||||
* cases it is also desirable to disable some double-width operations. For
|
||||
* example, if double-width division is implemented in software, disabling
|
||||
* it can reduce code size in some embedded targets.
|
||||
*/
|
||||
//#define MBEDTLS_NO_UDBL_DIVISION
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_HAVE_SSE2
|
||||
*
|
||||
@ -71,6 +99,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
|
||||
@ -148,6 +180,8 @@
|
||||
* \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
|
||||
*/
|
||||
@ -157,6 +191,7 @@
|
||||
//#define MBEDTLS_PLATFORM_PRINTF_ALT
|
||||
//#define MBEDTLS_PLATFORM_SNPRINTF_ALT
|
||||
//#define MBEDTLS_PLATFORM_NV_SEED_ALT
|
||||
//#define MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_DEPRECATED_WARNING
|
||||
@ -212,16 +247,16 @@
|
||||
* \def MBEDTLS_AES_ALT
|
||||
*
|
||||
* 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.
|
||||
* alternate core implementation of a symmetric crypto, an arithmetic 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.
|
||||
*
|
||||
* Example: In case you uncomment MBEDTLS_AES_ALT, mbed TLS will no longer
|
||||
* provide the "struct mbedtls_aes_context" definition and omit the base function
|
||||
* declarations and implementations. "aes_alt.h" will be included from
|
||||
* provide the "struct mbedtls_aes_context" definition and omit the base
|
||||
* function declarations and implementations. "aes_alt.h" will be included from
|
||||
* "aes.h" to include the new function definitions.
|
||||
*
|
||||
* Uncomment a macro to enable alternate implementation of the corresponding
|
||||
@ -240,6 +275,16 @@
|
||||
//#define MBEDTLS_SHA1_ALT
|
||||
//#define MBEDTLS_SHA256_ALT
|
||||
//#define MBEDTLS_SHA512_ALT
|
||||
/*
|
||||
* When replacing the elliptic curve module, pleace consider, that it is
|
||||
* implemented with two .c files:
|
||||
* - ecp.c
|
||||
* - ecp_curves.c
|
||||
* You can replace them very much like all the other MBEDTLS__MODULE_NAME__ALT
|
||||
* macros as described above. The only difference is that you have to make sure
|
||||
* that you provide functionality for both .c files.
|
||||
*/
|
||||
//#define MBEDTLS_ECP_ALT
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_MD2_PROCESS_ALT
|
||||
@ -257,9 +302,15 @@
|
||||
* of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible
|
||||
* with this definition.
|
||||
*
|
||||
* Note: if you use the AES_xxx_ALT macros, then is is recommended to also set
|
||||
* MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES
|
||||
* tables.
|
||||
* \note Because of a signature change, the core AES encryption and decryption routines are
|
||||
* currently named mbedtls_aes_internal_encrypt and mbedtls_aes_internal_decrypt,
|
||||
* respectively. When setting up alternative implementations, these functions should
|
||||
* be overriden, but the wrapper functions mbedtls_aes_decrypt and mbedtls_aes_encrypt
|
||||
* must stay untouched.
|
||||
*
|
||||
* \note If you use the AES_xxx_ALT macros, then is is recommended to also set
|
||||
* MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES
|
||||
* tables.
|
||||
*
|
||||
* Uncomment a macro to enable alternate implementation of the corresponding
|
||||
* function.
|
||||
@ -279,6 +330,59 @@
|
||||
//#define MBEDTLS_AES_ENCRYPT_ALT
|
||||
//#define MBEDTLS_AES_DECRYPT_ALT
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_ECP_INTERNAL_ALT
|
||||
*
|
||||
* Expose a part of the internal interface of the Elliptic Curve Point module.
|
||||
*
|
||||
* MBEDTLS_ECP__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use your
|
||||
* alternative core implementation of elliptic curve arithmetic. Keep in mind
|
||||
* that function prototypes should remain the same.
|
||||
*
|
||||
* This partially replaces one function. The header file from mbed TLS is still
|
||||
* used, in contrast to the MBEDTLS_ECP_ALT flag. The original implementation
|
||||
* is still present and it is used for group structures not supported by the
|
||||
* alternative.
|
||||
*
|
||||
* Any of these options become available by defining MBEDTLS_ECP_INTERNAL_ALT
|
||||
* and implementing the following functions:
|
||||
* unsigned char mbedtls_internal_ecp_grp_capable(
|
||||
* const mbedtls_ecp_group *grp )
|
||||
* int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp )
|
||||
* void mbedtls_internal_ecp_deinit( const mbedtls_ecp_group *grp )
|
||||
* The mbedtls_internal_ecp_grp_capable function should return 1 if the
|
||||
* replacement functions implement arithmetic for the given group and 0
|
||||
* otherwise.
|
||||
* The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_deinit are
|
||||
* called before and after each point operation and provide an opportunity to
|
||||
* implement optimized set up and tear down instructions.
|
||||
*
|
||||
* Example: In case you uncomment MBEDTLS_ECP_INTERNAL_ALT and
|
||||
* MBEDTLS_ECP_DOUBLE_JAC_ALT, mbed TLS will still provide the ecp_double_jac
|
||||
* function, but will use your mbedtls_internal_ecp_double_jac if the group is
|
||||
* supported (your mbedtls_internal_ecp_grp_capable function returns 1 when
|
||||
* receives it as an argument). If the group is not supported then the original
|
||||
* implementation is used. The other functions and the definition of
|
||||
* mbedtls_ecp_group and mbedtls_ecp_point will not change, so your
|
||||
* implementation of mbedtls_internal_ecp_double_jac and
|
||||
* mbedtls_internal_ecp_grp_capable must be compatible with this definition.
|
||||
*
|
||||
* Uncomment a macro to enable alternate implementation of the corresponding
|
||||
* function.
|
||||
*/
|
||||
/* Required for all the functions in this section */
|
||||
//#define MBEDTLS_ECP_INTERNAL_ALT
|
||||
/* Support for Weierstrass curves with Jacobi representation */
|
||||
//#define MBEDTLS_ECP_RANDOMIZE_JAC_ALT
|
||||
//#define MBEDTLS_ECP_ADD_MIXED_ALT
|
||||
//#define MBEDTLS_ECP_DOUBLE_JAC_ALT
|
||||
//#define MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT
|
||||
//#define MBEDTLS_ECP_NORMALIZE_JAC_ALT
|
||||
/* Support for curves with Montgomery arithmetic */
|
||||
//#define MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT
|
||||
//#define MBEDTLS_ECP_RANDOMIZE_MXZ_ALT
|
||||
//#define MBEDTLS_ECP_NORMALIZE_MXZ_ALT
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_TEST_NULL_ENTROPY
|
||||
*
|
||||
@ -934,18 +1038,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
|
||||
*
|
||||
@ -1531,7 +1623,7 @@
|
||||
* library/pkwrite.c
|
||||
* library/x509_create.c
|
||||
* library/x509write_crt.c
|
||||
* library/mbedtls_x509write_csr.c
|
||||
* library/x509write_csr.c
|
||||
*/
|
||||
#define MBEDTLS_ASN1_WRITE_C
|
||||
|
||||
@ -1665,6 +1757,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
|
||||
*
|
||||
@ -1879,7 +1984,7 @@
|
||||
*
|
||||
* Enable the generic message digest layer.
|
||||
*
|
||||
* Module: library/mbedtls_md.c
|
||||
* Module: library/md.c
|
||||
* Caller:
|
||||
*
|
||||
* Uncomment to enable generic message digest wrappers.
|
||||
@ -1891,7 +1996,7 @@
|
||||
*
|
||||
* Enable the MD2 hash algorithm.
|
||||
*
|
||||
* Module: library/mbedtls_md2.c
|
||||
* Module: library/md2.c
|
||||
* Caller:
|
||||
*
|
||||
* Uncomment to enable support for (rare) MD2-signed X.509 certs.
|
||||
@ -1903,7 +2008,7 @@
|
||||
*
|
||||
* Enable the MD4 hash algorithm.
|
||||
*
|
||||
* Module: library/mbedtls_md4.c
|
||||
* Module: library/md4.c
|
||||
* Caller:
|
||||
*
|
||||
* Uncomment to enable support for (rare) MD4-signed X.509 certs.
|
||||
@ -1915,8 +2020,8 @@
|
||||
*
|
||||
* Enable the MD5 hash algorithm.
|
||||
*
|
||||
* Module: library/mbedtls_md5.c
|
||||
* Caller: library/mbedtls_md.c
|
||||
* Module: library/md5.c
|
||||
* Caller: library/md.c
|
||||
* library/pem.c
|
||||
* library/ssl_tls.c
|
||||
*
|
||||
@ -1954,7 +2059,7 @@
|
||||
* environment:
|
||||
* https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS
|
||||
*
|
||||
* Module: library/net.c
|
||||
* Module: library/net_sockets.c
|
||||
*
|
||||
* This module provides networking routines.
|
||||
*/
|
||||
@ -1973,11 +2078,11 @@
|
||||
* library/rsa.c
|
||||
* library/x509.c
|
||||
* library/x509_create.c
|
||||
* library/mbedtls_x509_crl.c
|
||||
* library/mbedtls_x509_crt.c
|
||||
* library/mbedtls_x509_csr.c
|
||||
* library/x509_crl.c
|
||||
* library/x509_crt.c
|
||||
* library/x509_csr.c
|
||||
* library/x509write_crt.c
|
||||
* library/mbedtls_x509write_csr.c
|
||||
* library/x509write_csr.c
|
||||
*
|
||||
* This modules translates between OIDs and internal values.
|
||||
*/
|
||||
@ -2005,9 +2110,9 @@
|
||||
* Module: library/pem.c
|
||||
* Caller: library/dhm.c
|
||||
* library/pkparse.c
|
||||
* library/mbedtls_x509_crl.c
|
||||
* library/mbedtls_x509_crt.c
|
||||
* library/mbedtls_x509_csr.c
|
||||
* library/x509_crl.c
|
||||
* library/x509_crt.c
|
||||
* library/x509_csr.c
|
||||
*
|
||||
* Requires: MBEDTLS_BASE64_C
|
||||
*
|
||||
@ -2023,7 +2128,7 @@
|
||||
* Module: library/pem.c
|
||||
* Caller: library/pkwrite.c
|
||||
* library/x509write_crt.c
|
||||
* library/mbedtls_x509write_csr.c
|
||||
* library/x509write_csr.c
|
||||
*
|
||||
* Requires: MBEDTLS_BASE64_C
|
||||
*
|
||||
@ -2053,8 +2158,8 @@
|
||||
* Enable the generic public (asymetric) key parser.
|
||||
*
|
||||
* Module: library/pkparse.c
|
||||
* Caller: library/mbedtls_x509_crt.c
|
||||
* library/mbedtls_x509_csr.c
|
||||
* Caller: library/x509_crt.c
|
||||
* library/x509_csr.c
|
||||
*
|
||||
* Requires: MBEDTLS_PK_C
|
||||
*
|
||||
@ -2145,8 +2250,8 @@
|
||||
*
|
||||
* Enable the RIPEMD-160 hash algorithm.
|
||||
*
|
||||
* Module: library/mbedtls_ripemd160.c
|
||||
* Caller: library/mbedtls_md.c
|
||||
* Module: library/ripemd160.c
|
||||
* Caller: library/md.c
|
||||
*
|
||||
*/
|
||||
#define MBEDTLS_RIPEMD160_C
|
||||
@ -2174,14 +2279,15 @@
|
||||
*
|
||||
* Enable the SHA1 cryptographic hash algorithm.
|
||||
*
|
||||
* Module: library/mbedtls_sha1.c
|
||||
* Caller: library/mbedtls_md.c
|
||||
* Module: library/sha1.c
|
||||
* Caller: library/md.c
|
||||
* library/ssl_cli.c
|
||||
* library/ssl_srv.c
|
||||
* library/ssl_tls.c
|
||||
* library/x509write_crt.c
|
||||
*
|
||||
* This module is required for SSL/TLS and SHA1-signed certificates.
|
||||
* This module is required for SSL/TLS up to version 1.1, for TLS 1.2
|
||||
* depending on the handshake parameters, and for SHA1-signed certificates.
|
||||
*/
|
||||
#define MBEDTLS_SHA1_C
|
||||
|
||||
@ -2190,9 +2296,9 @@
|
||||
*
|
||||
* Enable the SHA-224 and SHA-256 cryptographic hash algorithms.
|
||||
*
|
||||
* Module: library/mbedtls_sha256.c
|
||||
* Module: library/sha256.c
|
||||
* Caller: library/entropy.c
|
||||
* library/mbedtls_md.c
|
||||
* library/md.c
|
||||
* library/ssl_cli.c
|
||||
* library/ssl_srv.c
|
||||
* library/ssl_tls.c
|
||||
@ -2207,9 +2313,9 @@
|
||||
*
|
||||
* Enable the SHA-384 and SHA-512 cryptographic hash algorithms.
|
||||
*
|
||||
* Module: library/mbedtls_sha512.c
|
||||
* Module: library/sha512.c
|
||||
* Caller: library/entropy.c
|
||||
* library/mbedtls_md.c
|
||||
* library/md.c
|
||||
* library/ssl_cli.c
|
||||
* library/ssl_srv.c
|
||||
*
|
||||
@ -2357,9 +2463,9 @@
|
||||
* Enable X.509 core for using certificates.
|
||||
*
|
||||
* Module: library/x509.c
|
||||
* Caller: library/mbedtls_x509_crl.c
|
||||
* library/mbedtls_x509_crt.c
|
||||
* library/mbedtls_x509_csr.c
|
||||
* Caller: library/x509_crl.c
|
||||
* library/x509_crt.c
|
||||
* library/x509_csr.c
|
||||
*
|
||||
* Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C,
|
||||
* MBEDTLS_PK_PARSE_C
|
||||
@ -2373,7 +2479,7 @@
|
||||
*
|
||||
* Enable X.509 certificate parsing.
|
||||
*
|
||||
* Module: library/mbedtls_x509_crt.c
|
||||
* Module: library/x509_crt.c
|
||||
* Caller: library/ssl_cli.c
|
||||
* library/ssl_srv.c
|
||||
* library/ssl_tls.c
|
||||
@ -2389,8 +2495,8 @@
|
||||
*
|
||||
* Enable X.509 CRL parsing.
|
||||
*
|
||||
* Module: library/mbedtls_x509_crl.c
|
||||
* Caller: library/mbedtls_x509_crt.c
|
||||
* Module: library/x509_crl.c
|
||||
* Caller: library/x509_crt.c
|
||||
*
|
||||
* Requires: MBEDTLS_X509_USE_C
|
||||
*
|
||||
@ -2403,7 +2509,7 @@
|
||||
*
|
||||
* Enable X.509 Certificate Signing Request (CSR) parsing.
|
||||
*
|
||||
* Module: library/mbedtls_x509_csr.c
|
||||
* Module: library/x509_csr.c
|
||||
* Caller: library/x509_crt_write.c
|
||||
*
|
||||
* Requires: MBEDTLS_X509_USE_C
|
||||
@ -2503,6 +2609,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 */
|
||||
@ -2512,7 +2619,7 @@
|
||||
//#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 */
|
||||
//#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! */
|
||||
@ -2528,8 +2635,8 @@
|
||||
//#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 */
|
||||
//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time 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! */
|
||||
@ -2563,11 +2670,36 @@
|
||||
|
||||
/* 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'). */
|
||||
|
||||
/**
|
||||
* Allow SHA-1 in the default TLS configuration for certificate signing.
|
||||
* Without this build-time option, SHA-1 support must be activated explicitly
|
||||
* through mbedtls_ssl_conf_cert_profile. Turning on this option is not
|
||||
* recommended because of it is possible to generte SHA-1 collisions, however
|
||||
* this may be safe for legacy infrastructure where additional controls apply.
|
||||
*/
|
||||
// #define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
|
||||
|
||||
/**
|
||||
* Allow SHA-1 in the default TLS configuration for TLS 1.2 handshake
|
||||
* signature and ciphersuite selection. Without this build-time option, SHA-1
|
||||
* support must be activated explicitly through mbedtls_ssl_conf_sig_hashes.
|
||||
* The use of SHA-1 in TLS <= 1.1 and in HMAC-SHA-1 is always allowed by
|
||||
* default. At the time of writing, there is no practical attack on the use
|
||||
* of SHA-1 in handshake signatures, hence this option is turned on by default
|
||||
* for compatibility with existing peers.
|
||||
*/
|
||||
#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE
|
||||
|
||||
/* \} name SECTION: Customisation configuration options */
|
||||
|
||||
/* Target and application specific configurations */
|
||||
//#define YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE "target_config.h"
|
||||
//#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
|
||||
|
||||
/*
|
||||
* Allow user to override any previous default.
|
||||
|
@ -69,6 +69,10 @@ extern "C" {
|
||||
* \param f_rng RNG function
|
||||
* \param p_rng RNG parameter
|
||||
*
|
||||
* \note If the bitlength of the message hash is larger than the
|
||||
* bitlength of the group order, then the hash is truncated as
|
||||
* prescribed by SEC1 4.1.3 step 5.
|
||||
*
|
||||
* \return 0 if successful,
|
||||
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
|
||||
*/
|
||||
@ -89,6 +93,10 @@ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s,
|
||||
* \param blen Length of buf
|
||||
* \param md_alg MD algorithm used to hash the message
|
||||
*
|
||||
* \note If the bitlength of the message hash is larger than the
|
||||
* bitlength of the group order, then the hash is truncated as
|
||||
* prescribed by SEC1 4.1.3 step 5.
|
||||
*
|
||||
* \return 0 if successful,
|
||||
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
|
||||
*/
|
||||
@ -107,6 +115,10 @@ int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi
|
||||
* \param r First integer of the signature
|
||||
* \param s Second integer of the signature
|
||||
*
|
||||
* \note If the bitlength of the message hash is larger than the
|
||||
* bitlength of the group order, then the hash is truncated as
|
||||
* prescribed by SEC1 4.1.4 step 3.
|
||||
*
|
||||
* \return 0 if successful,
|
||||
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid
|
||||
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
|
||||
@ -120,7 +132,7 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp,
|
||||
* serialized as defined in RFC 4492 page 20.
|
||||
* (Not thread-safe to use same context in multiple threads)
|
||||
*
|
||||
* \note The deterministice version (RFC 6979) is used if
|
||||
* \note The deterministic version (RFC 6979) is used if
|
||||
* MBEDTLS_ECDSA_DETERMINISTIC is defined.
|
||||
*
|
||||
* \param ctx ECDSA context
|
||||
@ -136,6 +148,10 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp,
|
||||
* size of the curve used, plus 9 (eg. 73 bytes if a 256-bit
|
||||
* curve is used). MBEDTLS_ECDSA_MAX_LEN is always safe.
|
||||
*
|
||||
* \note If the bitlength of the message hash is larger than the
|
||||
* bitlength of the group order, then the hash is truncated as
|
||||
* prescribed by SEC1 4.1.3 step 5.
|
||||
*
|
||||
* \return 0 if successful,
|
||||
* or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or
|
||||
* MBEDTLS_ERR_ASN1_XXX error code
|
||||
@ -172,6 +188,10 @@ int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t
|
||||
* size of the curve used, plus 9 (eg. 73 bytes if a 256-bit
|
||||
* curve is used). MBEDTLS_ECDSA_MAX_LEN is always safe.
|
||||
*
|
||||
* \note If the bitlength of the message hash is larger than the
|
||||
* bitlength of the group order, then the hash is truncated as
|
||||
* prescribed by SEC1 4.1.3 step 5.
|
||||
*
|
||||
* \return 0 if successful,
|
||||
* or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or
|
||||
* MBEDTLS_ERR_ASN1_XXX error code
|
||||
@ -193,6 +213,10 @@ int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx,
|
||||
* \param sig Signature to read and verify
|
||||
* \param slen Size of sig
|
||||
*
|
||||
* \note If the bitlength of the message hash is larger than the
|
||||
* bitlength of the group order, then the hash is truncated as
|
||||
* prescribed by SEC1 4.1.4 step 3.
|
||||
*
|
||||
* \return 0 if successful,
|
||||
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid,
|
||||
* MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if the signature is
|
||||
|
@ -116,7 +116,7 @@ int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx,
|
||||
const unsigned char *secret,
|
||||
size_t len );
|
||||
|
||||
/*
|
||||
/**
|
||||
* \brief Check if a context is ready for use
|
||||
*
|
||||
* \param ctx Context to check
|
||||
|
@ -37,6 +37,15 @@
|
||||
#define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80 /**< Invalid private or public key. */
|
||||
#define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 /**< Signature is valid but shorter than the user-supplied length. */
|
||||
|
||||
#if !defined(MBEDTLS_ECP_ALT)
|
||||
/*
|
||||
* default mbed TLS elliptic curve arithmetic implementation
|
||||
*
|
||||
* (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an
|
||||
* alternative implementation for the whole module and it will replace this
|
||||
* one.)
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -452,7 +461,7 @@ int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp
|
||||
* \brief Set a group using well-known domain parameters
|
||||
*
|
||||
* \param grp Destination group
|
||||
* \param index Index in the list of well-known domain parameters
|
||||
* \param id Index in the list of well-known domain parameters
|
||||
*
|
||||
* \return 0 if successful,
|
||||
* MBEDTLS_ERR_MPI_XXX if initialization failed
|
||||
@ -461,7 +470,7 @@ int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp
|
||||
* \note Index should be a value of RFC 4492's enum NamedCurve,
|
||||
* usually in the form of a MBEDTLS_ECP_DP_XXX macro.
|
||||
*/
|
||||
int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id index );
|
||||
int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id id );
|
||||
|
||||
/**
|
||||
* \brief Set a group from a TLS ECParameters record
|
||||
@ -654,16 +663,22 @@ int mbedtls_ecp_gen_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
|
||||
int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv );
|
||||
|
||||
#if defined(MBEDTLS_SELF_TEST)
|
||||
|
||||
/**
|
||||
* \brief Checkup routine
|
||||
*
|
||||
* \return 0 if successful, or 1 if a test failed
|
||||
*/
|
||||
int mbedtls_ecp_self_test( int verbose );
|
||||
#endif
|
||||
|
||||
#endif /* MBEDTLS_SELF_TEST */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* MBEDTLS_ECP_ALT */
|
||||
#include "ecp_alt.h"
|
||||
#endif /* MBEDTLS_ECP_ALT */
|
||||
|
||||
#endif /* ecp.h */
|
||||
|
292
tools/sdk/include/mbedtls/mbedtls/ecp_internal.h
Normal file
292
tools/sdk/include/mbedtls/mbedtls/ecp_internal.h
Normal file
@ -0,0 +1,292 @@
|
||||
/**
|
||||
* \file ecp_internal.h
|
||||
*
|
||||
* \brief Function declarations for alternative implementation of elliptic curve
|
||||
* point arithmetic.
|
||||
*
|
||||
* Copyright (C) 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)
|
||||
*/
|
||||
|
||||
/*
|
||||
* References:
|
||||
*
|
||||
* [1] BERNSTEIN, Daniel J. Curve25519: new Diffie-Hellman speed records.
|
||||
* <http://cr.yp.to/ecdh/curve25519-20060209.pdf>
|
||||
*
|
||||
* [2] CORON, Jean-S'ebastien. Resistance against differential power analysis
|
||||
* for elliptic curve cryptosystems. In : Cryptographic Hardware and
|
||||
* Embedded Systems. Springer Berlin Heidelberg, 1999. p. 292-302.
|
||||
* <http://link.springer.com/chapter/10.1007/3-540-48059-5_25>
|
||||
*
|
||||
* [3] HEDABOU, Mustapha, PINEL, Pierre, et B'EN'ETEAU, Lucien. A comb method to
|
||||
* render ECC resistant against Side Channel Attacks. IACR Cryptology
|
||||
* ePrint Archive, 2004, vol. 2004, p. 342.
|
||||
* <http://eprint.iacr.org/2004/342.pdf>
|
||||
*
|
||||
* [4] Certicom Research. SEC 2: Recommended Elliptic Curve Domain Parameters.
|
||||
* <http://www.secg.org/sec2-v2.pdf>
|
||||
*
|
||||
* [5] HANKERSON, Darrel, MENEZES, Alfred J., VANSTONE, Scott. Guide to Elliptic
|
||||
* Curve Cryptography.
|
||||
*
|
||||
* [6] Digital Signature Standard (DSS), FIPS 186-4.
|
||||
* <http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf>
|
||||
*
|
||||
* [7] Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer
|
||||
* Security (TLS), RFC 4492.
|
||||
* <https://tools.ietf.org/search/rfc4492>
|
||||
*
|
||||
* [8] <http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian.html>
|
||||
*
|
||||
* [9] COHEN, Henri. A Course in Computational Algebraic Number Theory.
|
||||
* Springer Science & Business Media, 1 Aug 2000
|
||||
*/
|
||||
|
||||
#ifndef MBEDTLS_ECP_INTERNAL_H
|
||||
#define MBEDTLS_ECP_INTERNAL_H
|
||||
|
||||
#if defined(MBEDTLS_ECP_INTERNAL_ALT)
|
||||
|
||||
/**
|
||||
* \brief Indicate if the Elliptic Curve Point module extension can
|
||||
* handle the group.
|
||||
*
|
||||
* \param grp The pointer to the elliptic curve group that will be the
|
||||
* basis of the cryptographic computations.
|
||||
*
|
||||
* \return Non-zero if successful.
|
||||
*/
|
||||
unsigned char mbedtls_internal_ecp_grp_capable( const mbedtls_ecp_group *grp );
|
||||
|
||||
/**
|
||||
* \brief Initialise the Elliptic Curve Point module extension.
|
||||
*
|
||||
* If mbedtls_internal_ecp_grp_capable returns true for a
|
||||
* group, this function has to be able to initialise the
|
||||
* module for it.
|
||||
*
|
||||
* This module can be a driver to a crypto hardware
|
||||
* accelerator, for which this could be an initialise function.
|
||||
*
|
||||
* \param grp The pointer to the group the module needs to be
|
||||
* initialised for.
|
||||
*
|
||||
* \return 0 if successful.
|
||||
*/
|
||||
int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp );
|
||||
|
||||
/**
|
||||
* \brief Frees and deallocates the Elliptic Curve Point module
|
||||
* extension.
|
||||
*
|
||||
* \param grp The pointer to the group the module was initialised for.
|
||||
*/
|
||||
void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp );
|
||||
|
||||
#if defined(ECP_SHORTWEIERSTRASS)
|
||||
|
||||
#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT)
|
||||
/**
|
||||
* \brief Randomize jacobian coordinates:
|
||||
* (X, Y, Z) -> (l^2 X, l^3 Y, l Z) for random l.
|
||||
*
|
||||
* \param grp Pointer to the group representing the curve.
|
||||
*
|
||||
* \param pt The point on the curve to be randomised, given with Jacobian
|
||||
* coordinates.
|
||||
*
|
||||
* \param f_rng A function pointer to the random number generator.
|
||||
*
|
||||
* \param p_rng A pointer to the random number generator state.
|
||||
*
|
||||
* \return 0 if successful.
|
||||
*/
|
||||
int mbedtls_internal_ecp_randomize_jac( const mbedtls_ecp_group *grp,
|
||||
mbedtls_ecp_point *pt, int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_ADD_MIXED_ALT)
|
||||
/**
|
||||
* \brief Addition: R = P + Q, mixed affine-Jacobian coordinates.
|
||||
*
|
||||
* The coordinates of Q must be normalized (= affine),
|
||||
* but those of P don't need to. R is not normalized.
|
||||
*
|
||||
* This function is used only as a subrutine of
|
||||
* ecp_mul_comb().
|
||||
*
|
||||
* Special cases: (1) P or Q is zero, (2) R is zero,
|
||||
* (3) P == Q.
|
||||
* None of these cases can happen as intermediate step in
|
||||
* ecp_mul_comb():
|
||||
* - at each step, P, Q and R are multiples of the base
|
||||
* point, the factor being less than its order, so none of
|
||||
* them is zero;
|
||||
* - Q is an odd multiple of the base point, P an even
|
||||
* multiple, due to the choice of precomputed points in the
|
||||
* modified comb method.
|
||||
* So branches for these cases do not leak secret information.
|
||||
*
|
||||
* We accept Q->Z being unset (saving memory in tables) as
|
||||
* meaning 1.
|
||||
*
|
||||
* Cost in field operations if done by [5] 3.22:
|
||||
* 1A := 8M + 3S
|
||||
*
|
||||
* \param grp Pointer to the group representing the curve.
|
||||
*
|
||||
* \param R Pointer to a point structure to hold the result.
|
||||
*
|
||||
* \param P Pointer to the first summand, given with Jacobian
|
||||
* coordinates
|
||||
*
|
||||
* \param Q Pointer to the second summand, given with affine
|
||||
* coordinates.
|
||||
*
|
||||
* \return 0 if successful.
|
||||
*/
|
||||
int mbedtls_internal_ecp_add_mixed( const mbedtls_ecp_group *grp,
|
||||
mbedtls_ecp_point *R, const mbedtls_ecp_point *P,
|
||||
const mbedtls_ecp_point *Q );
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Point doubling R = 2 P, Jacobian coordinates.
|
||||
*
|
||||
* Cost: 1D := 3M + 4S (A == 0)
|
||||
* 4M + 4S (A == -3)
|
||||
* 3M + 6S + 1a otherwise
|
||||
* when the implementation is based on the "dbl-1998-cmo-2"
|
||||
* doubling formulas in [8] and standard optimizations are
|
||||
* applied when curve parameter A is one of { 0, -3 }.
|
||||
*
|
||||
* \param grp Pointer to the group representing the curve.
|
||||
*
|
||||
* \param R Pointer to a point structure to hold the result.
|
||||
*
|
||||
* \param P Pointer to the point that has to be doubled, given with
|
||||
* Jacobian coordinates.
|
||||
*
|
||||
* \return 0 if successful.
|
||||
*/
|
||||
#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT)
|
||||
int mbedtls_internal_ecp_double_jac( const mbedtls_ecp_group *grp,
|
||||
mbedtls_ecp_point *R, const mbedtls_ecp_point *P );
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Normalize jacobian coordinates of an array of (pointers to)
|
||||
* points.
|
||||
*
|
||||
* Using Montgomery's trick to perform only one inversion mod P
|
||||
* the cost is:
|
||||
* 1N(t) := 1I + (6t - 3)M + 1S
|
||||
* (See for example Algorithm 10.3.4. in [9])
|
||||
*
|
||||
* This function is used only as a subrutine of
|
||||
* ecp_mul_comb().
|
||||
*
|
||||
* Warning: fails (returning an error) if one of the points is
|
||||
* zero!
|
||||
* This should never happen, see choice of w in ecp_mul_comb().
|
||||
*
|
||||
* \param grp Pointer to the group representing the curve.
|
||||
*
|
||||
* \param T Array of pointers to the points to normalise.
|
||||
*
|
||||
* \param t_len Number of elements in the array.
|
||||
*
|
||||
* \return 0 if successful,
|
||||
* an error if one of the points is zero.
|
||||
*/
|
||||
#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT)
|
||||
int mbedtls_internal_ecp_normalize_jac_many( const mbedtls_ecp_group *grp,
|
||||
mbedtls_ecp_point *T[], size_t t_len );
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Normalize jacobian coordinates so that Z == 0 || Z == 1.
|
||||
*
|
||||
* Cost in field operations if done by [5] 3.2.1:
|
||||
* 1N := 1I + 3M + 1S
|
||||
*
|
||||
* \param grp Pointer to the group representing the curve.
|
||||
*
|
||||
* \param pt pointer to the point to be normalised. This is an
|
||||
* input/output parameter.
|
||||
*
|
||||
* \return 0 if successful.
|
||||
*/
|
||||
#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT)
|
||||
int mbedtls_internal_ecp_normalize_jac( const mbedtls_ecp_group *grp,
|
||||
mbedtls_ecp_point *pt );
|
||||
#endif
|
||||
|
||||
#endif /* ECP_SHORTWEIERSTRASS */
|
||||
|
||||
#if defined(ECP_MONTGOMERY)
|
||||
|
||||
#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT)
|
||||
int mbedtls_internal_ecp_double_add_mxz( const mbedtls_ecp_group *grp,
|
||||
mbedtls_ecp_point *R, mbedtls_ecp_point *S, const mbedtls_ecp_point *P,
|
||||
const mbedtls_ecp_point *Q, const mbedtls_mpi *d );
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Randomize projective x/z coordinates:
|
||||
* (X, Z) -> (l X, l Z) for random l
|
||||
*
|
||||
* \param grp pointer to the group representing the curve
|
||||
*
|
||||
* \param P the point on the curve to be randomised given with
|
||||
* projective coordinates. This is an input/output parameter.
|
||||
*
|
||||
* \param f_rng a function pointer to the random number generator
|
||||
*
|
||||
* \param p_rng a pointer to the random number generator state
|
||||
*
|
||||
* \return 0 if successful
|
||||
*/
|
||||
#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT)
|
||||
int mbedtls_internal_ecp_randomize_mxz( const mbedtls_ecp_group *grp,
|
||||
mbedtls_ecp_point *P, int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng );
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Normalize Montgomery x/z coordinates: X = X/Z, Z = 1.
|
||||
*
|
||||
* \param grp pointer to the group representing the curve
|
||||
*
|
||||
* \param P pointer to the point to be normalised. This is an
|
||||
* input/output parameter.
|
||||
*
|
||||
* \return 0 if successful
|
||||
*/
|
||||
#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT)
|
||||
int mbedtls_internal_ecp_normalize_mxz( const mbedtls_ecp_group *grp,
|
||||
mbedtls_ecp_point *P );
|
||||
#endif
|
||||
|
||||
#endif /* ECP_MONTGOMERY */
|
||||
|
||||
#endif /* MBEDTLS_ECP_INTERNAL_ALT */
|
||||
|
||||
#endif /* ecp_internal.h */
|
||||
|
@ -255,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
|
||||
|
@ -41,7 +41,9 @@ 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.
|
||||
|
@ -71,7 +71,7 @@
|
||||
* Name ID Nr of Errors
|
||||
* PEM 1 9
|
||||
* PKCS#12 1 4 (Started from top)
|
||||
* X509 2 19
|
||||
* X509 2 20
|
||||
* PKCS5 2 4 (Started from top)
|
||||
* DHM 3 9
|
||||
* PK 3 14 (Started from top)
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -304,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
|
||||
@ -317,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
|
||||
*
|
||||
|
@ -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
tools/sdk/include/mbedtls/mbedtls/net_sockets.h
Normal file
225
tools/sdk/include/mbedtls/mbedtls/net_sockets.h
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 */
|
@ -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
|
||||
@ -243,39 +247,6 @@ int mbedtls_platform_set_exit( void (*exit_func)( int status ) );
|
||||
#define MBEDTLS_EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
|
||||
/*
|
||||
* The function pointers for reading from and writing a seed file to
|
||||
* Non-Volatile storage (NV) in a platform-independent way
|
||||
@ -317,6 +288,54 @@ int mbedtls_platform_set_nv_seed(
|
||||
#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */
|
||||
#endif /* MBEDTLS_ENTROPY_NV_SEED */
|
||||
|
||||
#if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
|
||||
|
||||
/**
|
||||
* \brief Platform context structure
|
||||
*
|
||||
* \note This structure may be used to assist platform-specific
|
||||
* setup/teardown operations.
|
||||
*/
|
||||
typedef struct {
|
||||
char dummy; /**< Placeholder member as empty structs are not portable */
|
||||
}
|
||||
mbedtls_platform_context;
|
||||
|
||||
#else
|
||||
#include "platform_alt.h"
|
||||
#endif /* !MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */
|
||||
|
||||
/**
|
||||
* \brief Perform any platform initialisation operations
|
||||
*
|
||||
* \param ctx mbed TLS context
|
||||
*
|
||||
* \return 0 if successful
|
||||
*
|
||||
* \note This function is intended to allow platform specific initialisation,
|
||||
* and should be called before any other library functions. Its
|
||||
* implementation is platform specific, and by default, unless platform
|
||||
* specific code is provided, it does nothing.
|
||||
*
|
||||
* Its use and whether its necessary to be called is dependent on the
|
||||
* platform.
|
||||
*/
|
||||
int mbedtls_platform_setup( mbedtls_platform_context *ctx );
|
||||
/**
|
||||
* \brief Perform any platform teardown operations
|
||||
*
|
||||
* \param ctx mbed TLS context
|
||||
*
|
||||
* \note This function should be called after every other mbed TLS module has
|
||||
* been correctly freed using the appropriate free function.
|
||||
* Its implementation is platform specific, and by default, unless
|
||||
* platform specific code is provided, it does nothing.
|
||||
*
|
||||
* Its use and whether its necessary to be called is dependent on the
|
||||
* platform.
|
||||
*/
|
||||
void mbedtls_platform_teardown( mbedtls_platform_context *ctx );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
81
tools/sdk/include/mbedtls/mbedtls/platform_time.h
Normal file
81
tools/sdk/include/mbedtls/mbedtls/platform_time.h
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 */
|
@ -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
|
||||
@ -206,7 +206,7 @@ int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rs
|
||||
* \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
|
||||
*
|
||||
* \note This function does NOT take care of message
|
||||
* padding. Also, be sure to set input[0] = 0 or assure that
|
||||
* padding. Also, be sure to set input[0] = 0 or ensure that
|
||||
* input is smaller than N.
|
||||
*
|
||||
* \note The input and output buffers must be large
|
||||
@ -329,9 +329,15 @@ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx,
|
||||
*
|
||||
* \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
|
||||
*
|
||||
* \note The output buffer must be as large as the size
|
||||
* of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
|
||||
* an error is thrown.
|
||||
* \note The output buffer length \c output_max_len should be
|
||||
* as large as the size ctx->len of ctx->N (eg. 128 bytes
|
||||
* if RSA-1024 is used) to be able to hold an arbitrary
|
||||
* decrypted message. If it is not large enough to hold
|
||||
* the decryption of the particular ciphertext provided,
|
||||
* the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
|
||||
*
|
||||
* \note The input buffer must be as large as the size
|
||||
* of ctx->N (eg. 128 bytes if RSA-1024 is used).
|
||||
*/
|
||||
int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
@ -355,9 +361,15 @@ int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx,
|
||||
*
|
||||
* \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
|
||||
*
|
||||
* \note The output buffer must be as large as the size
|
||||
* of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
|
||||
* an error is thrown.
|
||||
* \note The output buffer length \c output_max_len should be
|
||||
* as large as the size ctx->len of ctx->N (eg. 128 bytes
|
||||
* if RSA-1024 is used) to be able to hold an arbitrary
|
||||
* decrypted message. If it is not large enough to hold
|
||||
* the decryption of the particular ciphertext provided,
|
||||
* the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
|
||||
*
|
||||
* \note The input buffer must be as large as the size
|
||||
* of ctx->N (eg. 128 bytes if RSA-1024 is used).
|
||||
*/
|
||||
int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
@ -383,9 +395,15 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
|
||||
*
|
||||
* \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
|
||||
*
|
||||
* \note The output buffer must be as large as the size
|
||||
* of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
|
||||
* an error is thrown.
|
||||
* \note The output buffer length \c output_max_len should be
|
||||
* as large as the size ctx->len of ctx->N (eg. 128 bytes
|
||||
* if RSA-1024 is used) to be able to hold an arbitrary
|
||||
* decrypted message. If it is not large enough to hold
|
||||
* the decryption of the particular ciphertext provided,
|
||||
* the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
|
||||
*
|
||||
* \note The input buffer must be as large as the size
|
||||
* of ctx->N (eg. 128 bytes if RSA-1024 is used).
|
||||
*/
|
||||
int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "platform.h"
|
||||
#include "bignum.h"
|
||||
#include "ecp.h"
|
||||
|
||||
@ -53,7 +52,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
#include <time.h>
|
||||
#include "mbedtls/platform_time.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -108,6 +107,8 @@
|
||||
#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
|
||||
@ -184,6 +185,9 @@
|
||||
#define MBEDTLS_SSL_PRESET_DEFAULT 0
|
||||
#define MBEDTLS_SSL_PRESET_SUITEB 2
|
||||
|
||||
#define MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED 1
|
||||
#define MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED 0
|
||||
|
||||
/*
|
||||
* Default range for DTLS retransmission timer value, in milliseconds.
|
||||
* RFC 6347 4.2.4.1 says from 1 second to 60 seconds.
|
||||
@ -530,6 +534,7 @@ typedef struct mbedtls_ssl_config mbedtls_ssl_config;
|
||||
/* Defined in ssl_internal.h */
|
||||
typedef struct mbedtls_ssl_transform mbedtls_ssl_transform;
|
||||
typedef struct mbedtls_ssl_handshake_params mbedtls_ssl_handshake_params;
|
||||
typedef struct mbedtls_ssl_sig_hash_set_t mbedtls_ssl_sig_hash_set_t;
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
typedef struct mbedtls_ssl_key_cert mbedtls_ssl_key_cert;
|
||||
#endif
|
||||
@ -748,6 +753,10 @@ struct mbedtls_ssl_config
|
||||
#if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
|
||||
unsigned int fallback : 1; /*!< is this a fallback? */
|
||||
#endif
|
||||
#if defined(MBEDTLS_SSL_SRV_C)
|
||||
unsigned int cert_req_ca_list : 1; /*!< enable sending CA list in
|
||||
Certificate Request messages? */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -836,7 +845,9 @@ struct mbedtls_ssl_context
|
||||
size_t in_hslen; /*!< current handshake message length,
|
||||
including the handshake header */
|
||||
int nb_zero; /*!< # of 0-length encrypted messages */
|
||||
int record_read; /*!< record is already present */
|
||||
|
||||
int keep_current_message; /*!< drop or reuse current message
|
||||
on next call to record layer? */
|
||||
|
||||
/*
|
||||
* Record layer (outgoing data)
|
||||
@ -1041,7 +1052,7 @@ void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *conf, int authmode );
|
||||
*
|
||||
* If set, the verify callback is called for each
|
||||
* certificate in the chain. For implementation
|
||||
* information, please see \c x509parse_verify()
|
||||
* information, please see \c mbedtls_x509_crt_verify()
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param f_vrfy verification function
|
||||
@ -1106,9 +1117,10 @@ void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf,
|
||||
* \c mbedtls_ssl_recv_t and \c mbedtls_ssl_recv_timeout_t for
|
||||
* the conventions those callbacks must follow.
|
||||
*
|
||||
* \note On some platforms, net.c provides \c mbedtls_net_send(),
|
||||
* \c mbedtls_net_recv() and \c mbedtls_net_recv_timeout()
|
||||
* that are suitable to be used here.
|
||||
* \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,
|
||||
@ -1144,7 +1156,7 @@ void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout )
|
||||
*
|
||||
* \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.
|
||||
* callbacks must follow.
|
||||
*
|
||||
* \note On some platforms, timing.c provides
|
||||
* \c mbedtls_timing_set_delay() and
|
||||
@ -2029,6 +2041,20 @@ void mbedtls_ssl_conf_extended_master_secret( mbedtls_ssl_config *conf, char ems
|
||||
void mbedtls_ssl_conf_arc4_support( mbedtls_ssl_config *conf, char arc4 );
|
||||
#endif /* MBEDTLS_ARC4_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SRV_C)
|
||||
/**
|
||||
* \brief Whether to send a list of acceptable CAs in
|
||||
* CertificateRequest messages.
|
||||
* (Default: do send)
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param cert_req_ca_list MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED or
|
||||
* MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED
|
||||
*/
|
||||
void mbedtls_ssl_conf_cert_req_ca_list( mbedtls_ssl_config *conf,
|
||||
char cert_req_ca_list );
|
||||
#endif /* MBEDTLS_SSL_SRV_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
/**
|
||||
* \brief Set the maximum fragment length to emit and/or negotiate
|
||||
@ -2181,7 +2207,7 @@ void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_
|
||||
|
||||
/**
|
||||
* \brief Set record counter threshold for periodic renegotiation.
|
||||
* (Default: 2^64 - 256.)
|
||||
* (Default: 2^48 - 1)
|
||||
*
|
||||
* Renegotiation is automatically triggered when a record
|
||||
* counter (outgoing or ingoing) crosses the defined
|
||||
@ -2192,9 +2218,17 @@ void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_
|
||||
* Lower values can be used to enforce policies such as "keys
|
||||
* must be refreshed every N packets with cipher X".
|
||||
*
|
||||
* The renegotiation period can be disabled by setting
|
||||
* conf->disable_renegotiation to
|
||||
* MBEDTLS_SSL_RENEGOTIATION_DISABLED.
|
||||
*
|
||||
* \note When the configured transport is
|
||||
* MBEDTLS_SSL_TRANSPORT_DATAGRAM the maximum renegotiation
|
||||
* period is 2^48 - 1, and for MBEDTLS_SSL_TRANSPORT_STREAM,
|
||||
* the maximum renegotiation period is 2^64 - 1.
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param period The threshold value: a big-endian 64-bit number.
|
||||
* Set to 2^64 - 1 to disable periodic renegotiation
|
||||
*/
|
||||
void mbedtls_ssl_conf_renegotiation_period( mbedtls_ssl_config *conf,
|
||||
const unsigned char period[8] );
|
||||
@ -2426,7 +2460,7 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )
|
||||
* \param len how many bytes must be written
|
||||
*
|
||||
* \return the number of bytes actually written (may be less than len),
|
||||
* or MBEDTLS_ERR_SSL_WANT_WRITE of MBEDTLS_ERR_SSL_WANT_READ,
|
||||
* or MBEDTLS_ERR_SSL_WANT_WRITE or MBEDTLS_ERR_SSL_WANT_READ,
|
||||
* or another negative error code.
|
||||
*
|
||||
* \note If this function returns something other than a positive
|
||||
@ -2511,7 +2545,6 @@ void mbedtls_ssl_config_init( mbedtls_ssl_config *conf );
|
||||
* \param transport MBEDTLS_SSL_TRANSPORT_STREAM for TLS, or
|
||||
* MBEDTLS_SSL_TRANSPORT_DATAGRAM for DTLS
|
||||
* \param preset a MBEDTLS_SSL_PRESET_XXX value
|
||||
* (currently unused).
|
||||
*
|
||||
* \note See \c mbedtls_ssl_conf_transport() for notes on DTLS.
|
||||
*
|
||||
|
@ -260,6 +260,47 @@ typedef enum {
|
||||
#define MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED
|
||||
#endif
|
||||
|
||||
/* Key exchanges allowing client certificate requests */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||
#define MBEDTLS_KEY_EXCHANGE__CERT_REQ_ALLOWED__ENABLED
|
||||
#endif
|
||||
|
||||
/* Key exchanges involving server signature in ServerKeyExchange */
|
||||
#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__WITH_SERVER_SIGNATURE__ENABLED
|
||||
#endif
|
||||
|
||||
/* Key exchanges using ECDH */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
|
||||
#define MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED
|
||||
#endif
|
||||
|
||||
/* Key exchanges that don't involve ephemeral keys */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED)
|
||||
#define MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED
|
||||
#endif
|
||||
|
||||
/* Key exchanges that involve ephemeral keys */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
#define MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED
|
||||
#endif
|
||||
|
||||
/* Key exchanges using a PSK */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
|
||||
@ -268,7 +309,13 @@ typedef enum {
|
||||
#define MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED
|
||||
#endif
|
||||
|
||||
/* Key exchanges using a ECDHE */
|
||||
/* Key exchanges using DHE */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
|
||||
#define MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED
|
||||
#endif
|
||||
|
||||
/* Key exchanges using ECDHE */
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
|
||||
@ -309,11 +356,128 @@ const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_id( int ciphersuit
|
||||
|
||||
#if defined(MBEDTLS_PK_C)
|
||||
mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg( const mbedtls_ssl_ciphersuite_t *info );
|
||||
mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_alg( const mbedtls_ssl_ciphersuite_t *info );
|
||||
#endif
|
||||
|
||||
int mbedtls_ssl_ciphersuite_uses_ec( const mbedtls_ssl_ciphersuite_t *info );
|
||||
int mbedtls_ssl_ciphersuite_uses_psk( const mbedtls_ssl_ciphersuite_t *info );
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED)
|
||||
static inline int mbedtls_ssl_ciphersuite_has_pfs( const mbedtls_ssl_ciphersuite_t *info )
|
||||
{
|
||||
switch( info->key_exchange )
|
||||
{
|
||||
case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_DHE_PSK:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECJPAKE:
|
||||
return( 1 );
|
||||
|
||||
default:
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED)
|
||||
static inline int mbedtls_ssl_ciphersuite_no_pfs( const mbedtls_ssl_ciphersuite_t *info )
|
||||
{
|
||||
switch( info->key_exchange )
|
||||
{
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDH_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_PSK:
|
||||
case MBEDTLS_KEY_EXCHANGE_RSA_PSK:
|
||||
return( 1 );
|
||||
|
||||
default:
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED)
|
||||
static inline int mbedtls_ssl_ciphersuite_uses_ecdh( const mbedtls_ssl_ciphersuite_t *info )
|
||||
{
|
||||
switch( info->key_exchange )
|
||||
{
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDH_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA:
|
||||
return( 1 );
|
||||
|
||||
default:
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED */
|
||||
|
||||
static inline int mbedtls_ssl_ciphersuite_cert_req_allowed( const mbedtls_ssl_ciphersuite_t *info )
|
||||
{
|
||||
switch( info->key_exchange )
|
||||
{
|
||||
case MBEDTLS_KEY_EXCHANGE_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDH_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
|
||||
return( 1 );
|
||||
|
||||
default:
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED)
|
||||
static inline int mbedtls_ssl_ciphersuite_uses_dhe( const mbedtls_ssl_ciphersuite_t *info )
|
||||
{
|
||||
switch( info->key_exchange )
|
||||
{
|
||||
case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_DHE_PSK:
|
||||
return( 1 );
|
||||
|
||||
default:
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED) */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED)
|
||||
static inline int mbedtls_ssl_ciphersuite_uses_ecdhe( const mbedtls_ssl_ciphersuite_t *info )
|
||||
{
|
||||
switch( info->key_exchange )
|
||||
{
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK:
|
||||
return( 1 );
|
||||
|
||||
default:
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED) */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED)
|
||||
static inline int mbedtls_ssl_ciphersuite_uses_server_signature( const mbedtls_ssl_ciphersuite_t *info )
|
||||
{
|
||||
switch( info->key_exchange )
|
||||
{
|
||||
case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
|
||||
case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
|
||||
return( 1 );
|
||||
|
||||
default:
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -157,6 +157,24 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
|
||||
defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
|
||||
/*
|
||||
* Abstraction for a grid of allowed signature-hash-algorithm pairs.
|
||||
*/
|
||||
struct mbedtls_ssl_sig_hash_set_t
|
||||
{
|
||||
/* At the moment, we only need to remember a single suitable
|
||||
* hash algorithm per signature algorithm. As long as that's
|
||||
* the case - and we don't need a general lookup function -
|
||||
* we can implement the sig-hash-set as a map from signatures
|
||||
* to hash algorithms. */
|
||||
mbedtls_md_type_t rsa;
|
||||
mbedtls_md_type_t ecdsa;
|
||||
};
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 &&
|
||||
MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
|
||||
|
||||
/*
|
||||
* This structure contains the parameters only needed during handshake.
|
||||
*/
|
||||
@ -165,8 +183,11 @@ struct mbedtls_ssl_handshake_params
|
||||
/*
|
||||
* Handshake specific crypto variables
|
||||
*/
|
||||
int sig_alg; /*!< Hash algorithm for signature */
|
||||
int verify_sig_alg; /*!< Signature algorithm for verify */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
|
||||
defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
|
||||
mbedtls_ssl_sig_hash_set_t hash_algs; /*!< Set of suitable sig-hash pairs */
|
||||
#endif
|
||||
#if defined(MBEDTLS_DHM_C)
|
||||
mbedtls_dhm_context dhm_ctx; /*!< DHM key exchange */
|
||||
#endif
|
||||
@ -179,7 +200,7 @@ struct mbedtls_ssl_handshake_params
|
||||
unsigned char *ecjpake_cache; /*!< Cache for ClientHello ext */
|
||||
size_t ecjpake_cache_len; /*!< Length of cached data */
|
||||
#endif
|
||||
#endif
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
|
||||
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
const mbedtls_ecp_curve_info **curves; /*!< Supported elliptic curves */
|
||||
@ -195,7 +216,7 @@ struct mbedtls_ssl_handshake_params
|
||||
mbedtls_ssl_key_cert *sni_key_cert; /*!< key/cert list from SNI */
|
||||
mbedtls_x509_crt *sni_ca_chain; /*!< trusted CAs from SNI callback */
|
||||
mbedtls_x509_crl *sni_ca_crl; /*!< trusted CAs CRLs from SNI */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
unsigned int out_msg_seq; /*!< Outgoing handshake sequence number */
|
||||
@ -218,7 +239,7 @@ struct mbedtls_ssl_handshake_params
|
||||
resending messages */
|
||||
unsigned char alt_out_ctr[8]; /*!< Alternative record epoch/counter
|
||||
for resending messages */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
/*
|
||||
* Checksum contexts
|
||||
@ -329,6 +350,28 @@ struct mbedtls_ssl_flight_item
|
||||
};
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
|
||||
defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
|
||||
|
||||
/* Find an entry in a signature-hash set matching a given hash algorithm. */
|
||||
mbedtls_md_type_t mbedtls_ssl_sig_hash_set_find( mbedtls_ssl_sig_hash_set_t *set,
|
||||
mbedtls_pk_type_t sig_alg );
|
||||
/* Add a signature-hash-pair to a signature-hash set */
|
||||
void mbedtls_ssl_sig_hash_set_add( mbedtls_ssl_sig_hash_set_t *set,
|
||||
mbedtls_pk_type_t sig_alg,
|
||||
mbedtls_md_type_t md_alg );
|
||||
/* Allow exactly one hash algorithm for each signature. */
|
||||
void mbedtls_ssl_sig_hash_set_const_hash( mbedtls_ssl_sig_hash_set_t *set,
|
||||
mbedtls_md_type_t md_alg );
|
||||
|
||||
/* Setup an empty signature-hash set */
|
||||
static inline void mbedtls_ssl_sig_hash_set_init( mbedtls_ssl_sig_hash_set_t *set )
|
||||
{
|
||||
mbedtls_ssl_sig_hash_set_const_hash( set, MBEDTLS_MD_NONE );
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2) &&
|
||||
MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
|
||||
|
||||
/**
|
||||
* \brief Free referenced items in an SSL transform context and clear
|
||||
@ -355,6 +398,84 @@ 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 );
|
||||
|
||||
/**
|
||||
* \brief Update record layer
|
||||
*
|
||||
* This function roughly separates the implementation
|
||||
* of the logic of (D)TLS from the implementation
|
||||
* of the secure transport.
|
||||
*
|
||||
* \param ssl SSL context to use
|
||||
*
|
||||
* \return 0 or non-zero error code.
|
||||
*
|
||||
* \note A clarification on what is called 'record layer' here
|
||||
* is in order, as many sensible definitions are possible:
|
||||
*
|
||||
* The record layer takes as input an untrusted underlying
|
||||
* transport (stream or datagram) and transforms it into
|
||||
* a serially multiplexed, secure transport, which
|
||||
* conceptually provides the following:
|
||||
*
|
||||
* (1) Three datagram based, content-agnostic transports
|
||||
* for handshake, alert and CCS messages.
|
||||
* (2) One stream- or datagram-based transport
|
||||
* for application data.
|
||||
* (3) Functionality for changing the underlying transform
|
||||
* securing the contents.
|
||||
*
|
||||
* The interface to this functionality is given as follows:
|
||||
*
|
||||
* a Updating
|
||||
* [Currently implemented by mbedtls_ssl_read_record]
|
||||
*
|
||||
* Check if and on which of the four 'ports' data is pending:
|
||||
* Nothing, a controlling datagram of type (1), or application
|
||||
* data (2). In any case data is present, internal buffers
|
||||
* provide access to the data for the user to process it.
|
||||
* Consumption of type (1) datagrams is done automatically
|
||||
* on the next update, invalidating that the internal buffers
|
||||
* for previous datagrams, while consumption of application
|
||||
* data (2) is user-controlled.
|
||||
*
|
||||
* b Reading of application data
|
||||
* [Currently manual adaption of ssl->in_offt pointer]
|
||||
*
|
||||
* As mentioned in the last paragraph, consumption of data
|
||||
* is different from the automatic consumption of control
|
||||
* datagrams (1) because application data is treated as a stream.
|
||||
*
|
||||
* c Tracking availability of application data
|
||||
* [Currently manually through decreasing ssl->in_msglen]
|
||||
*
|
||||
* For efficiency and to retain datagram semantics for
|
||||
* application data in case of DTLS, the record layer
|
||||
* provides functionality for checking how much application
|
||||
* data is still available in the internal buffer.
|
||||
*
|
||||
* d Changing the transformation securing the communication.
|
||||
*
|
||||
* Given an opaque implementation of the record layer in the
|
||||
* above sense, it should be possible to implement the logic
|
||||
* of (D)TLS on top of it without the need to know anything
|
||||
* about the record layer's internals. This is done e.g.
|
||||
* in all the handshake handling functions, and in the
|
||||
* application data reading function mbedtls_ssl_read.
|
||||
*
|
||||
* \note The above tries to give a conceptual picture of the
|
||||
* record layer, but the current implementation deviates
|
||||
* from it in some places. For example, our implementation of
|
||||
* the update functionality through mbedtls_ssl_read_record
|
||||
* discards datagrams depending on the current state, which
|
||||
* wouldn't fall under the record layer's responsibility
|
||||
* following the above definition.
|
||||
*
|
||||
*/
|
||||
int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl );
|
||||
int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want );
|
||||
|
||||
@ -379,11 +500,13 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch
|
||||
|
||||
#if defined(MBEDTLS_PK_C)
|
||||
unsigned char mbedtls_ssl_sig_from_pk( mbedtls_pk_context *pk );
|
||||
unsigned char mbedtls_ssl_sig_from_pk_alg( mbedtls_pk_type_t type );
|
||||
mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig( unsigned char sig );
|
||||
#endif
|
||||
|
||||
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 );
|
||||
|
@ -38,7 +38,7 @@
|
||||
* Major, Minor, Patchlevel
|
||||
*/
|
||||
#define MBEDTLS_VERSION_MAJOR 2
|
||||
#define MBEDTLS_VERSION_MINOR 3
|
||||
#define MBEDTLS_VERSION_MINOR 6
|
||||
#define MBEDTLS_VERSION_PATCH 0
|
||||
|
||||
/**
|
||||
@ -46,9 +46,9 @@
|
||||
* MMNNPP00
|
||||
* Major version | Minor version | Patch version
|
||||
*/
|
||||
#define MBEDTLS_VERSION_NUMBER 0x02030000
|
||||
#define MBEDTLS_VERSION_STRING "2.3.0"
|
||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.3.0"
|
||||
#define MBEDTLS_VERSION_NUMBER 0x02060000
|
||||
#define MBEDTLS_VERSION_STRING "2.6.0"
|
||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.6.0"
|
||||
|
||||
#if defined(MBEDTLS_VERSION_C)
|
||||
|
||||
|
@ -76,6 +76,7 @@
|
||||
#define MBEDTLS_ERR_X509_ALLOC_FAILED -0x2880 /**< Allocation of memory failed. */
|
||||
#define MBEDTLS_ERR_X509_FILE_IO_ERROR -0x2900 /**< Read/write of file failed. */
|
||||
#define MBEDTLS_ERR_X509_BUFFER_TOO_SMALL -0x2980 /**< Destination buffer is too small. */
|
||||
#define MBEDTLS_ERR_X509_FATAL_ERROR -0x3000 /**< A fatal error occured, eg the chain is too long or the vrfy callback failed. */
|
||||
/* \} name */
|
||||
|
||||
/**
|
||||
@ -157,7 +158,7 @@
|
||||
#define MBEDTLS_X509_EXT_INIHIBIT_ANYPOLICY (1 << 13)
|
||||
#define MBEDTLS_X509_EXT_FRESHEST_CRL (1 << 14)
|
||||
|
||||
#define MBEDTLS_X509_EXT_NS_CERT_TYPE (1 << 16) /* Parsed (and then ?) */
|
||||
#define MBEDTLS_X509_EXT_NS_CERT_TYPE (1 << 16)
|
||||
|
||||
/*
|
||||
* Storage format identifiers
|
||||
@ -246,12 +247,12 @@ int mbedtls_x509_serial_gets( char *buf, size_t size, const mbedtls_x509_buf *se
|
||||
* \note Intended usage is "if( is_past( valid_to ) ) ERROR".
|
||||
* Hence the return value of 1 if on internal errors.
|
||||
*
|
||||
* \param time mbedtls_x509_time to check
|
||||
* \param to mbedtls_x509_time to check
|
||||
*
|
||||
* \return 1 if the given time is in the past or an error occured,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int mbedtls_x509_time_is_past( const mbedtls_x509_time *time );
|
||||
int mbedtls_x509_time_is_past( const mbedtls_x509_time *to );
|
||||
|
||||
/**
|
||||
* \brief Check a given mbedtls_x509_time against the system time
|
||||
@ -260,12 +261,12 @@ int mbedtls_x509_time_is_past( const mbedtls_x509_time *time );
|
||||
* \note Intended usage is "if( is_future( valid_from ) ) ERROR".
|
||||
* Hence the return value of 1 if on internal errors.
|
||||
*
|
||||
* \param time mbedtls_x509_time to check
|
||||
* \param from mbedtls_x509_time to check
|
||||
*
|
||||
* \return 1 if the given time is in the future or an error occured,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int mbedtls_x509_time_is_future( const mbedtls_x509_time *time );
|
||||
int mbedtls_x509_time_is_future( const mbedtls_x509_time *from );
|
||||
|
||||
/**
|
||||
* \brief Checkup routine
|
||||
@ -294,7 +295,7 @@ int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x50
|
||||
mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg,
|
||||
void **sig_opts );
|
||||
int mbedtls_x509_get_time( unsigned char **p, const unsigned char *end,
|
||||
mbedtls_x509_time *time );
|
||||
mbedtls_x509_time *t );
|
||||
int mbedtls_x509_get_serial( unsigned char **p, const unsigned char *end,
|
||||
mbedtls_x509_buf *serial );
|
||||
int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end,
|
||||
|
@ -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)
|
||||
*/
|
||||
@ -263,7 +267,13 @@ int mbedtls_x509_crt_verify_info( char *buf, size_t size, const char *prefix,
|
||||
*
|
||||
* All flags left after returning from the callback
|
||||
* are also returned to the application. The function should
|
||||
* return 0 for anything but a fatal error.
|
||||
* return 0 for anything (including invalid certificates)
|
||||
* other than fatal error, as a non-zero return code
|
||||
* immediately aborts the verification process. For fatal
|
||||
* errors, a specific error code should be used (different
|
||||
* from MBEDTLS_ERR_X509_CERT_VERIFY_FAILED which should not
|
||||
* be returned at this point), or MBEDTLS_ERR_X509_FATAL_ERROR
|
||||
* can be used if no better code is available.
|
||||
*
|
||||
* \note In case verification failed, the results can be displayed
|
||||
* using \c mbedtls_x509_crt_verify_info()
|
||||
@ -285,12 +295,13 @@ int mbedtls_x509_crt_verify_info( char *buf, size_t size, const char *prefix,
|
||||
* \param f_vrfy verification function
|
||||
* \param p_vrfy verification parameter
|
||||
*
|
||||
* \return 0 if successful or MBEDTLS_ERR_X509_CERT_VERIFY_FAILED
|
||||
* in which case *flags will have one or more
|
||||
* MBEDTLS_X509_BADCERT_XXX or MBEDTLS_X509_BADCRL_XXX flags
|
||||
* set,
|
||||
* or another error in case of a fatal error encountered
|
||||
* during the verification process.
|
||||
* \return 0 (and flags set to 0) if the chain was verified and valid,
|
||||
* MBEDTLS_ERR_X509_CERT_VERIFY_FAILED if the chain was verified
|
||||
* but found to be invalid, in which case *flags will have one
|
||||
* or more MBEDTLS_X509_BADCERT_XXX or MBEDTLS_X509_BADCRL_XXX
|
||||
* flags set, or another error (and flags set to 0xffffffff)
|
||||
* in case of a fatal error encountered during the
|
||||
* verification process.
|
||||
*/
|
||||
int mbedtls_x509_crt_verify( mbedtls_x509_crt *crt,
|
||||
mbedtls_x509_crt *trust_ca,
|
||||
|
@ -282,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