1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-05-20 16:13:50 +03:00

17370 Commits

Author SHA1 Message Date
Gilles Peskine
160df1d136
Merge pull request #6908 from Mbed-TLS/features/new-code-style/mbedtls-2.28
Switch to new code style: mbedtls-2.28
2023-01-11 19:26:59 +01:00
Gilles Peskine
b9e56fb560 Switch code style check to enforcement mode
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-11 14:52:38 +01:00
Gilles Peskine
ec03b0431d Update generated files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-11 14:52:37 +01:00
Gilles Peskine
1b6c09a62e Switch to the new code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-11 14:52:35 +01:00
Gilles Peskine
480f683d15
Merge pull request #6906 from gilles-peskine-arm/code-style-casts-psa-headers-more-2.28
Backport 2.28: Remove redundant error code definitions
2023-01-11 14:40:38 +01:00
Gilles Peskine
f8d190d23f
Merge pull request #6901 from gilles-peskine-arm/check-files-unicode-2.28
Backport 2.28: Reject bad characters in source code
2023-01-11 13:47:08 +01:00
Gilles Peskine
dc633d9393 Remove redundant error code definitions
We're including psa/crypto_values.h, which defines the necessary error
codes. Remove redundant definitions, which hurt because they need to be
styled in exactly the same way (same presence/absence of spaces between
tokens).

