567 Commits

Author SHA1 Message Date
David Horstmann
eae12b1a01 Move some test helpers out of Mbed TLS
Everything not TLS-related and not ALT-interface-related has been moved
out of tests/src and tests/include and into the framework.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:17:28 +00:00
Manuel Pégourié-Gonnard
6f35a4dbe0
Merge pull request #9547 from davidhorstmann-arm/align-development-3.6-test-helpers-3.6
Align 3.6 test helpers with development
2024-10-30 09:09:36 +00:00
Paul Elliott
d3aa6d91b9 Add const specifiers to pacify armclang
Functions designed for local scope only should be const

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-10-24 15:25:57 +01:00
David Horstmann
a7d2afe119 Tidy up header guards
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-10-23 16:55:20 +01:00
David Horstmann
dfd3075e32 Only guard with CRYPTO_CLIENT when version >= 4
In 4.x the semantics of MBEDTLS_PSA_CRYPTO_C and
MBEDTLS_PSA_CRYPTO_CLIENT are different compared with 3.6.

Where this is a problem, make guards more version-specific so that we
are guarding with MBEDTLS_PSA_CRYPTO_C for 3.6 and
MBEDTLS_PSA_CRYPTO_CLIENT for 4.x, keeping each branch the same as it
was formerly.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-10-21 14:13:41 +01:00
David Horstmann
3ee3223d9f Regenerate PSA test wrappers
These necessarily differ from development

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-10-21 14:13:41 +01:00
David Horstmann
8660e4bde6 Align 3.6 tests/{src,include} with development PR
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-10-21 14:13:21 +01:00
Manuel Pégourié-Gonnard
9ec6d45e99 Fix code style (for real this time, hopefully)
For some reason I didn't think about other files in the previous commit.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:41:05 +02:00
Janos Follath
96cfd7a77a Move bignum code path testing out of the library
Without this, it's not at all obvious that turning on MBEDTLS_TEST_HOOKS
doesn't change the functional behavior of the code.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-09-02 10:30:47 +02:00
Ronald Cron
9f44c883f4 Rename some "new_session_tickets" symbols
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 17:47:46 +02:00
Ronald Cron
d67f801c63 Do not add a new field in the SSL config
We cannot add a new field in SSL config in
an LTS. Use `session_tickets` field instead.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 10:41:54 +02:00
Ronald Cron
23303a47f4 Enable TLS 1.3 ticket handling in resumption tests
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-27 16:20:40 +02: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
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
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
Gilles Peskine
a8e39f2156 Update PSA wrappers
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
Michael Schuster
6d6cae53ad Fix tests build with MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS enabled
In that case mbedtls_psa_platform_get_builtin_key is already declared.

Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-06 12:09:13 +01:00
Michael Schuster
31b1cb8601 Adjust spacing in tests/suites function sources
Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-06 12:09:13 +01:00
Michael Schuster
b1e33fb707 Fix missing-prototype errors in tests/suites
Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-06 12:09:13 +01:00
Michael Schuster
3a4c43174c Move print_buf into mbedtls_test_print_buf helper function in sample programs
Reduce code duplication and fix missing-prototype error for print_buf

Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-06 12:09:13 +01:00
Michael Schuster
b4d55bb5db Add missing include in tests/src/asn1_helpers.c
Signed-off-by: Michael Schuster <michael@schuster.ms>
2024-08-06 12:09:13 +01:00
Bence Szépkúti
52992e5c38
Merge pull request #9395 from sezrab/mbedtls_test_ssl_message_queue_pop_info-3.6
[Backport 3.6] tests/ssl_helpers: Check that message queue is popped
2024-08-01 18:38:31 +00:00
Ronald Cron
1640bd3154 Update auto-generated psa_test_wrappers.
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-07-23 18:16:57 +02:00
Gilles Peskine
d66dc64622 Keep track of PSA keys used interally
When PSA uses CTR_DRBG for its random generator and CTR_DRBG uses PSA for
AES, as currently implemented, there is one volatile key in permanent use
for the CTR_DRBG instance. Account for that in tests that want to know
exactly how many volatile keys are in use, or how many volatile keys can be
created.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-07-17 14:00:31 +02:00
Gilles Peskine
4804847b15 Make it possible to enable CTR_DRBG/PSA without a PSA AES driver
Make it possible, but not officially supported, to switch the CTR_DRBG
module to PSA mode even if MBEDTLS_AES_C is defined. This is not really
useful in practice, but is convenient to test the PSA mode without setting
up drivers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-07-17 12:21:21 +02:00
Tomás González
1fb69a9e91 tests/ssl_helpers: Check that message queue is popped
mbedtls_test_mock_tcp_recv_msg is currently popping a message
queue and does not check if this was done correctly.

