Skip to content

Update mbed TLS feature to mbedtls-2.4.2 #3877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/mbedtls/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mbedtls-2.4.0
mbedtls-2.4.2
2 changes: 1 addition & 1 deletion features/mbedtls/importer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#

# Set the mbed TLS release to import (this can/should be edited before import)
MBED_TLS_RELEASE ?= mbedtls-2.4.0
MBED_TLS_RELEASE ?= mbedtls-2.4.2

# Translate between mbed TLS namespace and mbed namespace
TARGET_PREFIX:=../
Expand Down
10 changes: 7 additions & 3 deletions features/mbedtls/inc/mbedtls/cmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ struct mbedtls_cmac_context_t
/**
* \brief Set the CMAC key and prepare to authenticate the input
* data.
* Should be called with an initialised cipher context.
* Should be called with an initialized cipher context.
*
* \param ctx 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)
Expand Down Expand Up @@ -115,7 +119,7 @@ int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx,
int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx );

/**
* \brief Output = Generic_CMAC( hmac key, input buffer )
* \brief Output = Generic_CMAC( cmac key, input buffer )
*
* \param cipher_info message digest info
* \param key CMAC key
Expand Down
1 change: 0 additions & 1 deletion features/mbedtls/inc/mbedtls/compat-1.3.h
Original file line number Diff line number Diff line change
Expand Up @@ -2453,7 +2453,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
Expand Down
62 changes: 31 additions & 31 deletions features/mbedtls/inc/mbedtls/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,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

Expand Down Expand Up @@ -1901,7 +1901,7 @@
*
* Enable the generic message digest layer.
*
* Module: library/mbedtls_md.c
* Module: library/md.c
* Caller:
*
* Uncomment to enable generic message digest wrappers.
Expand All @@ -1913,7 +1913,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.
Expand All @@ -1925,7 +1925,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.
Expand All @@ -1937,8 +1937,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
*
Expand Down Expand Up @@ -1995,11 +1995,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.
*/
Expand Down Expand Up @@ -2027,9 +2027,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
*
Expand All @@ -2045,7 +2045,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
*
Expand Down Expand Up @@ -2075,8 +2075,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
*
Expand Down Expand Up @@ -2167,8 +2167,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
Expand Down Expand Up @@ -2196,8 +2196,8 @@
*
* 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
Expand All @@ -2212,9 +2212,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
Expand All @@ -2229,9 +2229,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
*
Expand Down Expand Up @@ -2379,9 +2379,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
Expand All @@ -2395,7 +2395,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
Expand All @@ -2411,8 +2411,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
*
Expand All @@ -2425,7 +2425,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
Expand Down
2 changes: 1 addition & 1 deletion features/mbedtls/inc/mbedtls/rsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions features/mbedtls/inc/mbedtls/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,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
Expand Down Expand Up @@ -2183,7 +2183,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
Expand All @@ -2194,9 +2194,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] );
Expand Down Expand Up @@ -2428,7 +2436,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
Expand Down Expand Up @@ -2513,7 +2521,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.
*
Expand Down
8 changes: 4 additions & 4 deletions features/mbedtls/inc/mbedtls/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@
*/
#define MBEDTLS_VERSION_MAJOR 2
#define MBEDTLS_VERSION_MINOR 4
#define MBEDTLS_VERSION_PATCH 0
#define MBEDTLS_VERSION_PATCH 2

/**
* The single version number has the following structure:
* MMNNPP00
* Major version | Minor version | Patch version
*/
#define MBEDTLS_VERSION_NUMBER 0x02040000
#define MBEDTLS_VERSION_STRING "2.4.0"
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.4.0"
#define MBEDTLS_VERSION_NUMBER 0x02040200
#define MBEDTLS_VERSION_STRING "2.4.2"
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.4.2"

#if defined(MBEDTLS_VERSION_C)

Expand Down
2 changes: 1 addition & 1 deletion features/mbedtls/inc/mbedtls/x509.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,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
Expand Down
6 changes: 5 additions & 1 deletion features/mbedtls/src/base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen,
return( 0 );
}

n = ( ( n * 6 ) + 7 ) >> 3;
/* The following expression is to calculate the following formula without
* risk of integer overflow in n:
* n = ( ( n * 6 ) + 7 ) >> 3;
*/
n = ( 6 * ( n >> 3 ) ) + ( ( 6 * ( n & 0x7 ) + 7 ) >> 3 );
n -= j;

if( dst == NULL || dlen < n )
Expand Down
7 changes: 6 additions & 1 deletion features/mbedtls/src/bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,12 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix,
n = mbedtls_mpi_bitlen( X );
if( radix >= 4 ) n >>= 1;
if( radix >= 16 ) n >>= 1;
n += 3;
/*
* Round up the buffer length to an even value to ensure that there is
* enough room for hexadecimal values that can be represented in an odd
* number of digits.
*/
n += 3 + ( ( n + 1 ) & 1 );

if( buflen < n )
{
Expand Down
4 changes: 2 additions & 2 deletions features/mbedtls/src/cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i
* If there is not enough data for a full block, cache it.
*/
if( ( ctx->operation == MBEDTLS_DECRYPT &&
ilen + ctx->unprocessed_len <= block_size ) ||
ilen <= block_size - ctx->unprocessed_len ) ||
( ctx->operation == MBEDTLS_ENCRYPT &&
ilen + ctx->unprocessed_len < block_size ) )
ilen < block_size - ctx->unprocessed_len ) )
{
memcpy( &( ctx->unprocessed_data[ctx->unprocessed_len] ), input,
ilen );
Expand Down
Loading