Commit graph

911 commits

Author SHA1 Message Date
Werner Lewis
1b20e7e645 Redefine result() method to return List
Many bignum tests have multiple calculated result values, so return
these as a list, rather than formatting as a string.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
7a2731463b Add function to generate random montmul cases
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
a850312e9d Add test generation for mpi_core_montmul
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
0a9c48b68e Add test generation for mpi_core_mla
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
bbf0a32d67 Add flag for unique combinations in operations
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
6351c7f5f3 Add test generation for mpi_core_sub
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
ce769d1fc9 Add test generation for mpi_core_add_if
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Werner Lewis
99e8178fa7 Add module for bignum_core test generation
Separate file is added for classes used to generate cases for tests
in bignum_core.function. Common elements of the BignumOperation class
are added to classes in a new common file, for use across files.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-10-19 15:20:01 +01:00
Janos Follath
7cd1ebe0bb
Merge pull request #6296 from gilles-peskine-arm/test_data_generation-pr_6093_followup
Minor fixes to test_data_generation.py
2022-10-18 13:38:28 +01:00
Gilles Peskine
8874cd570e
Merge pull request #4826 from RcColes/development
Add LMS implementation
2022-10-14 18:33:01 +02:00
Manuel Pégourié-Gonnard
b3c30907d6
Merge pull request #6383 from mprse/aead_driver_test
Enable testing of AEAD drivers with libtestdriver1
2022-10-14 11:11:01 +02:00
Raef Coles
7dce69a27a
Make LMOTS a private api
Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:22 +01:00
Raef Coles
8ff6df538c
Add LMS implementation
Also an LM-OTS implementation as one is required for LMS.

Signed-off-by: Raef Coles <raef.coles@arm.com>
2022-10-13 14:28:15 +01:00
Gilles Peskine
0fe6631486
Merge pull request #6291 from gilles-peskine-arm/platform.h-unconditional-3.2
Include platform.h unconditionally
2022-10-13 10:19:22 +02:00
Gilles Peskine
cf42536d4e Add a note that config.py must remain compatible with Python 3.4
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-10 22:52:30 +02:00
Przemek Stekiel
8a05a646f4 Remove psa_driver_get_tag_len() and use PSA_ALG_AEAD_GET_TAG_LENGTH macro instead
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
2022-10-06 17:01:58 +02:00
Gilles Peskine
c217f48251 Replace the output file atomically
When writing the new .data file, first write the new content, then replace
the target. This way, there isn't a temporary state in which the file is
partially written. This temporary state can be misleading if the build is
interrupted. It's annoying if you're watching changes to the output and the
changes appear as emptying the file following by the new version appearing.
Now interrupted builds don't leave a file that appears to be up to date but
isn't, and when watching the output, there's a single transition to the new
version.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-04 15:10:00 +02:00
Gilles Peskine
31a8815f25 Documentation typo
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-29 18:48:41 +02:00
Manuel Pégourié-Gonnard
f3f9e450b6
Merge pull request #6115 from AndrzejKurek/ecjpake-kdf-tls-1-2
Ad-hoc KDF for EC J-PAKE in TLS 1.2
2022-09-28 09:47:32 +02:00
Gilles Peskine
b3ea98c606 Replace the output file atomically
When writing the new .data file, first write the new content, then replace
the target. This way, there isn't a temporary state in which the file is
partially written. This temporary state can be misleading if the build is
interrupted. It's annoying if you're watching changes to the output and the
changes appear as emptying the file following by the new version appearing.
Now interrupted builds don't leave a file that appears to be up to date but
isn't, and when watching the output, there's a single transition to the new
version.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-21 22:00:06 +02:00
Gilles Peskine
d9071e7d96 Unify check_repo_path
We had 4 identical copies of the check_repo_path function. Replace them by a
single copy in the build_tree module where it naturally belongs.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-18 21:17:09 +02:00
Gilles Peskine
15997bd389 Use relative imports when importing other modules in the same directory
We were using absolute imports under the assumption that the /scripts
directory is in the path. This worked in normal use because every one of our
Python scripts either were in the /scripts directory, or added the /scripts
directory to the module search path in order to reference mbedtls_dev.
However, this broke things like
```
python3 -m unittest scripts/mbedtls_dev/psa_storage.py
```

Fix this by using relative imports.

