Commit Graph

1740 Commits

Author SHA1 Message Date
Gilles Peskine cb27d4f7a2 Use standard code instead of the homemade FileWrapper
We had a home-made FileWrapper class, written in the days of Python 2,
whose main purpose was to add line numbers. Use the standard class fileinput
instead.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-05 18:00:43 +01:00
Gilles Peskine 612ccb7217 Use utf-8 when opening text files
All of our source files are encoded in UTF-8. We have other scripts that
make this assumption. We don't want to depend on the platform encoding.

This fixes a bug whereby non-ASCII characters in .function files led to an
error when writing the generated C file. Fix Mbed-TLS/mbedtls-framework#64.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-05 17:58:10 +01:00
Ronald Cron d68446c9da Merge pull request #47 from gabor-mezei-arm/9140_stderr_for_c_build
Validated by #9292 (dev) and #9709 (3.6) CI.
2024-10-21 14:15:33 +02:00
Gabor Mezei d1d2e3c061 fix typo
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-10-17 14:29:18 +02:00
Gilles Peskine 3eafac12ae Merge pull request #58 from Mbed-TLS/dev/gilles-peskine-arm/generate_config_tests-require_psa
PSA_WANT_xxx is only meaningful when PSA crypto is enabled
2024-10-16 19:31:07 +02:00
David Horstmann 311d8acd1c Merge pull request #56 from eleuzi01/issue-54
Move TLS auxiliary test scripts to the framework
2024-10-16 14:47:38 +01:00
Elena Uziunaite 53a0461c4d Remove unused import
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-10-15 12:28:59 +01:00
Elena Uziunaite e966d35352 Merge branch 'tmp-branch-move-files-to-framework' into issue-54 2024-10-15 12:28:34 +01:00
Elena Uziunaite 1bce0cbfff Move some files to framework repository
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-10-15 12:28:33 +01:00
Ronald Cron cb81d8086f Merge pull request #9671 from Harry-Ramsey/duplicate-common-header-file-development
Refactor duplicate common header file
2024-10-15 06:05:07 +00:00
Harry Ramsey b81cd1af64 Update includes for generated files
This commit replaces the include of "common.h" with "ssl_misc.h" for
generated files.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-14 08:41:23 +01:00
Bence Szépkúti d9a70c758a Merge pull request #48 from valeriosetti/enhance-config-py
enhance common_config.py and generate_test_code.py
2024-10-11 15:46:17 +02:00
Valerio Setti c9d6bf4534 generate_test_code.py: simplify regex expression
"\w" already matches "[a-zA-Z0-9_]" so CONDITION_VALUE_REGEX
can be simplified as proposed in this commit.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-10-11 15:12:02 +02:00
Gilles Peskine 239c0d8d17 PSA_WANT_xxx is only meaningful when PSA crypto is enabled
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-10 21:38:26 +02:00
Tom Cosgrove 0b4ccdd7c9 Merge pull request #9674 from gergelykarm/development
Fix driver schema json default type requirements
2024-10-10 13:53:14 +00:00
Gilles Peskine 80352ac58c Merge pull request #9668 from gilles-peskine-arm/analyze_outcome-split-dev
Split check_test_cases.py and outcome_analysis.py
2024-10-10 13:45:49 +00:00
Gergely Korcsák a3c2a8f2a2 Fix driver schema json default type requirements
Signed-off-by: Gergely Korcsák <gergely.korcsak@arm.com>
2024-10-10 13:16:32 +02:00
Gilles Peskine 041a84d1dc Downgrade mypy to a version that works with our code base
mypy >=0.960 rejects macro_collector.py.
https://github.com/Mbed-TLS/mbedtls-framework/issues/50

We currently need mypy >=0.940, <0.960. Pick 0.942, which works, and is the
system version on Ubuntu 22.04.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 14:12:59 +02:00
Gilles Peskine 1c5a252729 Upgrade mypy to the last version supporting Python 3.6
Upgrade mypy to 0.971, which is the last version that supports Python 3.6
(the oldest Python version that we currently run on the CI).

This fixes the error
```
framework/scripts/mbedtls_framework/outcome_analysis.py:119: error: Incompatible return value type (got "IO[Any]", expected "TextIO")
framework/scripts/mbedtls_framework/outcome_analysis.py:121: error: Incompatible return value type (got "IO[Any]", expected "TextIO")
```
As far as I can tell the fix is https://github.com/python/mypy/pull/9275
which was released in mypy 0.940.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 14:12:59 +02:00
Gilles Peskine 6759e8012d Make open calls more uniform
Text mode ('t') is the default for the open builtin, but not for gzip.open
and its imitators. Always specify it explicitly to avoid making maintiners
wonder if there's an intended difference in behavior.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine d63709d3db collect_test_cases.py is now a separate module
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine 9c9d9fa5b0 Default to requiring full test coverage
Command-line options allow choosing whether a never-executed test results in
a warning or an error. Also, a consuming script can make the default
permissive by setting FULL_COVERAGE_BY_DEFAULT to False.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine b111d9fe54 Support compressed outcome files transparently
Transparently read outcome files compressed with xz (which we currently use
on the CI) or with gzip.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine 67e415fc6a Also write to a log file by default
Write the log of outcome analysis to a log file by default. This is a cheap
way of getting the outcome analysis log in an easy-to-access form on the CI:
with our current CI scripts, they are now automatically available as an
artifact called `analyze_outcomes.log`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine 48c005f569 Adjust import path after script moves
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:53:57 +02:00
Gilles Peskine 4103f92134 Merge branch 'tmp-branch-move-files-to-framework' into move-files-into-framework 2024-10-09 13:49:41 +02:00
Gilles Peskine ce00cfe798 Move some files to framework repository
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 13:49:38 +02:00
Valerio Setti bf87497fdc generate_test_code.py: improve detection of ambiguous numerical values
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-10-09 10:21:10 +02:00
Valerio Setti f8025e4362 generate_test_code.py: allow bitwise operators in depends_on expressions
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-10-09 10:21:10 +02:00
Valerio Setti a6e9c083a1 generate_test_code.py: add check for numerical format
Do not allow values starting with a 0 because they can be either
accidentally octal or accidentally decimal. Hex values are not
affected by this change.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-10-09 10:21:10 +02:00
Valerio Setti b6dc14c3c8 generate_test_code: ease checks on the test data depends_on
In case of depends_on elements that include a conditional check
on some symbol's value, we allow the comparison element to
be anything and not just a fixed value as it was before.
This allows for more complex depends_on conditions where
build symbols and macros are used on both sides of the comparison.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-10-09 10:21:10 +02:00
Valerio Setti 6b04996bda config_common.py: remove unnecessary if statements
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-10-09 10:21:10 +02:00
Valerio Setti 40a28bd2af config_common.py: make get_matching() a generator
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-10-09 10:21:10 +02:00
Valerio Setti 9b987bd204 config.py: add get-all and get-all-enabled commands
Both commands use regex expressions to get a list of symbols.
The difference between the 2 is that:

