17914 Commits

Author SHA1 Message Date
Dave Rodgman
dd7b24c3bf whitespace fix
Signed-off-by: Dave Rodgman <dave.rodgman@gmail.com>
2023-07-27 20:01:04 +01:00
Dave Rodgman
e67ffd6d20 pylint tidy-up
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-07-27 18:50:50 +01:00
Dave Rodgman
73b87e39d6 Make code_style.py -s default to -s=mbedtls-2.28
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-07-27 18:44:52 +01:00
Dave Rodgman
b96dbc6486 Make code_style.py -s more precise
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-07-27 18:44:45 +01:00
Gilles Peskine
ae68c09a69
Merge pull request #7987 from gilles-peskine-arm/ssl_premaster_secret-empty-2.28
Backport 2.28: Fix empty union when TLS is disabled
2023-07-27 10:29:27 +02:00
Gilles Peskine
e5507d5f20 Fix empty union when TLS is disabled
When all TLS 1.2 support is disabled, union mbedtls_ssl_premaster_secret was
empty, which is not valid C even if the union is never used. Fixes #6628.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-26 17:22:04 +02:00
Gilles Peskine
b98d39ce2a
Merge pull request #7965 from gilles-peskine-arm/psa_inject_entropy-file-stability-2.28
Backport 2.28: Fix and test MBEDTLS_PSA_INJECT_ENTROPY
2023-07-21 17:37:19 +02:00
Gilles Peskine
1fc71160b1 Add missing dependencies on real entropy
Tests that call mbedtls_test_ssl_endpoint_init() need mbedtls_entropy_func()
to work.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 20:04:27 +02:00
Gilles Peskine
24d0124868 Fix copypasta in function documentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:11:22 +02:00
Gilles Peskine
581c6e12ce MBEDTLS_PSA_INJECT_ENTROPY: ignore seed file
The test framework leaves the seed file behind (like it does with the
corresponding file in the legacy API, namely seedfile), so ignore it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:11:22 +02:00
Gilles Peskine
58d085419c MBEDTLS_PSA_INJECT_ENTROPY: check the seed file UID
The seed file UID is part of the library's stable interface.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:11:22 +02:00
Gilles Peskine
154dadfae8 MBEDTLS_PSA_INJECT_ENTROPY: check the lifecycle of the seed file
The seed file is part of the stable interface of PSA_CRYPTO_INJECT_ENTROPY,
because it has to survive a library upgrade on a device. So check that its
existence and content are as expected at each point in the tested life cycle.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:11:22 +02:00
Gilles Peskine
cf21e944f6 Modernize remove_seed_file()
This function was written before the PSA storage layer switched to the PSA
ITS API as its storage abstraction. Now we can just call PSA ITS functions
unconditionally.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:11:22 +02:00
Gilles Peskine
55e89985f0 Test MBEDTLS_PSA_INJECT_ENTROPY
Until now, we were never enabling this option in any test.

MBEDTLS_PSA_INJECT_ENTROPY requires MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES, so
it cannot be enabled in the full config and it gets its own component.

Test with MBEDTLS_USE_PSA_CRYPTO enabled, since MBEDTLS_PSA_INJECT_ENTROPY
is a very PSA feature (which can break non-PSA applications), and Mbed
OS (for whch MBEDTLS_PSA_INJECT_ENTROPY was designed) enables
MBEDTLS_USE_PSA_CRYPTO when it enables MBEDTLS_PSA_INJECT_ENTROPY.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:11:21 +02:00
Gilles Peskine
bfda1a96bb MBEDTLS_PSA_INJECT_ENTROPY: Skip incompatible tests
When MBEDTLS_PSA_INJECT_ENTROPY is enabled, we disable standard entropy
sources, so mbedtls_entropy_func() doesn't work out of the box. Disable
tests that rely on it. MBEDTLS_PSA_INJECT_ENTROPY is intended for PSA-only
environments anyway, so it doesn't matter if some legacy features don't work
normally.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:10:26 +02:00
Gilles Peskine
4f8bf3cc54 MBEDTLS_PSA_INJECT_ENTROPY: Make sure the seed file exist when running tests
The seed file must exist before running tests. Because the location is
somewhat platform- and configuration-dependent, and to be friendly to
developers who run test suites individually and aren't familiar with this
feature, rely on the test framework code rather than on test scripts to
create the seed file.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:09:02 +02:00
Gilles Peskine
73521b0715 Tests: provide necessary functions for MBEDTLS_PSA_INJECT_ENTROPY
The build option MBEDTLS_PSA_INJECT_ENTROPY requires some extra platform
functions, for historical reasons. To enable us to test this option, provide
a version of these functions for testing.

