1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-04-20 12:07:51 +03:00

892 Commits

Author SHA1 Message Date
Gilles Peskine
ae59c52322 Create configuration option to bypass the mbedtls_ssl_set_hostname check
Update generated files.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-24 18:04:14 +01:00
Manuel Pégourié-Gonnard
a674e988c9 Drop building with armcc5 in all.sh
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-29 11:52:49 +01:00
Gilles Peskine
744741bf2c Adjust generate_config_tests.py for 2.28
* Move to the correct location.
* Adjust the package name for auxiliary modules.
* Adjust the hack to import a module from scripts.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:05:10 +02:00
Gilles Peskine
1afb70351e Terminology: use "dependencies" for a list of settings
"Super settings" were effectively the dependencies of a setting, so align on
that terminology.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:03:37 +02:00
Gilles Peskine
5454a84772 Terminology: consistently use "setting", not "option"
The two were used interchangeably. Align on "setting", which is what
config.py uses in its documentation.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:03:32 +02:00
Gilles Peskine
f75c70bb81 Explain why we require TLS client and server simultaneously
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:03:27 +02:00
Gilles Peskine
c08d5bfda7 Fix missing negation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:03:23 +02:00
Gilles Peskine
556249e134 Pacify mypy
I had accidentally reused a variable name inside the same function. Python
copes but mypy doesn't.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:03:18 +02:00
Gilles Peskine
c79ecea42b Detect sub-options
When option A is only meaningful if option B is enabled, when enumerating
single-option test cases, emit A:B and !A:B rather than A and !A. This way
the "!A" case is actually meaningful.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:03:11 +02:00
Gilles Peskine
693611e532 Generate config test cases for single options
Generate option-on and option-off cases for test_suite_config, for all
boolean options (MBEDTLS_xxx and PSA_WANT_xxx, collected from the mbedtls
and PSA config files).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:02:49 +02:00
Gilles Peskine
41ad6601eb Recognize that a double-inclusion guard is not a config setting
Fix PSA_CRYPTO_CONFIG_H being treated as a configuration setting in
include/psa/crypto_config.h.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 19:49:46 +02:00
Gilles Peskine
9ffffab4d6 Fix edge case with half-supported ECDSA
ECDSA has two variants: deterministic (PSA_ALG_DETERMINISTIC_ECDSA) and
randomized (PSA_ALG_ECDSA). The two variants are different for signature but
identical for verification. Mbed TLS accepts either variant as the algorithm
parameter for verification even when only the other variant is supported,
so we need to handle this as a special case when generating not-supported
test cases.

In this commit:

* Automatically generated not-supported test cases for ECDSA now require
  both variants to be disabled.
* Add manually written not-supported test cases for the signature
  operation when exactly one variant is supported.
* Add manually written positive test cases for the verification
  operation when exactly one variant is supported.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-19 19:33:29 +02:00
Gilles Peskine
0311b211e4 Explain why DH and DSA are still explicitly excluded
If we don't exclude them from test case enumeration, then
detect_not_implemented_dependencies would cause the generated test cases to
be commented out, but the test case generation would fail before that
because asymmetric_key_data.py doesn't include DH and DSA keys.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:55 +02:00
Gilles Peskine
b8ddf6acd4 PSA test case generation: comment out always-skipped test cases
When we generate a test case for a mechanism that is not implemented,
comment out the test case rather than giving it a never-fulfilled
dependency. That way we don't create test cases that cannot be executed.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:55 +02:00
Gilles Peskine
696b7eef7b TestCase: add mechanism to skip a test case
Allow "skipping" a test case, meaning that the test case is generated
commented out. This is useful when systematically generating test cases
according to certain rules, where some generated tests cannot be executed
but we still want them to be visible when auditing the generation output.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:55 +02:00
Gilles Peskine
519762b7e6 Clean up not-implemented detection
Move hack_dependencies_not_implemented into a class to make the file
structure easier to understand and reduce the visibility of the
_implemented_dependencies cache. Rename it because it's no longer a
temporary hack (originally intended to work around the fact that not all
PSA_WANT symbols were implemented), it's now a way to detect test cases for
cryptographic mechanisms that are declared but not implemented.

