Commit Graph

9740 Commits

Author SHA1 Message Date
Gilles Peskine
8b5bbda156 Merge pull request #4828 from gilles-peskine-arm/generate_errors-multiline-2.16
Backport 2.16: Move MBEDTLS_ERR_xxx Doxygen comments before the definition
2021-08-03 13:46:26 +02:00
Gilles Peskine
3418c24d8c Merge pull request #4830 from spencer-burke/fixing_4222-2.16
2.16 Backport of #4659
2021-08-03 12:53:23 +02:00
Spencer Burke
9fd9ce7b16 Remove the duplicate code in mbedtls/include/mbedtls/check_config.h
Removing the extra preprocessor directives found within the specified
source file.

Signed-off-by: Spencer Burke <info.spencer.burke@gmail.com>
2021-08-03 09:40:33 +02:00
Gilles Peskine
915f258c32 Show warnings if something looks wrong
This makes no difference to the output.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-02 22:59:16 +02:00
Gilles Peskine
000a231e3c Document the big regex
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-02 22:59:16 +02:00
Gilles Peskine
1990fab5a9 Move MBEDTLS_ERR_xxx Doxygen comments before the definition
Now that descriptions of error codes no longer have to be on the same line
for the sake of generate_errors.pl, move them to their own line before the
definition. This aligns them with what we do for other definitions, and
means that we no longer need to have very long lines containing both the C
definition and the comment.

```
perl -i -pe 's~^(#define +MBEDTLS_ERR_\w+ +-\w+) */\*[*!]<(.*)\*/~/**$2*/\n$1~' include/mbedtls/*.h
```

This commit does not change the output of generate_errors.pl.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-02 22:59:16 +02:00
Gilles Peskine
63518ead7c Better support multiline comments for MBEDTLS_ERR_xxx
They were recognized by a prior commit. In this commit, replace line
breaks (with optional comment continuation marker) by spaces.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-02 22:58:39 +02:00
Gilles Peskine
2638a62f1c More flexible parsing of Doxygen comments for MBEDTLS_ERR_xxx
Before this commit, definitions of error codes must match a strict pattern,
with a Doxygen comment following the definition on the same line and
starting with "/**<". Change how generate_errors.pl so that the Doxygen
comment can be before the definition instead of after, and doesn't have to
be on the same line.

Also allow spaces between "#" and "define", and allow Doxygen comments to
start with "/*!" rather than "/**". Starting with "///" or "//!" is not
supported.

This commit does not change the output of generate_errors.pl.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-02 22:58:39 +02:00
Gilles Peskine
7b89d9faa4 Remove reference to compat-1.2.h
This has been irrelevant since Mbed TLS 2.0.0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-02 22:58:39 +02:00
Manuel Pégourié-Gonnard
1689ba41ac Merge pull request #4804 from gilles-peskine-arm/save-coverage-summary-2.16
Backport 2.16: Save the basic-build-test.sh test report summary to coverage-summary.txt
2021-07-29 10:52:52 +02:00
Manuel Pégourié-Gonnard
4576c8b18b Merge pull request #4798 from gilles-peskine-arm/make-test-python-windows-2.16
Backport 2.16: Fix python in tests/Makefile, etc.
2021-07-29 09:58:36 +02:00
Ronald Cron
ae466e78f4 Merge pull request #4787 from gilles-peskine-arm/fix-clang12-Wstring-concatenation-2.16
Backport 2.16: Prevent triggering Clang 12 -Wstring-concatenation warning
2021-07-23 14:07:58 +02:00
Gilles Peskine
31bf22c06a Fix mixup about the directory containing the success indicator file
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 20:00:18 +02:00
Gilles Peskine
a6b4582add More robust failure detection for the coverage report generation
The previous implementation was hard to understand and could in principle
fail to notice if there was a test case failure and the writing of the
line "Note: $TOTAL_FAIL failures." failed. KISS.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 20:00:18 +02:00
Gilles Peskine
3a8d854d73 Explain the final error checking
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 20:00:18 +02:00
Gilles Peskine
d9437e6863 Save the coverage report to a file
Save the "Test Report Summary" to a file. This can help both CI scripts and
human readers who want the summary after the fact without having to copy the
console output.

