11362 Commits

Author SHA1 Message Date
David Horstmann
dfba499c16 Extend python checks to framework scripts
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-06-07 11:10:43 +01:00
Bence Szépkúti
2cfa6c9b45
Merge pull request #9208 from davidhorstmann-arm/move-test-generation-files-3.6
[Backport 3.6] Move test generation files to framework
2024-06-04 09:23:23 +00:00
David Horstmann
ea09152be9 Update file paths for moved files
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-31 15:51:41 +01:00
David Horstmann
a5eadf45ab Move some test generation files to framework
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-31 15:51:41 +01:00
Gilles Peskine
cddcd7ac0b
Merge pull request #9177 from ttytm/fix-typo-bp-3.6
Backport 3.6: fix typo
2024-05-30 17:24:57 +00:00
Gilles Peskine
c75048c162 ssl-opt.sh, compat.sh: Error out if not executing any tests
Alert if all tests are filtered out or skipped: that probably indicates a
test script that set up an unintended configuration or an overly strict
filter. You can pass `--min 0` to bypass this check. You can pass `--min`
with a larger value to require that many test cases to run.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-29 20:01:51 +02:00
Ronald Cron
22a092be63 Do not use --recurse-submodules
On the CI, the git version when running on
Ubuntu 16.04 is 2.7 and it does not support
the "--recurse-submodules" option of
"git ls-files" thus do not use it.

Another argument to not use it is that
when TF-PSA-Crypto will be a submodule of
mbedtls we will not want check_files.py to
check the TF-PSA-Crypto files as well.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-29 09:51:26 +02:00
Ronald Cron
c521badcea Extend basic checks of files to framework files
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-29 09:51:26 +02:00
Bence Szépkúti
29c4017007
Merge pull request #9131 from davidhorstmann-arm/move-mbedtls-dev-to-framework-3.6
[Backport 3.6] Move `mbedtls_dev` to framework submodule
2024-05-28 15:50:56 +00:00
Turiiya
20f4488cd0 fix typo
Signed-off-by: Turiiya <34311583+ttytm@users.noreply.github.com>
2024-05-23 21:43:55 +02:00
Gilles Peskine
2c3aa942aa
Merge pull request #9166 from gilles-peskine-arm/analyze_outcomes-generate_files-3.6
Backport 3.6: Generate test data before coverage analysis
2024-05-23 12:08:12 +00:00
Ronald Cron
baf6775a73
Merge pull request #9160 from ronald-cron-arm/crypto-config-test_ref_configs-3.6
[Backport 3.6] Partial backport of #9057
2024-05-23 09:30:04 +00:00
Gilles Peskine
7fbbb43a57 Pacify pylint
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-22 18:09:39 +02:00
Gilles Peskine
8941033a40 Generate test data before coverage analysis
Fixes #8300.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-22 18:09:39 +02:00
Ronald Cron
8526751ec4 Improve test-ref-configs.pl
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-22 09:12:19 +02:00
Ronald Cron
f313902890 Fix "maybe-uninitialized" warning with GCC 11.3
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-22 09:12:19 +02:00
Ronald Cron
7d949ae1a3 Resolve PBKDF2_AES_CMAC_PRF_128 dependencies
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-22 09:12:19 +02:00
Ronald Cron
e3283ed019 test-ref-configs.pl: Detect automatically test with USE_PSA enabled
Change the way we decide if for a given
configuration we need to run tests with
and without MBEDTLS_USE_PSA_CRYPTO enabled.
That makes the script suitable for 3.6 and
development branch.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-22 09:12:19 +02:00
Ronald Cron
f47f5459b1 Fix compat.sh filters
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-22 09:12:19 +02:00
Gilles Peskine
281aa2ea6f
Merge pull request #9136 from gilles-peskine-arm/ssl-opt-server2-detection-3.6
Backport 3.6: Fix skipped tests in configurations without RSA
2024-05-15 12:06:35 +00:00
Gilles Peskine
f287691e0c Add missing dependency that isn't autodetected
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:21 +02:00
Gilles Peskine
d2d9bbf9a6 Remove redundant RSA dependency
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:21 +02:00
Gilles Peskine
5194ff8e00 Explicitly use TLS 1.2 on <=1.2-specific keyUsage/extKeyusage tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:21 +02:00
Gilles Peskine
abb1c22588 Fix PSK invocation: GnuTLS PSK length (more)
Replace more sample PSK by longer (GnuTLS-compatible) strings, taking care
of keeping distinct PSK distinct for wrong-PSK tests.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:21 +02:00
Gilles Peskine
89ef2fabb5 Driver-only FFDH is not good enough for DHE support in TLS 1.2
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:20 +02:00
Gilles Peskine
21ad57677c Add seme missing dependencies on renegotiation support
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:20 +02:00
Gilles Peskine
f9c798cb97 Default NEXT versions to be the base executables
This allows many tests to pass with the system openssl and gnutls-*. As
before, not all test cases will pass due to differences between versions and
build options.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:20 +02:00
Gilles Peskine
e373c9417a Force some test cases to use TLS 1.2
Some OpenSSL or GnuTLS interoperability test cases fail if the other
implementation is recent enough to support TLS 1.3. Force those test cases
to use TLS 1.2 so that the script works with more recent $OPENSSL or
$GNUTLS_CLI or $GNUTLS_SERV than our official CI versions.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:20 +02:00
Gilles Peskine
80e54a20ac Add some missing dependencies on crypto features
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:20 +02:00
Gilles Peskine
02cd7168e6 Fix PSK invocation: GnuTLS PSK length
ssl-opt.sh uses a 3-byte PSK in many test cases. Unfortunately GnuTLS >=3.4.0
rejects a PSK that is less than 4 bytes long:

