Skip to content

Commit 5317e87

Browse files
committed
Update Mbed TLS to version 2.9.0
1 parent a2370d5 commit 5317e87

Some content is hidden

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

70 files changed

+3522
-2408
lines changed

features/mbedtls/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
mbedtls-2.7.1
1+
mbedtls-2.9.0

features/mbedtls/inc/mbedtls/aes.h

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/**
22
* \file aes.h
33
*
4-
* \brief The Advanced Encryption Standard (AES) specifies a FIPS-approved
4+
* \brief This file contains AES definitions and functions.
5+
*
6+
* The Advanced Encryption Standard (AES) specifies a FIPS-approved
57
* cryptographic algorithm that can be used to protect electronic
68
* data.
79
*
@@ -12,6 +14,7 @@
1214
* techniques -- Encryption algorithms -- Part 2: Asymmetric
1315
* ciphers</em>.
1416
*/
17+
1518
/* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved.
1619
* SPDX-License-Identifier: Apache-2.0
1720
*
@@ -59,14 +62,14 @@
5962
#define inline __inline
6063
#endif
6164

62-
#if !defined(MBEDTLS_AES_ALT)
63-
// Regular implementation
64-
//
65-
6665
#ifdef __cplusplus
6766
extern "C" {
6867
#endif
6968

69+
#if !defined(MBEDTLS_AES_ALT)
70+
// Regular implementation
71+
//
72+
7073
/**
7174
* \brief The AES context-type definition.
7275
*/
@@ -85,6 +88,10 @@ typedef struct
8588
}
8689
mbedtls_aes_context;
8790

91+
#else /* MBEDTLS_AES_ALT */
92+
#include "aes_alt.h"
93+
#endif /* MBEDTLS_AES_ALT */
94+
8895
/**
8996
* \brief This function initializes the specified AES context.
9097
*
@@ -112,8 +119,8 @@ void mbedtls_aes_free( mbedtls_aes_context *ctx );
112119
* <li>192 bits</li>
113120
* <li>256 bits</li></ul>
114121
*
115-
* \return \c 0 on success or #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
116-
* on failure.
122+
* \return \c 0 on success.
123+
* \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
117124
*/
118125
int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
119126
unsigned int keybits );
@@ -128,7 +135,8 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
128135
* <li>192 bits</li>
129136
* <li>256 bits</li></ul>
130137
*
131-
* \return \c 0 on success, or #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
138+
* \return \c 0 on success.
139+
* \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
132140
*/
133141
int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
134142
unsigned int keybits );
@@ -192,7 +200,8 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
192200
* \param input The buffer holding the input data.
193201
* \param output The buffer holding the output data.
194202
*
195-
* \return \c 0 on success, or #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
203+
* \return \c 0 on success.
204+
* \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
196205
* on failure.
197206
*/
198207
int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
@@ -313,7 +322,7 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
313322
* \param input The buffer holding the input data.
314323
* \param output The buffer holding the output data.
315324
*
316-
* \return \c 0 on success.
325+
* \return \c 0 on success.
317326
*/
318327
int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
319328
size_t length,
@@ -391,22 +400,11 @@ MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
391400
#undef MBEDTLS_DEPRECATED
392401
#endif /* !MBEDTLS_DEPRECATED_REMOVED */
393402

