1643 Commits

Author SHA1 Message Date
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
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
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
Gilles Peskine
d961929615
Merge pull request #9155 from ttytm/fix-typo
fix typo
2024-05-30 17:24:55 +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
Thomas Daubney
bbb41f7afb Modify lcov.sh to use new project name file
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2024-05-30 09:38:22 +01:00
Thomas Daubney
c0386bf2a7 Introduce project_name.txt
This file is used for detecting which project a script is being
run from.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2024-05-30 09:27:27 +01:00
Turiiya
27098b458b fix typo
Signed-off-by: Turiiya <34311583+ttytm@users.noreply.github.com>
2024-05-18 18:08:12 +02:00
David Horstmann
ecd6d01023 Rename framework_path to framework_scripts_path
This name is more descriptive of its purpose, since it actually adds
framework/scripts to the path rather than just framework/

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-13 14:43:38 +01:00
David Horstmann
875c32fa07 Add framework_path module
This allows scripts in the scripts/ directory to get the path to the
mbedtls_framework module in framework/scripts/

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-13 14:43:38 +01:00
David Horstmann
cd84bb287b Update references to mbedtls_dev
Change these to point to the new mbedtls_framework module in the
framework submodule.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-13 14:43:29 +01:00
David Horstmann
6343a83057 Move some files to framework repository
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-13 13:48:13 +01:00
Ronald Cron
62a908d869 Extend C code style check to framework files
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-02 16:53:23 +02:00
Valerio Setti
455fb4e803 generate_test_cert_macros: embed input args
- Embed input arguments inside the script so as to simplify the
  calls in Makefiles/CMakeLists.
- add a new "--list-dependencies" command line option to print
  out the list of dependencies.
- Modify tests/Makefile accordinlgy.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Valerio Setti
96daf67701 fix "make generated_files" for test_keys.h and test_certs.h
This also add the check in tests/scripts/check-generated-files.sh

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Manuel Pégourié-Gonnard
024d3daa7d
Merge pull request #8986 from valeriosetti/issue8871
Improve test key generation in test_suite_pk
2024-04-29 09:25:37 +00:00
Valerio Setti
776dce51d3 asymmetric_key_data: fix public RSA-2048 key
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-15 17:41:21 +02:00
Valerio Setti
6bda5f5717 generate_test_keys: use keys from asymmetric_key_data.py
asymmetric_key_data.py already provides EC/RSA key pair values that
are suitable for generate_test_keys.py. So instead of re-generating
the keys using gen_key program, we use those keys.