> Error setting the PSK credentials: The request is invalid.

Use a longer PSK throughout ssl-opt. Only the test cases involving GnuTLS
need to change, but it's easier to do a global search-and-replace, and it's
easier to not have to worry about mismatches in constructed test cases
later, so replace everything.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:20 +02:00
Gilles Peskine
f12359ded4 Fix PSK invocation: GnuTLS prompting
When given a PSK key but no username, gnutls-cli prompts for a password.
Prevent that by passing --pskusername with the same identity that
ssl_server2 uses by default.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:20 +02:00
Gilles Peskine
7fa055b57b Fix PSK invocation: OpenSSL client
Only s_server has a -nocert option, s_client doesn't. Fixes OpenSSL client
test cases in PSK-only builds.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:20 +02:00
Gilles Peskine
121a7bfc37 Require RSA when using server1* key or certificate
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:20 +02:00
Gilles Peskine
1bc28fe34b Fix skipped tests in configurations without RSA
Tighten the matching when detecting which certificates are in use to
determine algorithm requirements. This fixes a bug whereby all tests were
skipped in configurations without RSA except for an Mbed TLS client against
a GnuTLS or OpenSSL server, due to *server2* matching ssl_server2.
Fixes #8366.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-14 12:06:20 +02:00
Andre Goddard Rosa
3711734a0a Add invalid padding_len check in get_pkcs_padding
When trying to decrypt data with an invalid key, we found that `mbedtls`
returned `0x6200` (`-25088`), which means "_CIPHER - Input data contains
invalid padding and is rejected_" from `mbedtls_cipher_finish`, but it also
set the output len as `18446744073709551516`.

In case we detect an error with padding, we leave the output len zero'ed
and return `MBEDTLS_ERR_CIPHER_INVALID_PADDING`.

Here's a reference for the way `openssl` checks the padding length:
  - 1848c561ec/crypto/evp/evp_enc.c (L1023)
  - b554eef43b

So add a check ensuring output is set to the least-harmful value in the
error cases.

With the robustness fix:
`PASSED (125 suites, 26644 tests run)`

Without the robustness fix:
`FAILED (125 suites, 26644 tests run)`

Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Andre Goddard Rosa <agoddardrosa@roku.com>
2024-05-13 09:27:57 -05:00
David Horstmann
b1827cb42d Add mbedtls_framework to mypy checks
Since this python module resides in the framework submodule we must
add an extra explicit path to it for mypy.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-13 14:44:37 +01:00
David Horstmann
9638ca389b Update references to mbedtls_dev
Change these to point to the new mbedtls_framework module in the
framework submodule.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-13 14:44:37 +01:00
David Horstmann
04f3433a55 Add framework/scripts to scripts_path.py
This allows test scripts to find the new mbedtls_framework module.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-13 14:44:37 +01:00
Valerio Setti
a927e81fb0 gitignore: ignore test_keys.h and test_certs.h
These files are automatically generated at build time so they
do not need to be tracked.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-13 11:39:29 +02:00
David Horstmann
df097d3b38 Add note explaining component purpose
We are testing that we don't break OSS-Fuzz, primarily.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-10 15:39:54 +01:00
David Horstmann
90dddc68b9 Add all.sh component for programs without tests
Check that we can build under CMake with ENABLE_TESTING=OFF but
ENABLE_PROGRAMS=ON.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-10 14:55:04 +01:00
David Horstmann
58b660c66a Move test generated files to main CMakeLists.txt
Move the generation of tests/src/test_certs.h and tests/src/test_keys.h
to the main CMakeLists.txt. This is required because these files are
needed both by tests and programs, whereas tests/CMakeLists.txt is only
included when ENABLE_TESTING is on.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-10 14:55:04 +01:00
Valerio Setti
b03778560b generate_test_keys: move code for arrays and LUT generation to a separate function
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 12:37:45 +02:00
Valerio Setti
6f86a4a5a3 check-generated-files: move check for generate_test_cert_macros.py
This test should only be performed when in MbedTLS repo and not
in tf-psa-crypto one.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 11:15:57 +02:00
Valerio Setti
3d54a9d7a3 generate_test_[keys/cert_macros]: minor fixes
- remove new line at beginning of test_keys.h
- add footer at the end of both generated files

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 10:54:44 +02:00
Valerio Setti
d714259c01 generate_test_keys: move output file writing to a separate function
This helps removing the previous pylint exception.

Also use "with" statement for opening the file in order to
ensure that all the content is flushed to the file before
exiting.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 10:54:44 +02:00
Valerio Setti
42efdd83ff generate_test_keys: sort keys before processing them
Without this fix keys could be listed differently on Ubuntu 16
between different runs therefore causing
check_generated_files() to fail.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 10:54:44 +02:00
Valerio Setti
feb87a9dfc check-generated-files: add test_certs.h file to the list of checked items
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 10:54:44 +02:00
Valerio Setti
97e4e04a52 generate_test_cert_macros: minor fixes
- use build_tree to get the project root path
- remove "if True" in an "if" statement

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 10:54:44 +02:00
Valerio Setti
e2f2dd5b91 generated_test_keys: minor fixes
- rewrite output file (do not append)
- remove useless "os" import
- move pylint for main() function

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 10:54:44 +02:00