Commit Graph

184 Commits

Author SHA1 Message Date
Waleed Elmelegy
df186be8f5 Add extra tests cases for different Weierstrass curves for key generation
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-04 17:28:54 +00:00
Waleed Elmelegy
1f5075b23f Revert "Add testing valid attributes after aborting an invalid input in iop key generation"
This reverts commit 005b78c307.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-04 17:28:34 +00:00
Gilles Peskine
9602ce7d8b Fix MD_PSA_INIT called before initializing some data structures
This fixes accesses to uninitialized memory in test code if
`psa_crypto_init()` fails.

A lot of those were pointed out by Coverity. I quickly reviewed all calls to
`MD_PSA_INIT()` manually, rather than follow any particular list.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-04 18:28:01 +01:00
Harry Ramsey
099623c8e9 Improve GCM buffer overlap test cases
This commit fixes an issue with GCM testing to handle edge cases by
replacing malloc with calloc. Additionally, fix an issue where different
buffers were used for encryption.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-11-04 11:02:29 +00:00
Harry Ramsey
415d1bc99c Fix issues with new GCM overlap buffer test cases
This commit code style and initialisation issues with the new buffer
overlap test cases for GCM.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-11-04 11:02:29 +00:00
Harry Ramsey
2e2036c84b Fix indentation in test_suite_gcm.function
Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-11-04 11:02:29 +00:00
Harry Ramsey
b070eb6c52 Add test cases for AES GCM input and output buffer overlap
This commit adds test cases for input and output buffer overlap. The
data for the test cases is a duplicate of existing encrypt/decrypt test
cases.

The two test functions gcm_<encrypt/decrypt>_input_output_buffer_overlap
are modified to use a single malloc buffer rounded to the nearest
128-bits/16-bytes for input and output.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-11-04 11:02:29 +00:00
Waleed Elmelegy
005b78c307 Add testing valid attributes after aborting an invalid input in iop key generation
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-11-01 17:08:57 +00:00
Waleed Elmelegy
e3abcc3ff5 Improve interuptible key generation testing
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-10-31 16:39:02 +00:00
Waleed Elmelegy
1c3c5b15c2 Add Testing interuptible key generation initialization
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-10-31 16:35:38 +00:00
Bence Szépkúti
15baf8b027
Merge pull request #9708 from ronald-cron-arm/target-compile-options
cmake: Define compile and link options target by target
2024-10-29 18:59:07 +00:00
Gilles Peskine
8ed4d94166
Merge pull request #9614 from gilles-peskine-arm/use_psa_crypto-always_on
Always enable MBEDTLS_USE_PSA_CRYPTO in all.sh
2024-10-29 14:58:55 +00:00
David Horstmann
f8d13d8fad
Merge pull request #9721 from paul-elliott-arm/fix_new_coverity_issues
Fix new coverity issues
2024-10-25 16:43:37 +00:00
Ronald Cron
d093edd2bd cmake: tests: Set test specific compile options target by target
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-25 18:09:40 +02:00
Ronald Cron
b2478989e2 cmake: GNU GCC: Set base compile options target by target
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-25 18:09:33 +02:00
Ronald Cron
5f6e69dae5
Merge pull request #9693 from Harry-Ramsey/split-revert-error-development
Split error.h and move back error.c to mbedtls
2024-10-25 13:12:58 +00:00
Gilles Peskine
4e9d77e6e7
Merge pull request #9703 from valeriosetti/fix-9690-workarounds
Revert & fix #9690 workarounds
2024-10-25 11:47:44 +00:00
Paul Elliott
a87a906a4c Move AES_PSA_INIT to after drbg init
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-10-25 12:27:36 +01:00
Paul Elliott
da510d6390 Fix double free in case of test failure
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-10-24 14:58:22 +01:00
Paul Elliott
65b276c613 Add missing check of return
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-10-24 14:58:22 +01:00
Paul Elliott
7c6686014b Fix tests where tests were done prior to init
Variables that are in any way destructed on exit should be initialised
prior to any tests that might jump to exit, to save potential
uninitialised memory accesses.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-10-24 14:58:14 +01:00
Manuel Pégourié-Gonnard
a4f0227669 all.sh: prevent a silly mistake
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-24 10:05:36 +02:00
Gilles Peskine
202b69c2b6
Merge pull request #9302 from valeriosetti/psa-use-static-slots
PSA: use static key slots to store keys
2024-10-24 07:27:48 +00:00
Ronald Cron
ed230c4fb3
Merge pull request #9706 from ronald-cron-arm/pkg-install-doc-lcov
tf-psa-crypto: cmake: Add support for pkg install, doc, lcov
2024-10-24 06:39:58 +00:00
Manuel Pégourié-Gonnard
8bcad48ca5 Add tf-psa-crypto's own all.sh
With a first component.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-23 10:41:15 +02:00
Gilles Peskine
8fd2117360 Remove !MBEDTLS_USE_PSA_CRYPTO test cases that have a USE_PSA alternate
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-22 22:10:42 +02:00
Valerio Setti
cac061f1d4 test_suite_psa_crypto.data: fix some depends_on
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
a35c8a0a7e test_suite_psa_crypto: use finer grained checks on the key slot buffer size
Instead of skipping some tests when !MBEDTLS_PSA_STATIC_KEY_SLOTS,
add a proper check in the depends_on to verify if
MBEDTLS_PSA_KEY_BUFFER_MAX_SIZE is actually large enough to contain
the key used in such test.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
175a494d01 psa_crypto_helpers: enhance definitions for static key slot related test symbols
- MBEDTLS_TEST_STATIC_KEY_SLOTS_SUPPORT_RSA_[2048/4096] are always
  defined because they are only used in test_suite_psa_crypto
  tests.