This completes the fix of https://github.com/Mbed-TLS/mbedtls/issues/6875.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-11 11:33:11 +01:00
Gilles Peskine
b60b7a33c0 Reject invalid UTF-8 and weird characters in text files
Reject "weird" characters in text files, especially control characters that
might be escape sequences or that might cause other text to appear garbled
(as in https://trojansource.codes/).

Also reject byte sequences that aren't valid UTF-8.

Accept only ASCII (except most control characters), letters, some non-ASCII
punctuation and some mathematical and technical symbols. This covers
everything that's currently present in Mbed TLS ( §áèéëñóöüłŽ–—’“”…≥).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-10 22:13:27 +01:00
Gilles Peskine
ff723d8649 Pass line number to issue_with_line
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-10 22:13:27 +01:00
Gilles Peskine
66548d1fa7 Treat more *.bin files as binary
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-10 22:13:27 +01:00
Gilles Peskine
19374d08d3
Merge pull request #6896 from mpg/unify-openssl-variables-2.28
[Backport 2.28] Use OPENSSL everywhere, not OPENSSL_CMD
2023-01-10 22:10:21 +01:00
Gilles Peskine
0aba751326
Merge pull request #6894 from tom-daubney-arm/modify_generate_errors_script_2-28
Backport 2.28: Make generate_errors.pl handle directory names containing spaces when opening files
2023-01-10 22:09:44 +01:00
Gilles Peskine
83fc93e154
Merge pull request #6897 from gilles-peskine-arm/code-style-casts-psa-headers-2.28
Backport 2.28: Don't restyle some PSA macros
2023-01-10 22:09:10 +01:00
Gilles Peskine
19d078d601
Merge pull request #6889 from daverodgman/fix-iar-warning-bignum-backport
Backport 2.28: Fix iar warning bignum backport
2023-01-10 22:08:34 +01:00
Dave Rodgman
b3aefa3983 Add Changelog
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-01-10 10:08:53 +00:00
Thomas Daubney
b462005958 Add ChangeLog entry
Add ChangeLog entry documenting bugfix.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-01-10 09:37:43 +00:00
Manuel Pégourié-Gonnard
89d4027d6c Use OPENSSL everywhere, not OPENSSL_CMD
These variables were both uses to select the default version of OpenSSL
to use for tests:
- when running compat.sh or ssl-opt.sh directly, OPENSSL_CMD was used;
- when running all.sh, OPENSSL was used.

This caused surprising situations if you had one but not the other set
in your environment. For example I used to have OPENSSL_CMD set but not
OPENSSL, so ssl-opt.sh was failing in some all.sh components but passing
when I ran it manually in the same configuration and build, a rather
unpleasant experience.

The natural name would be OPENSSL, and that's what set in the Docker
images used by the CI. However back in the 1.3.x days, that name was
already used in library/Makefile, so it was preferable to pick a
different one, hence OPENSSL_CMD. However the build system has not been
using this name since at least Mbed TLS 2.0.0, so it's now free for use
again (as demonstrated by the fact that it's been set in the CI without
causing any trouble).

So, unify things and use OPENSSL everywhere. Just leave an error message
for the benefit of developers which might have OPENSSL_CMD, not OPENSSL,
set in their environment from the old days.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-01-10 09:47:09 +01:00
Thomas Daubney
0c6052f041 Modify generate errors script
Modify generate_errors.pl such that it can now handle
opening files where the file path includes a directory
name containing spaces.

Raised in issue #6879. Fix provided by
@tom-cosgrove-arm in aforementioned issue.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2023-01-09 18:48:01 +00:00
Glenn Strauss
b6466c88df Fix IAR warning
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-01-06 11:31:54 +00:00
Manuel Pégourié-Gonnard
ec14c7c268
Merge pull request #6880 from mpg/fix-derive-key-exercise-2.28
[Backport 2.28] Fix test function derive_key_exercise()
2023-01-06 11:50:07 +01:00
Gilles Peskine
7f3659a713 Skip restyling of PSA macros also defined in psa-arch-tests
Some preprocessor macro definitions must have a specific expansion so that
the same macro name can be defined in different products. The definition of
having the same expansion (per the C language specification) means the same
sequence of tokens, and also the same absence/presence of spacing between
tokens.

Two macros are also defined in headers in the PSA Compliance test suite, so
the test suite would fail to build if we changed the definitions. Preserve
those definitions. Technically this is a bug in the test suite, since having
extra spaces (or even a completely different constant expression with the
same value) would still be compliant. Bug reported as
https://github.com/ARM-software/psa-arch-tests/issues/337

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-05 19:23:53 +01:00
Gilles Peskine
d3ce75c5f9 Skip restyling of PSA error code definitions
Some preprocessor macro definitions must have a specific expansion so that
the same macro name can be defined in different products. The definition of
having the same expansion (per the C language specification) means the same
sequence of tokens, and also the same absence/presence of spacing between
tokens.

For PSA error code definitions, the specific expansion is mandated by the
PSA Status code specification and the PSA Crypto API specification. In
particular, there must not be a space between (psa_status_t) and the
numerical value (whereas K&R would put a space).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-05 19:23:51 +01:00
Gilles Peskine
e4627f34da
Merge pull request #6877 from davidhorstmann-arm/2.28-disable-code-style-for-bn-asm
[Backport 2.28] Check for Uncrustify errors in `code_style.py`
2023-01-05 14:35:11 +01:00
David Horstmann
242df48cab Fix pylint warnings about comparison to True
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-05 10:04:21 +00:00
David Horstmann
fa69def8e3 Fix incorrect typing of function in code_style.py
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-05 10:03:48 +00:00
David Horstmann
2ccd77ac83 Don't restyle end of file
Move the *INDENT-ON* annotation to the end of the file so that
uncrustify does not restyle the later sections (since it introduces a
risk of future problems).

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-05 09:53:22 +00:00
Manuel Pégourié-Gonnard
6d08dba4f6 Fix test function derive_key_exercise()
mbedtls_test_psa_setup_key_derivation_wrap() returns 1 for success, 0
for error, so the test here was wrong.

This is just a hotfix in order to avoid a testing gap. Larger issues not
addressed here:

- I don't think we should just exit and mark the test as passed; if
we're not doing the actual testing this should be marked as SKIP.
- Returning 1 for success and 0 for failure is a violation of our
documented coding guidelines. We're also supposed to test with == 0 or
!= 0. Having consistent conventions is supposed to help avoid errors
like this.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2023-01-05 10:53:10 +01:00
David Horstmann
b92d30f987 Check Uncrustify returncode in code_style.py
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-04 18:44:35 +00:00
David Horstmann
d6818e3f94 Disable code style correction for bignum assembly
The inline assembly defined in bn_mul.h confuses code style parsing,
causing code style correction to fail. Disable code style correction for
the whole section gated by "#if defined(MBEDTLS_HAVE_ASM)" to prevent
this.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-04 17:57:00 +00:00
Gilles Peskine
d1a96b6b99
Merge pull request #6869 from davidhorstmann-arm/2.28-workaround-uncrustify-asm-defines
[Backport 2.28] Workaround Uncrustify parsing of "asm"
2023-01-04 10:37:55 +01:00
David Horstmann
b6bf5f5533 Workaround Uncrustify parsing of "asm"
The following code:

 #ifndef asm
 #define asm __asm
 #endif

causes Uncrustify to stop correcting the rest of the file. This may be
due to parsing the "asm" keyword in the definition.

Work around this by wrapping the idiom in an *INDENT-OFF* comment
wherever it appears.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-03 11:27:18 +00:00
Gilles Peskine
a6ad7f4702
Merge pull request #6837 from gilles-peskine-arm/code-style-more-kr-20221222-2.28
Backport 2.28: Tweak code style to be more like K&R
2022-12-23 18:23:24 +01:00
Gilles Peskine
68968f4d66 Require a space after a cast
Align with K&R2.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-22 23:29:42 +01:00
Manuel Pégourié-Gonnard
8ee18d3787
Merge pull request #6798 from gilles-peskine-arm/check_test_cases-quiet_ci-2.28
Hide check_test_cases warnings on the CI
2022-12-21 09:42:59 +01:00
Dave Rodgman
97a85fe110
Merge pull request #6827 from daverodgman/mbedtls-2.28
Backport 2.28 - fix gettimeofday overflow
2022-12-20 16:01:34 +00:00
Dave Rodgman
e5c5b1d3ea Add Changelog entry
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-12-20 13:21:19 +00:00
Dave Rodgman
b03c55892a Fix overflow in mbedtls_timing_hardclock()
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-12-20 13:20:01 +00:00
Manuel Pégourié-Gonnard
71e934f8d1
Merge pull request #6821 from gilles-peskine-arm/code-style-skip-generated-files-2.28
Backport 2.28: Don't touch the style of generated files
2022-12-19 13:06:29 +01:00
Manuel Pégourié-Gonnard
910222bc1b
Merge pull request #6822 from mpg/basic-build-test-lcov-format-robustness-2.28
[Backport 2.28] Fix code_coverage broken by extra echo in make lcov
2022-12-19 13:03:40 +01:00
Gilles Peskine
38a49560de Simplify the coverage statistics summary
The script was parsing the output from `make lcov` to extract numbers and
calculate percentages. But everything including the percentages is already
present in the output of `make lcov`, just with a slightly different
presentation. So replace all this by a simple extraction of the relevant
lines from the output of `make lcov`.

This is more robust than the previous code, which relied on `tail -n4` to
extract relevant lines, which broke when `make lcov` started to emit one
extra line at the end.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-19 10:17:10 +01:00
Gilles Peskine
4ca54d417e Don't touch the style of generated files
Ideally the result of the generator would conform to the code style, but
this would be difficult, especially with respect to the placement of line
breaks in long logical lines. So, to avoid surprises when checking the style
of generated files (which happens in releases and in long-time support
branches), systematically skip generated files.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-19 00:58:25 +01:00
Gilles Peskine
2200f12094
Merge pull request #6807 from mpg/doc-docker-from-ci-2.28
[Backport 2.28] Point to docker images used in the CI
2022-12-17 01:54:27 +01:00
Gilles Peskine
cdae0d3752
Merge pull request #6811 from davidhorstmann-arm/2.28-fix-check-names-enum-regex
[Backport 2.28] Fix an incorrect regex in check_names.py
2022-12-17 01:52:29 +01:00
David Horstmann
e1e776caf7 Fix an incorrect regex in check_names.py
Allow check_names.py to detect declarations of the form:

enum some_enum_name {

This pattern has only just appeared due to code style correction, which
explains why the issue was not previously noticed.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-16 13:49:09 +00:00
Manuel Pégourié-Gonnard
7314798412 Point to docker images used in the CI
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-12-16 10:21:11 +01:00
Gilles Peskine
63c8be6075
Merge pull request #6753 from mpg/restartable-docfix-2.28
[Backport 2.28] Document ECP_RESTARTABLE
2022-12-15 19:47:47 +01:00
Gilles Peskine
adc07aa708
Merge pull request #6696 from gilles-peskine-arm/fuzz-cflags-2.28
Backport 2.28: programs/fuzz: set sensible default CFLAGS
2022-12-15 19:47:28 +01:00
Gilles Peskine
5898796480 Hide check_test_cases warnings on the CI
We aren't paying attention to the warnings. So hide them and save log size.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-15 15:22:13 +01:00
Gilles Peskine
4b3806eb46
Merge pull request #6688 from gilles-peskine-arm/generate_test_code-function_comments-2.28
Backport 2.28: Allow comments in test function prototypes
2022-12-15 12:32:07 +01:00
Manuel Pégourié-Gonnard
4a9fa30211
Merge pull request #6782 from gilles-peskine-arm/lcov-script-2.28
Backport 2.28: lcov script
2022-12-15 12:29:30 +01:00