5863 Commits

Author SHA1 Message Date
Dave Rodgman
c7cc83cc44
Merge pull request #1119 from davidhorstmann-arm/psa-buffer-copy-fn
Implement buffer copying functions for PSA crypto
2023-11-24 10:46:38 +00:00
David Horstmann
89875a4f20 Rename "output_copy" -> "local_output"
This helps to prevent confusion as it avoids overloading the word
"copy" as both an action and an object.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-20 17:55:13 +00:00
David Horstmann
f1734054fa Rename "input_copy" -> "local_input"
This helps to prevent confusion as it avoids overloading the word
"copy" as both an action and an object.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-20 17:54:57 +00:00
David Horstmann
2f307b4216 De-abbreviate "len" -> "length"
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-20 13:04:06 +00:00
David Horstmann
671f5f539e Change psa_crypto_copy_output error code
When we are copying output, it makes sense to return
PSA_ERROR_BUFFER_TOO_SMALL since the buffer we are copying to is a user
output buffer.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-20 13:03:43 +00:00
David Horstmann
9abf535078 Add initializers for input / output copies
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-20 12:29:54 +00:00
Ronald Cron
97137f91b6
Merge pull request #7071 from yuhaoth/pr/tls13-ticket-add-max_early_data_size-field
TLS 1.3 EarlyData: add `max_early_data_size` field for ticket
2023-11-20 08:04:57 +00:00
David Horstmann
365df3f16c Remove unnecessary checks for NULL-ness of copies
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-16 20:30:36 +00:00
David Horstmann
58909704e3 Check for len == 0 rather than buffer == NULL
This makes the intention clearer

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-16 20:26:16 +00:00
David Horstmann
0fca150b81 Compare buffers even for zero-length cases
This enables us to test that lengths are correctly zero when the buffer
pointer is NULL.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-16 20:12:17 +00:00
David Horstmann
23f1122838 Use TEST_CALLOC_NONNULL
Check that input/output copying works for zero-length NULL input
buffers.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-16 20:01:32 +00:00
David Horstmann
b4e3f36918 Change data pattern to simpler one
Just use the index modulo 256, as this has a greater stride and is
simpler to use.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-16 19:57:25 +00:00
David Horstmann
1b7279a849 Make copy functions static-testable
This allows greater compiler optimisation.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-15 17:26:18 +00:00
Manuel Pégourié-Gonnard
dc848955d6
Merge pull request #8519 from mpg/block-cipher
[G2] Add internal module block_cipher
2023-11-15 11:53:22 +00:00
Manuel Pégourié-Gonnard
9e80a91f27
Merge pull request #8164 from yanrayw/adjust_tfm_configs
Adjust how we handle TF-M config files
2023-11-15 08:21:27 +00:00
Manuel Pégourié-Gonnard
cf582df426
Merge pull request #8498 from mpg/legacy-deps-psa-tests
Remove legacy dependencies from PSA tests
2023-11-13 08:16:30 +00:00
Manuel Pégourié-Gonnard
76fa16cab3 block_cipher: add encrypt()
Test data copied from existing test suites.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-11-10 12:14:53 +01:00
Manuel Pégourié-Gonnard
3e0884fc53 block_cipher: add setkey()
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-11-10 11:52:10 +01:00
Manuel Pégourié-Gonnard
21718769d1 Start adding internal module block_cipher.c
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-11-10 11:21:17 +01:00
Manuel Pégourié-Gonnard
7d7ce0e66a
Merge pull request #8495 from lpy4105/issue/6322/driver-only-cipher_aead-tls
[G3] Driver-only cipher+aead: TLS: main test suite
2023-11-09 11:10:34 +00:00
David Horstmann
0a57ed25c4 Add output round-trip testcase
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-08 18:18:14 +00:00
David Horstmann
35dd103688 Add input round-trip testcase
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-08 18:17:58 +00:00
David Horstmann
63a73588cf Add testcase for psa_crypto_output_copy_free()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-08 18:13:23 +00:00
David Horstmann
70b82256b5 Add testcase for psa_crypto_output_copy_alloc()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-08 18:13:23 +00:00
David Horstmann
4700144817 Add testcase for psa_crypto_input_copy_free()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-08 18:13:15 +00:00
Gilles Peskine
4dec9ebdc2
Merge pull request #8378 from mschulz-at-hilscher/fixes/issue-8377
Fixes "CSR parsing with critical fields fails"
2023-11-08 18:07:04 +00:00
Dave Rodgman
0d22539de0
Merge pull request #8468 from daverodgman/mbedtls-3.5.1-pr
Mbed TLS 3.5.1
2023-11-08 18:01:32 +00:00
Dave Rodgman
28d40930ae Restore bump version
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-11-08 11:40:08 +00:00
Gilles Peskine
1d6de4ceb7 No more limitations accelerated algorithms using a built-in hash
It used to be the case that when an algorithm that uses a hash inside was
accelerated through a PSA driver, it might end up calling a hash algorithm
that is not available from the driver. Since we introduced MBEDTLS_MD_LIGHT,
this no longer happens: PSA accelerated hashes are available to callers of
the MD module, so the test driver can use all available hash algorithms.
Hence the workaround to skip testing certain accelerated cases is no longer
needed.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-08 12:30:52 +01:00
Manuel Pégourié-Gonnard
fcc5f31bb8 Rm unjustified MD_C dependencies in PSA test
RSA will auto-enable MD_LIGHT, we don't need to list MD_C as a
dependency here.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-11-08 12:30:52 +01:00
Manuel Pégourié-Gonnard
af302b9e5d Rm unjustified PK_C dependencies in PSA tests
Some are about raw or AES keys where PK seems really unrelated.

