Commit Graph

9587 Commits

Author SHA1 Message Date
Gilles Peskine
5f45bd2bab New macros TEST_EQUAL, ASSERT_ALLOC, ASSERT_ALLOC_WEAK
Backports some test helper macros added after 2.16. This will facilitate
backporting new test code.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-31 15:40:31 +02:00
Gilles Peskine
e0b455fb51 Remove spurious dependencies on PEM
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-31 15:23:00 +02:00
Gilles Peskine
7f3f02d230 Merge pull request #4558 from gilles-peskine-arm/aria_alt-2.16
Backport 2.16: Fix ARIA_ALT header and self-test and CAMELLIA_ALT self-test
2021-05-25 20:32:49 +02:00
Gilles Peskine
a776bf8deb Changelog entry for the ARIA_ALT and CAMELLIA_ALT fixes
Fix ARMmbed/mbed-os#14694

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-25 18:45:46 +02:00
Gilles Peskine
39f5dae5b6 CAMELLIA: add missing context init/free
This fixes the self-test with alternative implementations.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-25 18:45:46 +02:00
Gilles Peskine
ba93f598cc ARIA: add missing context init/free
This fixes the self-test with alternative implementations.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-25 18:45:46 +02:00
Gilles Peskine
e0e132f847 Fix misplaced extern "C" affecting MBEDTLS_ARIA_ALT
Reported via Mbed OS:
https://github.com/ARMmbed/mbed-os/issues/14694

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-25 18:45:46 +02:00
Ronald Cron
1bc2c9cb8b Merge pull request #4534 from gilles-peskine-arm/host_test-int32-2.16
Backport 2.16: Fix build error in host_test.function when int32_t is not int
2021-05-21 16:01:50 +02:00
Manuel Pégourié-Gonnard
5ee166b264 Merge pull request #4326 from gilles-peskine-arm/openssl-dhparam-robustness-2.16
Backport 2.16: Fix SSL tests scripts with recent OpenSSL server with Diffie-Hellman
2021-05-21 10:15:54 +02:00
Gilles Peskine
85060d2fad Merge pull request #4498 from netfoundry/gcc11.fixes_2.16
Backport 2.16: build with gcc11
2021-05-20 15:54:17 +02:00
Gilles Peskine
1012b7c696 Merge pull request #4504 from gilles-peskine-arm/ciphersuite-sha384-guard-2.16
Backport 2.16: fix SHA384 guards in TLS
2021-05-19 21:13:10 +02:00
Gilles Peskine
f26d12caa5 Fix dependency for TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384
Fix #4472

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-19 16:54:32 +02:00
Dave Rodgman
8e405103b8 Merge pull request #4540 from daverodgman/padlock-docs-fix-2.16
Fix docs for mbedtls_padlock_has_support: 2.16 backport
2021-05-19 12:12:32 +01:00
Dave Rodgman
2317f7f9a1 Fix docs for mbedtls_padlock_has_support
Fix a slight inaccuracy in the docs for the return value of
mbedtls_padlock_has_support.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-05-19 09:05:33 +01:00
Gilles Peskine
04e12cf81e Fix build error when int32_t is not int
Fix a pointer mismatch when int32_t is not int, for example on Cortex-M where
in32_t is long int. Fix #4530

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-18 16:44:22 +02:00
Ronald Cron
174b18ba4a Merge pull request #4461 from gilles-peskine-arm/generate-tests-python3-make-2.16
Generate tests python3 make 2.16
2021-05-18 13:07:29 +02:00
Gilles Peskine
6c0f91ec00 Merge pull request #4502 from d3zd3z/bp216-posix-define
Backport 2.16: Check if feature macro is defined before define it
2021-05-17 12:10:07 +02:00
David Brown
6e57cb9d5d Add changelog for posix definition
Signed-off-by: David Brown <david.brown@linaro.org>
2021-05-13 11:18:59 -06:00
Flavio Ceolin
9911e4add4 Check if feature macro is defined before define it
Zephyr's native posix port define _POSIX_C_SOURCE with a higher value
during the build, so when mbedTLS defines it with a different value
breaks the build.

As Zephyr is already defining a higher value is guaranteed that mbedTLS
required features will be available. So, just define it in case it was
not defined before.