- get-all returns both enabled and commented out symbols while
- get-all-enabled returns only enabled ones.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-10-09 10:21:10 +02:00
Gilles Peskine fecb9b916d Downgrade mypy to a version that works with our code base
mypy >=0.960 rejects macro_collector.py.
https://github.com/Mbed-TLS/mbedtls-framework/issues/50

We currently need mypy >=0.940, <0.960. Pick 0.942, which works, and is the
system version on Ubuntu 22.04.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-08 19:54:43 +02:00
Gilles Peskine 199c9195f5 Upgrade mypy to the last version supporting Python 3.6
Upgrade mypy to 0.971, which is the last version that supports Python 3.6
(the oldest Python version that we currently run on the CI).

This fixes the error
```
framework/scripts/mbedtls_framework/outcome_analysis.py:119: error: Incompatible return value type (got "IO[Any]", expected "TextIO")
framework/scripts/mbedtls_framework/outcome_analysis.py:121: error: Incompatible return value type (got "IO[Any]", expected "TextIO")
```
As far as I can tell the fix is https://github.com/python/mypy/pull/9275
which was released in mypy 0.940.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-08 19:54:43 +02:00
Harry Ramsey c19f8aea8a Update config.py crypto for version files
Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-04 13:37:42 +01:00
Harry Ramsey 468c0aede9 Revert move of version.h to tf-psa-crypto libray
This commit moves version.h back into /include/mbedtls from
tf-psa-crypto/drivers/builtin/include. This commit also changes the
necessary build files and scripts to generate version_features.c

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-04 13:37:42 +01:00
Elena Uziunaite f7b24653d7 Remove extra spaces
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 15:19:36 +01:00
Elena Uziunaite 21a6a20c84 Replace MBEDTLS_MD_CAN_SHA256 with PSA_WANT_ALG_SHA_256
And add temporary solution so it works with 3.6 and 4.0

Temporary solution to be resolved in #51.

Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 15:19:36 +01:00
Elena Uziunaite 010c1f1ae0 Adapt changes to work with both 3.6 and 4.0
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 15:19:36 +01:00
Elena Uziunaite 4f80439a5f Replace MBEDTLS_PK_HAVE_ECC_KEYS with PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-26 15:19:36 +01:00
Manuel Pégourié-Gonnard 560265154c Merge pull request #9604 from gilles-peskine-arm/config-full-booleans-only
config.py: don't rely on section names
2024-09-26 10:03:19 +00:00
Gilles Peskine 3943a1a3bf Automatically generate tests/opt-testcases/tls13-compat.sh
`tests/opt-testcases/tls13-compat.sh` is supposed to be automatically
generated by `tests/scripts/generate_tls13_compat_tests.py`. So far, the
output has been updated by running the script manually and committing the
output. Switch to using our framework for generated files.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-24 18:59:31 +02:00
Paul Elliott edc27bc080 Merge pull request #9128 from gilles-peskine-arm/make_generated_files-document_CC
make_generated_files.bat: document C compiler requirement
2024-09-24 12:36:14 +00:00
Tom Cosgrove 475ed86c7a Merge pull request #9600 from gilles-peskine-arm/use_psa_crypto-key_id_encodes_owner-compatible-config-dev
Fix obsolete comment about MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
2024-09-24 10:44:56 +00:00
Gilles Peskine 00b9144608 Don't pass the section name to adapters
We have finished removing the reliance of named configuration on section
names.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-23 15:56:26 +02:00
Gilles Peskine 2f639b6bf4 Don't pass the section name to adapters
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-23 15:46:37 +02:00
Gilles Peskine 36571d6d8a Change "realfull" to activate everything
Change "realfull" to activate everything. After investigation, it seems that
having "realfull" not activate everything was a historical oddity due to
proximity with "full", not a goal in itself.

https://github.com/Mbed-TLS/mbedtls/issues/520#issuecomment-727190862
https://github.com/Mbed-TLS/mbedtls/pull/965/files#r523409092

This changes the output of `scripts/config.py realfull`: now all non-boolean
options are uncommented.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-23 15:44:46 +02:00
Gilles Peskine e4c6955e43 Change "full" to affect boolean settings rather than use sections
To get rid on the reliance on sections, change "full" and friends to enable
settings based on whether the setting is boolean, rather than based on the
section it contains.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-23 15:44:46 +02:00