Commit graph

212 commits

Author SHA1 Message Date
Werner Lewis
3366ebcb66 Add test_generation.py dependency in builds
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-25 16:18:22 +01:00
Werner Lewis
383461c92f Separate CMake targets for bignum and PSA
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-24 15:07:55 +01:00
Werner Lewis
75ef944da3 Fix CMake change failures on Windows
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-08 11:58:21 +01:00
Werner Lewis
8b2df74b12 Add bignum test generation framework
Adds python script for generation of bignum test cases, with initial
classes for mpi_cmp_mpi test cases. Build scripts are updated to
generate test data.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-08 11:58:21 +01:00
Gilles Peskine
09dc05b880
Merge pull request #5635 from gilles-peskine-arm/psa-test-op-fail
PSA: systematically test operation failure
2022-04-15 10:52:47 +02:00
Gilles Peskine
26f9054d8f Declare modules used by generate_psa_tests.py as dependencies
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-03-15 18:32:10 +01:00
Jerry Yu
3b86d1b3c6 fix comments grammar issues
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-03-08 14:07:39 +08:00
Jerry Yu
80bc860aab add depends to avoid file not found
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-03-08 14:07:39 +08:00
Jerry Yu
89e7654fc9 fix parallel build fail of test_cmake_out_source
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2022-03-08 14:07:39 +08:00
Gilles Peskine
d5438a5678 Enable -Wunused-function in cmake builds for tests
This has been the case when building with make since
d3d8a64dfa. Be consistent.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-02-26 19:54:41 +01:00
Gilles Peskine
a18fb9d9ac Fix string/regexp backslash escapes
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-01-25 23:24:34 +01:00
Gilles Peskine
cd55fe02ef Remove accidental use of a feature that doesn't exist in CMake 3.5
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-01-25 23:13:49 +01:00
Gilles Peskine
29080e8e6a CMake: generate the list of test suites automatically
We keep forgetting to register new test suites in tests/CMakeLists.txt. To
fix this problem once and for all, remove the need for manual registration.

The following test suites were missing:
  test_suite_cipher.aria
  test_suite_psa_crypto_driver_wrappers
  test_suite_psa_crypto_generate_key.generated

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-01-25 22:36:12 +01:00
Gilles Peskine
a5c18512b9
Merge pull request #5155 from paul-elliott-arm/pcks12_fix
Fixes for pkcs12 with NULL and/or zero length password
2021-12-13 14:52:36 +01:00
Jerry Yu
55ee769b51 Fix out-of-source build fail
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2021-12-06 18:20:43 +08:00
Paul Elliott
d663543004 Add PKCS12 tests
Only regression tests for the empty password bugs for now. Further tests
will follow later.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-11-22 10:10:24 +00:00
David Horstmann
a8d1406107 Rename DEV_MODE to GEN_FILES
GEN_FILES is a bit clearer as it describes what the setting
does more precisely.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2021-10-25 13:16:04 +01:00
David Horstmann
3e30ad9b0d Use MBEDTLS_PYTHON_EXECUTABLE
Change one occurrence of ${PYTHON} to ${MBEDTLS_PYTHON_EXECUTABLE}
and add implied ${MBEDTLS_PYTHON_EXECUTABLE} to the start of a
different command.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2021-10-25 13:16:04 +01:00
David Horstmann
f602eb19ba Add comment explaining generate_psa_code.py
Explain that the output filename is derived from the -d
argument, so that it's obvious why the CMakefile code
does what it does.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2021-10-25 13:16:04 +01:00
David Horstmann
7570d24d3d Fix issue with DEV_MODE=OFF case
When DEV_MODE=OFF, link_to_source() was being called with
a full path in the build directory, rather than just a base
name starting at "suites/" as was intended. Fix this by
generating a list of base names and using that for
link_to_source(), then deriving full paths afterwards.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2021-10-25 13:16:04 +01:00
David Horstmann
ae7bd3513c Select test data directory using generated list
Remove a hardcoded list of tests that use generated
".data" files, and instead derive this list from the existing
list of test files (created using generate_psa_tests.py).