Internal refactoring only. No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:55 +02:00
Gilles Peskine
995d7d4c15 Do run not-supported test cases on not-implemented mechanisms
In automatically generated PSA test cases, we detect cryptographic
mechanisms that are not implemented, and skip the corresponding test cases.
Originally this detection was intended for mechanisms for which the PSA_WANT
symbols were not implemented, but then it morphed into skipping mechanisms
that are declared in crypto_values.h but not actually implemented. So it no
longer makes sense to skip the test cases for which a negative
dependency (!PSA_WANT_xxx) is not implemented.

This causes more not-supported test cases to run.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:55 +02:00
Gilles Peskine
764c2d3013 PSA test case generation: dependency inference class: operation fail
Use psa_information.TestCase for operation failure test cases.

This changes the generated output in two ways:

* Not-implemented mechanisms now have a `DEPENDENCY_NOT_IMPLEMENTED_YET_xxx`
  dependency in addition to the never-fulfilled `PSA_WANT_xxx` dependency.
  This does not affect when test cases run.
* ECC test cases now have correct dependency symbols, e.g.
  `PSA_WANT_ECC_SECP_R1_192` instead of `PSA_WANT_ECC_FAMILY_SECP_R1`. This
  is a bug fix: ECC test cases were formerly never executed because of
  incorrect dependency symbols.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:54 +02:00
Gilles Peskine
1ae57ec203 PSA test case generation: dependency inference class: key not supported
Use psa_information.TestCase for not-supported test cases for key import and
generation.

No change to the generated output.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:54 +02:00
Gilles Peskine
d3286af1b7 hack_dependencies_not_implemented: apply to positive test cases
In automatically generated PSA test cases, annotate the test cases that are
expected to be never executed due to a dependency that is not implemented.
This was already done for not-supported test cases and for key generation,
but not for positive test cases of key usage.