- MBEDTLS_TEST_ALLOW_RSA_4096 was renamed as
  MBEDTLS_TEST_PK_ALLOW_RSA_KEY_PAIR_4096 because this is only used in
  PK related test suites.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
69d19e7bdd psa_crypto_helpers: add MBEDTLS_TEST_ prefix to newly created symbols
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
2b9d180f8e test_suite_psa_crypto_storage_format: improve input bit length specification for static key buffer
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
4d9a8219ac test: properly select MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE value
This value should be:
- OK for all EC/FFDH key pairs/public keys;
- OK for all supported public RSA keys;
- OK for RSA key pairs up to 2048 bits;
- FAIL for RSA key pairs above 2048 bits.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
c975d5e602 test: add test with persitent key whose length is larger than MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
2a3c9b347c test: extend component_test_crypto_with_static_key_slots
Intentionally set MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE slightly
smaller than the maximum RSA key pair size for an RSA key of 4096
bits. Also add a test in test_suite_psa_crypto to verify this
condition.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
5278ebd186 test: revert fixes for PSA entropy
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
31cca13779 test_suite_psa_crypto_driver_wrappers: revert changes and fix validate_key()
Use only volatile keys in order to remove dependency on storage.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
261baa8e9f psa-core: properly set PSA_CRYPTO_MAX_STORAGE_SIZE
If MBEDTLS_PSA_STATIC_KEY_SLOTS is set then limit PSA_CRYPTO_MAX_STORAGE_SIZE
to MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE, otherwise keep the previous
PSA_BITS_TO_BYTES(PSA_MAX_KEY_BITS) size.

