Skip to content

Commit 72fae94

Browse files
committed
Updates the mbed TLS library to the latest development head
1 parent d761e3f commit 72fae94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+465
-365
lines changed

core/mbedtls/AUTHORS.txt

Lines changed: 0 additions & 39 deletions
This file was deleted.

core/mbedtls/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
yotta-2.3.0
1+
yotta-2.3.0-144-g9fa2e86d93b9b6e04c0a797b34aaf7b6066fbb25

core/mbedtls/inc/mbedtls/bn_mul.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@
162162

163163
#define MULADDC_INIT \
164164
asm( \
165-
"movq %3, %%rsi \n\t" \
166-
"movq %4, %%rdi \n\t" \
167-
"movq %5, %%rcx \n\t" \
168-
"movq %6, %%rbx \n\t" \
169165
"xorq %%r8, %%r8 \n\t"
170166

171167
#define MULADDC_CORE \
@@ -181,12 +177,9 @@
181177
"addq $8, %%rdi \n\t"
182178

183179
#define MULADDC_STOP \
184-
"movq %%rcx, %0 \n\t" \
185-
"movq %%rdi, %1 \n\t" \
186-
"movq %%rsi, %2 \n\t" \
187-
: "=m" (c), "=m" (d), "=m" (s) \
188-
: "m" (s), "m" (d), "m" (c), "m" (b) \
189-
: "rax", "rcx", "rdx", "rbx", "rsi", "rdi", "r8" \
180+
: "+c" (c), "+D" (d), "+S" (s) \
181+
: "b" (b) \
182+
: "rax", "rdx", "r8" \
190183
);
191184

192185
#endif /* AMD64 */

core/mbedtls/inc/mbedtls/check_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@
362362
#error "MBEDTLS_RSA_C defined, but not all prerequisites"
363363
#endif
364364

365+
#if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_PKCS1_V21) && \
366+
!defined(MBEDTLS_PKCS1_V15) )
367+
#error "MBEDTLS_RSA_C defined, but none of the PKCS1 versions enabled"
368+
#endif
369+
365370
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) && \
366371
( !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_PKCS1_V21) )
367372
#error "MBEDTLS_X509_RSASSA_PSS_SUPPORT defined, but not all prerequisites"

core/mbedtls/inc/mbedtls/config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
* platform function
153153
*/
154154
//#define MBEDTLS_PLATFORM_EXIT_ALT
155+
//#define MBEDTLS_PLATFORM_TIME_ALT
155156
//#define MBEDTLS_PLATFORM_FPRINTF_ALT
156157
//#define MBEDTLS_PLATFORM_PRINTF_ALT
157158
//#define MBEDTLS_PLATFORM_SNPRINTF_ALT
@@ -2465,6 +2466,7 @@
24652466
//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */
24662467
//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */
24672468
//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */
2469+
//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined */
24682470
//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
24692471
//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
24702472
/* Note: your snprintf must correclty zero-terminate the buffer! */
@@ -2477,6 +2479,8 @@
24772479
//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */
24782480
//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */
24792481
//#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */
2482+
//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined */
2483+
//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined */
24802484
//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */
24812485
//#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */
24822486
/* Note: your snprintf must correclty zero-terminate the buffer! */