Take care to exit with a nonzero status if there is a failure while
generating the test report summary.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 20:00:18 +02:00
Gilles Peskine
499abc90f8 Show the udp_proxy seed in the console log
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 20:00:18 +02:00
Gilles Peskine
bd7222d526 Only run an unbridled parallel make (make -j) if MAKEFLAGS is unset
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 20:00:13 +02:00
Gilles Peskine
78c8e828e8 Add a few echo statements to make the logs easier to follow
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-22 19:58:14 +02:00
Gilles Peskine
e739fbb6c4 Merge pull request #4778 from yutotakano/fix-reserved-identifier-clash-2.16
Backport 2.16: Replace reserved identifier clashes with suitable replacements
2021-07-22 16:21:02 +02:00
Gilles Peskine
c221e5360c Fix typo in test dependencies
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-21 19:30:22 +02:00
Gilles Peskine
cf3c4497ed Use python3 when building on non-Windows for Windows
The makefiles look for python3 on Unix-like systems where python is often
Python 2. This uses sh code so it doesn't work on Windows. On Windows, the
makefiles just assume that python is Python 3.

The code was incorrectly deciding not to try python3 based on WINDOWS_BUILD,
which indicates that the build is *for* Windows. Switch to checking WINDOWS,
which indicates that the build is *on* Windows.

Fix #4774

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-21 19:30:13 +02:00
Guido Vranken
70bdf8d1df Use single-line string literals.
Signed-off-by: Guido Vranken <guidovranken@gmail.com>
2021-07-18 16:16:44 +02:00
Guido Vranken
4a78d58f25 Prevent triggering Clang 12 -Wstring-concatenation warning
Wrap multi-line string literals in parentheses
to prevent a Clang 12 -Wstring-concatenation warning
(activated by -Wall), which caused the build to fail.

Fixes https://github.com/ARMmbed/mbedtls/issues/3586

Signed-off-by: Guido Vranken <guidovranken@gmail.com>
2021-07-18 16:16:43 +02:00
Yuto Takano
2f7f574cfa Add ChangeLog entry for reserved identifier replacments
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
2021-07-14 15:04:20 +01:00
Yuto Takano
1cded872a8 Replace _RR with prec_RR to prevent reserved identifier clashes
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
2021-07-14 15:04:11 +01:00
Yuto Takano
d7cd60fba0 Replace _B with B to prevent reserved identifier clashes
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
2021-07-14 15:03:09 +01:00
Gilles Peskine
2847f879aa Merge pull request #4763 from mpg/fix-overly-aggressive-udp-proxy-2.16
[Backport 2.16] Fix bug with UDP proxy not forwarding enough
2021-07-09 11:57:47 +02:00
Manuel Pégourié-Gonnard
934cff30f6 Fix bug with UDP proxy not forwarding enough
We previously introduced a safety check ensuring that if a datagram had
already been dropped twice, it would no longer be dropped or delayed
after that.

This missed an edge case: if a datagram is dropped once, it can be
delayed any number of times. Since "delay" is not defined in terms of
time (x seconds) but in terms of ordering with respect to other messages
(will be forwarded after the next message is forwarded), depending on
the RNG results this could result in an endless loop where all messages
are delayed until the next, which is itself delayed, etc. and no message
is ever forwarded.

The probability of this happening n times in a row is (1/d)^n, where d
is the value passed as delay=d, so for delay=5 and n=5 it's around 0.03%
which seems small but we still happened on such an occurrence in real
life:

    tests/ssl-opt.sh --seed 1625061502 -f 'DTLS proxy: 3d, min handshake, resumption$'

results (according to debug statements added for the investigation) in
the ClientHello of the second handshake being dropped once then delayed
5 times, after which the client stops re-trying and the test fails for
no interesting reason.

