11591 Commits

Author SHA1 Message Date
Waleed Elmelegy
790f3b16d4 Add regression testing to handling Legacy_compression_methods
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-08-22 15:50:45 +00:00
Janos Follath
5f316972b2 Add header for mbedtls_mpi_exp_mod_unsafe()
To silence no previous prototype warnings. And this is the proper way to
do it anyway.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-22 15:00:09 +01:00
Manuel Pégourié-Gonnard
273d07b0c0
Merge pull request #9240 from gilles-peskine-arm/psa-keystore-dynamic-3.6
Backport 3.6: dynamically sized key store
2024-08-22 12:53:32 +00:00
Manuel Pégourié-Gonnard
ff28e4c7f4 Fix two dependency declarations in ssl-opt
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-20 22:03:10 +02:00
Manuel Pégourié-Gonnard
dee6ffa961 Add support for context f_vrfy callback in 1.3
This was only supported in 1.2 for no good reason.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-20 22:03:10 +02:00
Ronald Cron
8d5da8f4a3 ssl-opt.sh: Test trusted certificate callback in TLS 1.3
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-20 22:03:10 +02:00
Ronald Cron
84442a3bff ssl-opt.sh: Fix test case titles
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-20 22:03:10 +02:00
Manuel Pégourié-Gonnard
2b98a4ee3b Allow no authentication of the server in 1.3
See notes about optional two commits ago for why we're doing this.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-20 22:03:10 +02:00
Manuel Pégourié-Gonnard
a0a781eadd Reorder some tests in ssl-opt.sh
The tests above are required then optional then none. Follow the same
pattern here.