This reduces the maintenance burden as only the list
in generate_psa_tests.py needs to be updated.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2021-10-25 13:16:04 +01:00
David Horstmann
1732b5d6ee Move test link_to_source() calls into a foreach
This removes a hardcoded list of generated test names

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2021-10-25 13:16:04 +01:00
David Horstmann
7b78ec88a4 Change variable name to lowercase
This seems more correct for variables that are only used in
a small area of the cmake file.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2021-10-25 13:16:04 +01:00
David Horstmann
e12e7f47de Get generated data file list from script
Use the generate_psa_tests.py script to generate the list
of test data files used as output files by cmake.

Do this by introducing a new option --list-for-cmake
that prints a semicolon-separated list of the data files
with no terminating newline (since this is how a cmake list
is represented).

Replace the hard-coded output file list with a variable
generated by the script using this option.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2021-10-25 13:16:04 +01:00
Manuel Pégourié-Gonnard
389150d4db Cleanup: remove *.datax files with CMake
Unrelated to other commits in this PR, except when running manual tests
I kept noticing these files where left over.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-10-25 13:16:04 +01:00
Manuel Pégourié-Gonnard
e90e405e15 Introduce "Dev mode" option
When the option is On, CMake will have rules to generate the generated
files using scripts etc. When the option is Off, CMake will assume the
files are available from the source tree; in that mode, it won't require
any extra tools (Perl for example) compared to when we committed the
files to git.

The intention is that users will never need to adjust this option:

- in the development branch (and features branches etc.) the option is
always On (development mode);
- in released tarballs, which include the generated files, we'll switch
the option to Off (release mode) in the same commit that re-adds the
generated files.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-10-25 13:16:04 +01:00
Manuel Pégourié-Gonnard
313bcfcde8 Stop writing to the source tree.
Due to the directory test/suites being linked, the files generated there
where actually written to the source tree, not just the binary tree.

We no longer need this directory to be linked, that was a remnant of the
time where the .data files were read while running the tests; nowadays
they're processed when generating the test .c file.

Just create the directory, as the generating script quite reasonably
assumes that the output directory passed on the command line exists.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-10-25 13:16:04 +01:00
Manuel Pégourié-Gonnard
ce3ba8f030 Allow CMake to run generate_psa_tests
Note: the test suites are actually generated in the source tree, due to
the use of

    link_to_source(suites)

This will be fixed in the next commit.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-10-25 13:16:04 +01:00
Manuel Pégourié-Gonnard
42681f3bd0 Improve formatting of CMake file
- avoid very long lines
- match order of command arguments and dependencies
- group compiler flags together

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-10-25 13:16:03 +01:00
TRodziewicz
10e8cf5fef Remove MD2, MD4, RC4, Blowfish and XTEA
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-06-16 10:34:25 +02:00
Gilles Peskine
0225d3a0ce Add missing test suites to CMakeLists.txt
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-25 20:11:48 +02:00
Mateusz Starzyk
f9c7b3eb11 Remove PKCS#11 library wrapper.
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-04-21 11:05:00 +02:00
Mateusz Starzyk
c301bd56f0 Merge branch 'development_3.0' into drop_old_tls_options 2021-04-15 13:55:20 +02:00
Hanno Becker
09d880aa38 MPS Reader Tests: Test basic feed-get-commit-reclaim cycle
This commit adds an MPS unit test suite `test_suite_mps` which will
subsequently be populated with unit tests for all components of MPS.

As a start, a test case

```
   mbedtls_mps_reader_no_pausing_single_step_single_round()
```

is added which exercises the most basic usage of the MPS reader
component; see the test case description for more details.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-03-29 14:19:32 +01:00
Mateusz Starzyk
a3a9984a5d Drop support for TLS record-level compression.
Remove option MBEDTLS_ZLIB_SUPPORT.

Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-03-16 12:49:51 +01:00
Gilles Peskine
00d37d0026 Test code for storage format stability
Save tests are for forward compatibility: import a key in the current format
and check that it has the expected storage format so that future versions
will still be able to read it.

