30936 Commits

Author SHA1 Message Date
Bence Szépkúti
d28534c5b0
Merge pull request #9062 from tom-daubney-arm/crypto_config-tls1_2_default_stream_cipher_only_use_psa
Make TLS 1.2 components work with PSA_CRYPTO_CONFIG set
2024-06-10 11:54:37 +00:00
Bence Szépkúti
2bceec830a
Merge pull request #9227 from davidhorstmann-arm/check-framework-python-files
Extend python checks to framework scripts
2024-06-10 11:33:27 +00:00
Ronald Cron
4ac0182cae
Merge pull request #9233 from davidhorstmann-arm/make-code-style-work-in-commit-hook
Allow `code_style.py` to work from a git hook
2024-06-07 14:07:31 +00:00
David Horstmann
8493452d6f Extend python checks to framework scripts
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-06-07 11:09:31 +01:00
David Horstmann
f8bbc2d532 Remove multi-type variable
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-06-06 16:16:31 +01:00
David Horstmann
330680e9fe Allow code_style.py to work from a git hook
When running a git hook, git sets certain environment variables (such
as GIT_INDEX_FILE) which force git to look at the main repository,
overriding other options. This trips up code_style.py whenever it
tries to run a git command on the framework submodule.

Fix this by explicitly clearing git-related environment-variables
before running git commands on the framework. This is recommended
by git's documentation[1]:

> Environment variables, such as GIT_DIR, GIT_WORK_TREE, etc., are
> exported so that Git commands run by the hook can correctly locate
> the repository. If your hook needs to invoke Git commands in a
> foreign repository or in a different working tree of the same
> repository, then it should clear these environment variables so
> they do not interfere with Git operations at the foreign location.

[1] https://git-scm.com/docs/githooks

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-06-06 15:25:10 +01:00
Bence Szépkúti
c085cc767d
Merge pull request #9200 from davidhorstmann-arm/move-test-generation-files
Move test generation files to framework
2024-06-04 09:23:17 +00:00
David Horstmann
fd59a06165 Update to latest framework
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-06-03 18:18:49 +01:00
Tom Cosgrove
98ffc8e7c3
Merge pull request #9178 from valeriosetti/fix-psa-cmac
adjust_legacy_crypto: enable CIPHER_C when PSA CMAC is builtin
2024-06-03 15:35:32 +00:00
Tom Cosgrove
e2add3ac08
Merge pull request #9220 from valeriosetti/fix-psa-doc
fix documentation of psa_hash_compare()
2024-06-03 15:34:19 +00:00
Valerio Setti
351efa0ece crypto.h: fix documentation for some functions
Some functions has input parameters which are erroneously
reported as "param[out]" in the documentation. This commit
fixes them.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-06-03 11:17:37 +02:00
David Horstmann
ce7af04795 Update framework submodule
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-31 15:49:02 +01:00
David Horstmann
f6f3bcae43 Update file paths for moved files
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-31 15:49:02 +01:00
David Horstmann
a7b0bb4de8 Move some test generation files to framework
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-31 15:49:02 +01:00
David Horstmann
b8360cf3ca Make abi_check.py look in both locations
To deal with situations where we are comparing revisions before and
after the move of generate_psa_tests.py to the framework, look for
it in both the old and new locations.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-31 15:48:55 +01:00
Valerio Setti
7e2ce99400 changelog: add changelog for PSA CMAC fix
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-31 14:52:54 +02:00
Tom Cosgrove
30a9b6f2fc
Merge pull request #9198 from tom-cosgrove-arm/psa-sim-hashing
Test psa_hash_xxx() APIs in the PSA crypto simulator
2024-05-31 11:13:55 +00:00
Gilles Peskine
ea297e5870
Merge pull request #9061 from gilles-peskine-arm/config-headers-do-not-include
Document check-config.h and *adjust*.h as internal headers
2024-05-31 07:32:39 +00:00
Gilles Peskine
d961929615
Merge pull request #9155 from ttytm/fix-typo
fix typo
2024-05-30 17:24:55 +00:00
Gilles Peskine
8c60b16188
Merge pull request #8643 from gilles-peskine-arm/tls12_server-pk_opaque-dead_code
Guard configuration-specific code in ssl_tls12_server.c
2024-05-30 17:24:33 +00:00
Gilles Peskine
c15544e217
Merge pull request #9088 from ronald-cron-arm/check-framework-files
Extend basic checks and C coding style check to framework files
2024-05-30 17:24:18 +00:00
Tom Cosgrove
0ca70d51d7 Add missing licences
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-30 11:12:22 +01:00
Tom Cosgrove
8bfb758e87 PSA crypto sim's server wrappers need to free deseraliased buffers when they're no longer needed
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 22:48:45 +01:00
Tom Cosgrove
ca0c147354 Mark temporary PSA crypto sim Perl scripts as executable
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 16:52:38 +01:00
Tom Cosgrove
e2f0e3012a Extend PSA crypto simulator tests to run psa_hash.c under the simulator
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 15:19:27 +01:00
Tom Cosgrove
61ee59f041 Add the rest of the psa_hash_xxx() functions to the simulator
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 15:19:27 +01:00
Tom Cosgrove
39f8b09f5b Add PSA crypto sim serialisation functions needed for the remaining PSA hash APIs
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 15:19:27 +01:00
Tom Cosgrove
3ebb880f90 Hook the new psa_sim_crypto_{client,server} into the build and tests
- smoke test client.c becomes a trivial call to psa_crypto_init()
- server.c now uses psa_sim_crypto_server.c's psa_crypto_call()
- Makefile is updated to build all the modules, and allow a different MAIN
- all.sh's test_psasim now tests the simulation of psa_hash_compute() too

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 15:19:10 +01:00
Tom Cosgrove
cb12604d55
Merge pull request #9191 from tom-cosgrove-arm/psa-sim-fixes
Some fixes to the PSA simulator
2024-05-29 12:31:05 +00:00
Tom Cosgrove
a4952f9450 The PSA sim logs aren't very many lines, so show them during tests
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 12:39:40 +01:00
Tom Cosgrove
54b4ccdbf8 Add PSA crypto sim client and server implementations of psa_hash_compute()
A Perl script that creates them is also included as reference. This is not the
final script (that will be in Python) but a proof-of-concept to show that
creaation client and server wrappers can be scripted.

