Commit Graph

9781 Commits

Author SHA1 Message Date
Paul Elliott
46e57d986b Remove bash specific code
Use case pattern matching instead of multiline split, given there is
only the well formatted PIDs to match on this should be safe.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-10-26 11:07:24 +01:00
Paul Elliott
355a1f4bc8 Remove use of -p with lsof
On machines with more modern kernels (>5.4 from testing so far) the
useage of -b seems to conflict with the usage of -p. Whilst the usage of
-b seems like a good idea to avoid blocks as we are tight looping on it,
the usage of -p seems to require the usage of stat() (specifically in
/proc) which -b forbids. All you get is a load of warnings
(suppressable by -w) but never a positive result, which means that all
servers are reported as "Failed to start". We are not keen on losing
-b, so instead parse the output of lsof (using -F to format it) to
check the if PIDs that it outputs match that we are looking for.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-10-26 11:07:13 +01:00
Gilles Peskine
90b10c379f Merge pull request #4847 from mstarzyk-mobica/ecb-alt-ret-2.16
Backport 2.16: Catch failures of mbedtls_aes_crypt_ecb and its DES equivalents
2021-10-14 12:10:58 +02:00
Gilles Peskine
91341c35f9 Merge pull request #5074 from paul-elliott-arm/fix-resumption-openssl-client-tests-2.16
Backport 2.16: Use newer OpenSSL for tests failing with the old
2021-10-13 21:05:09 +02:00
Paul Elliott
0ab794103d Use 127.0.0.1 rather than localhost
This was causing some tests using the openssl s_client to not connect -
I suspect this was due to localhost (at least on my machine) resolving
to ::1 rather than 127.0.0.1. Note that the error seen would have been
that the session file specified with -sess_out did not get created.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-10-13 18:43:54 +01:00
Paul Elliott
316a6aaae4 Fix incorrect check for DTLS
Missing wildcards meant that some servers were not identified as DTLS,
which lead to port checking on TCP rather than UDP, and thus mistakenly
cancelling tests as the server had not come up.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-10-13 18:43:54 +01:00
Paul Elliott
6c64983e32 Spelling fix
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-10-13 18:43:54 +01:00
Manuel Pégourié-Gonnard
a4700756a4 Use newer OpenSSL for tests failing with the old
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-10-13 18:43:50 +01:00
Paul Elliott
19f1f786fc Backport OPENSSL_NEXT to ssl-opt.sh
Add support for a newer version of OpenSSL, as well as a legacy version.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-10-13 18:42:19 +01:00
Gilles Peskine
9e0402b040 Merge pull request #5036 from gilles-peskine-arm/readme-add-contacts-2.16
Backport 2.16: Add contact information directly on the home page
2021-10-06 19:35:37 +02:00
Gilles Peskine
1c9137d8d1 Merge pull request #5034 from gilles-peskine-arm/all.sh-makeflags-nproc-2.16
Backport 2.16: Limit make parallelism to the number of CPUs in all.sh
2021-10-06 19:35:19 +02:00
Gilles Peskine
0bf8f98743 Add contact information directly on the home page
This information was already present in SECURITY.md and SUPPORT.md, but that
wasn't very apparent.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-06 17:52:51 +02:00
Gilles Peskine
bbce37755a Limit make parallelism to the number of CPUs
Don't default to unbridled -j, which causes a load spike and isn't really
faster.

"Number of CPUs" is implemented here as a reasonable compromise between
portability, correctness and simplicity. This is just a default that can be
overridden by setting MAKEFLAGS in the environment.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-06 17:23:24 +02:00
Gilles Peskine
c72255fa37 Fix the build without MBEDTLS_PLATFORM_C
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-01 18:08:41 +02:00
Gilles Peskine
ccfc2bff6f Merge pull request #4958 from gilles-peskine-arm/make-tests-v-2.16
Backport 2.16: Facilitate reproducing unit tests from all.sh
2021-09-30 16:09:01 +02:00
Gilles Peskine
24180accf5 'make test': show failing test cases when cmake does
When building with make, `make test` runs `run-test-suites.pl` which has a
verbose mode that reports the failing test cases, but it didn't provide a
way to enable this verbose mode. With the present commit, you can run `make
test TEST_FLAGS=-v` to use verbose mode.

Base the default for verbose mode on the same environment variable that
`make test` uses when building with CMake: default off, but enabled if
`CTEST_OUTPUT_ON_FAILURE` is true. In particular, verbose mode will now be
on when building from `all.sh`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-09-21 09:41:58 +02:00
Gilles Peskine
c68b9e0839 Merge pull request #4948 from gilles-peskine-arm/muladdc-amd64-memory-2.16
Backport 2.16: Fix x86_64 assembly for bignum multiplication
2021-09-20 22:23:45 +02:00
Gilles Peskine
666e3df80b Update the list of issues fixed
This had actually been reported multiple times.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-09-15 17:04:31 +02:00
Gilles Peskine
7c847235e8 x86_64 MULADDC assembly: add missing constraints about memory
MULADDC_CORE reads from (%%rsi) and writes to (%%rdi). This fragment is
repeated up to 16 times, and %%rsi and %%rdi are s and d on entry
respectively. Hence the complete asm statement reads 16 64-bit words
from memory starting at s, and writes 16 64-bit words starting at d.

