5905 Commits

Author SHA1 Message Date
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
Yanray Wang
4995e0c31b cipher.c: return error for ECB-decrypt under BLOCK_CIPHER_NO_DECRYPT
- fix remaining dependency in test_suite_psa_crypto.data

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-11-07 17:51:32 +08: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
David Horstmann
ac12d2dc69 Remove psa_crypto_ prefix from test functions
This ensures they have a different name to the functions they test.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-03 19:23:49 +00:00
David Horstmann
8995b50cf4 Remove superfluous comment
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-03 19:20:33 +00:00
David Horstmann
676cfdd0ea Replace compound-initializers with memset
This should eliminate some pedantic compiler warnings.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 20:47:04 +00:00
David Horstmann
8f77dc7f68 Refactor: move buffer pattern fills into helper
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:40:19 +00:00
David Horstmann
70fda48670 Add full round-trip tests for buffer copying
Test that a buffer pair can be created with psa_crypto_alloc_and_copy()
and destroyed with psa_crypto_copy_and_free() correctly.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:39:42 +00:00
David Horstmann
5b9c21756a Add test case for overlapping buffers
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:39:42 +00:00
David Horstmann
72ab8ad44a Reject zero-lengths in psa_crypto_copy_and_free()
Zero-length buffers should be represented in the
psa_crypto_buffer_copy_t struct as NULL if it was created in
psa_crypto_alloc_and_copy(), so reject non-NULL zero-length buffers.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:39:42 +00:00
David Horstmann
2b79cbaa17 Reject NULL original_output with non-NULL output
If we have a copy buffer but no original to copy back to, there is not
much sensible we can do. The psa_crypto_buffer_copy_t state is invalid.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:39:42 +00:00
David Horstmann
9700876520 Add testcases for psa_crypto_copy_and_free()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:39:37 +00:00
David Horstmann
0fee689e57 Simplify zero-length buffers to always be NULL
Since it is implementation-dependent whether
malloc(0) returns NULL or a pointer, explicitly
represent zero-length buffers as NULL in the
buffer-copy struct, so as to have a uniform
behaviour.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:33:17 +00:00
David Horstmann
03b0472413 Zero-length test for psa_crypto_alloc_and_copy()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:33:17 +00:00
David Horstmann
f06ac88284 Add extra testcases for buffer copying
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:33:17 +00:00
David Horstmann
24f11f9cc7 Add testcases for psa_crypto_alloc_and_copy()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:33:08 +00:00
David Horstmann
2f96423147 Add testcases for psa_crypto_copy_output()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 17:16:25 +00:00
David Horstmann
0b241ee584 Add testcases for psa_crypto_copy_input()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 17:15:30 +00:00
Yanray Wang
eefd2695d2 test_suite_psa_crypto: add dependency for decrypt test cases
If MBEDTLS_BLOCK_CIPHER_NO_DECRYPT, we can't test decrypt for
AES-ECB, so adding this dependency for some test cases

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-11-02 12:38:01 +08:00
Pengyu Lv
2151ba55f6 test_suite_x509write: use plaintext key file
Some test cases are using encrypted key file, thus have
dependency on low-level block cipher modules (e.g. AES).
This commit adds unencrypted key file so that we could
get rid of those dependencies.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-10-31 18:12:04 +08:00
Yanray Wang
b67b47425e Rename MBEDTLS_CIPHER_ENCRYPT_ONLY as MBEDTLS_BLOCK_CIPHER_NO_DECRYPT
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-10-31 17:22:06 +08:00
Yanray Wang
5779096753 Merge remote-tracking branch 'origin/development' into adjust_tfm_configs 2023-10-31 13:39:07 +08:00
Paul Elliott
afc6a992c5
Merge pull request #8381 from gilles-peskine-arm/20231017-misc-cleanup
Cleanups in test code
2023-10-30 18:08:01 +00:00
Paul Elliott
835edd627d
Merge pull request #8404 from paul-elliott-arm/fix_coverity_issues
Fix two coverity issues
2023-10-30 18:00:14 +00:00