Relative imports are only supposed to be used inside a package (Python
doesn't complain, but Pylint does). So make /scripts/mbedtls_dev a proper
package by creating __init__.py.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-17 10:38:58 +02:00
Gilles Peskine
7b3fa657af generate_*_tests.py --directory: fix handling of relative path
The option to --directory was intended to be relative to the current
directory when the script is invoked, which is the intuitive behavior. But
this was not implemented correctly, and it was actually interpreted relative
to the mbedtls root (which the script chdir's into). Fix this.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-17 10:38:58 +02:00
Gilles Peskine
049042586e Clarify the descriptions of test-case-data-related modules
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-17 10:38:58 +02:00
Gilles Peskine
64f2efdc40 More precise name for test data generation
We have Python code both for test code generation
(tests/scripts/generate_test_code.py) and now for test data generation.
Avoid the ambiguous expression "test generation".

This commit renames the Python module and adjusts all references to it. A
subsequent commit will adjust the documentation.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-17 10:38:58 +02:00
Gilles Peskine
1716f06ee3
Merge pull request #6093 from wernerlewis/bignum_test_script
Add bignum test case generation script
2022-09-17 10:37:26 +02:00
Werner Lewis
c2fb540c67 Use a script specific description in CLI help
Previous changes used the docstring of the test_generation module,
which does not inform a user about the script.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-16 17:03:54 +01:00
Gilles Peskine
945b23c46f Include platform.h unconditionally: automatic part
We used to include platform.h only when MBEDTLS_PLATFORM_C was enabled, and
to define ad hoc replacements for mbedtls_xxx functions on a case-by-case
basis when MBEDTLS_PLATFORM_C was disabled. The only reason for this
complication was to allow building individual source modules without copying
platform.h. This is not something we support or recommend anymore, so get
rid of the complication: include platform.h unconditionally.

There should be no change in behavior since just including the header should
not change the behavior of a program.

This commit replaces most occurrences of conditional inclusion of
platform.h, using the following code:

```
perl -i -0777 -pe 's!#if.*\n#include "mbedtls/platform.h"\n(#else.*\n(#define (mbedtls|MBEDTLS)_.*\n|#include <(stdarg|stddef|stdio|stdlib|string|time)\.h>\n)*)?#endif.*!#include "mbedtls/platform.h"!mg' $(git grep -l '#include "mbedtls/platform.h"')
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-15 20:33:07 +02:00
Werner Lewis
07c830c164 Fix setting for default test suite directory
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-15 09:02:07 +01:00
Werner Lewis
52ae326ebb Update references to file targets in docstrings
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-14 16:52:45 +01:00
Werner Lewis
00d02423a5 Remove argparser default for directory
This reverts commit f156c43702. Adds a
comment to explain reasoning for current implementation.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-14 16:52:42 +01:00
Werner Lewis
858cffde1e Add toggle for test case count in descriptions
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-14 16:52:25 +01:00
Werner Lewis
34d6d3e4e5 Update comments/docstrings in TestGenerator
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-14 16:52:18 +01:00
Andrzej Kurek
08d34b8693 Add an EC J-PAKE KDF to transform K -> SHA256(K.X) for TLS 1.2
TLS uses it to derive the session secret. The algorithm takes a serialized
point in an uncompressed form, extracts the X coordinate and computes
SHA256 of it. It is only expected to work with P-256.
Fixes #5978.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-09-14 08:39:26 -04:00
Werner Lewis
56013081c7 Remove unused imports
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-02 12:57:37 +01:00
Werner Lewis
a4668a6b6c Rework TestGenerator to add file targets
BaseTarget-derived targets are now added to TestGenerator.targets in
initialization. This reduces repeated code in generate_xxx_tests.py
scripts which use this framework.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-09-02 11:56:34 +01:00
Werner Lewis
aaf3b79bbb Use Python 3.5 style typing for dependencies
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-31 17:16:44 +01:00
Werner Lewis
466f036326 Add dependencies attribute to BaseTarget
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-31 17:01:38 +01:00
Werner Lewis
81f24443b7 Modify wording in docstrings
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-30 09:37:07 +01:00
Werner Lewis
76f45625e6 Fix trailing whitespace
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-25 13:21:45 +01:00
Werner Lewis
9df9faac5c Use argparser default for targets
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-25 12:49:41 +01:00
Werner Lewis
6ef5436f3c Clarify documentation
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-25 12:29:46 +01:00
Werner Lewis
f156c43702 Use argparser default for directory
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-25 11:31:55 +01:00
Werner Lewis
e3ad22ecf2 Fix TARGET types and code style
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-25 10:02:06 +01:00
Werner Lewis
6d654c6491 Raise NotImplementedError in abstract methods
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-25 09:56:51 +01:00
Werner Lewis
a195ce73f5 Disable pylint unused arg in __new__
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-24 18:10:55 +01:00
Werner Lewis
d03d2a3a91 Remove trailing whitespace in description
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-24 18:10:25 +01:00
Werner Lewis
cfd4768df2 Use __new__() for case counting
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-24 18:10:13 +01:00
Werner Lewis
2b527a394d Split generate_tests to reduce code complexity
Previous implementation mixed the test case generation and the
recursive generation calls together. A separate method is added to
generate test cases for the current class' test function. This reduces
the need to override generate_tests().

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-24 18:10:13 +01:00
Werner Lewis
699e126942 Use ABCMeta for abstract classes
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-08-24 17:33:21 +01:00