18186 Commits

Author SHA1 Message Date
Demi Marie Obenour
6b8e8ff079 Fix segfault in mbedtls_oid_get_numeric_string
When passed an empty OID, mbedtls_oid_get_numeric_string would read one
byte from the zero-sized buffer and return an error code that depends on
its value.  This is demonstrated by the test suite changes, which
check that an OID with length zero and an invalid buffer pointer does
not cause Mbed TLS to segfault.

Also check that second and subsequent subidentifiers are terminated, and
add a test case for that.  Furthermore, stop relying on integer division
by 40, use the same loop for both the first and subsequent
subidentifiers, and add additional tests.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
2023-03-16 01:07:35 -04:00
Yanray Wang
3d1d418f9e Fix failure in check_generated_files
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-16 11:10:17 +08:00
Yanray Wang
e16808cddc Move #define Directive into ssl_helpers.h
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-16 11:10:17 +08:00
Yanray Wang
d2696f2aa2 Fix issue of conversion from size_t to int
ssl_helpers.c is treated with W3 warning level in MSVC complier.
So that it's reported as error for warning of conversion from
size_t to int. This change fixes all this type of warning seen in
Microsoft Visual Studio 12.0. Besides, some potential problems of
type conversion are also handled.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-16 11:10:17 +08:00
Yanray Wang
89b4d12d4a Fix build error in CI about test_fail_if_psa_leaking
During test of component build_arm_linux_gnueabi_gcc_arm5vte and
build_arm_none_eabi_gcc_m0plus. It fails with
 - error: implicit declaration of function
   ‘test_fail_if_psa_leaking’

