Commit Graph

2965 Commits

Author SHA1 Message Date
Paul Elliott
88ba5b5fa5 Simplify Input usage macros
Also ensure they are used in test data rather than values

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-12-10 18:08:31 +00:00
Paul Elliott
fe35e84692 Rename (and relabel) pkcs12 test case
Remove surplus _test suffix. Change labeling from Pcks12 to PCKS#12 as
it should be.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-12-10 18:08:31 +00:00
Paul Elliott
2ed0537424 Remove incorrect test dependency
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-12-10 18:08:31 +00:00
Paul Elliott
c7b320547f Stop CMake out of source tests running on 16.04
Running the out of source CMake test on Ubuntu 16.04 using more than one
processor (as the CI does) can create a race condition whereby the build
fails to see a generated file, despite that file actually having been
generated. This problem appears to go away with 18.04 or newer, so make
the out of source tests not supported on Ubuntu 16.04

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-12-10 18:08:31 +00:00
Paul Elliott
159c8f8e7e Fix missing test dependancies
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-12-10 18:08:31 +00:00
Paul Elliott
faba220672 Add PKCS12 tests
Only regression tests for the empty password bugs for now. Further tests
will follow later.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-12-10 18:08:31 +00:00
Gilles Peskine
a0b0dcea7d Don't fail until everything is initialized
Can't call mbedtls_cipher_free(&invalid_ctx) in cleanup if
mbedtls_cipher_init(&invalid_ctx) hasn't been called.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-10 15:21:58 +01:00
Paul Elliott
4eadb02bf9 Add checked return to cipher setup
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-12-09 21:38:48 +00:00
Manuel Pégourié-Gonnard
d895668359 Merge pull request #5088 from gilles-peskine-arm/test_ssl_o2-2.16
Backport 2.16: Build with -O2 when running ssl-opt
2021-10-29 09:25:37 +02:00
paul-elliott-arm
27fc78690c Merge pull request #5098 from gilles-peskine-arm/ssl-opt-resend-retry-2.16
Backport 2.16: Retry a test case if it fails due to an unexpected resend
2021-10-27 16:24:05 +01:00
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
3712501465 Move is-it-resend logic into a function
Improve the code structure in case we want to add other similar conditions
later. Document better what we're doing, and document why we're doing it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-21 11:25:40 +02:00
Gilles Peskine
838902547c Retry if a test case fails because of an unexpected resend
Palliative for https://github.com/ARMmbed/mbedtls/issues/3377. If a test
case fails due to an unexpected resend, allow retrying, like in the case of
a client timeout.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-21 11:25:40 +02:00
Gilles Peskine
e31a9ea601 Move retry logic into check_test_failure
This will allow having other retry conditions, in particular based on
run_test options.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-21 11:25:40 +02:00
Gilles Peskine
ad58e92eac Move the core loop of run_test into an auxiliary function
No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-21 11:25:40 +02:00
Gilles Peskine
342147a8a8 Move some code of run_test into auxiliary functions
No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-21 11:25:40 +02:00
Gilles Peskine
87b036f572 Add trivial record_outcome function to facilitate backports
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-21 11:25:40 +02:00
Gilles Peskine
30b8132ca9 Remove redundant "should we skip?" block
There's a second one just below.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-21 11:25:40 +02:00
Gilles Peskine
77624b2bd8 Always set a build type for cmake when building for testing
Set the build type to Release (-O2) when running CPU-intensive tests (ssl-opt,
or unit tests with debug features). A build type of Check (-Os) would be best
when the main objective of the build is to check for build errors or warnings
and there aren't many tests to run; in this commit there are no such test
cases to change. Only use cmake with no build type (which results in not
passing a -O option, and thus missing some GCC warnings) when exercising cmake
features.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-19 21:39:45 +02:00
Gilles Peskine
13236707a2 Fix cmake invocation syntax
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-18 20:28:00 +02:00
Gilles Peskine
858373a26e Switch cmake -O2 builds around to where we test a lot
Use Release mode (-O2) for component_test_full_cmake_clang which runs SSL
tests.

To have some coverage with Check mode (which enables more compiler warnings
but compiles with -Os), change a few other builds that only run unit tests
at most to Check mode.

Don't add any new builds, to keep the total build volume down. We don't need
extensive coverage of all combinations, just a reasonable set.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-18 20:27:05 +02:00
Gilles Peskine
3638a962bc Clarify a comment
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-18 20:24:41 +02:00
Gilles Peskine
2ae243139d Correct support function name
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-18 20:24:38 +02:00
Gilles Peskine
c1317759f2 Build with -O2 when running ssl-opt
SSL testing benefits from faster executables, so use -O2 rather than -O1.
Some builds use -O1, but that's intended for jobs that only run unit tests,
where the build takes longer than the tests.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-18 20:24:35 +02: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
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
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
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
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
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
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
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
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
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
Yuto Takano
c75df63718 Add content length constraint to tests that use max_frag_len
Includes:
- DTLS fragmenting tests
- SSLv3 with extensions test (backport only)

Signed-off-by: Yuto Takano <yuto.takano@arm.com>
2021-07-12 09:18:01 +01:00
Yuto Takano
bc632c23f0 Move repetitive equality check to requires_config_value_equals
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
2021-07-12 09:18:01 +01:00