1634 Commits

Author SHA1 Message Date
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
Manuel Pégourié-Gonnard
454ab28be5
Merge pull request #8668 from gilles-peskine-arm/asymmetric_key_data-secpr1
Fix incorrect test data for SECP_R1 in automatically generated tests
2024-01-09 09:21:14 +00:00
Paul Elliott
7ed1cf57ba Enable common.make to be included by programs/fuzz
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-01-05 21:04:59 +00:00
Gilles Peskine
68b5182dad Add test data for secp192r1
Same generation methodology as 0cbaf056fadf60228b32245aeba893959be31ede:

```
openssl genpkey -algorithm ec -pkeyopt ec_paramgen_curve:P-192 -text |perl -0777 -pe 's/.*\npriv:([\n 0-9a-f:]*)pub:([\n 0-9a-f:]*).*/"$1","$2"/s or die; y/\n ://d; s/,/,\n              /;'
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-03 20:57:52 +01:00
Gilles Peskine
478dd84b63 Fix mixup between secp224r1 and secp224k1 in test scripts
secp224k1 is the one with 225-bit private keys.

The consequences of this mistake were:

* We emitted positive test cases for hypothetical SECP_R1_225 and
  SECP_K1_224 curves, which were never executed.
* We emitted useless not-supported test cases for SECP_R1_225 and SECP_K1_224.
* We were missing positive test cases for SECP_R1_224 in automatically
  generated tests.
* We were missing not-supported test cases for SECP_R1_224 and SECP_K1_225.

Thus this didn't cause test failures, but it caused missing test coverage
and some never-executed test cases.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-03 20:50:56 +01:00
Gilles Peskine
0ae58dd985 Unify MBEDTLS_TEST_OBJS
`$(MBEDTLS_TEST_OBJS)` included TLS-specific test support modules in
`tests/Makefile` but not in `programs/Makefile`. This difference is not
actually necessary. What is necessary is that all programs that use
functions from TLS-specific test support modules are linked with those
modules in addition to `-lmbedtls`, and programs that are not linked with
`-lmbedtls` are not linked with TLS-specific test support modules. Since we
always pass `-lmbedtls` when linking programs in `programs/Makefile`, we can
link with the TLS-specific test support modules as well. This keeps things
simpler.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-02 23:11:24 +01:00
Gilles Peskine
cd06a813c6 Fix name in documentation
fixup "Correct name and documentation of preprocessor symbol check function"

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-02 18:14:40 +01:00
Gilles Peskine
570e54822c Finish unifying LOCAL_CFLAGS
fixup "Create common.make with LOCAL_CFLAGS and friends"

The code wasn't what I had intended, although it was functionally
equivalent. Make it more readable and more robust.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-02 18:11:10 +01:00
Gilles Peskine
f3316f132b Correct name and documentation of preprocessor symbol check function
It's not remove_unset_options, it's remove_enabled_options (or
keep_disabled_options).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-12-22 18:30:37 +01:00
Gilles Peskine
2337a3b886 Explain the use of control
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-12-22 14:16:21 +01:00