core/mbedtls/inc/mbedtls/dhm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ int mbedtls_dhm_read_public( mbedtls_dhm_context *ctx,
221221
* \param ctx DHM context
222222
* \param x_size private value size in bytes
223223
* \param output destination buffer
224-
* \param olen must be equal to ctx->P.len
224+
* \param olen must be at least equal to the size of P, ctx->len
225225
* \param f_rng RNG function
226226
* \param p_rng RNG parameter
227227
*

core/mbedtls/inc/mbedtls/memory_buffer_alloc.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ void mbedtls_memory_buffer_alloc_status( void );
9898
/**
9999
* \brief Get the peak heap usage so far
100100
*
101-
* \param max_used Peak number of bytes reauested by the application
102-
* \param max_blocks Peak number of blocks reauested by the application
101+
* \param max_used Peak number of bytes in use or committed. This
102+
* includes bytes in allocated blocks too small to split
103+
* into smaller blocks but larger than the requested size.
104+
* \param max_blocks Peak number of blocks in use, including free and used
103105
*/
104106
void mbedtls_memory_buffer_alloc_max_get( size_t *max_used, size_t *max_blocks );
105107

@@ -111,8 +113,10 @@ void mbedtls_memory_buffer_alloc_max_reset( void );
111113
/**
112114
* \brief Get the current heap usage
113115
*
114-
* \param cur_used Number of bytes reauested by the application
115-
* \param cur_blocks Number of blocks reauested by the application
116+
* \param cur_used Current number of bytes in use or committed. This
117+
* includes bytes in allocated blocks too small to split
118+
* into smaller blocks but larger than the requested size.
119+
* \param cur_blocks Current number of blocks in use, including free and used
116120
*/
117121
void mbedtls_memory_buffer_alloc_cur_get( size_t *cur_used, size_t *cur_blocks );
118122
#endif /* MBEDTLS_MEMORY_DEBUG */

core/mbedtls/inc/mbedtls/pk.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,12 @@ int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx,
496496
* \brief Load and parse a public key
497497
*
498498
* \param ctx key to be initialized
499-
* \param path filename to read the private key from
499+
* \param path filename to read the public key from
500500
*
501501
* \note On entry, ctx must be empty, either freshly initialised
502-
* with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a
503-
* specific key type, check the result with mbedtls_pk_can_do().
502+
* with mbedtls_pk_init() or reset with mbedtls_pk_free(). If
503+
* you need a specific key type, check the result with
504+
* mbedtls_pk_can_do().
504505
*
505506
* \note The key is also checked for correctness.
506507
*

core/mbedtls/inc/mbedtls/platform.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ extern "C" {
4444
#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS)
4545
#include <stdio.h>
4646
#include <stdlib.h>
47+
#include <time.h>
4748
#if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF)
4849
#if defined(_WIN32)
4950
#define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf /**< Default snprintf to use */
@@ -66,6 +67,9 @@ extern "C" {
6667
#if !defined(MBEDTLS_PLATFORM_STD_EXIT)
6768
#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use */
6869
#endif
70+
#if !defined(MBEDTLS_PLATFORM_STD_TIME)
71+
#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use */
72+
#endif
6973
#if !defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS)
7074
#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS /**< Default exit value to use */
7175
#endif
@@ -227,6 +231,37 @@ int mbedtls_platform_set_exit( void (*exit_func)( int status ) );
227231
#define MBEDTLS_EXIT_FAILURE 1
228232
#endif
229233

234+
/*
235+
* The time_t datatype
236+
*/
237+
#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO)
238+
typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t;
239+
#else
240+
typedef time_t mbedtls_time_t;
241+
#endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */
242+
243+
/*
244+
* The function pointers for time
245+
*/
246+
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
247+
extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time );
248+
249+
/**
250+
* \brief Set your own time function pointer
251+
*
252+
* \param time_func the time function implementation
253+
*
254+
* \return 0
255+
*/
256+
int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) );
257+
#else
258+
#if defined(MBEDTLS_PLATFORM_TIME_MACRO)
259+
#define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO
260+
#else
261+
#define mbedtls_time time
262+
#endif /* MBEDTLS_PLATFORM_TIME_MACRO */
263+
#endif /* MBEDTLS_PLATFORM_TIME_ALT */
264+
230265
#ifdef __cplusplus
231266
}
232267
#endif