You can audit which mechanisms are detected as not-implemented with
```
grep -hEo 'DEPENDENCY_NOT_IMPLEMENTED_YET_\w+' tests/suites/*.data | sort -u
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:54 +02:00
Gilles Peskine
c113b42fc1 hack_dependencies_not_implemented: Also read inferred PSA_WANT symbols
To determine PSA mechanisms that are not implemented, also read PSA_WANT
symbols that cannot (or are not intended to) be configured independently,
and thus are not listed in psa/crypto_config.h. Find those symbols in
the config adjustment header mbedtls/config_psa.h.

No impact on generated files yet, because hack_dependencies_not_implemented
is currently only used on key types that have explicit dependencies. This
will allow using hack_dependencies_not_implemented in other places, for
example to handle algorithm variants like PSA_WANT_ALG_ECDSA_ANY which is
inferred from PSA_WANT_ALG_ECDSA.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:54 +02:00
Gilles Peskine
c7b58d53fc PSA test case generation: dependency inference class: base case
Create a class for test cases with automatically inferred dependencies,
suitable for PSA crypto API test cases. As of this commit, only basic cases
that use a key are supported. Subsequent commits will address negative tests
and key generation tests that require fancier handling of dependencies.

No change to the generated output.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:54 +02:00
Gilles Peskine
c3b261a4fc Sort dependencies in automatically generated PSA test cases
The output is less nice, since it no longer mostly matches the order in
which symbols are used in the test case arguments. But this makes the output
more canonical, so it will be easier to notice if semantic changes occur in
subsequent commits.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:54 +02:00
Gilles Peskine
c6fe12a155 hack_dependencies_not_implemented: more verbose indication
Indicate which dependencies are not implemented. This makes it feasible to
audit the not-implemented detection.

The generated test cases that are detected as never-executed now have one or
more `DEPENDENCY_NOT_IMPLEMENTED_YET_PSA_WANT_xxx` instead of a single
`DEPENDENCY_NOT_IMPLEMENTED`. This does not affect when the test cases run.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:54 +02:00
Minos Galanakis
d4b3fe7597 Merge branch 'mbedtls-2.28' into 'mbedtls-2.28-restricted' 2024-03-20 09:27:24 +00:00
David Horstmann
a7cb1d0fc9 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:54:42 +00:00
David Horstmann
c34fa81ea9 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 11:18:22 +00:00
Gilles Peskine
40895498b7
Merge pull request #8851 from billatarm/mbedtls-2.28-add-pc-files
Mbedtls 2.28 add pc files
2024-03-12 11:30:30 +00:00
David Horstmann
f06494dc9e Merge branch 'mbedtls-2.28' into buffer-sharing-merge-2.28 2024-03-11 16:28:50 +00:00
Dave Rodgman
e264a7dcd1 Fix generate_visualc_files.pl
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2024-02-29 21:22:59 +00:00
Bill Roberts
a4486ceff2
scripts/bump_version.sh: update pkgconfig version
Bump the version number in pkgconfig/CMakeLists.txt so the package
config files stay in sync with the project VERSION.

This is Related to:
- aa4862a5e ("Bump the version number in CMakeLists.txt")

But changes were made to support CMake prior to version 3.0.

Signed-off-by: Bill Roberts <bill.roberts@arm.com>
2024-02-23 09:09:17 -06:00
Dave Rodgman
9d52c713b2 Merge remote-tracking branch 'restricted/mbedtls-2.28' into mbedtls-2.28-restricted 2024-01-26 10:27:26 +00:00
Gilles Peskine
64dcb78e42 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-09 09:53:54 +01:00
Gilles Peskine
92b90b848a 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-09 09:53:54 +01:00
Gilles Peskine
f81f191770 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-08 21:06:47 +01:00
Gilles Peskine
7c7b7d5db3 Add review exception warning
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-04 17:28:59 +01:00
Gilles Peskine
17a14f1711 Adapt wrapper generators from 3.5 to 2.28
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-04 16:41:30 +01:00
Gilles Peskine
61a852216e 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-04 14:41:10 +01:00
Gilles Peskine
15d32bb60f 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-04 14:39:40 +01:00
Gilles Peskine
cedb112359 Python module to parse function declarations from a header file
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-01-04 14:39:34 +01:00
Dave Rodgman
b9c70581a0
Merge pull request #8222 from tgonzalezorlandoarm/tg/backport-psa-low-hash-mac-size
Backport 2.28: Start testing the PSA built-in drivers: hashes
2023-11-21 15:39:36 +00:00
Gilles Peskine
feb98ccada
Merge pull request #8497 from ronald-cron-arm/remove-cocci-files-2.28
[Backport 2.28] Remove unused *.cocci files
2023-11-20 14:07:36 +00:00
Gilles Peskine
2c04f57ffc programs/test/metatest indirectly includes library/common.h
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:50 +01:00
Tomás González
5fae560b4a Update new license headers
Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
2023-11-13 11:45:12 +00:00
Gilles Peskine
bfc1844eb2
Merge pull request #8480 from yuhaoth/backports/7649/add-command-for-server9-bad-saltlen
Backports for #7649 : add command for server9-bad-saltlen
2023-11-08 19:04:27 +01:00
Ronald Cron
eb8f498ef1 Remove unused *.cocci files
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2023-11-08 10:13:35 +01:00
Paul Elliott
8243ebf6b3
Merge pull request #8477 from paul-elliott-arm/full_no_platform_2_28
[Backport 2.28] Add build preset full_no_platform
2023-11-06 11:35:12 +00:00
Jerry Yu
0c835dbae3 move script to tests/scripts
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-11-06 10:06:03 +08:00
Jerry Yu
521ae846bc improve document
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-11-06 10:06:03 +08:00
Jerry Yu
60313c1e62 move asn1crypto to ci.requirements.txt
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-11-06 10:06:01 +08:00