[taken from Zephyr mbedtls module:
76dcd6eeca]

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Signed-off-by: David Brown <david.brown@linaro.org>
2021-05-13 11:18:59 -06:00
Shawn Carey
69c5f5d81c avoid -Wstringop-overflow when buiding with gcc11
Signed-off-by: Shawn Carey <shawn.carey@netfoundry.io>
2021-05-13 09:16:16 -04:00
Shawn Carey
7b81dcf90f avoid -Wfree-nonheap-object when buiding with gcc11
Signed-off-by: Shawn Carey <shawn.carey@netfoundry.io>
2021-05-13 09:08:02 -04:00
Gilles Peskine
3c546f71c9 Test that generate_test_code.py is still compatible with Python 2
When Mbed TLS 2.16 was released, the requirement was Python 2, not
Python 3. Since then, upstream Python 2 support has stopped, but it is
still maintained in some long-term-support distributions. For the sake
of users who build the unit tests in such environments, test that
generate_test_code.py remains compatible with Python 2.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-12 19:01:31 +02:00
Gilles Peskine
484df7583b Changelog entry for no longer explicitly invoking python2
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-12 19:01:26 +02:00
Gilles Peskine
99705a6813 Use Python 3 instead of Python 2 to generate test files
Python 2 is no longer officially supported, but we were still using it
to generate test suite .c files from .function files when using GNU
make. Switch to looking for Python 3.

CMake currently uses a system-dependent version of the Python language.
This commit does not affect CMake builds.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-12 19:00:31 +02:00
Ronald Cron
f2fa6e54a7 Merge pull request #4487 from gilles-peskine-arm/tniessen-typos-in-header-files-2.16
Backport 2.16: Fix typos in C header files
2021-05-12 18:23:33 +02:00
Tobias Nießen
00a01c90bf Fix typos in C header files
Signed-off-by: Tobias Nießen <tniessen@tnie.de>
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-12 10:39:39 +02:00
Gilles Peskine
5b8f4db757 Merge pull request #4439 from gilles-peskine-arm/aes2crypt-removal-2.16
Backport 2.16: Remove the sample program aescrypt2
2021-04-30 11:15:29 +02:00
Gilles Peskine
23e5f715f1 Merge pull request #4325 from gilles-peskine-arm/dhm_min_bitlen-bits-2.16
Backport 2.16: Enforce dhm_min_bitlen exactly
2021-04-29 14:55:41 +02:00
Gilles Peskine
e2c417d324 Remove the sample program aescrypt2
The sample program aescrypt2 shows bad practice: hand-rolled CBC
implementation, CBC+HMAC for AEAD, hand-rolled iterated SHA-2 for key
stretching, no algorithm agility. The new sample program pbcrypt does
the same thing, but better. So remove aescrypt2.

Fix #1906

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-04-28 17:45:12 +02:00
Ronald Cron
377f4eda27 Merge pull request #4436 from gilles-peskine-arm/error-add-2.16
Backport 2.16: Add macro to check error code additions/combinations
2021-04-28 16:37:16 +02:00
Chris Jones
531aede488 Fix an incorrect error code addition in pk_parse_key_pkcs8_unencrypted_der
An incorrect error code addition was spotted by the new invasive testing
infrastructure whereby pk_get_pk_alg will always return a high level
error or zero and pk_parse_key_pkcs8_unencrypted_der will try to add
another high level error, resulting in a garbage error code.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Signed-off-by: Gilles Peskine <gilles.peskine@arm.com>
2021-04-28 13:54:16 +02:00
Ronald Cron
87e7b95767 Merge pull request #4241 from stevew817/fix_missing_parenthesis_2.16
[backport 2.16] Add missing parenthesis when MBEDTLS_ECP_NORMALIZE_MXZ_ALT is declared