core/mbedtls/inc/mbedtls/ssl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ typedef struct mbedtls_ssl_flight_item mbedtls_ssl_flight_item;
542542
struct mbedtls_ssl_session
543543
{
544544
#if defined(MBEDTLS_HAVE_TIME)
545-
time_t start; /*!< starting time */
545+
mbedtls_time_t start; /*!< starting time */
546546
#endif
547547
int ciphersuite; /*!< chosen ciphersuite */
548548
int compression; /*!< chosen compression */
@@ -976,7 +976,7 @@ int mbedtls_ssl_setup( mbedtls_ssl_context *ssl,
976976
* pointers and data.
977977
*
978978
* \param ssl SSL context
979-
* \return 0 if successful, or POLASSL_ERR_SSL_MALLOC_FAILED,
979+
* \return 0 if successful, or MBEDTLS_ERR_SSL_ALLOC_FAILED,
980980
MBEDTLS_ERR_SSL_HW_ACCEL_FAILED or
981981
* MBEDTLS_ERR_SSL_COMPRESSION_FAILED
982982
*/

core/mbedtls/inc/mbedtls/ssl_cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ typedef struct mbedtls_ssl_cache_entry mbedtls_ssl_cache_entry;
6060
struct mbedtls_ssl_cache_entry
6161
{
6262
#if defined(MBEDTLS_HAVE_TIME)
63-
time_t timestamp; /*!< entry timestamp */
63+
mbedtls_time_t timestamp; /*!< entry timestamp */
6464
#endif
6565
mbedtls_ssl_session session; /*!< entry session */
6666
#if defined(MBEDTLS_X509_CRT_PARSE_C)

core/mbedtls/inc/mbedtls/threading.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t *
8181
void mbedtls_threading_free_alt( void );
8282
#endif /* MBEDTLS_THREADING_ALT */
8383

84+
#if defined(MBEDTLS_THREADING_C)
8485
/*
8586
* The function pointers for mutex_init, mutex_free, mutex_ and mutex_unlock
8687
*
@@ -96,6 +97,7 @@ extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex );
9697
*/
9798
extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex;
9899
extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex;
100+
#endif /* MBEDTLS_THREADING_C */
99101

100102
#ifdef __cplusplus
101103
}

core/mbedtls/src/aes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
/* Implementation that should never be optimized out by the compiler */
5858
static void mbedtls_zeroize( void *v, size_t n ) {
59-
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
59+
volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0;
6060
}
6161

6262
/*

core/mbedtls/src/aesni.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx,
100100
asm( "movdqu (%3), %%xmm0 \n\t" // load input
101101
"movdqu (%1), %%xmm1 \n\t" // load round key 0
102102
"pxor %%xmm1, %%xmm0 \n\t" // round 0
103-
"addq $16, %1 \n\t" // point to next round key
103+
"add $16, %1 \n\t" // point to next round key
104104
"subl $1, %0 \n\t" // normal rounds = nr - 1
105105
"test %2, %2 \n\t" // mode?
106106
"jz 2f \n\t" // 0 = decrypt
107107

108108
"1: \n\t" // encryption loop
109109
"movdqu (%1), %%xmm1 \n\t" // load round key
110110
AESENC xmm1_xmm0 "\n\t" // do round
111-
"addq $16, %1 \n\t" // point to next round key
111+
"add $16, %1 \n\t" // point to next round key
112112
"subl $1, %0 \n\t" // loop
113113
"jnz 1b \n\t"
114114
"movdqu (%1), %%xmm1 \n\t" // load round key
@@ -118,7 +118,7 @@ int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx,
118118
"2: \n\t" // decryption loop
119119
"movdqu (%1), %%xmm1 \n\t"
120120
AESDEC xmm1_xmm0 "\n\t" // do round
121-
"addq $16, %1 \n\t"
121+
"add $16, %1 \n\t"
122122
"subl $1, %0 \n\t"
123123
"jnz 2b \n\t"
124124
"movdqu (%1), %%xmm1 \n\t" // load round key

core/mbedtls/src/arc4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
/* Implementation that should never be optimized out by the compiler */
5151
static void mbedtls_zeroize( void *v, size_t n ) {
52-
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
52+
volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0;
5353
}
5454

5555
void mbedtls_arc4_init( mbedtls_arc4_context *ctx )

core/mbedtls/src/asn1parse.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
/* Implementation that should never be optimized out by the compiler */
4747
static void mbedtls_zeroize( void *v, size_t n ) {
48-
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
48+
volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0;
4949
}
5050

5151
/*
@@ -269,7 +269,8 @@ int mbedtls_asn1_get_sequence_of( unsigned char **p,
269269
/* Allocate and assign next pointer */
270270
if( *p < end )
271271
{
272-
cur->next = mbedtls_calloc( 1, sizeof( mbedtls_asn1_sequence ) );
272+
cur->next = (mbedtls_asn1_sequence*)mbedtls_calloc( 1,
273+
sizeof( mbedtls_asn1_sequence ) );
273274

274275
if( cur->next == NULL )
275276
return( MBEDTLS_ERR_ASN1_ALLOC_FAILED );

core/mbedtls/src/asn1write.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ mbedtls_asn1_named_data *mbedtls_asn1_store_named_data( mbedtls_asn1_named_data
312312
{
313313
// Add new entry if not present yet based on OID
314314
//
315-
if( ( cur = mbedtls_calloc( 1, sizeof(mbedtls_asn1_named_data) ) ) == NULL )
315+
cur = (mbedtls_asn1_named_data*)mbedtls_calloc( 1,
316+
sizeof(mbedtls_asn1_named_data) );
317+
if( cur == NULL )
316318
return( NULL );
317319

318320
cur->oid.len = oid_len;

0 commit comments

Comments
 (0)