Skip to content

Commit 63dd5cb

Browse files
authored
Merge pull request #9920 from sbutcher-arm/mbedtls-5.12-release
Update Mbed TLS for 5.12 release to Mbed TLS development HEAD
2 parents 03bb615 + 5285b39 commit 63dd5cb

Some content is hidden

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

119 files changed

+8110
-3053
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.15.1
1+
development

features/mbedtls/importer/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#
2828

2929
# Set the mbed TLS release to import (this can/should be edited before import)
30-
MBED_TLS_RELEASE ?= mbedtls-2.15.1
31-
MBED_TLS_REPO_URL ?= [email protected]:ARMmbed/mbedtls-restricted.git
30+
MBED_TLS_RELEASE ?= development
31+
MBED_TLS_REPO_URL ?= [email protected]:ARMmbed/mbedtls.git
3232

3333
# Translate between mbed TLS namespace and mbed namespace
3434
TARGET_PREFIX:=../

features/mbedtls/importer/adjust-config.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,3 @@ conf unset MBEDTLS_PLATFORM_TIME_TYPE_MACRO
145145
# Reduce the maximal MBEDTLS_MPI_MAX_SIZE to 512 bytes,
146146
# which should fit RSA 4096 bit keys.
147147
conf set MBEDTLS_MPI_MAX_SIZE 512
148-
149-
# The following configurations are needed for Mbed Crypto.
150-
# They are related to the persistent key storage feature.
151-
conf set MBEDTLS_PSA_CRYPTO_STORAGE_C
152-
conf set MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C
153-
conf unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C

features/mbedtls/inc/mbedtls/aes.h

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,16 @@ typedef struct mbedtls_aes_xts_context
121121
* It must be the first API called before using
122122
* the context.
123123
*
124-
* \param ctx The AES context to initialize.
124+
* \param ctx The AES context to initialize. This must not be \c NULL.
125125
*/
126126
void mbedtls_aes_init( mbedtls_aes_context *ctx );
127127

128128
/**
129129
* \brief This function releases and clears the specified AES context.
130130
*
131131
* \param ctx The AES context to clear.
132+
* If this is \c NULL, this function does nothing.
133+
* Otherwise, the context must have been at least initialized.
132134
*/
133135
void mbedtls_aes_free( mbedtls_aes_context *ctx );
134136

@@ -139,14 +141,16 @@ void mbedtls_aes_free( mbedtls_aes_context *ctx );
139141
* It must be the first API called before using
140142
* the context.
141143
*
142-
* \param ctx The AES XTS context to initialize.
144+
* \param ctx The AES XTS context to initialize. This must not be \c NULL.
143145
*/
144146
void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx );
145147

