Skip to content

Commit 866850a

Browse files
author
Cruz Monrreal
authored
Merge pull request #7171 from ARMmbed/release-candidate
Release candidate for mbed-os-5.9.0-rc3
2 parents 4aa2bf6 + e5b59ab commit 866850a

Some content is hidden

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

77 files changed

+2894
-484
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.9.0
1+
mbedtls-2.10.0

features/mbedtls/importer/Makefile

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

2929
# Set the mbed TLS release to import (this can/should be edited before import)
30-
MBED_TLS_RELEASE ?= mbedtls-2.9.0
30+
MBED_TLS_RELEASE ?= mbedtls-2.10.0
3131

3232
# Translate between mbed TLS namespace and mbed namespace
3333
TARGET_PREFIX:=../
@@ -68,8 +68,9 @@ deploy: rsync
6868
# Adjusting the default mbed TLS config file to mbed purposes
6969
./adjust-config.sh $(MBED_TLS_DIR)/scripts/config.pl $(TARGET_INC)/mbedtls/config.h
7070
#
71-
# Copy the trimmed config that does not require entropy source
71+
# Copy and adjust the trimmed config that does not require entropy source
7272
cp $(MBED_TLS_DIR)/configs/config-no-entropy.h $(TARGET_INC)/mbedtls/.
73+
./adjust-no-entropy-config.sh $(MBED_TLS_DIR)/scripts/config.pl $(TARGET_INC)/mbedtls/config-no-entropy.h
7374

7475
deploy-tests: deploy
7576
#

features/mbedtls/importer/adjust-config.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ conf unset MBEDTLS_RIPEMD160_C
112112
conf unset MBEDTLS_SHA1_C
113113
conf unset MBEDTLS_XTEA_C
114114

115+
conf set MBEDTLS_CMAC_C
116+
115117
conf set MBEDTLS_AES_ROM_TABLES
116118

117119
conf unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/sh
2+
#
3+
# This file is part of mbed TLS (https://tls.mbed.org)
4+
#
5+
# Copyright (c) 2018, ARM Limited, All Rights Reserved
6+
#
7+
# Purpose
8+
#
9+
# Comments and uncomments #define lines in the given configuration header file
10+
# to configure the file for use in mbed OS.
11+
#
12+
# Usage: adjust-no-entropy-config.sh [path to config script] [path to no-entropy config file]
13+
#
14+
set -eu
15+
16+
if [ $# -ne 2 ]; then
17+
echo "Usage: $0 path/to/config.pl path/to/config.h" >&2
18+
exit 1
19+
fi
20+
21+
SCRIPT=$1
22+
FILE=$2
23+
24+
conf() {
25+
$SCRIPT -o -f $FILE $@
26+
}
27+
28+
add_code() {
29+
MATCH_PATTERN="$1"
30+
shift
31+
CODE=$(IFS=""; printf "%s" "$*")
32+
33+
perl -i -pe \
34+
"s/$MATCH_PATTERN/$MATCH_PATTERN$CODE/igs" \
35+
"$FILE"
36+
}
37+
38+
conf set MBEDTLS_CMAC_C

features/mbedtls/inc/mbedtls/aes.h

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */
5454
#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */
5555

56-
/* Error codes in range 0x0023-0x0025 */
56+
/* Error codes in range 0x0021-0x0025 */
57+
#define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021 /**< Invalid input data. */
5758
#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023 /**< Feature not available. For example, an unsupported AES key size. */
5859
#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025 /**< AES hardware accelerator failed. */
5960

@@ -309,7 +310,49 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
309310
* must use the context initialized with mbedtls_aes_setkey_enc()
310311
* for both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
311312
*
312-
* \warning You must keep the maximum use of your counter in mind.
313+
* \warning You must never reuse a nonce value with the same key. Doing so
314+
* would void the encryption for the two messages encrypted with
315+
* the same nonce and key.
316+
*
317+
* There are two common strategies for managing nonces with CTR:
318+
*
319+
* 1. You can handle everything as a single message processed over
320+
* successive calls to this function. In that case, you want to
321+
* set \p nonce_counter and \p nc_off to 0 for the first call, and
322+
* then preserve the values of \p nonce_counter, \p nc_off and \p
323+
* stream_block across calls to this function as they will be
324+
* updated by this function.
325+
*
326+
* With this strategy, you must not encrypt more than 2**128
327+
* blocks of data with the same key.
328+
*
329+
* 2. You can encrypt separate messages by dividing the \p
330+
* nonce_counter buffer in two areas: the first one used for a
331+
* per-message nonce, handled by yourself, and the second one
332+
* updated by this function internally.
333+
*
334+
* For example, you might reserve the first 12 bytes for the
335+
* per-message nonce, and the last 4 bytes for internal use. In that
336+
* case, before calling this function on a new message you need to
337+
* set the first 12 bytes of \p nonce_counter to your chosen nonce
338+
* value, the last 4 to 0, and \p nc_off to 0 (which will cause \p
339+
* stream_block to be ignored). That way, you can encrypt at most
340+
* 2**96 messages of up to 2**32 blocks each with the same key.
341+
*
342+
* The per-message nonce (or information sufficient to reconstruct
343+
* it) needs to be communicated with the ciphertext and must be unique.
344+
* The recommended way to ensure uniqueness is to use a message
345+
* counter. An alternative is to generate random nonces, but this
346+
* limits the number of messages that can be securely encrypted:
347+
* for example, with 96-bit random nonces, you should not encrypt
348+
* more than 2**32 messages with the same key.
349+
*
350+
* Note that for both stategies, sizes are measured in blocks and
351+
* that an AES block is 16 bytes.
352+
*
353+
* \warning Upon return, \p stream_block contains sensitive data. Its
354+
* content must not be written to insecure storage and should be
355+
* securely discarded as soon as it's no longer needed.
313356
*
314357
* \param ctx The AES context to use for encryption or decryption.
315358
* \param length The length of the input data.

0 commit comments

Comments
 (0)