It happens because test_fail_if_psa_leaking is defined in
helpers.function. This block of code is not converted into C code
while compiling ssl_helpers.c. The function has been moved to
psa_crypto_helpers.c in order to fix this build error.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-16 11:10:17 +08:00
Yanray Wang
3742b1211d Fix build errors in CMake
tests/src/ssl_helpers.c depends on functions defined
in library/*.c. If it's complied as an OBJECT with other c files,
cmake complains undefined reference in link stage under programs/.
Therefore, tests/src/test_helpers/ is created to hold c files with
dependency of library/*.c. Besides, tests/src/test_helper/*.c is
separated into another OBJECT, mbedtls_test_helpers, as sources
to build all test suite executables.

In addition, everest header directory is included in case
MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED is enabled.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-16 11:10:17 +08:00
Yanray Wang
1ef77c01c4 ssl_helpers.c: remove duplicate comments for some functions
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-16 11:10:17 +08:00
Yanray Wang
4323e459e9 Resolve build errors for ssl_helpers.c and test_suite_ssl.c
Since we move many functions from test_suite_ssl.function to
ssl_helpers.c in commit bd56b03. This causes various of
build errors. This commit fixes all the build errors by
 - including header files
 - providing function definition
 - adding guards for typedef statements and functions

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-16 11:10:15 +08:00
Janos Follath
35f5ef01f2 Threat Model: adjust to 2.28
MBEDTLS_AESCE_C is not available in 2.28., remove it from workarounds.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:43:08 +00:00
Janos Follath
6cd045905f Threat Model: adjust modality
Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
e3d677c6aa Threat Model: remove references
Remove references to scientific papers as they are too specific and
might be misleading.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
08094b8313 Threat Model: clarify stance on timing attacks
Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
6ce259d287 Threat Model: improve wording and grammar
Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
8257d8aa00 Threat Model: clarify attack vectors
Timing attacks can be launched by any of the main 3 attackers. Clarify
exactly how these are covered.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
18ffba6100 Threat Model: improve wording
Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
5e68d3b05f Threat Model: move the block cipher section
The block cipher exception affects both remote and local timing attacks.
Move them to the Caveats section and reference it from both the local
and the remote attack section.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
389cdf43ab Threat model: explain dangling countermeasures
Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
adc8a0bcef Threat Model: increase classification detail
Originally for the sake of simplicity there was a single category for
software based attacks, namely timing side channel attacks.

Be more precise and categorise attacks as software based whether or not
they rely on physical information.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
5adb2c2328 Threat Model: reorganise threat definitions
Simplify organisation by placing threat definitions in their respective
sections.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
e57ed98f9e Threat Model: Miscellaneous clarifications
Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
661c88f2ba Threat Model: Improve wording
Signed-off-by: Janos Follath <janos.follath@arm.com>

Co-authored-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-15 15:35:29 +00:00
Janos Follath
ce2985b22c Add Threat Model Summary
Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-03-15 15:35:29 +00:00
Yanray Wang
bd56b035f1 Move TLS connection related functions to ssl_helpers.c
Some functions are renamed in commit c463849. This change moves all
those functions which are used to set up a TLS connection from
test_suite_ssl.function into ssl_helpers.c.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-15 16:12:41 +08:00
Yanray Wang
82b414938e Improve code readability for test_suite_ssl.function
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-15 16:12:21 +08:00
Yanray Wang
862ef862fd Rewrap the lines to fit code standard in test_suite_ssl.function
As the typedef statements and functions are renamed in commit
abfdcd8 and commit c463849 respectively. This commit aims
to align code lines to fit code standard and improve code
readability.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-15 16:12:12 +08:00
Yanray Wang
c463849598 Rename the functions which are used to set up TLS connection
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-15 16:11:41 +08:00
Yanray Wang
59ab276ef1 Move the renamed typedef statements to ssl_helpers.h
With this change, the renamed typedef statements (commit abfdcd8)
are moved from test_suite_ssl.function into ssl_helpers.h

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-15 16:11:32 +08:00
Yanray Wang
abfdcd8ee2 Rename the typedef statements which are used for TLS connection
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-14 19:04:42 +08:00
Yanray Wang
5fce145d00 Create ssl_helpers.c to hold functions of TLS connection
test_suite_ssl.function contains many functions that are used to set
up a TLS connection. To reduce its file size, those functions would
be moved to ssl_helpers.c under tests/src. As the start of this
implementation, some necessary header files are moved in advance.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-03-14 19:04:42 +08:00
Gilles Peskine
a93b06dd5b
Merge pull request #7204 from lpy4105/issue/backport-all_sh-do-not-list-unsupported-cases
Backport 2.28: all.sh: Do not list unsupported cases
2023-03-14 10:34:12 +01:00
Dave Rodgman
39987ebde7
Merge pull request #7172 from daverodgman/fix_UB_in_ssl_read-2.28
Backport 2.28: Fix undefined behavior in ssl_read if buf parameter is NULL
2023-03-13 10:46:24 +00:00
Gilles Peskine
ed36bbeb9a
Merge pull request #7238 from davidhorstmann-arm/2.28-move-getting-started-guide
[Backport 2.28] Move docs/getting_started.md to docs repo
2023-03-10 10:59:25 +01:00
Dave Rodgman
362142f6d3
Merge pull request #7223 from gilles-peskine-arm/doc-tls13-psa_crypto_init-2.28
2.28: Document the need to call psa_crypto_init() with USE_PSA_CRYPTO
2023-03-09 15:44:39 +00:00
David Horstmann
29216d21e7 Move docs/getting_started.md to docs repo
Delete docs/getting_started.md as it has been moved to the dedicated
documentation repo.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-03-09 09:59:46 +00:00
Janos Follath
803dbdbd22
Merge pull request #7232 from tom-cosgrove-arm/update-changelog-230308-2.28
Backport 2.28: Update ChangeLog to make "fix" explicit
2023-03-09 08:47:37 +00:00
Dave Rodgman
8a8e75e127
Merge pull request #7219 from tom-cosgrove-arm/fix-typos-230307-2.28
Fix typos in LTS prior to release
2023-03-08 17:20:04 +00:00
Tom Cosgrove
fc09b75023 Update ChangeLog to make "fix" explicit
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-03-08 15:58:47 +00:00
Gilles Peskine
07ae208f12 Document the need to call psa_crypto_init() with USE_PSA_CRYPTO
When MBEDTLS_USE_PSA_CRYPTO is enabled, the application must call
psa_crypto_init() before directly or indirectly calling cipher or PK code
that will use PSA under the hood. Document this explicitly for some
functions.

To avoid clutter, this commit only documents the need to call
psa_crypto_init() in common, non-obvious cases: using a PK object that was
not constructed using PSA, X.509 processing, or setting up an SSL context.
Functions that are normally only called after such a function (for example,
using a cipher or PK context constructed from a PSA key), or where the need
for PSA is obvious because they take a key ID as argument, do not need more
explicit documentaion.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-07 20:25:02 +01:00
Tom Cosgrove
601e839416 Fix typos
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-03-07 11:43:12 +00:00
Sergey
04eb7c032e
Fix llvm error: variable 'default_iv_length' may be used uninitialized
Backport of https://github.com/Mbed-TLS/mbedtls/pull/7210

Signed-off-by: Sergey <sergio_nsk@yahoo.de>
2023-03-06 15:37:23 -07:00
Pengyu Lv
d216c0411d all.sh: add support function for build_armcc
With this change, "--list-components" will not list
"build_armcc" on the system which is not installed
with Arm Compilers.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-03-03 18:23:35 +08:00
Pengyu Lv
a19ce12e47 all.sh: Skip build_mingw correctly
If i686-w64-mingw32-gcc is not installed, then
build_mingw should be unsupported.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-03-03 18:21:14 +08:00
Dave Rodgman
40d79cef35
Merge pull request #7199 from daverodgman/armclang-sha-warning-2.28
Backport 2.28: enable -Werror for armclang
2023-03-03 09:01:50 +00:00
Dave Rodgman
6cda3d3b5b Enable -Werror for armclang
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-02 15:34:42 +00:00
Gilles Peskine
2b810e3a74
Merge pull request #7104 from AndrzejKurek/pymod-2-28
[Backport 2.28] Use config.py as a module in depends.py
2023-03-02 15:38:45 +01:00
Gilles Peskine
440535e694
Merge pull request #7153 from lpy4105/issue/1785/backport-ssl-test-script-fail
Backport 2.28: compat.sh: Skip static ECDH cases if unsupported in openssl
2023-02-28 18:11:42 +01:00
Gilles Peskine
14b61666a5
Merge pull request #7139 from daverodgman/fix-test-output-length-on-success-only-2.28
Backport 2.28 - Fix test to check output length on PSA_SUCCESS only
2023-02-28 18:09:25 +01:00
Stephan Koch
6ed143635d Feedback from Arm: guarantee that output_length <= output_size even on error, to reduce the risk that a missing error check
escalates into a buffer overflow in the application code

Signed-off-by: Stephan Koch <koch@oberon.ch>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-02-28 15:13:35 +00:00
oberon-sk
8a23f49ebc asymmetric_encrypt: check output length only if return code is PSA_SUCCESS.
Signed-off-by: Stephan Koch <koch@oberon.ch>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-02-28 15:13:35 +00:00
Dave Rodgman
7a5168e90d
Merge pull request #7170 from AndrzejKurek/mpi-window-size-2.28
[Backport 2.28] Reduce the default MBEDTLS_ECP_WINDOW_SIZE value to 2
2023-02-27 17:12:29 +00:00