The others are about RSA where PK may be relevant, but the necessary
bits of PK are auto-enabled when RSA key types are requested, so we
shouldn't need to list them as dependencies in tests.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-11-08 12:30:52 +01:00
Manuel Pégourié-Gonnard
433150e8f2 Rm redundant ECC dependencies in psa_crypto tests
Since _DERIVE can't be accelerated now, in
config_adjust_legacy_from_psa.h we will notice and auto-enable ECP_LIGHT
as well as the built-in version of each curve that's supported in this
build. So, we don't need to list those as dependencies here - and they
would cause issues when we add support for _DERIVE drivers.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-11-08 12:30:51 +01:00
Manuel Pégourié-Gonnard
59a8b41ca3 Fix incorrect RSA dependencies in psa_crypto tests
There's no reason the tests would depend specifically on our built-in
implementation and not work with drivers, so replace the RSA_C
dependency with the correct PSA_WANT dependencies.

Those 6 cases use two different test functions, but both of those
functions only do `psa_import()`, so all that's needed is PUBLIC_KEY or
KEYPAIR_IMPORT (which implies KEYPAIR_BASIC) depending on the kind of
key being tested.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-11-08 12:30:51 +01:00
Manuel Pégourié-Gonnard
0d9a3618bd Rm unneeded dep on PK_PARSE_C in psa crypto tests
Most of them were removed in 7162, not sure how these ones slipped in.

There's no reason deterministic ECDSA verification would need PK parse
more than the other tests. The following finds no match:

    grep -i pk_parse library/ecdsa.c library/psa_crypto_ecp.c

Even if PK parse was actually needed for this, the right way would be to
auto-enable it based on PSA_WANT symbols, and then only depend on
PSA_WANT symbols here.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-11-08 12:30:51 +01:00
Ronald Cron
c27a4ce3dd
Merge pull request #8429 from gilles-peskine-arm/fix-test_suite_constant_time_hmac-not-executed
Fix test suite never executed due to an undefined symbol
2023-11-08 09:05:12 +00:00
Pengyu Lv
2bd56de3f4 ssl: replace MBEDTLS_SSL_HAVE_*_CBC with two seperate macros
MBEDTLS_SSL_HAVE_<block_cipher>_CBC equals
MBEDTLS_SSL_HAVE_<block_cipher> and MBEDTLS_SSL_HAVE_CBC.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-11-08 14:21:19 +08:00
Pengyu Lv
ba6825e37b ssl: use MBEDTLS_SSL_HAVE_* in tests
Done by commands:

```
sed -i "s/MBEDTLS_\(AES\|CAMELLIA\|ARIA\|CHACHAPOLY\)_C/MBEDTLS_SSL_HAVE_\1/g" tests/{suites,include,src}/**/*ssl*
sed -i "s/MBEDTLS_\(GCM\|CCM\)_C/MBEDTLS_SSL_HAVE_\1/g" tests/{suites,include,src}/**/*ssl*
sed -i "s/MBEDTLS_CIPHER_MODE_\(CBC\)/MBEDTLS_SSL_HAVE_\1/g" tests/{suites,include,src}/**/*ssl*
```

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-11-08 14:09:16 +08:00
Yanray Wang
30769696e7 Merge remote-tracking branch 'origin/development' into adjust_tfm_configs 2023-11-08 10:00:24 +08:00
David Horstmann
1ac7e24fb7 Add testcase for psa_crypto_input_copy_alloc()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-07 16:36:41 +00:00
Matthias Schulz
e92f6dcf5c New test cases requested in https://github.com/Mbed-TLS/mbedtls/pull/8378#discussion_r1383779861
Signed-off-by: Matthias Schulz <mschulz@hilscher.com>
2023-11-07 15:16:35 +01:00
David Horstmann
b3de69493c Remove psa_crypto_alloc_and_copy() API
This tied input and output buffers together in
awkward pairs, which made the API more difficult
to use.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-06 17:45:09 +00:00
David Horstmann
7dd8205423 Remove extra blank line at end of file
(This causes code style checks to fail)

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-06 17:45:09 +00:00
Manuel Pégourié-Gonnard
964dee6b3f
Merge pull request #8442 from lpy4105/issue/8355/driver-only-cipher_aead-x509
X.509: Support driver-only cipher+aead
2023-11-06 09:10:57 +00:00
Gilles Peskine
8b6b41f6cd
Merge pull request #8434 from valeriosetti/issue8407
[G2] Make TLS work without Cipher
2023-11-04 15:05:00 +00:00
Gilles Peskine
c5ce9fcf03
Merge pull request #8435 from valeriosetti/issue8415
Remove cipher/aead legacy dependencies from PSA test suites
2023-11-04 15:04:51 +00:00
David Horstmann
ad33ab376b Move buffer copy tests into new testsuite
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-03 20:01:37 +00:00
David Horstmann
49a7276c49 Switch error code to more appropriate value
Since we are internal rather than user-facing,
PSA_ERROR_CORRUPTION_DETECTED makes more sense than
PSA_ERROR_BUFFER_TOO_SMALL. Whilst it really is a buffer that is too
small, this error code is intended to indicate that a user-supplied
buffer is too small, not an internal one.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-03 19:51:40 +00:00
David Horstmann
86cdc7646d Switch to TEST_CALLOC_NONNULL()
This removes some gubbins related to making sure the buffer is not NULL
that was previously cluttering the test case.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-03 19:45:39 +00:00
David Horstmann
b8381513c1 Switch from ret to status as naming convention
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-03 19:31:35 +00:00
David Horstmann
8075c7faf7 Switch from int to psa_status_t for test args
Remove unnecessary casts as well.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-03 19:28:08 +00:00