30940 Commits

Author SHA1 Message Date
Valerio Setti
5ce51b153c generate_test_keys: do not quit script if output file already exists
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-02 14:40:03 +02:00
Thomas Daubney
1ca1f3d62f Restore Mbed TLS style AEAD options for now
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2024-05-02 09:48:29 +01:00
Manuel Pégourié-Gonnard
898066b851
Merge pull request #9049 from gilles-peskine-arm/test-dependencies-20240314-development
Fix some test case dependencies (PEM_C)
2024-05-02 08:00:25 +00:00
Gilles Peskine
ff3b8211ff Driver-only FFDH is not good enough for DHE support in TLS 1.2
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-30 16:20:20 +02:00
Gilles Peskine
6191f4aeb5 Add seme missing dependencies on renegotiation support
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-30 16:20:20 +02:00
Gilles Peskine
dd782f4197 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-04-30 16:20:20 +02:00
Gilles Peskine
01fde2c3cc 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-04-30 16:20:20 +02:00
Gilles Peskine
3b81ea1e9c Add some missing dependencies on crypto features
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-30 16:20:20 +02:00
Ryan Everett
c51e948370 Add changelog
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-04-30 14:04:17 +01:00
Gilles Peskine
489688c0f7
Merge pull request #9065 from paul-elliott-arm/fix_ubsan_mp_aead_gcm
Add early exit if zero length AEAD additional data passed in.
2024-04-30 09:48:20 +00:00
Janos Follath
93f20f45d1 Fix Changelog formatting
Add EOL and remove trailing whitespaces.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-04-30 10:32:17 +01:00
Valerio Setti
28cc31c9d5 md: fix guards for mbedtls_md_error_from_psa()
This should be CRYPTO_CLIENT and not CRYPTO_C as this function
can be used even when CRYPTO_C is not defined.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-30 10:49:00 +02:00
Valerio Setti
0ddab0ecee generate_test_keys: add missing flush at the end of script
Ensure that all the data is actually written to the output file.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-30 10:37:39 +02:00
nilesh.kale
d338d0156f Fixed issue of redefinition warning messages for _GNU_SOURCE
Signed-off-by: nilesh.kale <nilesh.kale@espressif.com>
2024-04-30 08:24:47 +05:30
Ryan Everett
925b2d76f4 Clarify psa_get_and_lock_key_slot return behaviour
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-04-29 18:29:48 +01:00
Ryan Everett
04e2b04f7f Explicitly document return behaviour
A bug existed previously where this guarantee was not met,
causing some issues in multi-threaded code.

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-04-29 18:26:19 +01:00
Ryan Everett
dd90507dc6 Fix potential non-NULL slot return on failure
If psa_get_and_lock_key_slot fails, the slot must be wiped.
This fixes a bug where a pointer to some valid key slot can
be incorrectly returned

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-04-29 18:24:58 +01:00
Valerio Setti
c21147efe7 test_suite_pk: use explicit key bit size instead of RSA_KEY_SIZE
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:38:37 +02:00
Valerio Setti
84dc3297fb generate_test_keys: use build_tree to guess the MbedTLS root path
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:33:48 +02:00
Valerio Setti
f27d407332 generate_test_cert_macros: minor fixes
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Valerio Setti
fb418166b5 cmake: relocate custom commands for test_certs.h and test_keys.h generation
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Valerio Setti
455fb4e803 generate_test_cert_macros: embed input args
- Embed input arguments inside the script so as to simplify the
  calls in Makefiles/CMakeLists.
- add a new "--list-dependencies" command line option to print
  out the list of dependencies.