146148
/**
147149
* \brief This function releases and clears the specified AES XTS context.
148150
*
149151
* \param ctx The AES XTS context to clear.
152+
* If this is \c NULL, this function does nothing.
153+
* Otherwise, the context must have been at least initialized.
150154
*/
151155
void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
152156
#endif /* MBEDTLS_CIPHER_MODE_XTS */
@@ -155,7 +159,9 @@ void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
155159
* \brief This function sets the encryption key.
156160
*
157161
* \param ctx The AES context to which the key should be bound.
162+
* It must be initialized.
158163
* \param key The encryption key.
164+
* This must be a readable buffer of size \p keybits bits.
159165
* \param keybits The size of data passed in bits. Valid options are:
160166
* <ul><li>128 bits</li>
161167
* <li>192 bits</li>
@@ -171,7 +177,9 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
171177
* \brief This function sets the decryption key.
172178
*
173179
* \param ctx The AES context to which the key should be bound.
180+
* It must be initialized.
174181
* \param key The decryption key.
182+
* This must be a readable buffer of size \p keybits bits.
175183
* \param keybits The size of data passed. Valid options are:
176184
* <ul><li>128 bits</li>
177185
* <li>192 bits</li>
@@ -189,8 +197,10 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
189197
* sets the encryption key.
190198
*
191199
* \param ctx The AES XTS context to which the key should be bound.
200+
* It must be initialized.
192201
* \param key The encryption key. This is comprised of the XTS key1
193202
* concatenated with the XTS key2.
203+
* This must be a readable buffer of size \p keybits bits.
194204
* \param keybits The size of \p key passed in bits. Valid options are:
195205
* <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
196206
* <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
@@ -207,8 +217,10 @@ int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx,
207217
* sets the decryption key.
208218
*
209219
* \param ctx The AES XTS context to which the key should be bound.
220+
* It must be initialized.
210221
* \param key The decryption key. This is comprised of the XTS key1
211222
* concatenated with the XTS key2.
223+
* This must be a readable buffer of size \p keybits bits.
212224
* \param keybits The size of \p key passed in bits. Valid options are:
213225
* <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
214226
* <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
@@ -234,10 +246,13 @@ int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx,
234246
* call to this API with the same context.
235247
*
236248
* \param ctx The AES context to use for encryption or decryption.
249+
* It must be initialized and bound to a key.
237250
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
238251
* #MBEDTLS_AES_DECRYPT.
239-
* \param input The 16-Byte buffer holding the input data.
240-
* \param output The 16-Byte buffer holding the output data.
252+
* \param input The buffer holding the input data.
253+
* It must be readable and at least \c 16 Bytes long.
254+
* \param output The buffer where the output data will be written.
255+
* It must be writeable and at least \c 16 Bytes long.
241256
242257
* \return \c 0 on success.
243258
*/
@@ -260,8 +275,8 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
260275
* mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called
261276
* before the first call to this API with the same context.
262277
*
263-
* \note This function operates on aligned blocks, that is, the input size
264-
* must be a multiple of the AES block size of 16 Bytes.
278+
* \note This function operates on full blocks, that is, the input size
279+
* must be a multiple of the AES block size of \c 16 Bytes.
265280
*
266281
* \note Upon exit, the content of the IV is updated so that you can
267282
* call the same function again on the next
@@ -272,13 +287,17 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
272287
*
273288
*
274289
* \param ctx The AES context to use for encryption or decryption.
290+
* It must be initialized and bound to a key.
275291
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
276292
* #MBEDTLS_AES_DECRYPT.
277293
* \param length The length of the input data in Bytes. This must be a
278-
* multiple of the block size (16 Bytes).
294+
* multiple of the block size (\c 16 Bytes).
279295
* \param iv Initialization vector (updated after use).
296+
* It must be a readable and writeable buffer of \c 16 Bytes.
280297
* \param input The buffer holding the input data.
298+
* It must be readable and of size \p length Bytes.
281299
* \param output The buffer holding the output data.
300+
* It must be writeable and of size \p length Bytes.
282301
*
283302
* \return \c 0 on success.
284303
* \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
@@ -306,25 +325,26 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
306325
* returns #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH.
307326
*
308327
* \param ctx The AES XTS context to use for AES XTS operations.
328+
* It must be initialized and bound to a key.
309329
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
310330
* #MBEDTLS_AES_DECRYPT.
311-
* \param length The length of a data unit in bytes. This can be any
331+
* \param length The length of a data unit in Bytes. This can be any
312332
* length between 16 bytes and 2^24 bytes inclusive
313333
* (between 1 and 2^20 block cipher blocks).
314334
* \param data_unit The address of the data unit encoded as an array of 16
315335
* bytes in little-endian format. For disk encryption, this
316336
* is typically the index of the block device sector that
317337
* contains the data.
318338
* \param input The buffer holding the input data (which is an entire
319-
* data unit). This function reads \p length bytes from \p
339+
* data unit). This function reads \p length Bytes from \p
320340
* input.
321341
* \param output The buffer holding the output data (which is an entire
322-
* data unit). This function writes \p length bytes to \p
342+
* data unit). This function writes \p length Bytes to \p
323343
* output.
324344
*
325345
* \return \c 0 on success.
326346
* \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH if \p length is
327-
* smaller than an AES block in size (16 bytes) or if \p
347+
* smaller than an AES block in size (16 Bytes) or if \p
328348
* length is larger than 2^20 blocks (16 MiB).
329349
*/
330350
int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
@@ -360,13 +380,18 @@ int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
360380
*
361381
*
362382
* \param ctx The AES context to use for encryption or decryption.
383+
* It must be initialized and bound to a key.
363384
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
364385
* #MBEDTLS_AES_DECRYPT.
365-
* \param length The length of the input data.
386+
* \param length The length of the input data in Bytes.
366387
* \param iv_off The offset in IV (updated after use).
388+
* It must point to a valid \c size_t.
367389
* \param iv The initialization vector (updated after use).
390+
* It must be a readable and writeable buffer of \c 16 Bytes.
368391
* \param input The buffer holding the input data.
392+
* It must be readable and of size \p length Bytes.
369393
* \param output The buffer holding the output data.
394+
* It must be writeable and of size \p length Bytes.
370395
*
371396
* \return \c 0 on success.
372397
*/
@@ -401,12 +426,16 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
401426
*
402427
*
403428
* \param ctx The AES context to use for encryption or decryption.
429+
* It must be initialized and bound to a key.
404430
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
405431
* #MBEDTLS_AES_DECRYPT
406432
* \param length The length of the input data.
407433
* \param iv The initialization vector (updated after use).
434+
* It must be a readable and writeable buffer of \c 16 Bytes.
408435
* \param input The buffer holding the input data.
436+
* It must be readable and of size \p length Bytes.
409437
* \param output The buffer holding the output data.
438+
* It must be writeable and of size \p length Bytes.
410439
*
411440
* \return \c 0 on success.
412441
*/
@@ -451,11 +480,16 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
451480
* will compromise security.
452481
*
453482
* \param ctx The AES context to use for encryption or decryption.
483+
* It must be initialized and bound to a key.
454484
* \param length The length of the input data.
455485
* \param iv_off The offset in IV (updated after use).
486+
* It must point to a valid \c size_t.
456487
* \param iv The initialization vector (updated after use).
488+
* It must be a readable and writeable buffer of \c 16 Bytes.
457489
* \param input The buffer holding the input data.
490+
* It must be readable and of size \p length Bytes.
458491
* \param output The buffer holding the output data.
492+
* It must be writeable and of size \p length Bytes.
459493
*
460494
* \return \c 0 on success.
461495
*/
@@ -527,15 +561,21 @@ int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
527561
* securely discarded as soon as it's no longer needed.
528562
*
529563
* \param ctx The AES context to use for encryption or decryption.
564+
* It must be initialized and bound to a key.
530565
* \param length The length of the input data.
531566
* \param nc_off The offset in the current \p stream_block, for
532567
* resuming within the current cipher stream. The
533568
* offset pointer should be 0 at the start of a stream.
569+
* It must point to a valid \c size_t.
534570
* \param nonce_counter The 128-bit nonce and counter.
571+
* It must be a readable-writeable buffer of \c 16 Bytes.
535572
* \param stream_block The saved stream block for resuming. This is
536573
* overwritten by the function.
574+
* It must be a readable-writeable buffer of \c 16 Bytes.
537575
* \param input The buffer holding the input data.
576+
* It must be readable and of size \p length Bytes.
538577
* \param output The buffer holding the output data.
578+
* It must be writeable and of size \p length Bytes.
539579
*
540580
* \return \c 0 on success.
541581
*/
@@ -588,7 +628,7 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
588628
* \brief Deprecated internal AES block encryption function
589629
* without return value.
590630
*
591-
* \deprecated Superseded by mbedtls_aes_encrypt_ext() in 2.5.0.
631+
* \deprecated Superseded by mbedtls_internal_aes_encrypt()
592632
*
593633
* \param ctx The AES context to use for encryption.
594634
* \param input Plaintext block.
@@ -602,7 +642,7 @@ MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
602642
* \brief Deprecated internal AES block decryption function
603643
* without return value.
604644
*
605-
* \deprecated Superseded by mbedtls_aes_decrypt_ext() in 2.5.0.
645+
* \deprecated Superseded by mbedtls_internal_aes_decrypt()
606646
*
607647
* \param ctx The AES context to use for decryption.
608648
* \param input Ciphertext block.
@@ -615,6 +655,8 @@ MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
615655
#undef MBEDTLS_DEPRECATED
616656
#endif /* !MBEDTLS_DEPRECATED_REMOVED */
617657

658+
659+
#if defined(MBEDTLS_SELF_TEST)
618660
/**
619661
* \brief Checkup routine.
620662
*
@@ -623,6 +665,8 @@ MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
623665
*/
624666
int mbedtls_aes_self_test( int verbose );
625667

668+
#endif /* MBEDTLS_SELF_TEST */
669+
626670
#ifdef __cplusplus
627671
}
628672
#endif

0 commit comments

Comments
 (0)