It is not hooked into the build: it must be run manually. It is not part of the
deliverables for this PR.

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 10:27:01 +01:00
Tom Cosgrove
e68fb72d8c Add PSA crypto sim serialisation functions for rest of types needed for psa_hash_compute()
Still not used

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 10:04:14 +01:00
Tom Cosgrove
2fc5687b21 Add PSA crypto sim serialisation functions for basic types
Not hooked into the build yet

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 10:03:06 +01:00
Tom Cosgrove
92024566fb Fix code style in psa_ff_server.c
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 09:58:56 +01:00
Gilles Peskine
c8d45cd3fc Error on unexpectedly defined symbols
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-29 09:44:20 +02:00
Gilles Peskine
9df7806b37 Tweak wording
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-29 09:44:20 +02:00
Gilles Peskine
d2f191adb0 Document that there is now an error for dangerous inclusions
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-29 09:44:20 +02:00
Gilles Peskine
690fb5e0b0 Warn if mbedtls_config.h is included manually
Some projects using Mbed TLS have migrated their configuration
file (config.h -> mbedtls_config.h, or MBEDTLS_CONFIG_FILE) from Mbed TLS
2.x, and kept including check_config.h. This is unnecessary since Mbed TLS
3.0, and increasingly in 3.x it may report spurious errors because the
configuration adjustments have not been done yet.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-29 09:44:20 +02:00
Gilles Peskine
0b8ece6beb Error out if *adjust* headers are included manually
Some projects using Mbed TLS have migrated their configuration
file (config.h -> mbedtls_config.h, or MBEDTLS_CONFIG_FILE) from Mbed TLS
2.x, and kept including check_config.h. This is unnecessary since Mbed TLS
3.0, and increasingly in 3.x it may report spurious errors because the
configuration adjustments have not been done yet. This has led some
projects to include configuration adjustment headers manually, but only
partially or in the wrong order, which can result in silent inconsistencies.
Error out if this happens, with a message mentioning check_config.h since
that's the likely root cause.

```
perl -i -pe '$name = $ARGV; $name =~ s!include/!!; $name =~ s!_adjust_.*!_adjust_*.h!; $_ .= "\n#if !defined(MBEDTLS_CONFIG_FILES_READ)\n#error \"Do not include $name manually! This can lead to problems, \" \\\n    \"up to and including runtime errors such as buffer overflows. \" \\\n    \"If you're trying to fix a complaint from check_config.h, just remove it \" \\\n    \"from your configuration file: since Mbed TLS 3.0, it is included \" \\\n    \"automatically at the right time.\"\n#endif /* !MBEDTLS_CONFIG_FILES_READ */\n" if /^#define .*_H$/' include/*/*adjust*.h
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-29 09:44:20 +02:00
Gilles Peskine
d33eb55cce Macros to indicate the finalization level of the configuration
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-29 09:44:20 +02:00
Gilles Peskine
fef877f51f Belated changelog entry for not including check_config.h
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-29 09:44:20 +02:00
Gilles Peskine
975e74cb1f Document check-config.h and *adjust*.h as internal headers
Including *adjust*.h directly is likely to cause them to be applied at the
wrong time, resulting in an invalid or unintended configuration.

Including check_config.h at the wrong time is likely to cause spurious
errors.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-29 09:44:20 +02:00
Ronald Cron
680bee45ca Update framework submodule to the merge of PR #15
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-28 18:33:42 +02:00
Bence Szépkúti
e3abb6a148
Merge pull request #9094 from davidhorstmann-arm/move-mbedtls-dev-to-framework
Move `mbedtls_dev` to framework submodule
2024-05-28 15:50:47 +00:00
Tom Cosgrove
38f6c86724 Remove unnecessary blank lines at top of functions in psa_ff_server.c
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00
Tom Cosgrove
9919543f5c Only print PSA crypto sim server messages when DEBUG defined
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00
Tom Cosgrove
f69445ccaf Fix sending a response of more than 184 bytes in psa_ff_server.c:psa_write()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00
Tom Cosgrove
bdc4c2d750 Fix PSA sim test awk script by removing extra $
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00
Tom Cosgrove
0a57a253cc Fix psa_ff_server.c to calculate the amount of data from client correctly
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00
Tom Cosgrove
b7e5f31e2a Replace final sprintf() with snprintf() in psa_ff_server.c
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00