This commit also removes changes to test_suite_psa_crypto_persistent_key.data
done previously since MBEDTLS_PSA_STATIC_KEY_SLOTS is always up to date
with key buffer size.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
a47b045a68 test: add new component to test core library without calloc/free
This commit also fixes issues found in test suites
function/data files.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Valerio Setti
dbb646b99a test: add new component to test MBEDTLS_PSA_STATIC_KEY_SLOTS
This commit also fixes related errors in test suites. In all
cases those failures are related to the use of raw keys whose
size cannot be determined a-priori.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-22 17:56:36 +02:00
Harry Ramsey
fa3663d633 Fix include for tf-psa-crypto tests
This commit replaces #includes "error.h" with #include "error_common.h"
since error.h no longer exists in tf-psa-crypto.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-22 10:43:23 +01:00
Waleed Elmelegy
cca4dbef4c Add PSA interruptible key generation setup & abort APIs
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-10-21 13:41:59 +01:00
Harry Ramsey
bef54c5003 Remove unnecessary if defined
This commit removes unnecessary if defined for multiple files as they
are already guarded.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-21 12:00:24 +01:00
Ronald Cron
d916cc9755 tf-psa-crypto: cmake: Add lcov target
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 11:45:37 +02:00
Ronald Cron
7b2fae2be9 cmake: Remove partial support for partial use CMake build system
Let the projects using some CMakeLists.txt files
without the top CMakeLists.txt define the variables
that the top CMakeLists.txt set for all.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 10:16:35 +02:00
Harry Ramsey
bd77a35b95 Move tests for error.c from tf-psa-crypto to Mbed TLS
This commit moves the test functions and test data from tf-psa-crypto to
Mbed TLS.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
Harry Ramsey
a05bfeed1e Refactor tf-psa-crypto to use error_common.h instead of error.h
This commit refactors tf-psa-crypto to include error_common.h instead of
error.h as these files have been split and the relevant error codes are
now inside error_common.h.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
Gilles Peskine
f5025e2680 Merge remote-tracking branch 'development' into test-cases-not-executed-enforce-development
Conflicts:
* framework: update to the head of 'main'.
2024-10-17 21:20:01 +02:00
Gilles Peskine
e1f37c58a2
Merge pull request #9566 from gilles-peskine-arm/error-codes-4.0-enforce-add-macro
Error codes: enforce add macro
2024-10-16 17:28:04 +00:00
Valerio Setti
401c917226 Revert "Temporarily comment out tests that are clogging the CI"
This reverts commit 50d7579dd1.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-16 16:22:12 +02:00
Gilles Peskine
4e4647a4e7
Merge pull request #9690 from valeriosetti/fix-pk-write-buffer-overrun
pkwrite: fix buffer overrun
2024-10-16 12:00:52 +00:00
Gilles Peskine
5255a9e805 Include "error.h" for MBEDTLS_ERROR_ADD
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 11:52:47 +02:00
Gilles Peskine
ed6feae513 Use MBEDTLS_ERROR_ADD instead of explicit addition: simple cases
Replace obvious additions of an `MBEDTLS_ERR_xxx` constant by a call to
`MBEDTLS_ERROR_ADD`.

Skip `case` statements since `MBEDTLS_ERROR_ADD(pp_constant)` is not a
preprocessor constant.

This commit does not replace additions split over lines. Those will be
handled in a subsequent commit.

