Partially revert "Give test code access to internal macros of the library".
I think that it would be better not to require every user of `test/macros.h`
to have access to the library source, but it's out of scope here.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Run some code in a child process. Propagate output from the child if the
test succeeds, and propagate the test result information otherwise.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Include `"test_common.h"` as the first thing in C files, and
`<test/build_info.h>` as the first thing in header files.
This requires moving `<test/test_common.h>` to its intended location
`"test_common.h"`.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
The header `test_common.h` contains two kinds of things:
* Things to do at the beginning of individual C files. Specifically,
defining macros that notify system headers about what we want from them.
Keep those in `test_common.h`, which will subsequently be moved out of
the include directory.
* Things to do at the beginning of every header. In particular, read the
library configuration. Move them to a new header `build_info.h`,
which is the only one intended to be included from headers.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This lets us define things that we want to have everywhere in test code. In
particular, this lets us define platform-specific symbols that influence
what system headers declare. This also takes care of including the library
configuration.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Keep TEST_EQUAL() on the function that might fail so that if a failure
happen the message will report the actual function that failed.
Documentation of the helper function is also updated.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
A new look-up table is created, "predefined_keys_psa", to list all the
predefined keys together with the corresponding PSA key type and bits.
A new look-up table was created in order not to conflict with the already
existing "predefined_keys" one.
"mbedtls_pk_helpers_get_predefined_key_data" is modified in order to
use the new look-up table.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Get rid of one subdirectory in include/ limitation.
Prefix all file basename instead of changing the
name of `include/mbedtls` to `include/libtestdriver1`.
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
In Mbed TLS 3.6, this error was used in the library as well as the test
framework, but since TF-PSA-Crypto 1.0, it has been removed from the
library.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
common.h has been renamed to tf_psa_crypto_common.h in the standalone
TF PSA Crypto library used in Mbed TLS 4.
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
Provide the new interface for `mbedtls_platform_get_entropy()` requested
in https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/307 when
`MBEDTLS_PSA_DRIVER_GET_ENTROPY` is enabled. Keep providing the old
interface when `MBEDTLS_PLATFORM_GET_ENTROPY_ALT` is enabled.
For now, the new interface is identical to the old one. Subsequent commits
will change the interface.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
In every existing test driver entry point that is the setup for a multipart
operation, check that the driver operation structure is all-bits-zero on
entry, as guaranteed by the driver specification.
There is a risk that this isn't the case, mostly, on platforms where
initializing a union to `{0}` initializes only the default member and not
all members.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Since mbedtls_platform_get_entropy_alt() is being renamed to
mbedtls_platform_get_entropy() on the tf-psa-crypto repo, this commit
adapts to testing support.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
For each multipart or interruptible operation, define an initializer
function that simulates the minimum that `my_op_t op = {0}` guarantees in C.
That is, initialize most fields to 0, but set the fields that are unions to
a nonzero value. This simulates platforms where initializing a union to
`{0}` only initializes the first member, and thus reading from another
member can yield a nonzero value. In our operation structures, the union's
first member is an unused `dummy`, and the other members are
driver-specific, so we just make the whole union nonzero and this has to be
good enough for the setup functions in the core to cope.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Fix various obsolete or copy-pasted things, and document what test
assertions this function makes.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
These changes to psa_exercise_key were added while the files were being
moved to the framework. Port them to the framework now.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
Move everything in tests/src and tests/include except for TLS-only
things, the alt-dummy headers and the generated PSA test wrappers.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
Since PSA is always on in 4.x, *_PSA_INIT() and *_PSA_DONE() can be
simply aliased to PSA_INIT() and PSA_DONE() until such a time as we
remove them.
Simplify the login of these PSA_INIT/DONE variants by aliasing them in
4.x and keeping the more complex 3.6 logic entirely separate.
Signed-off-by: David Horstmann <david.horstmann@arm.com>