Just moving things around (see git's --color-moved option).

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-20 22:03:10 +02:00
Manuel Pégourié-Gonnard
e1cc926717 Allow optional authentication of the server in 1.3
This is for compatibility, for people transitioning from 1.2 to 1.3.
See https://github.com/Mbed-TLS/mbedtls/issues/9223 "Mandatory server
authentication" and reports linked from there.

In the future we're likely to make server authentication mandatory in
both 1.2 and 1.3. See https://github.com/Mbed-TLS/mbedtls/issues/7080

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-20 22:03:10 +02:00
Manuel Pégourié-Gonnard
4192bba54f Test cert alert REVOKED -> CERT_REVOKED
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-20 22:03:09 +02:00
Manuel Pégourié-Gonnard
d6e20692dd Test cert alert NOT_TRUSTED -> UNKNOWN_CA
In terms of line coverage, this was covered, except we never checked the
behaviour was as intended.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-20 22:03:09 +02:00
Manuel Pégourié-Gonnard
a3cf1a53b4 Fix ordering of a test case in ssl-opt.sh
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-20 22:03:09 +02:00
Manuel Pégourié-Gonnard
060e284dee Add test forcing TLS 1.2 for clearer coverage
This is a duplicate from the previous test, except it forces TLS 1.2.

The previous test does not force a version, so it picks 1.3 in the
default/full config. However we have a build with 1.2 only in all.sh, in
which the previous test would pick 1.2. So, there was no test gap and
the behaviour was indeed tested with 1.2.

However when measuring code coverage with lcov, currently we can only
use a single build. So, I'm adding this variant of the test case as a
so that the 1.2 code looks covered in the report from
basic-build-test.sh. This is for my convenience while I make sure
everything is covered before refactoring.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-20 22:03:09 +02:00
Janos Follath
878af12807 Fix memory corruption in exp_mod tests
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-20 12:33:42 +01:00
Janos Follath
8786dd79f7 Disable optionally safe test hook in threading builds
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-20 10:21:54 +01:00
Elena Uziunaite
04db1fb481 Add test cases for extKeyUsage
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-08-16 17:19:37 +01:00
Elena Uziunaite
e74c840b5e Rationalize extKeyUsage tests
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-08-15 15:33:26 +01:00
Janos Follath
7342656098 Add tests for optionally unsafe code paths
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-13 11:39:03 +01:00
Janos Follath
e0842aa751 Add tests for optionally safe codepaths
The new test hooks allow to check whether there was an unsafe call of an
optionally safe function in the codepath. For the sake of simplicity the
MBEDTLS_MPI_IS_* macros are reused for signalling safe/unsafe codepaths
here too.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-13 08:40:31 +01:00
Gilles Peskine
7f9470ac02
Merge pull request #9451 from minosgalanakis/fix-v3.6-issues-9186-and-9188-bp
[Backport 3.6] Fix v3.6 issues 9186 and 9188 bp
2024-08-12 09:34:19 +00:00
Manuel Pégourié-Gonnard
cdd5b07eb1 Use P_CLI when O_CLI's status is not reliable
Generally speaking, in this group of test we use O_SRV when testing our
client's behaviour, and O_CLI when testing our server's behaviour. I
don't think that's essential, but why not.

Well, for these two tests there's a reason why not: O_CLI often exits 0,
seemingly not minding that the server aborted the handshake with a fatal
alert, but sometimes it exits 1. (I've observed 0 on my machine, on two
runs of OpenCI and Internal CI, and 1 in some test in one run of
Internal CI.)

So, use our client instead, which exits non-zero consistently.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-12 09:50:18 +02:00
Gilles Peskine
9dc903a316 Add test components with the PSA static key store
We were only testing the static key store (MBEDTLS_PSA_KEY_STORE_DYNAMIC
disabled) with configs/*.h. Add a component with the static key store and
everything else (including built-in keys), and a component with the static
key store and CTR_DBRG using PSA for AES (which means PSA uses a volatile
key internally).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 13:54:56 +02:00
Gilles Peskine
3bc9d2b5b9 Dynamic key store: make full-key-store tests work effectively
Add a practical way to fill the dynamic key store by artificially limiting
the slice length through a test hook.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 13:54:54 +02:00
Gilles Peskine
b5891cc2cd Dynamic key store: disable full-key-store tests
It's impractical to fill the key store when it can grow to accommodate
millions of keys.

A later commit will restore those tests in test configurations with the
dynamic key store.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 13:52:50 +02:00
Gilles Peskine
2bfd749e86 Dynamic key store: new compilation option
Create a new compilation option for a dynamically resized key store. The
implementation will follow in subsequent commits.

This option is off by default with custom configuration files, which is best
for typical deployments on highly constrained platforms. This option is on
by default with the provided configuration file, which is best for typical
deployments on relatively high-end platforms.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-09 13:52:30 +02:00
Gilles Peskine
3b41e1d2a5
Merge pull request #9403 from gilles-peskine-arm/psa-keystore-dynamic-prep-3.6
Backport 3.6: prepare for dynamic key store
2024-08-09 08:00:03 +00:00
Gilles Peskine
aaa96721d1 Improve documentation in some tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-08 15:56:46 +02:00
Manuel Pégourié-Gonnard
52c0f5a0fd Rationalize keyUsage testing, round 2
- cli-auth 1.2 was missing a test with an irrelevant bit set in addition
to the relevant bit (which was added for 1.3 previously)
- use consistent naming for fail (hard/soft)

Note: currently there are no "fail (soft)" cases for 1.3 authentication
of server by client, as server auth is mandatory in 1.3 (this will
change in 3.6.1).

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-08 12:34:56 +02:00
Manuel Pégourié-Gonnard
013d0798c0 Always print detailed cert errors in test programs
Previously the client was only printing them on handshake success, and
the server was printing them on success and some but not all failures.

This makes ssl-opt.sh more consistent as we can always check for the
presence of the expected message in the output, regardless of whether
the failure is hard or soft.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-08 12:34:56 +02:00
Manuel Pégourié-Gonnard
ef41d8ccbe Fix 1.3 failure to update flags for (ext)KeyUsage
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-08 12:34:56 +02:00
Manuel Pégourié-Gonnard
36d1b4a80f Rationalize ssl-opt tests for keyUsage
- consistent naming with explicit version
- in each section, have a positive case with just the needed bit set,
and one with an irrelevant bit set in addition (cli 1.3 only had the
former, and cli-auth 1.3 only the later)
- when auth_mode optional is supported failing cases should come in
pairs: soft+hard, this wasn't the case for cli-auth 1.3. (Note: cli 1.3
currently does not support auth_mode optional.)
- failing cases should check that the correct flag is printed and the
expected alert is sent.

The last (two) points have uncovered a bug in 1.3 code:
- In fail (hard) cases the correct alert isn't send, but a more generic
one instead.
- In fail (soft) cases the issue with the certificate is not reported,
actually the certificate is reported as valid.

Both share the same root cause: the flags are not updated properly when
checking the keyUsage extension. This will be addressed in future
commits.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-08 12:34:56 +02:00
Manuel Pégourié-Gonnard
ee1715cb5b Test cert alert KEY_USAGE -> UNSUPPORTED_CERT
In terms of line coverage, this was covered, except we never checked the
behaviour was as intended.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-08 12:34:56 +02:00
Manuel Pégourié-Gonnard
e217673996 Merge remote-tracking branch 'public/mbedtls-3.6' into merge-3.6
* public/mbedtls-3.6: (251 commits)
  Call in_mbedtls_repo
  Move some proj detection code inside pre_check_environment
  Match spacing in pointer types in documentation with the code style
  Rename one more deprecated identifier
  Documentation improvements
  Rename internal function psa_key_production_parameters_are_default
  key_custom: update analyze_outcomes.py
  Test cpp_dummy_build in pedantic mode
  Changelog entry for the move from key_ext to key_custom functions
  Remove some tests of psa_generate_key_ext
  Document the key_ext functions as deprecated
  Documentation: point to key_custom instead of key_ext
  Update PSA wrappers
  Implement psa_generate_key_custom
  all.sh/components: Removed components.sh
  all.sh/components: Moved build_aes_via_padlock to platform component.
  all.sh/components: Moved driver components to configuration crypto.
  all.sh/components: Moved more components to configuration crypto.
  all.sh/components: Fixed a typo in configuration-tls.
  all.sh/components: Moved more components to configuration tls.
  ...
2024-08-08 09:49:51 +02:00
Gilles Peskine
a9083b752c PSA_DONE: account for MBEDTLS_TEST_PSA_INTERNAL_KEYS
Replace the hard-coded 1 by the proper constant now that the proper constant
exists.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-07 20:09:08 +02:00
Tom Cosgrove
4306a69931
Merge pull request #9437 from tom-daubney-arm/bp_3-6_standardise_proj_detection
[3.6 Backport] Standardise Project Detection
2024-08-07 07:18:43 +00:00
Thomas Daubney
5f0b64aadf Move some proj detection code inside pre_check_environment
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2024-08-06 17:38:19 +01:00
Elena Uziunaite
bc7bffcb76 Remove test_valgrind_constant_flow_psa_no_asm
+ typo fix

Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-08-06 16:26:41 +01:00
Elena Uziunaite
81d6b6b576 Remove the hack in library/constant_time_impl.h
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-08-06 16:26:41 +01:00
Elena Uziunaite
27c953dcbc Edit component_release_test_valgrind_constant_flow_no_asm
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-08-06 16:26:41 +01:00
Elena Uziunaite
f0871be258 Change valgrind constant flow testing to test without asm
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-08-06 16:26:34 +01:00
Elena Uziunaite
9af882dcfb Disable asm in component_test_memsan
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-08-06 14:24:50 +01:00
Elena Uziunaite
cd2ae320e3 Alter constant-flow memsan testing
Disable asm in memsan constant-flow testing and add a check in
check_config.h

Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-08-06 14:23:52 +01:00
Gilles Peskine
472c10f4a5 key_custom: update analyze_outcomes.py
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-06 13:13:05 +02:00
Gilles Peskine
f5db72bbb9 Test cpp_dummy_build in pedantic mode
In public headers, we want to avoid things that are not standard C++,
including features that GCC and Clang support as extensions, such as
flexible array members. So compile with `-pedantic`.

Non-regression for https://github.com/Mbed-TLS/mbedtls/issues/9020.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-06 13:13:04 +02:00
Gilles Peskine
14134e7ddc Remove some tests of psa_generate_key_ext
We know it's a thin wrapper around psa_generate_key_custom, so we just need
to check that it's passing the information through, we don't need coverage
of the parameter interpretation.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-06 13:12:06 +02:00
Gilles Peskine
a8e39f2156 Update PSA wrappers
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-06 13:12:06 +02:00
Gilles Peskine
f36d785188 Implement psa_generate_key_custom
Implement `psa_generate_key_custom()` and
`psa_key_derivation_output_key_custom()`. These functions replace
`psa_generate_key_ext()` and `psa_key_derivation_output_key_ext()`.
They have the same functionality, but a slightly different interface:
the `ext` functions use a structure with a flexible array member to pass
variable-length data, while the `custom` functions use a separate parameter.

Keep the `ext` functions for backward compatibility with Mbed TLS 3.6.0.
But make them a thin wrapper around the new `custom` functions.

Duplicate the test code and data. The test cases have to be duplicated
anyway, and the test functions are individually more readable this way.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-06 13:12:06 +02:00
Michael Schuster
9bf1875146 Revert commit 33af72df in order to not depend on test code
Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-06 12:09:13 +01:00
Michael Schuster
ab4951fbef Add missing include in tests/src/psa_memory_poisoning_wrappers.c to fix missing-prototype error
Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-06 12:09:13 +01:00