6217 Commits

Author SHA1 Message Date
Tomás González
2fdd503c4e Add allow list for non-executed test cases
The allow list explicits which test cases are allowed to not be
executed when testing. This may be, for example, because a feature
is yet to be developed but the test for that feature is already in
our code base.

Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
2023-08-23 16:52:44 +01:00
Gilles Peskine
7fbbb61238 Merge remote-tracking branch 'mbedtls-2.28' into calloc-also-zeroizes-2-28 2023-08-21 17:25:47 +02:00
David Horstmann
dcf73265ba Fix incorrect detection of HardwareModuleName
The hardware module name otherName SAN contains 2 OIDs:

 OtherName ::= SEQUENCE {
      type-id    OBJECT IDENTIFIER,
      value      [0] EXPLICIT ANY DEFINED BY type-id }

 HardwareModuleName ::= SEQUENCE {
                           hwType OBJECT IDENTIFIER,
                           hwSerialNum OCTET STRING }

The first, type-id, is the one that identifies the otherName as a
HardwareModuleName. The second, hwType, identifies the type of hardware.

This change fixes 2 issues:

1. We were erroneously trying to identify HardwareModuleNames by looking
at hwType, not type-id.
2. We accidentally inverted the check so that we were checking that
hwType did NOT match HardwareModuleName.

This fix ensures that type-id is correctly checked to make sure that it
matches the OID for HardwareModuleName.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-08-18 19:51:06 +01:00
Gilles Peskine
64dbdc06fa
Merge pull request #7768 from lpy4105/backport-2.28/issue/renew_cert_2027-01-01
Backport 2.28: Updating crt/crl files due to expiry before 2027-01-01
2023-08-17 18:55:42 +00:00
Pengyu Lv
e453f9df10 Add description for invalid commands
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-08-17 16:32:34 +08:00
Pengyu Lv
96d0ef4f08 Fix invalid generation commands
`serial_hex` option is not supported by `cert_write` in 2.28,
use `serial` option instead.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-08-16 11:43:51 +08:00
Gilles Peskine
7740eaf32f
Merge pull request #7940 from AgathiyanB/backport-assert-false-macro
[Backport 2.28] Add TEST_FAIL macro for tests
2023-08-10 13:03:44 +00:00
Waleed Elmelegy
a55ffe5f37 Remove test helper functions not backported
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-08-08 17:07:04 +01:00
Waleed Elmelegy
3229cf9507 Replace MBEDTLS_MD_CAN_SHA1 config with old MBEDTLS_SHA1_C config
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-08-08 16:58:16 +01:00
Waleed Elmelegy
a230735d2f Fix CI errors related pkcs5_pbe changes
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-08-08 15:36:49 +01:00
Waleed Elmelegy
412629c815 Improve & test legacy mbedtls_pkcs5_pbe2
* Prevent pkcs5_pbe2 encryption when PKCS7 padding has been
  disabled since this not part of the specs.
* Allow decryption when PKCS7 padding is disabled for legacy
  reasons, However, invalid padding is not checked.
* Add tests to check these scenarios. Test data has been
  reused but with changing padding data in last block to
  check for valid/invalid padding.
* Document new behaviour, known limitations and possible
  security concerns.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2023-08-08 15:36:05 +01:00
Gilles Peskine
b438348774
Merge pull request #8010 from marekjansta/fix-x509-ec-algorithm-identifier-2.28
Backport 2.28: Fixed x509 certificate generation to conform to RFCs when using ECC key
2023-08-07 19:14:52 +00:00
Dave Rodgman
403ce0a6cc Bump version numbers
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-02 15:35:45 +01:00
Tom Cosgrove
c5f24c0128
Merge pull request #8001 from AgathiyanB/fix-control-bypass-2.28
Fix control bypass warnings
2023-08-02 07:45:22 +00:00
Bence Szépkúti
fb806b68ed
Merge pull request #7969 from gowthamsk-arm/use_earliest_latest_compilers_2.28
Backport 2.28: Use earliest latest compilers 2.28
2023-08-01 23:50:14 +00:00
Gowtham Suresh Kumar
cc029afbd0 Update default variable values for compilers
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-08-01 09:48:32 +01:00
Gowtham Suresh Kumar
2afb24f96a Use variables for selecting compilers
The latest and earliest clang/GCC compilers are now used through
variables instead of symlinks and also the all.sh script is updated
to support options for overriding the default values.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-08-01 09:45:57 +01:00
Gowtham Suresh Kumar
13850f387b Use compgen to gather components in all.sh
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-08-01 09:40:01 +01:00
Gowtham Suresh Kumar
53453cf250 Remove test_clang_opt check
The component functions in all.sh will be listed using
compgen instead of sed so this check is not needed.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-08-01 09:39:56 +01:00
Marek Jansta
0a6743b2de Fixed AlgorithmIdentifier parameters when used with ECDSA signature algorithm in x509 certificate
Signed-off-by: Marek Jansta <jansta@2n.cz>
2023-07-31 17:33:23 +02:00
Agathiyan Bragadeesh
e7eb8052be Seperate declarations from function body
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-31 16:20:27 +01:00
Agathiyan Bragadeesh
7b0ee1e655 Fix control bypass warnings
Declarations have been moved to the top of functions to fix this

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-27 15:51:46 +01:00
Gowtham Suresh Kumar
34d8bd37d9 Fix warnings from clang-16
Running clang-16 on mbedtls reports warnings of type "-Wstrict-prototypes".
This patch fixes these warnings by adding void to functions with no
arguments. The generate_test_code.py is modified to insert void into test
functions with no arguments in *.function files.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-07-27 00:03:21 +01:00
Gowtham Suresh Kumar
1e3af2485f Update test scripts to use latest/earliest compilers
The Ubuntu 16.04 and 22.04 docker images have been updated with
earliest and latest versions of gcc and clang respectively.
This patch adds the necessary component and support functions
required for the CI to run these compilers.

For FreeBSD we invoke the function by name so a condition is added
to disable the existing test_clang_opt function for linux.

Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2023-07-26 16:55:39 +01:00
Agathiyan Bragadeesh
1dd20a32e2 Remove trailing backslash
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-24 10:50:53 +01: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
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
Agathiyan Bragadeesh
27e2989840 Back port TEST_FAIL
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-18 12:54:30 +01:00
Andrzej Kurek
0841b5a178 Add a workaround for max test suite parameter sizes
int isn't enough for SIZE_MAX/2.
Hardcoding the value will make the compilers complain.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 15:16:35 -04:00
Andrzej Kurek
6e4a9beb2b Disable msan errors on null allocation in all.sh
Such error was raised in platform tests,
and it's a valid test case.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 10:16:11 -04:00
Andrzej Kurek
f1e61fcb09 Add a dummy usage of a pointer in tests
This way clang with O1 doesn't optimize it.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 10:16:00 -04:00
Andrzej Kurek
d95b8edf29 Disable asan errors on null allocation in all.sh
Such error was raised in platform tests,
and it's a valid test case.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 10:13:40 -04:00
Andrzej Kurek
f35490e7af Move the overallocation test to test suites
This way the compiler does not complain about
an overly large allocation made.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-07-14 10:13:31 -04: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
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
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
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
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