@mpg comment has been addressed thus this can be merged.
2021-04-28 08:38:41 +02:00
Dave Rodgman
91edd1e701 Improve changelog entry for #4217
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-04-27 17:10:41 +01:00
Ronald Cron
21dab7aee6 Merge pull request #4359 from gilles-peskine-arm/baremetal-no-test-hooks-2.16
Backport 2.16: Disable debugging features in baremetal
2021-04-23 10:09:29 +02:00
Gilles Peskine
bab7ef4f0d Disable debugging features in baremetal
The baremetal configuration is, among other things, our default
reference point for code size measurements. So disable debugging
features that would not be enabled in production where code size is
limited. In particular, this shrinks the core SSL modules by about
half. Keep debugging features that are solely in their own
modules (MBEDTLS_ERROR_C, MBEDTLS_VERSION_FEATURES) since it's easy to
filter them out.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-04-16 16:06:32 +02:00
Gilles Peskine
1724bd2a4f Merge pull request #4322 from gilles-peskine-arm/ecp-add-fix-tests-2.16
Backport 2.16: Test read of zero-padded negative number
2021-04-15 14:00:50 +02:00
Gilles Peskine
52d0b48f04 Merge pull request #4346 from mstarzyk-mobica/long_url_backport_mbedtls_216
Backport 2.16: Allow changelog entries to have URLs exceeding 80 char limit.
2021-04-15 11:12:24 +02:00
Mateusz Starzyk
270626ee70 Allow changelog entries to have URLs exceeding 80 char limit.
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-04-15 10:05:03 +02:00
Gilles Peskine
5a1d0fc55f Fix copypasta in test case description
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-04-13 11:12:22 +02:00
Gilles Peskine
8d2b7aaede Merge pull request #4337 from gilles-peskine-arm/changelog_linelength_enforcement-2.16
Backport 2.16: Make assemble changelog script enforce line length
2021-04-12 20:49:23 +02:00
Gilles Peskine
08d6737368 Explain the problem in more concrete terms
Don't try to make the reader guess what a “negative zero” might mean.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-04-12 17:17:34 +02:00
Paul Elliott
0ec5979461 Pythonify and fix reported line number
Use enumerate to give the line number and use the correct offset to
actually calculate it.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-04-12 16:18:30 +02:00
Paul Elliott
217565ef4e Improve error message
Make sure line number reported is correct for the overly long line, and
change the message to be more readable.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-04-12 16:18:29 +02:00
Paul Elliott
46bef5f929 Remove changelog entry
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-04-12 16:18:28 +02:00
Paul Elliott
c24a1e86da Make assemble changelog script enforce line length
As I descovered, a changelog entry with a line length greater than 80
characters would still pass CI. This is a quick change to the script to
make it detect these descrepancies and fail.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-04-12 16:18:26 +02:00
Gilles Peskine
6527cd382b Enforce dhm_min_bitlen exactly, not just the byte size
In a TLS client, enforce the Diffie-Hellman minimum parameter size
set with mbedtls_ssl_conf_dhm_min_bitlen() precisely. Before, the
minimum size was rounded down to the nearest multiple of 8.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-04-09 17:35:33 +02:00
Gilles Peskine
3e7b61c42b More precise testing of dhm_min_len
An SSL client can be configured to insist on a minimum size for the
Diffie-Hellman (DHM) parameters sent by the server. Add several test
cases where the server sends parameters with exactly the minimum
size (must be accepted) or parameters that are one bit too short (must
be rejected). Make sure that there are test cases both where the
boundary is byte-aligned and where it isn't.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-04-09 17:29:16 +02:00
Gilles Peskine
63a2b91269 Fix SSL tests scripts with recent OpenSSL server with Diffie-Hellman
Our interoperability tests fail with a recent OpenSSL server. The
reason is that they force 1024-bit Diffie-Hellman parameters, which
recent OpenSSL (e.g. 1.1.1f on Ubuntu 20.04) reject:
```
140072814650688:error:1408518A:SSL routines:ssl3_ctx_ctrl:dh key too small:../ssl/s3_lib.c:3782:
```

We've been passing custom DH parameters since
6195767554 because OpenSSL <=1.0.2a
requires it. This is only concerns the version we use as
OPENSSL_LEGACY. So only use custom DH parameters for that version. In
compat.sh, use it based on the observed version of $OPENSSL_CMD.

This way, ssl-opt.sh and compat.sh work (barring other issues) for all
our reference versions of OpenSSL as well as for a modern system OpenSSL.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-04-09 17:28:04 +02:00
Gilles Peskine
cd7d074ff9 mbedtls_mpi_read_string("-0") no longer produces a "negative zero"
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-04-09 17:11:34 +02:00
Gilles Peskine
2c8cfcf59f Fix an incorrect comment about fix_negative
We're subtracting multiples of 2^bits, not 2^(bits+32).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-04-09 16:32:08 +02:00