```
git ls-files '*.h' '*.c' '*.function' '*.data' |
xargs perl -i -pe '
    next if /\bcase\b/;
    s/\b(MBEDTLS_ERR_\w+)\s*\+\s*(\w+)\b/MBEDTLS_ERROR_ADD($1, $2)/g;
    s/\b(\w+)\s*\+\s*(MBEDTLS_ERR_\w+)\b/MBEDTLS_ERROR_ADD($1, $2)/g'
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 11:52:24 +02:00
Gilles Peskine
50d7579dd1 Temporarily comment out tests that are clogging the CI
The pk_write_pubkey_check sometimes take ~3 hours to run with
GCC+Asan on the CI in the full config. Comment out the slowest
ones while we investigate and release 3.6.2.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 10:48:56 +02:00
Valerio Setti
63348bed30 test_suite_pkwrite: extend coverage of wrong output buffer sizes in pk_write_check_common()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-14 09:44:06 +02:00
Valerio Setti
91577020a2 pkwrite: fix buffer overrun
This commit fixes potential buffer overrun in:
- pk_write_rsa_der
- pk_write_ec_pubkey

In both functions, when dealing with opaque keys, there was no
check that the provided buffer was large enough to contain the
key being exported. This commit fixes this problem and it also
adds some testing in test_suite_pkwrite to trigger these checks.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-11 14:55:24 +02:00
Gilles Peskine
b061ecd4e8 Remove test case involving SECP224K1 in PSA
Our PSA crypto implementation does not and will not support SECP224K1.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-10 17:26:11 +02:00
Gilles Peskine
0dbad8573d Assert non-empty data when needed
Pacify Coverity about subtracting from the length, and give a signal to
human readers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-07 11:12:17 +02:00
Gilles Peskine
d6b6c1d4ac Initialize CCM context before doing anything fallible
Otherwise mbedtls_ccm_free() in cleanup could corrupt memory if a failure
happens.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-07 11:11:32 +02:00
Gilles Peskine
1ba7e24e14 mbedtls_ecdsa_raw_to_der and mbedtls_ecdsa_der_to_raw: reject bits==0
Cleanly reject bits == 0 when calling mbedtls_ecdsa_raw_to_der() and
mbedtls_ecdsa_der_to_raw(). This can plausibly happen when bits is
user-provided data that the calling application doesn't check.

Before this patch, there was typically-benign undefined behavior, such as
adding 0 to a null pointer or calling memcpy on a null pointer with a size
of 0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-04 18:56:17 +02:00
Gilles Peskine
d5a21cf2fd mbedtls_mpi_write_binary{,_le}: test 0-size output
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-04 18:09:00 +02:00
Gilles Peskine
2e26a65ae3 Modernize mpi_write_binary and mpi_write_binary_le
Use TEST_CALLOC instead of a fixed-size buffer, so that Asan/Valgrind builds
will detect a buffer overflow.

Honor output_size regardless of the value of the number.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-04 18:07:55 +02:00
Harry Ramsey
f7e7acc9c1 Move version tests from tf-psa-crypto/test/suite to test/suites
This commit reverts the moves the test for version from
tf-psa-crypto/test/suite to test/suites.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-04 13:37:42 +01:00
Ronald Cron
8d887d18f1 cmake: tf-psa-crypto: Replace some Mbed TLS options/variables by TF-PSA-Crypto ones
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Ronald Cron
b6254f5b97 cmake: Add MBEDTLS_FRAMEWORK_DIR
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Ronald Cron
d3f717d536 CMake: Move build of crypto test suites to tf-psa-crypto
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Ronald Cron
e82ad15f5e CMake: Move build of the crypto library to tf-psa-crypto
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Ronald Cron
ac8dcb8966 Remove dependency on mbedtls_test_helpers
Remove dependency on mbedtls_test_helpers
to build the crypto test suites.
mbedtls_test_helpers is TLS specific.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Ronald Cron
7d5419b6f1 Move test_suite_constant_time_hmac back to mbedtls
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Ronald Cron
96c6f5eb36
Merge pull request #9492 from eleuzi01/remove-legacy-symbol-definitions
Remove definitions of legacy symbols
2024-10-01 10:33:06 +00:00
Elena Uziunaite
404311a702 Remove MBEDTLS_ECP_HAVE_SECP256R1 leftovers
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 14:48:59 +01:00
David Horstmann
b268d270ed
Merge pull request #9413 from sezrab/split_numeric_string_conversions_oid-development
Split numeric string conversions out of the OID module
2024-09-26 12:50:37 +00:00
David Horstmann
bae154d76c
Merge pull request #9385 from eleuzi01/replace-ecdsa-some
Replace MBEDTLS_PK_HAVE_ECDSA* with PSA_WANT counterparts
2024-09-19 13:53:18 +00:00
Sam Berry
2bb3f4d6d4 Move mbedtls_oid_from_numeric_string unit tests to test_suite_x509write
This commit moves all related mbedtls_oid_from_numeric_string unit tests
from test_suite_oid to test_suite_x509write.

Signed-off-by: Sam Berry <sam.berry@arm.com>
2024-09-18 21:23:17 +01:00
Sam Berry
4aee6a25ca Move mbedtls_oid_get_numeric_string unit tests to test_suite_x509parse
This commit moves all related mbedtls_oid_get_numeric_string unit tests
from test_suite_oid to test_suite_x509parse.

Signed-off-by: Sam Berry <sam.berry@arm.com>
2024-09-18 21:23:17 +01:00
Tom Cosgrove
b80516816d
Merge pull request #9536 from mpg/rsapub-perf-dev
[dev] Rsapub performance fix
2024-09-18 14:20:50 +00:00
David Horstmann
7ba04a298c Bump version to 4.0.0
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-09-10 10:43:14 +02:00
Elena Uziunaite
8d8620bf18 Address review comments: add PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-09 11:18:10 +01:00
Elena Uziunaite
bed21b55a6 Replace MBEDTLS_PK_CAN_ECDSA_VERIFY with PSA_HAVE_ALG_ECDSA_VERIFY
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-09 11:18:10 +01:00
Elena Uziunaite
39c7d5dc4b Replace MBEDTLS_PK_CAN_ECDSA_SIGN with PSA_HAVE_ALG_ECDSA_SIGN
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-09 11:18:08 +01:00
Elena Uziunaite
a6950b8ce7 Replace MBEDTLS_PK_CAN_ECDSA_SOME with PSA_HAVE_ALG_SOME_ECDSA
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-09 11:17:36 +01:00
Ronald Cron
8c95999b38
Merge pull request #9544 from eleuzi01/replace-224k1
Replace MBEDTLS_ECP_HAVE_SECP224K1 with PSA_WANT_ECC_SECP_K1_224
2024-09-06 15:15:35 +00:00
Elena Uziunaite
63cb13e494 Replace MBEDTLS_ECP_HAVE_SECP224K1 with PSA_WANT_ECC_SECP_K1_224
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-05 12:43:14 +01:00
Manuel Pégourié-Gonnard
0c4a115442 Remove codepath testing where it's redundant
Constant-time testing with Memsan or Valgrind is much more robust, as it
doesn't require cooperation from the code under test.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-05 12:55:11 +02:00
Janos Follath
21445c580f Prepare codepath tests for early termination
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-09-05 10:47:42 +02:00
Janos Follath
44eca95ace Fix incorrect test result
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-09-05 10:47:41 +02:00
Janos Follath
514e62c833 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-05 10:47:40 +02:00
Janos Follath
e0825bba49 Add tests for optionally safe code paths in RSA
Only add the test hooks where it is meaningful. That is, not adding
where the operation is essentially the same or the target is not the
function that is being tested.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-09-05 10:47:36 +02:00
Janos Follath
64467ff6d2 Add tests for optionally safe code paths in bignum
Not adding _unsafe version to the tests targeting behaviour related to
RR as it is independent from the secret involved in the safe/unsafe
distinction.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-09-05 10:47:35 +02:00
Janos Follath
c870e05a09 Add header for mbedtls_mpi_exp_mod_unsafe()
To silence no previous prototype warnings. And this is the proper way to
do it anyway.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-09-05 10:46:54 +02:00
Janos Follath
a7eb81290b Fix memory corruption in exp_mod tests
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-09-05 10:46:50 +02:00
Janos Follath
d6aaee10fd Disable optionally safe test hook in threading builds
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-09-05 10:45:50 +02:00
Janos Follath
1fa5f3a929 Add tests for optionally unsafe code paths
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-09-05 10:43:20 +02:00
Janos Follath
df5e55bcb7 Add tests for optionally safe codepaths
The new test hooks allow to check whether there was an unsafe call of an
optionally safe function in the codepath. For the sake of simplicity the
MBEDTLS_MPI_IS_* macros are reused for signalling safe/unsafe codepaths
here too.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-09-05 10:41:04 +02:00
Elena Uziunaite
9fc5be09cb Replace MBEDTLS_MD_CAN_SHA1 with PSA_WANT_ALG_SHA_1
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-04 18:12:59 +01:00
David Horstmann
36fe9188e2
Merge pull request #9252 from gabor-mezei-arm/9114_replace_MBEDTLS_MD_CAN_SHA512_with_PSA_WANT
Replace MBEDTLS_MD_CAN_SHA512 with its PSA_WANT counterpart
2024-09-03 14:07:05 +00:00
Manuel Pégourié-Gonnard
0b0f090b6e Merge remote-tracking branch 'restricted/development-restricted' into dev-mergeback
* restricted/development-restricted: (30 commits)
  Tiny fix in ChangeLog pt 2
  Tiny fix in ChangeLog
  Changelog entry for the RSA memory leak
  Edit ChangeLog entry
  Update ChangeLog
  Add test cases for extKeyUsage
  Rationalize extKeyUsage tests
  Use P_CLI when O_CLI's status is not reliable
  Rationalize keyUsage testing, round 2
  Always print detailed cert errors in test programs
  Fix 1.3 failure to update flags for (ext)KeyUsage
  Rationalize ssl-opt tests for keyUsage
  Test cert alert KEY_USAGE -> UNSUPPORTED_CERT
  Free allocated memory where methods were returning without freeing
  Force MBEDTLS_PSA_HMAC_DRBG_MD_TYPE based on CTR_DRBG
  Document that MBEDTLS_PSA_HMAC_DRBG_MD_TYPE does not force HMAC
  Clean up constant-flow memsan testing
  Improve description of who is affected
  More diversified sizes in tests
  Fix stack buffer overflow in ECDSA signature format conversions
  ...
2024-09-02 09:18:34 +02:00
Gabor Mezei
c15ef93aa5
Replace MBEDTLS_MD_CAN_SHA512 with PSA_WANT_ALG_SHA_512
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-08-28 18:20:25 +02:00
Gilles Peskine
ab0af45d11
Merge pull request #9464 from gilles-peskine-arm/psa-keystore-dynamic-development
dynamically sized key store
2024-08-26 10:47:00 +00:00
Gilles Peskine
0a2b6e2945 Merge remote-tracking branch 'development' into development-restricted 2024-08-23 11:14:11 +02:00
Waleed Elmelegy
d1562407c3 Fix possible issues in testing and implementation of psa_key_agreement()
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-08-16 14:37:46 +01:00