394-
#ifdef __cplusplus
395-
}
396-
#endif
397-
398-
#else /* MBEDTLS_AES_ALT */
399-
#include "aes_alt.h"
400-
#endif /* MBEDTLS_AES_ALT */
401-
402-
#ifdef __cplusplus
403-
extern "C" {
404-
#endif
405-
406403
/**
407404
* \brief Checkup routine.
408405
*
409-
* \return \c 0 on success, or \c 1 on failure.
406+
* \return \c 0 on success.
407+
* \return \c 1 on failure.
410408
*/
411409
int mbedtls_aes_self_test( int verbose );
412410

features/mbedtls/inc/mbedtls/arc4.h

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@
3838

3939
#define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019 /**< ARC4 hardware accelerator failed. */
4040

41-
#if !defined(MBEDTLS_ARC4_ALT)
42-
// Regular implementation
43-
//
44-
4541
#ifdef __cplusplus
4642
extern "C" {
4743
#endif
4844

45+
#if !defined(MBEDTLS_ARC4_ALT)
46+
// Regular implementation
47+
//
48+
4949
/**
5050
* \brief ARC4 context structure
5151
*
@@ -61,6 +61,10 @@ typedef struct
6161
}
6262
mbedtls_arc4_context;
6363

64+
#else /* MBEDTLS_ARC4_ALT */
65+
#include "arc4_alt.h"
66+
#endif /* MBEDTLS_ARC4_ALT */
67+
6468
/**
6569
* \brief Initialize ARC4 context
6670
*
@@ -118,18 +122,6 @@ void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key,
118122
int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input,
119123
unsigned char *output );
120124

121-
#ifdef __cplusplus
122-
}
123-
#endif
124-
125-
#else /* MBEDTLS_ARC4_ALT */
126-
#include "arc4_alt.h"
127-
#endif /* MBEDTLS_ARC4_ALT */
128-
129-
#ifdef __cplusplus
130-
extern "C" {
131-
#endif
132-
133125
/**
134126
* \brief Checkup routine
135127
*

features/mbedtls/inc/mbedtls/asn1.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@
8888
#define MBEDTLS_ASN1_PRIMITIVE 0x00
8989
#define MBEDTLS_ASN1_CONSTRUCTED 0x20
9090
#define MBEDTLS_ASN1_CONTEXT_SPECIFIC 0x80
91+
92+
/*
93+
* Bit masks for each of the components of an ASN.1 tag as specified in
94+
* ITU X.690 (08/2015), section 8.1 "General rules for encoding",
95+
* paragraph 8.1.2.2:
96+
*
97+
* Bit 8 7 6 5 1
98+
* +-------+-----+------------+
99+
* | Class | P/C | Tag number |
100+
* +-------+-----+------------+
101+
*/
102+
#define MBEDTLS_ASN1_TAG_CLASS_MASK 0xC0
103+
#define MBEDTLS_ASN1_TAG_PC_MASK 0x20
104+
#define MBEDTLS_ASN1_TAG_VALUE_MASK 0x1F
105+
91106
/* \} name */
92107
/* \} addtogroup asn1_module */
93108

features/mbedtls/inc/mbedtls/bignum.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ void mbedtls_mpi_free( mbedtls_mpi *X );
204204
/**
205205
* \brief Enlarge to the specified number of limbs
206206
*
207+
* This function does nothing if the MPI is already large enough.
208+
*
207209
* \param X MPI to grow
208210
* \param nblimbs The target number of limbs
209211
*
@@ -215,19 +217,23 @@ int mbedtls_mpi_grow( mbedtls_mpi *X, size_t nblimbs );
215217
/**
216218
* \brief Resize down, keeping at least the specified number of limbs
217219
*
220+
* If \c X is smaller than \c nblimbs, it is resized up
221+
* instead.
222+
*
218223
* \param X MPI to shrink
219224
* \param nblimbs The minimum number of limbs to keep
220225
*
221226
* \return 0 if successful,
222227
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
228+
* (this can only happen when resizing up).
223229
*/
224230
int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs );
225231

226232
/**
227233
* \brief Copy the contents of Y into X
228234
*
229-
* \param X Destination MPI
230-
* \param Y Source MPI
235+
* \param X Destination MPI. It is enlarged if necessary.
236+
* \param Y Source MPI.
231237
*
232238
* \return 0 if successful,
233239
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed

features/mbedtls/inc/mbedtls/blowfish.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@
4444
#define MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED -0x0017 /**< Blowfish hardware accelerator failed. */
4545
#define MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH -0x0018 /**< Invalid data input length. */
4646

47-
#if !defined(MBEDTLS_BLOWFISH_ALT)
48-
// Regular implementation
49-
//
50-
5147
#ifdef __cplusplus
5248
extern "C" {
5349
#endif
5450

51+
#if !defined(MBEDTLS_BLOWFISH_ALT)
52+
// Regular implementation
53+
//
54+
5555
/**
5656
* \brief Blowfish context structure
5757
*/
@@ -62,6 +62,10 @@ typedef struct
6262
}
6363
mbedtls_blowfish_context;
6464

65+
#else /* MBEDTLS_BLOWFISH_ALT */
66+
#include "blowfish_alt.h"
67+
#endif /* MBEDTLS_BLOWFISH_ALT */
68+
6569
/**
6670
* \brief Initialize Blowfish context
6771
*
@@ -198,8 +202,4 @@ int mbedtls_blowfish_crypt_ctr( mbedtls_blowfish_context *ctx,
198202
}
199203
#endif
200204

201-
#else /* MBEDTLS_BLOWFISH_ALT */
202-
#include "blowfish_alt.h"
203-
#endif /* MBEDTLS_BLOWFISH_ALT */
204-
205205
#endif /* blowfish.h */

features/mbedtls/inc/mbedtls/camellia.h

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040
#define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026 /**< Invalid data input length. */
4141
#define MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED -0x0027 /**< Camellia hardware accelerator failed. */
4242

43-
#if !defined(MBEDTLS_CAMELLIA_ALT)
44-
// Regular implementation
45-
//
46-
4743
#ifdef __cplusplus
4844
extern "C" {
4945
#endif
5046

47+
#if !defined(MBEDTLS_CAMELLIA_ALT)
48+
// Regular implementation
49+
//
50+
5151
/**
5252
* \brief CAMELLIA context structure
5353
*/
@@ -58,6 +58,10 @@ typedef struct
5858
}
5959
mbedtls_camellia_context;
6060

61+
#else /* MBEDTLS_CAMELLIA_ALT */
62+
#include "camellia_alt.h"
63+
#endif /* MBEDTLS_CAMELLIA_ALT */
64+
6165
/**
6266
* \brief Initialize CAMELLIA context
6367
*
@@ -211,18 +215,6 @@ int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx,
211215
unsigned char *output );
212216
#endif /* MBEDTLS_CIPHER_MODE_CTR */
213217

214-
#ifdef __cplusplus
215-
}
216-
#endif
217-
218-
#else /* MBEDTLS_CAMELLIA_ALT */
219-
#include "camellia_alt.h"
220-
#endif /* MBEDTLS_CAMELLIA_ALT */
221-
222-
#ifdef __cplusplus
223-
extern "C" {
224-
#endif
225-
226218
/**
227219
* \brief Checkup routine
228220
*

0 commit comments

Comments
 (0)