Make sure this doesn't happen again by putting a cap on the number of
times we fail to forward a given datagram immediately.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-07-08 12:47:57 +02:00
Dave Rodgman
a3dbb383a3 Merge pull request #848 from ARMmbed/mbedtls-2.16.11_merge_into_release
Mbedtls 2.16.11 merge into release
2021-07-07 11:18:05 +01:00
Dave Rodgman
aa1d4e0973 Merge pull request #845 from ARMmbed/mbedtls-2.16.11rc0-pr
Mbedtls 2.16.11rc0 pr
mbedtls-2.16.11 v2.16.11
2021-07-06 12:59:45 +01:00
Bence Szépkúti
571f475788 Set version and release date in ChangeLog
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2021-07-05 19:48:18 +02:00
Dave Rodgman
8005aa2adf Fix indentation in the Changelog
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-07-05 19:40:48 +02:00
Bence Szépkúti
124a87ea6f Bump library version numbers
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2021-07-05 18:47:36 +02:00
Bence Szépkúti
53b960d9e0 Create aggregated ChangeLog
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2021-07-05 16:17:07 +01:00
Bence Szépkúti
726a8ccb6d Merge branch 'mbedtls-2.16-restricted' into mbedtls-2.16.11rc0-pr 2021-07-02 14:00:19 +01:00
Dave Rodgman
4c20c774a1 Merge pull request #4735 from daverodgman/alert_bugfixes_2.16
Backport 2.16: Fix alert raised for invalid fragment length
2021-06-30 09:02:45 +01:00
Dave Rodgman
cee9e92255 Correct required config flag in ECJPAKE tests
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-06-29 21:15:28 +01:00
Gilles Peskine
90e6c24cf9 Merge pull request #4719 from nick-child-ibm/2.16-hashlen
Backport 2.16: pk.c: Ensure min hash_len in pk_hashlen_helper
2021-06-29 18:16:55 +02:00
Dave Rodgman
ffbbeee284 TLS UNSUPPORTED_EXTENSION error code changes
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-06-29 15:19:26 +01:00
Nick Child
c15e31d355 pk.c: Ensure min hash_len in pk_hashlen_helper
The function `pk_hashlen_helper` exists to ensure a valid hash_len is
used in pk_verify and pk_sign functions. This function has been
used to adjust to the corrsponding hash_len if the user passes in 0
for the hash_len argument based on the md algorithm given. If the user
does not pass in 0 as the hash_len, then it is not adjusted. This is
problematic if the user gives a hash_len and hash buffer that is less than the
associated length of the md algorithm. This error would go unchecked
and eventually lead to buffer overread when given to specific pk_sign/verify
functions, since they both ignore the hash_len argument if md_alg is not
MBEDTLS_MD_NONE.

This commit, adds a conditional to `pk_hashlen_helper` so that an
error is thrown if the user specifies a hash_length (not 0) and it is
less than the expected for the associated message digest algorithm.
This aligns better with the api documentation where it states "If
hash_len is 0, then the length associated with md_alg is used instead,
or an error returned if it is invalid"

Signed-off-by: Nick Child <nick.child@ibm.com>
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
2021-06-29 09:44:04 -04:00
Dave Rodgman
84fa2c941a Improve Changelog for TLS alert codes
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-06-29 14:41:55 +01:00
Dave Rodgman
459a46102d Fix TLS alert codes
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-06-29 09:44:35 +01:00
Gilles Peskine
f8ed50c74a Merge pull request #841 from yanesca/reject-low-order-points-early-x25519-restricted-2.16
[Backport 2.16] Reject low order points early x25519
2021-06-28 13:45:54 +02:00
Janos Follath
1001d2c711 Fix unused parameter warning
Signed-off-by: Janos Follath <janos.follath@arm.com>
2021-06-28 10:24:20 +01:00
Janos Follath
7a8a0d7e3d Add ChangeLog entry
Signed-off-by: Janos Follath <janos.follath@arm.com>
2021-06-28 10:24:20 +01:00
Janos Follath
9a64d3e0ca Add prefix to BYTES_TO_T_UINT_*
These macros were moved into a header and now check-names.sh is failing.
Add an MBEDTLS_ prefix to the macro names to make it pass.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2021-06-28 10:24:20 +01:00
Janos Follath
84ef97a450 Fix ecp_check_pub() test cases
Negative x coordinate was tested with the value -1. It happens to be one
of the low order points both for Curve25519 and Curve448 and might be
rejected because of that and not because it is negative. Make sure that
x < 0 is the only plausible reason for the point to be rejected.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2021-06-28 10:24:20 +01:00
Janos Follath
921415b0c2 Add ecp_check_pub tests for Curve 448
Signed-off-by: Janos Follath <janos.follath@arm.com>
2021-06-28 10:24:20 +01:00
Janos Follath
5f9b667396 Reject low-order points on Curve448 early
We were already rejecting them at the end, due to the fact that with the
usual (x, z) formulas they lead to the result (0, 0) so when we want to
normalize at the end, trying to compute the modular inverse of z will
give an error.

If we wanted to support those points, we'd a special case in
ecp_normalize_mxz(). But it's actually permitted by all sources (RFC
7748 say we MAY reject 0 as a result) and recommended by some to reject
those points (either to ensure contributory behaviour, or to protect
against timing attack when the underlying field arithmetic is not
constant-time).

Since our field arithmetic is indeed not constant-time, let's reject
those points before they get mixed with sensitive data (in
ecp_mul_mxz()), in order to avoid exploitable leaks caused by the
special cases they would trigger. (See the "May the Fourth" paper
https://eprint.iacr.org/2017/806.pdf)

Signed-off-by: Janos Follath <janos.follath@arm.com>
2021-06-28 10:24:20 +01:00