Read tests are for backward compatibility: read a key in the format of a
past version (injected into storage) and check that this version can use it.
Exercise the key unless it is meant to test metadata storage only.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-03-10 23:22:35 +01:00
Gilles Peskine
1c0e48a2ce New test suite: net
A place to put tests for the net_sockets module (MBEDTLS_NET_C feature).

Start with a context smoke test.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-24 18:37:46 +01:00
Gilles Peskine
f29019f9cc Build tests with -Wdocumentation when using Clang
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-23 20:36:07 +01:00
Dave Rodgman
d6ee36ed04
Merge pull request #4110 from gilles-peskine-arm/psa-external-random-in-mbedtls
Expose the PSA RNG in mbedtls
2021-02-22 14:47:29 +00:00
Gilles Peskine
79f2166c22 Fix test suite declarations for cmake
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-17 14:58:29 +01:00
Gilles Peskine
342cc7c475 Declare the new (automatically generated) test data file
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-17 14:50:17 +01:00
Gilles Peskine
069346cdab New test suite for not-supported cases: key creation (import, generate)
To start with, test that key creation fails as intended when the key
type is not supported. This commit only covers psa_import_key and
psa_generate_key. A follow-up will cover psa_key_derivation_output_key.

My primary intent in creating this new test suite is to automatically
generate test cases by enumerating the key types and algorithms that
the library supports. But this commit only adds a few manually written
test cases, to get the ball rolling.

Move the relevant test cases of test_suite_psa_crypto.data that only
depend on generic knowledge about the API. Keep test cases that depend
more closely on the implementation, such as tests of non-supported key
sizes, in test_suite_psa_crypto.data.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-17 14:50:17 +01:00
Gilles Peskine
077599ad85 New test suite for random generation
Test random generation as a whole. This is different from
test_suite_*_drbg and test_suite_entropy, which respectively test PRNG
modules and entropy collection.

Start with basic tests: good-case tests, and do it twice and compare
the results to validate that entropy collection doesn't repeat itself.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-02-03 18:55:39 +01:00
Ronald Cron
f7b666c508 tests: psa: Move PSA key attributes tests
Move PSA key attributes tests to their own
test suite to be able to run them when
MBEDTLS_PSA_CRYPTO_CLIENT is enabled but
not MBEDTLS_PSA_CRYPTO_C.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-02-01 13:17:23 +01:00
Gilles Peskine
935b4f96f9
Merge pull request #3407 from RcColes/development
Increase compatibility with external cmake
2020-10-28 12:29:14 +01:00
David Brown
c74441802a Add context-info.sh to linked tests
Add context-info.sh to the test scripts linked into the cmake build
directory, so that these tests are available as well.

Signed-off-by: David Brown <david.brown@linaro.org>
2020-10-20 13:35:21 -06:00
Raef Coles
995c66f702 Build: Add MBEDTLS_TARGET_PREFIX
Allows required targets to have prefixes added to them, so that external
projects can avoid target names clashing.

Signed-off-by: Raef Coles <raef.coles@arm.com>
2020-10-20 13:44:44 +01:00
Gilles Peskine
76dd3aa5bb Add comments explaining include paths
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-07-02 15:59:45 +02:00
Ronald Cron
ddaf99c9d4 build: Add top-level mbedtls_test target
In preparation of linking common test objects in programs,
add the top-level mbedtls_test target.

This target consists of the common test objects.

It is necessary to declare it at the top-level as both
tests and programs will depend on it and it is necessary
to synchronize the compilation of those objects for tests
and programs for the case of parallel building.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2020-06-26 10:45:09 +02:00
Ronald Cron
f5ea29adcb tests: Improve naming of build common test variables
Use the mbedtls_test_ prefix for (c)make variables
related to test common code.

This aligns with the prefix used for the common test
functions.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2020-06-26 10:32:20 +02:00