- Modify tests/Makefile accordinlgy.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Valerio Setti
34f280538c tests/Makefile: minor fix: specify Python binary to be used
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Valerio Setti
96daf67701 fix "make generated_files" for test_keys.h and test_certs.h
This also add the check in tests/scripts/check-generated-files.sh

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Valerio Setti
52516a6a86 generate_test_keys: add default output file option
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Valerio Setti
b0a524f4bf tests: remove test_certs.h and test_keys.h as they are auto-generated
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:15:08 +02:00
Valerio Setti
8284f3dcbc test: automatically generate test_certs.h and test_keys.h
Ensure that when tests are built also test_certs.h and
test_keys.h are generated.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:14:50 +02:00
Valerio Setti
270dcd15d9 tests: update Makefile to generate tests/src/test_keys.h
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:14:50 +02:00
Gilles Peskine
77c13e67d4 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-04-29 16:09:52 +02:00
Gilles Peskine
c158fe6eb8 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-04-29 16:05:54 +02:00
Gilles Peskine
2776240af4 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-04-29 16:05:38 +02:00
Gilles Peskine
d00b93b621 Require RSA when using server1* key or certificate
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-29 16:03:29 +02:00
Gilles Peskine
dde67bbb5a Fix a compilation warning in pk.c when PSA is enabled and RSA is disabled
It isn't detected on the CI because we only test this with an ancient Clang
that doesn't warn. Old GCC, modern GCC and modern Clang do
warn (-Wunused-but-set-variable).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-29 12:38:16 +02:00
Manuel Pégourié-Gonnard
024d3daa7d
Merge pull request #8986 from valeriosetti/issue8871
Improve test key generation in test_suite_pk
2024-04-29 09:25:37 +00:00
Gilles Peskine
e855317957 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-04-26 21:28:49 +02:00
Paul Elliott
0f37a157a2 Add Changelog entry
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-04-26 18:56:00 +01:00
Paul Elliott
a3daff47d8 Add early exit if zero length AEAD AD passed in.
With multipart AEAD, if we attempt to add zero length additional data,
then with the buffer sharing fixes this can now lead to undefined
behaviour when using gcm. Fix this by returning early, as there is
nothing to do if the input length is zero.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-04-26 18:47:40 +01:00
Thomas Daubney
ff33abd599 Modify component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only_use_psa
Replace relevant Mbed TLS API config options with their PSA
API equivalents.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2024-04-26 17:08:34 +01:00
Thomas Daubney
6258621a0b Modify component_test_tls1_2_deafult_cbc_legacy_cipher_only_use_psa
Replace relevant Mbed TLS API config options with their PSA
API equivalents.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2024-04-26 17:01:16 +01:00
Thomas Daubney
b8cbbe7c90 Modify component_test_tls1_2_default_stream_cipher_only_use_psa
Replace relevant Mbed TLS API config options with their PSA
API equivalents.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2024-04-26 16:46:06 +01:00
Gilles Peskine
014a63b2cf Convert recent RSA key files in PEM format from PKCS8 to PKCS1
Like `openssl rsa`, `openssl genrsa` changed its output format from PKCS8 to
PKCS1 in OpenSSL 3.0. Note that the makefile instructions assume older
OpenSSL. Convert the files that were generated with OpenSSL 3.x and hence
were not in the intended format. The files are converted, not regenerated,
so the key material is the same.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-26 11:51:08 +02:00
Gilles Peskine
0652b62d5e Fix rsa_pkcs1_*_clear.der to actually be PKCS#1 files
With OpenSSL 3.0.2 (which I used to generate the previous set of "pkcs1" DER
files), the output of `openssl rsa -outform DER` is actually a
PKCS#8-encoded key, despite what the documentation says. This is a change
from OpenSSL 1.x, where the output is a PKCS#1-encoded key. OpenSSL 3.0.8
documents the output as PKCS#8.

Change to `openssl pkey`, which seems more reliable. The documentation
states that the output is PKCS#8, but the output is actually consistently
PKCS#1 at least from 1.0.2g to 3.3.0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-25 16:32:38 +02:00
Gilles Peskine
cbb4507b44 Use large enough keys when testing parsing of non-word-aligned RSA sizes
When PSA is available, we exercise the parsed RSA key with PKCS#1v1.5
signature, which requires the modulus size in bytes to be at least
tLen + 11 (per RFC 8017 §9.2) where tLen = hLen + oidLen + 6 and
hLen = 32, oidLen = 9 for SHA-512 or SHA3-512. 10 is the DER overhead
(3 ASN.1 type-length headers with lengths <128). Replace 512-bit test
cases (good enough for SHA-256 but not SHA-384 and up) by 768-bit and
up (good enough for SHA-512).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-24 16:28:00 +02:00
Gilles Peskine
9c3ebe30b8 Add some test RSA keys of sizes 768 and up
These are sufficiently large for PKCS#1v1.5 signature with SHA-512 or
SHA3-512. Cover some non-word-aligned sizes.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-24 16:21:59 +02:00
Gilles Peskine
b612f9fe7c Cleartext RSA keys: also make DER formats available
We can use DER keys in builds without PEM, so it's good to have them around.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-24 16:21:19 +02:00
Manuel Pégourié-Gonnard
771fd7d1dc
Merge pull request #9022 from mpg/compat-fixes-dev
[dev] Small fixes to compat.sh (partial forward-port)
2024-04-24 07:11:49 +00:00
Ronald Cron
87a6d277a8
Merge pull request #9040 from Ryan-Everett-arm/crypto-config-psa_crypto_rsa_no_genprime
Make component_test_psa_crypto_rsa_no_genprime work with PSA_CRYPTO_CONFIG set
2024-04-23 06:30:39 +00:00
Gilles Peskine
1f4e0390bd Fix misspelled dependency: there is no MBEDTLS_PEM_C
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-22 17:24:45 +02:00
Gilles Peskine
6b3a9ee2d8 Allow PSA to not support RSA keys with non-byte-aligned sizes
Work around https://github.com/Mbed-TLS/mbedtls/issues/9048

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-22 17:24:45 +02:00
Gilles Peskine
57a0b915fd Remove redundant dependency
In the test data, remove a dependency that is already present on the function.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-22 17:24:45 +02:00