Skip to content

Commit 66ed227

Browse files
authored
Merge pull request #50 from mswarowsky/tfm_20_upmerge
mbedTLS v3.5.0 upmerge for TF-M v2.0.0
2 parents 7053083 + 8f7718e commit 66ed227

File tree

759 files changed

+130688
-57919
lines changed

Some content is hidden

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

759 files changed

+130688
-57919
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Please write a few sentences describing the overall goals of the pull request's
44

55

66

7-
## Gatekeeper checklist
7+
## PR checklist
8+
9+
Please tick as appropriate and edit the reasons (e.g.: "backport: not needed because this is a new feature")
810

911
- [ ] **changelog** provided, or not required
1012
- [ ] **backport** done, or not required
@@ -16,4 +18,3 @@ Please write a few sentences describing the overall goals of the pull request's
1618

1719
Please refer to the [contributing guidelines](https://github.com/Mbed-TLS/mbedtls/blob/development/CONTRIBUTING.md), especially the
1820
checklist for PR contributors.
19-

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Random seed file created by test scripts and sample programs
22
seedfile
3+
# MBEDTLS_PSA_INJECT_ENTROPY seed file created by the test framework
4+
00000000ffffff52.psa_its
35

46
# CMake build artifacts:
57
CMakeCache.txt
@@ -28,6 +30,9 @@ massif-*
2830
.project
2931
/.settings
3032

33+
# Unix-like build artifacts:
34+
*.o
35+
3136
# MSVC build artifacts:
3237
*.exe
3338
*.pdb
@@ -57,3 +62,6 @@ massif-*
5762
/TAGS
5863
/cscope*.out
5964
/tags
65+
66+
# Clangd compilation database
67+
compile_commands.json

.readthedocs.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ build:
1212
python: "3.9"
1313
jobs:
1414
pre_build:
15-
- make apidoc
16-
- breathe-apidoc -o docs/api apidoc/xml
15+
- ./scripts/apidoc_full.sh
16+
- breathe-apidoc -o docs/api apidoc/xml
17+
post_build:
18+
- |
19+
# Work around Readthedocs bug: Command parsing fails if the 'if' statement is on the first line
20+
if [ "$READTHEDOCS_VERSION" = "development" ]; then
21+
"$READTHEDOCS_VIRTUALENV_PATH/bin/rtd" projects "Mbed TLS API" redirects sync --wet-run -f docs/redirects.yaml
22+
fi
1723
1824
# Build documentation in the docs/ directory with Sphinx
1925
sphinx:

.travis.yml

Lines changed: 10 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,24 @@
11
# Declare python as our language. This way we get our chosen Python version,
22
# and pip is available. Gcc and clang are available anyway.
3+
dist: jammy
4+
os: linux
35
language: python
4-
python: 3.5
5-
sudo: false
6-
cache: ccache
7-
8-
jobs:
9-
include:
10-
- name: basic checks and reference configurations
11-
addons:
12-
apt:
13-
packages:
14-
- gnutls-bin
15-
- doxygen
16-
- graphviz
17-
- gcc-arm-none-eabi
18-
- libnewlib-arm-none-eabi
19-
- gcc-arm-linux-gnueabi
20-
- libc6-dev-armel-cross
21-
script:
22-
- tests/scripts/all.sh -k 'check_*'
23-
- tests/scripts/all.sh -k test_default_out_of_box
24-
- tests/scripts/all.sh -k test_ref_configs
25-
- tests/scripts/all.sh -k build_arm_linux_gnueabi_gcc_arm5vte build_arm_none_eabi_gcc_m0plus
26-
27-
- name: full configuration
28-
os: linux
29-
dist: focal
30-
addons:
31-
apt:
32-
packages:
33-
- clang-10
34-
- gnutls-bin
35-
script:
36-
# Do a manual build+test sequence rather than using all.sh,
37-
# because there's no all.sh component that does what we want,
38-
# which is a build with Clang >= 10 and ASan, running all the SSL
39-
# testing.
40-
# - The clang executable in the default PATH is Clang 7 on
41-
# Travis's focal instances, but we want Clang >= 10.
42-
# - Running all the SSL testing requires a specific set of
43-
# OpenSSL and GnuTLS versions and we don't want to bother
44-
# with those on Travis.
45-
# So we explicitly select clang-10 as the compiler, and we
46-
# have ad hoc restrictions on SSL testing based on what is
47-
# passing at the time of writing. We will remove these limitations
48-
# gradually.
49-
- make generated_files
50-
- make CC=clang-10 CFLAGS='-Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all -O2' LDFLAGS='-Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all'
51-
- make test
52-
- programs/test/selftest
53-
- tests/scripts/test_psa_constant_names.py
54-
- tests/ssl-opt.sh
55-
# Modern OpenSSL does not support null ciphers.
56-
- tests/compat.sh -p OpenSSL -e 'NULL'
57-
- tests/scripts/travis-log-failure.sh
58-
# GnuTLS supports CAMELLIA but compat.sh doesn't properly enable it.
59-
- tests/compat.sh -p GnuTLS -e 'CAMELLIA'
60-
- tests/scripts/travis-log-failure.sh
61-
- tests/context-info.sh
6+
python: 3.10
627

63-
- name: Windows
64-
os: windows
65-
# The language 'python' is currently unsupported on the
66-
# Windows Build Environment. And 'generic' causes the job to get stuck
67-
# on "Booting virtual machine".
68-
language: c
69-
before_install:
70-
- choco install python --version=3.5.4
71-
env:
72-
# Add the directory where the Choco packages go
73-
- PATH=/c/Python35:/c/Python35/Scripts:$PATH
74-
- PYTHON=python.exe
75-
script:
76-
- type perl; perl --version
77-
- type python; python --version
78-
- scripts/make_generated_files.bat
79-
# Logs appear out of sequence on Windows. Give time to catch up.
80-
- sleep 5
81-
- scripts/windows_msbuild.bat v141 # Visual Studio 2017
82-
- visualc/VS2013/x64/Release/selftest.exe
83-
84-
- name: full configuration on arm64
85-
os: linux
86-
dist: focal
87-
arch: arm64
88-
addons:
89-
apt:
90-
packages:
91-
- gcc
92-
script:
93-
# Do a manual build+test sequence rather than using all.sh.
94-
#
95-
# On Arm64 host of Travis CI, the time of `test_full_cmake_*` exceeds
96-
# limitation of Travis CI. Base on `test_full_cmake_*`, we removed
97-
# `ssl-opt.sh` and GnuTLS compat.sh here to meet the time limitation.
98-
- scripts/config.py full
99-
- make generated_files
100-
- make CFLAGS='-O3 -Werror -fsanitize=address,undefined -fno-sanitize-recover=all' LDFLAGS='-Werror -fsanitize=address,undefined -fno-sanitize-recover=all'
101-
- make test
102-
- programs/test/selftest
103-
- tests/scripts/test_psa_constant_names.py
104-
# Modern OpenSSL does not support fixed ECDH or null ciphers.
105-
- tests/compat.sh -p OpenSSL -e 'NULL\|ECDH_'
106-
- tests/scripts/travis-log-failure.sh
107-
- tests/context-info.sh
8+
cache: ccache
1089

109-
- name: full configuration(GnuTLS compat tests) on arm64
110-
os: linux
111-
dist: focal
112-
arch: arm64
113-
addons:
114-
apt:
115-
packages:
116-
- clang
117-
- gnutls-bin
118-
script:
119-
# Do a manual build+test sequence rather than using all.sh.
120-
#
121-
# On Arm64 host of Travis CI, the time of `test_full_cmake_*` exceeds
122-
# limitation of Travis CI. Base on `test_full_cmake_*`, we removed
123-
# `ssl-opt.sh` and OpenSSl compat.sh here to meet the time limitation.
124-
- scripts/config.py full
125-
- make generated_files
126-
- make CC=clang CFLAGS='-O3 -Werror -fsanitize=address,undefined -fno-sanitize-recover=all' LDFLAGS='-Werror -fsanitize=address,undefined -fno-sanitize-recover=all'
127-
# GnuTLS supports CAMELLIA but compat.sh doesn't properly enable it.
128-
- tests/compat.sh -p GnuTLS -e 'CAMELLIA'
129-
- tests/scripts/travis-log-failure.sh
130-
- tests/context-info.sh
10+
branches:
11+
only:
12+
coverity_scan
13113

132-
after_failure:
133-
- tests/scripts/travis-log-failure.sh
14+
install:
15+
- $PYTHON scripts/min_requirements.py
13416

13517
env:
13618
global:
13719
- SEED=1
138-
- secure: "JECCru6HASpKZ0OLfHh8f/KXhKkdrCwjquZghd/qbA4ksxsWImjR7KEPERcaPndXEilzhDbKwuFvJiQX2duVgTGoq745YGhLZIjzo1i8tySkceCVd48P8WceYGz+F/bmY7r+m6fFNuxDSoGGSVeA4Lnjvmm8PFUP45YodDV9no4="
139-
140-
install:
141-
- $PYTHON scripts/min_requirements.py
142-
20+
- secure: "GF/Fde5fkm15T/RNykrjrPV5Uh1KJ70cP308igL6Xkk3eJmqkkmWCe9JqRH12J3TeWw2fu9PYPHt6iFSg6jasgqysfUyg+W03knRT5QNn3h5eHgt36cQJiJr6t3whPrRaiM6U9omE0evm+c0cAwlkA3GGSMw8Z+na4EnKI6OFCo="
14321
addons:
144-
apt:
145-
packages:
146-
- gnutls-bin
14722
coverity_scan:
14823
project:
14924
name: "ARMmbed/mbedtls"

3rdparty/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
execute_process(COMMAND ${MBEDTLS_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/config.py -f ${CMAKE_CURRENT_SOURCE_DIR}/../include/mbedtls/mbedtls_config.h get MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED RESULT_VARIABLE result)
2-
3-
if(${result} EQUAL 0)
4-
add_subdirectory(everest)
5-
endif()
1+
add_subdirectory(everest)
2+
add_subdirectory(p256-m)

3rdparty/Makefile.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
THIRDPARTY_DIR = $(dir $(lastword $(MAKEFILE_LIST)))
1+
THIRDPARTY_DIR = $(dir $(word 2, $(MAKEFILE_LIST)))
22
include $(THIRDPARTY_DIR)/everest/Makefile.inc
3+
include $(THIRDPARTY_DIR)/p256-m/Makefile.inc

3rdparty/everest/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
*.o
21
Makefile

3rdparty/everest/CMakeLists.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
1-
add_library(everest
1+
set(everest_target "${MBEDTLS_TARGET_PREFIX}everest")
2+
3+
add_library(${everest_target}
24
library/everest.c
35
library/x25519.c
46
library/Hacl_Curve25519_joined.c)
57

6-
target_include_directories(everest
8+
target_include_directories(${everest_target}
79
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
810
$<BUILD_INTERFACE:${MBEDTLS_DIR}/include>
911
$<INSTALL_INTERFACE:include>
1012
PRIVATE include/everest
1113
include/everest/kremlib
1214
${MBEDTLS_DIR}/library/)
1315

16+
# Pass-through MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE
17+
# This must be duplicated from library/CMakeLists.txt because
18+
# everest is not directly linked against any mbedtls targets
19+
# so does not inherit the compile definitions.
20+
if(MBEDTLS_CONFIG_FILE)
21+
target_compile_definitions(everest
22+
PUBLIC MBEDTLS_CONFIG_FILE="${MBEDTLS_CONFIG_FILE}")
23+
endif()
24+
if(MBEDTLS_USER_CONFIG_FILE)
25+
target_compile_definitions(everest
26+
PUBLIC MBEDTLS_USER_CONFIG_FILE="${MBEDTLS_USER_CONFIG_FILE}")
27+
endif()
28+
1429
if(INSTALL_MBEDTLS_HEADERS)
1530

1631
install(DIRECTORY include/everest
@@ -21,7 +36,7 @@ if(INSTALL_MBEDTLS_HEADERS)
2136

2237
endif(INSTALL_MBEDTLS_HEADERS)
2338

24-
install(TARGETS everest
39+
install(TARGETS ${everest_target}
2540
EXPORT MbedTLSTargets
2641
DESTINATION ${CMAKE_INSTALL_LIBDIR}
2742
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)

3rdparty/everest/include/everest/vs2013/inttypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* See the License for the specific language governing permissions and
1818
* limitations under the License.
1919
*
20-
* This file is part of mbed TLS (https://tls.mbed.org)
20+
* This file is part of Mbed TLS (https://tls.mbed.org)
2121
*/
2222

2323
#ifndef _INTTYPES_H_VS2010

3rdparty/everest/include/everest/vs2013/stdbool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* See the License for the specific language governing permissions and
1818
* limitations under the License.
1919
*
20-
* This file is part of mbed TLS (https://tls.mbed.org)
20+
* This file is part of Mbed TLS (https://tls.mbed.org)
2121
*/
2222

2323
#ifndef _STDBOOL_H_VS2010

3rdparty/everest/include/everest/x25519.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*
19-
* This file is part of mbed TLS (https://tls.mbed.org)
19+
* This file is part of Mbed TLS (https://tls.mbed.org)
2020
*/
2121

2222
#ifndef MBEDTLS_X25519_H

3rdparty/everest/library/Hacl_Curve25519_joined.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*
19-
* This file is part of mbed TLS (https://tls.mbed.org)
19+
* This file is part of Mbed TLS (https://tls.mbed.org)
2020
*/
2121
#ifndef _BSD_SOURCE
2222
/* Required to get htole64() from gcc/glibc's endian.h (older systems)

3rdparty/everest/library/x25519.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*
19-
* This file is part of mbed TLS (https://tls.mbed.org)
19+
* This file is part of Mbed TLS (https://tls.mbed.org)
2020
*/
2121

2222
#include "common.h"

3rdparty/p256-m/CMakeLists.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
set(p256m_target ${MBEDTLS_TARGET_PREFIX}p256m)
2+
3+
add_library(${p256m_target}
4+
p256-m_driver_entrypoints.c
5+
p256-m/p256-m.c)
6+
7+
target_include_directories(${p256m_target}
8+
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
9+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/p256-m>
10+
$<BUILD_INTERFACE:${MBEDTLS_DIR}/include>
11+
$<INSTALL_INTERFACE:include>
12+
PRIVATE ${MBEDTLS_DIR}/library/)
13+
14+
# Pass-through MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE
15+
# This must be duplicated from library/CMakeLists.txt because
16+
# p256m is not directly linked against any mbedtls targets
17+
# so does not inherit the compile definitions.
18+
if(MBEDTLS_CONFIG_FILE)
19+
target_compile_definitions(p256m
20+
PUBLIC MBEDTLS_CONFIG_FILE="${MBEDTLS_CONFIG_FILE}")
21+
endif()
22+
if(MBEDTLS_USER_CONFIG_FILE)
23+
target_compile_definitions(p256m
24+
PUBLIC MBEDTLS_USER_CONFIG_FILE="${MBEDTLS_USER_CONFIG_FILE}")
25+
endif()
26+
27+
if(INSTALL_MBEDTLS_HEADERS)
28+
29+
install(DIRECTORY :${CMAKE_CURRENT_SOURCE_DIR}
30+
DESTINATION include
31+
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
32+
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
33+
FILES_MATCHING PATTERN "*.h")
34+
35+
endif(INSTALL_MBEDTLS_HEADERS)
36+
37+
install(TARGETS ${p256m_target}
38+
EXPORT MbedTLSTargets
39+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
40+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)

3rdparty/p256-m/Makefile.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
THIRDPARTY_INCLUDES+=-I../3rdparty/p256-m/p256-m/include -I../3rdparty/p256-m/p256-m/include/p256-m -I../3rdparty/p256-m/p256-m_driver_interface
2+
3+
THIRDPARTY_CRYPTO_OBJECTS+= \
4+
../3rdparty/p256-m//p256-m_driver_entrypoints.o \
5+
../3rdparty/p256-m//p256-m/p256-m.o

3rdparty/p256-m/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The files within the `p256-m/` subdirectory originate from the [p256-m GitHub repository](https://github.com/mpg/p256-m), which is distributed under the Apache 2.0 license. They are authored by Manuel Pégourié-Gonnard. p256-m is a minimalistic implementation of ECDH and ECDSA on NIST P-256, especially suited to constrained 32-bit environments. Mbed TLS documentation for integrating drivers uses p256-m as an example of a software accelerator, and describes how it can be integrated alongside Mbed TLS. It should be noted that p256-m files in the Mbed TLS repo will not be updated regularly, so they may not have fixes and improvements present in the upstream project.
2+
3+
The files `p256-m.c` and `.h`, along with the license, have been taken from the `p256-m` repository.
4+
It should be noted that p256-m deliberately does not supply its own cryptographically secure RNG function. As a result, the PSA RNG is used, with `p256_generate_random()` wrapping `psa_generate_random()`.

0 commit comments

Comments
 (0)