This commit also:
- extends asymmetric_key_data.py to introduce
RSA bit sizes that are used in test_suite_pk but were missing from
asymmetric_key_data.py.
- updates test_keys.h with new keys.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-10 12:33:21 +02:00
Minos Galanakis
96948e9a7b Merge pull request #8980 from adeaarm/fix_jinja_template
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2024-03-22 11:44:46 +00:00
Antonio de Angelis
700632eca2 Fix #ifdef guard in driver wrapper template
The #ifdef guard in the get_builtin_key() should be
PSA_CRYPTO_ACCELERATOR_DRIVER_PRESENT to allow for
multiple drivers to be plugged into the wrapper.

Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2024-03-22 11:43:19 +00:00
Minos Galanakis
b70f0fd9a9 Merge branch 'development' into 'development-restricted'
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2024-03-19 22:24:40 +00:00
Dave Rodgman
1bd787a3e0 Minor relaxation to auto-gen regex
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-03-18 12:32:49 +00:00
Dave Rodgman
4e4540d8e0 line length fix
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-03-18 11:55:39 +00:00
Dave Rodgman
2a9eb22107 Check file content to see if it looks auto-generated
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-03-18 11:16:05 +00:00
Bence Szépkúti
567591eec7
Merge pull request #8923 from bensze01/drop-old-compilers
Drop Support for MSVC 2013, 2015 and Arm Compiler 5
2024-03-15 12:56:21 +00:00
David Horstmann
6f8c95ba1d Preserve alphabetical sorting of config options
In the list that is excluded from the full config.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-03-14 14:52:45 +00:00
David Horstmann
5a71e76e65 Remove MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS from full
This option removes a feature (buffer protection) so should not be
in the full config.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-03-14 14:47:48 +00:00
Gilles Peskine
5c77ad0f4f
Merge pull request #8926 from gilles-peskine-arm/lcov-cannot-write-investigation
Work around a bug in ancient lcov
2024-03-13 17:52:15 +00:00
Gilles Peskine
539d7d54af Work around a bug in ancient lcov
lcov had a bug whereby it tries to create the output file relative to /
if it has emitted a warning. We do CI runs on Ubuntu 16.04 which is too
old to have the fix. As a quick fix for the CI, work around the bug.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-03-13 17:19:17 +01:00
Dave Rodgman
775c7768ee
Merge pull request #8877 from gilles-peskine-arm/split-minimal-3.6
Create a minimal framework submodule
2024-03-13 14:30:09 +00:00
Bence Szépkúti
0719d7c3d8 Update the MSBuild toolset versions to VS2017
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-03-13 11:23:16 +01:00
Bence Szépkúti
fac1122b85 Rename solution files to referece VS2017
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-03-13 11:23:16 +01:00
David Horstmann
93fa4e1b87 Merge branch 'development' into buffer-sharing-merge 2024-03-12 15:05:06 +00:00
Gilles Peskine
f9bbe0de4c Show guidance if the framework is not found
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-03-04 17:12:59 +01:00
Gilles Peskine
469f7811fa Require framework directory to exist when building
The framework directory will be provided by a submodule.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-29 18:19:56 +01:00
Gilles Peskine
8988767b0e Use attribute accessor functions in driver wrappers
Fully automated:
```
perl -i -pe 's/(\w+)->core\.(\w+)/psa_get_key_$2($1)/g' scripts/data_files/driver_templates/*.jinja docs/psa-driver-example-and-guide.md
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-28 01:29:13 +01:00
Gilles Peskine
092ce51c47 Rename "key generation method" to "key production parameters"
"Key generation method" was misleading since it also applies to key
derivation. Change "key generation" to "key production", which we aren't
using yet and has roughly the right intuition. Change "method" to
"parameters" which there seems to be a slight preference for. Discussion
thread: https://github.com/Mbed-TLS/mbedtls/pull/8815#discussion_r1486524295

Identifiers renamed:
psa_key_generation_method_t → psa_key_production_parameters_t
psa_key_generation_method_s → psa_key_production_parameters_s
PSA_KEY_GENERATION_METHOD_INIT → PSA_KEY_PRODUCTION_PARAMETERS_INIT
method → params
method_data_length → params_data_length
default_method → default_production_parameters
psa_key_generation_method_is_default → psa_key_production_parameters_are_default
setup_key_generation_method → setup_key_production_parameters
key_generation_method_init → key_production_parameters_init

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-20 16:18:13 +01:00
Gilles Peskine
69f11c8dfb generate key ext: skip driver invocation with non-default method
In the driver wrapper for psa_generate_key() and psa_generate_key_ext():

* Invoke the built-in code if using a non-default method, even if there
  might be an accelerator. This is ok because we only support non-default
  methods for RSA and we don't support driver-only RSA, therefore a
  non-default method will always have built-in code behind it.
* Return NOT_SUPPORTED if trying to use a non-default method with an opaque
  driver.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-15 11:57:48 +01:00
Gilles Peskine
c81393b2ed generate/derive key ext: pass method_data_length rather than method_length
Instead of passing the size of the whole structure, just pass the data
length and let the implementation worry about adding the size of the
structure. The intent with passing the structure size was to allow
the client code in a client-server implementation to know nothing
about the structure and just copy the bytes to the server. But that was not
really a useful consideration since the application has to know the
structure layout, so it has to be available in the client implementation's
headers. Passing the method data length makes life simpler for everyone by
not having to worry about possible padding at the end of the structure, and
removes a potential error condition
(method_length < sizeof(psa_key_generation_method_t)).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-15 11:57:48 +01:00
Gilles Peskine
7a18f9645c psa_generate_key_ext: RSA: support custom public exponent
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-15 11:57:46 +01:00
Janos Follath
7a28738205
Merge pull request #8636 from paul-elliott-arm/new_test_thread_interface
New test thread interface
2024-02-08 12:35:40 +00:00
Dave Rodgman
047c724c22 Merge remote-tracking branch 'restricted/development-restricted' into update-development-r
Conflicts:
	programs/Makefile
	tests/scripts/check-generated-files.sh
2024-01-26 12:42:51 +00:00
Valerio Setti
48a847afb7 tests: add guards for DH groups
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-01-17 15:57:06 +01:00
Gilles Peskine
89b50a7cb4 Fix parsing of C line comments
Fix // comments stopping on 'n' instead of newlines. Also allow
backslash-newline in // comments.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-15 19:30:54 +01:00
Gilles Peskine
a1871f318b Add review exception warning
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-15 19:30:28 +01:00
Gilles Peskine
f838eb2259 Guard the macro definition
It doesn't make sense to define a macro expanding to a non-existent function.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-15 19:03:08 +01:00
Gilles Peskine
d022093ea6 C function wrapper generator
The Base class generates trivial wrappers that just call the underlying
function. It is meant as a base class to construct useful wrapper generators.

The Logging class generates wrappers that can log the inputs and outputs to
a function.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-15 19:03:08 +01:00
Gilles Peskine
00ed38c25b Python module to parse function declarations from a header file
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-15 19:03:08 +01:00
Waleed Elmelegy
f37c70746b Add MBEDTLS_SSL_RECORD_SIZE_LIMIT to full config
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-01-10 16:17:28 +00:00