(These versions would actually work in production, but providing them in the
library in a way that doesn't break existing users might be slightly tricky,
so it's out of scope of this commit.)

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:08:24 +02:00
Gilles Peskine
9a9d5eea53 Fix a build error when MBEDTLS_PSA_INJECT_ENTROPY is enabled
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-20 18:07:47 +02:00
Dave Rodgman
668323c49e
Merge pull request #7922 from AndrzejKurek/doxygen-bad-param-names-2-28
[Backport 2.28] Fix wrong doxygen parameter names and misused \p commands
2023-07-20 14:10:13 +01:00
Andrzej Kurek
db54dbdc56 Fix \p misuses in documentation
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 05:35:38 -04:00
Andrzej Kurek
532ec20983 doxygen: \p commands misuse - review comments
Apply comments suggested in review.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 05:29:33 -04:00
Andrzej Kurek
c00fb7f379 doxygen: fix parameter name typos and misused \p commands
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 05:29:20 -04:00
Andrzej Kurek
0cbfbd96c1 doxygen: fix misused \p commands in rsa.h
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 05:22:57 -04:00
Andrzej Kurek
96ce1b04ea doxygen: fix parameter name typos and misused \p commands
\p is reserved for function parameters.
\c is used to describe other values and variables.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 05:22:42 -04:00
Andrzej Kurek
a490042f1c Fix documentation - parameter name mistakes
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-13 10:16:08 -04:00
Andrzej Kurek
a3d315a216 doxygen: remove unnecessary description
Due to the nature of CTR, there is no mode parameter.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-13 10:15:02 -04:00
Gilles Peskine
4e73afe6ed
Merge pull request #7907 from gowthamsk-arm/fix_ecp_group_compare
tests/test_suite_ecp: Fix ECP group compare test
2023-07-13 12:43:10 +02:00
Gowtham Suresh Kumar
21f2b7a64b tests/test_suite_ecp: Fix ECP group compare test
ECP group compare function should not check the value of T. We only need
to assert the value of T after the ECP group copy function is called.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-07-12 13:59:18 +01:00
Gilles Peskine
76a54ff1a8
Merge pull request #7901 from tgonzalezorlandoarm/tg/7879-backport
Backport 2.28: tests/test_suite_pem: Augment DES test cases with AES: PEM
2023-07-10 18:27:55 +02:00
Dave Rodgman
814a14a994
Merge pull request #7897 from tgonzalezorlandoarm/7136-backport
Backport 2.28: Record the outcome of each test case in compat.sh
2023-07-10 12:08:41 +01:00
Tomás González
991c49f812 tests/test_suite_pem: Augment DES test cases with AES: PEM
A few negative test cases in test_suite_pem.data rely on DES
(“invalid iv”, “malformed”). DES is deprecated.
Construct similar test cases using AES.

Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
2023-07-10 11:38:30 +01:00
Yanray Wang
5659981cf8 ssl-opt.sh: support to parse --outcome-file
Adjust where to set absolute path for MBEDTLS_TEST_OUTCOME_FILE
as it's supposed to set its absolute path after all possible
value assignment.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-10 09:38:24 +01:00
Dave Rodgman
b18d45f042
Merge pull request #7483 from gilles-peskine-arm/mbedtls_x509_crt_parse_path-qemu-bug-2.28
Backport 2.28: More mbedtls_x509_crt_parse_path() tests, and note qemu-user bug when 32-bit code run on 64-bit host
2023-07-07 19:15:46 +01:00
Paul Elliott
dc1244d135
Merge pull request #6974 from davidhorstmann-arm/2.28-cmake-pass-through-config-defines
[Backport 2.28] Pass `MBEDTLS_CONFIG_FILE` defines through cmake
2023-07-07 17:01:24 +01:00
Tom Cosgrove
f788a45d47
Merge pull request #7213 from sergio-nsk/patch-5
mbedtls-2.28: Fix error: comparison of integers of different signs: 'SOCKET' and 'int'
2023-07-07 16:46:03 +01:00
Dave Rodgman
f8f4c6053a
Merge branch 'mbedtls-2.28' into mbedtls_x509_crt_parse_path-qemu-bug-2.28
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-07-07 15:15:47 +01:00
Yanray Wang
31d5046f32 test-framework.md: document compat.sh
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-07 12:25:19 +01:00
Yanray Wang
44ba969acb compat.sh: add support to record outcome of test cases
If the environment variable MBEDTLS_TEST_OUTCOME_FILE is set,
the test outcome file records each test case in a single line
with the format of

 PLATFORM;CONFIGURATION;compat;TEST CASE DESCRIPTION;RESULT;[CAUSE]

- CONFIGURATION comes from MBEDTLS_TEST_CONFIGURATION to record
  configuration of each test case
- PLATFORM is either set by users or calculated from test
  platform
- RESULT is one of PASS, FAIL or SKIP. If test case fails,
  srv_out/cli_out follows as FAILURE CAUSE.

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-07 12:23:08 +01:00
Dave Rodgman
e992af6fba
Merge pull request #7585 from gilles-peskine-arm/fuzz-file-open-fail-2.28
Backport 2.28: Fuzz programs: print an error if loading the reproducer fails
2023-07-07 11:51:50 +01:00
Yanray Wang
0f386b7372 compat.sh: call record_fail if test case fails
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-07 11:34:54 +01:00
David Horstmann
63b06a8889 Add ChangeLog entry for CMake config defines
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-07 11:29:23 +01:00
Dave Rodgman
b8e6b66644
Merge pull request #7868 from gilles-peskine-arm/readme-python3.6
Backport 2.28: officially require Python 3.6
2023-07-07 09:58:22 +01:00
David Horstmann
58dda6713c Use emptiness-checks rather than DEFINED checks
For the MBEDTLS_CONFIG_FILE and MBEDTLS_USER_CONFIG_FILE variables,
check that they are non-empty and defined. This means they can be
unconditionally created in the cache, simplifying the CMakeLists.txt

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 18:12:09 +01:00
David Horstmann
6762231e4b Use CONFIG_H variable rather than config file name
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 14:35:25 +01:00
David Horstmann
175afbdfe8 all.sh component to test cmake custom config file
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 14:35:25 +01:00
David Horstmann
1a30cf70cc Pass config file options to mbedtls_test(_helpers)
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 14:35:08 +01:00
David Horstmann
e31e287109 Pass MBEDTLS_CONFIG_FILE defines through cmake
When -DMBEDTLS_CONFIG_FILE or -DMBEDTLS_USER_CONFIG_FILE are passed to
cmake, pass them through as compile definitions. This allows different
mbedtls configs to be passed at configure time without modifying any
cmake files.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-07-05 14:33:11 +01:00
Dave Rodgman
09f198da19
Merge pull request #7876 from gilles-peskine-arm/code-style-since-2.28
Backport 2.28: code_style.py --since
2023-07-05 10:55:53 +01:00
Gilles Peskine
7b780491f0 Handle deleted files correctly
Don't attempt to run on a file that isn't present now.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-04 15:47:02 +02:00
Gilles Peskine
8ceeba4f22 Add --since option to check files modified since a given commit
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-07-04 15:47:01 +02:00