This extra check makes the test more complete/robust.

Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
2024-07-15 11:07:38 +01:00
Ronald Cron
2463ec8d70 tests: src: Fix PSA test wrappers for PAKE
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-06-19 10:34:21 +02:00
Valerio Setti
4b9aebf4d9 tests: remove test_certs.h and test_keys.h as they are auto-generated
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 10:54:44 +02:00
Valerio Setti
a607a1b322 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-05-07 10:54:44 +02:00
Valerio Setti
5e965845d6 generate_test_keys: split group_id and key bitsize in the generated structure
- group_id is only used for EC keys;
- key bitsize only for RSA.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-22 05:20:47 +02:00
Valerio Setti
04ee26404b generate_test_keys: generate also look-up table in script
Remove static declaration of look-up table from test_suite_pk
and generate it automatically with Python.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:36 +02:00
Valerio Setti
65953e227a generate_test_keys: generate arrays for all keys in asymmetric_key_data.py
Only unused (from test_suite_pk point of view) EC curves are skipped.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:36 +02:00
Valerio Setti
f38640d07d generate_test_keys: generate also RSA public key arrays
This is to manage RSA and EC keys in the same way in order to
prepare for the following commits.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:36 +02:00
Valerio Setti
ea9c8bdb5c generate_test_keys: minor improvements
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:36 +02:00
Valerio Setti
7affeef725 generate_test_keys: use keys from asymmetric_key_data.py
asymmetric_key_data.py already provides EC/RSA key pair values that
are suitable for generate_test_keys.py. So instead of re-generating
the keys using gen_key program, we use those keys.

This commit also:
- extends asymmetric_key_data.py to introduce
RSA bit sizes that are used in test_suite_pk but were missing from
asymmetric_key_data.py.
- updates test_keys.h with new keys.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:36 +02:00
Valerio Setti
001ec961c6 generate_test_keys.py: minor improvements
- remove BEGIN_FILE/END_FILE lines from output header file.
- add single disclaimer at the beginning of the file instead
  of having it repeated for every array.
- improved exception message for missing key generation program.

This commits also regenerates "test_keys.h" in order to fully
comply with the new format.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:36 +02:00
Valerio Setti
bdb7ae1dad test_suite_pk: add python script to generate predefined keys
This commit adds "generate_test_keys.py" script to generate
predefined keys used in test_suite_pk. Keys are generated with
"programs/pkey/gen_key" tool and converted to C array using
the python script.

tests/src/test_keys.h is automatically generated using the
above mentioned script.

test_suite_pk is updated in order to use the new format.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:36 +02:00
Valerio Setti
cca2d437d2 test_suite_pk: use look-up table instead of file for the predefined keys
This helps dropping dependency on FS_IO.
This commit also removes DER files that were previusly added and which
are not more needed/used.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-17 05:28:36 +02:00
Gilles Peskine
79d25877ff
Merge pull request #9009 from mpg/fix-wrong-dep-test-case-3.6
[Backport 3.6]   Fix wrong dependencies in test cases + follow-up
2024-04-09 11:34:10 +00:00
Ronald Cron
346b81877d tests: ssl: Add hostname checks in session serialization tests
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-04-05 14:16:31 +02:00
Ronald Cron
819636994e tests: ssl: Fix session field guards
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-04-05 14:16:31 +02:00
Pengyu Lv
3bb89dc935 Fix failures in psa_cryto_driver_wrappers suite
- "in-driver" test should depend on the present
  of a driver.
- add new counter in key manangement driver test
  hook which counts the calls of generate_key.
- We only care about the hits when processing
  `psa_generate_key`.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2024-04-04 12:57:06 +02:00
Minos Galanakis
b70f0fd9a9 Merge branch 'development' into 'development-restricted'
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2024-03-19 22:24:40 +00:00
Waleed Elmelegy
4dfb0e7c90 Add ALPN checking when accepting early data
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-03-15 12:12:15 +00:00
Paul Elliott
44ccc8764b
Merge pull request #8924 from Ryan-Everett-arm/threading-same-key-tests
Add testing for concurrently loading/using/destroying the same key
2024-03-15 10:24:44 +00:00
Ronald Cron
6bee910dbd
Merge pull request #8858 from waleed-elmelegy-arm/add_alpn_to_session
Add ALPN information in session tickets
2024-03-15 09:50:24 +00:00
Ryan Everett
6de38ac91c Add missing PSA_ASSERT in mbedtls_test_psa_raw_key_agreement_with_self
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-03-14 17:50:39 +00:00
David Horstmann
0a8abdea8b Update wrapper generation script and regenerate
Update the guards generated by the wrapper generation script to use
!MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS and regenerate the PSA test
wrappers.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-03-14 14:47:48 +00:00