Without any declaration of modified memory, Clang 12 and Clang 13 generated
non-working code for mbedtls_mpi_mod_exp. The constraints make the unit
tests pass with Clang 12.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-09-15 15:52:30 +02:00
Gilles Peskine
c7bd734063 Merge pull request #4904 from kennethsoerensen/pkparse-warning_2_16
Backport 2.16: Remove compiler warning if only MBEDTLS_PK_PARSE_C is …
2021-09-01 16:53:54 +02:00
Kenneth Soerensen
806ac52be3 Backport 2.16: Remove compiler warning if only MBEDTLS_PK_PARSE_C is defined
Warning reported with IAR compiler:
"mbedtls\library\pkparse.c",1167  Warning[Pe550]: variable "ret" was set but never used

Signed-off-by: Kenneth Soerensen <knnthsrnsn@gmail.com>
2021-09-01 11:27:17 +02:00
Janos Follath
5e5ca8e3c7 Merge pull request #4893 from davidhorstmann-arm/4044-chglog-take2
Create ChangeLog entry correcting the record on #4044
2021-08-26 16:25:10 +01:00
Janos Follath
f1b0c70faf Merge pull request #4044 from darrenkrahn/mbedtls-2.16
[Backport 2.16] Mark basic constraints critical as appropriate.
2021-08-26 16:23:58 +01:00
David Horstmann
68e5a221ba Create ChangeLog entry explaining #4044
The change made by PR #4044 was previously advertised in the
2.16.10 ChangeLog, however #4044 had not yet been merged.
Create a new entry for #4044, with a note that the previous
entry was in error.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2021-08-24 12:16:28 +01:00
Manuel Pégourié-Gonnard
e115547417 Merge pull request #4874 from mpg/bio_recv_ret_0_eof-2.16
Backport 2.16: Document that returning 0 from the recv callback means EOF
2021-08-17 10:31:08 +02:00
Hanno Becker
0f54b357e4 Document that returning 0 from the recv callback means EOF
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2021-08-16 13:03:24 +02:00
Manuel Pégourié-Gonnard
e8466a7a77 Merge pull request #4856 from mpg/add-arm-linux-build-2.16
Backport 2.16: Add arm-linux-gnueabi-gcc build
2021-08-12 13:16:09 +02:00
Manuel Pégourié-Gonnard
0a1a9e7571 Fix missing dependency on Travis
Was getting errors like:

In file included from /usr/include/limits.h:25:0,
                 from /usr/lib/gcc-cross/arm-linux-gnueabi/5/include-fixed/limits.h:168,
                 from /usr/lib/gcc-cross/arm-linux-gnueabi/5/include-fixed/syslimits.h:7,
                 from /usr/lib/gcc-cross/arm-linux-gnueabi/5/include-fixed/limits.h:34,
                 from ../include/mbedtls/check_config.h:30,
                 from ../include/mbedtls/build_info.h:81,
                 from common.h:26,
                 from asn1write.c:20:
/usr/include/features.h:367:25: fatal error: sys/cdefs.h: No such file or directory

There are two packages to choose from: armhf or armel. Since the comment
in all.sh says we're trying to be close to Debian's "armel"
architecture, choose that, and fix a comment that was mentioning
gnueabihf for no apparent reason.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-08-09 12:24:50 +02:00
Manuel Pégourié-Gonnard
3d04f63dfc Enable arm-linux-gnueabi-gcc build on Travis
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-08-09 12:24:50 +02:00
Manuel Pégourié-Gonnard
9d9445279e Add arm-linux-gnueabi-gcc build to all.sh
Currently it can't be mandatory, since we can't install the required toolchain
on Jenkins right away.

Also, while at it, remove `SHELL='sh -x'` from the other arm5vte component; it
was a leftover from debugging.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-08-09 12:24:48 +02:00
Gilles Peskine
621333f41b Catch failures of AES or DES operations
A DES or AES block operation can fail in alternative implementations of
mbedtls_internal_aes_encrypt() (under MBEDTLS_AES_ENCRYPT_ALT),
mbedtls_internal_aes_decrypt() (under MBEDTLS_AES_DECRYPT_ALT),
mbedtls_des_crypt_ecb() (under MBEDTLS_DES_CRYPT_ECB_ALT),
mbedtls_des3_crypt_ecb() (under MBEDTLS_DES3_CRYPT_ECB_ALT).
A failure can happen if the accelerator peripheral is in a bad state.
Several block modes were not catching the error.

This commit does the following code changes:

* Fix DES and AES API calls which ignored the return values:
    * In library code: on failure, goto exit and return ret.
    * In pkey programs: goto exit.
    * In the benchmark program: exit (not ideal since there's no error
      message, but it's what the code currently does for failures).
    * In test code: TEST_ASSERT.
* Changelog entry.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-08-05 15:31:48 +02:00
Gilles Peskine
f762433785 Merge pull request #4697 from yutotakano/fix-ssl-opt.sh-hard-abort-2.16
Backport 2.16: ssl-opt.sh: Skip tests instead of conditional hard abort
2021-08-04 10:16:24 +02:00
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