Commit Graph

9600 Commits

Author SHA1 Message Date
Ronald Cron
6f4fbb4640 Merge pull request #838 from gilles-peskine-arm/ecp_max_bits-check-2.16
Backport 2.16: check MBEDTLS_ECP_MAX_BITS
2021-06-15 11:12:52 +02:00
Gilles Peskine
5a6549752f Check MBEDTLS_ECP_MAX_xxx constants in unit tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-14 13:04:48 +02:00
Gilles Peskine
eaf7442f62 Fail the build if MBEDTLS_ECP_MAX_BITS is not large enough
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-14 13:04:45 +02:00
Manuel Pégourié-Gonnard
1283ed9e3b Merge branch 'mbedtls-2.16' into mbedtls-2.16-restricted
* mbedtls-2.16:
  Disable OS X builds on Travis
  Fix null pointer arithmetic in error case
  Fix ecp_muladd test cases never getting executed
  New macros TEST_EQUAL, ASSERT_ALLOC, ASSERT_ALLOC_WEAK
  Remove spurious dependencies on PEM
  Fix misuse of MD API in SSL constant-flow HMAC
2021-06-11 10:18:55 +02:00
Dave Rodgman
7ef266045b Merge pull request #4645 from daverodgman/travis-disable-osx-2.16
Backport 2.16: Disable OS X Travis builds
2021-06-10 17:48:42 +01:00
Dave Rodgman
58d238a3a4 Disable OS X builds on Travis
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-06-10 15:51:28 +01:00
Gilles Peskine
6db34e6e01 Merge pull request #4542 from mpg/fix-ssl-cf-hmac-alt-2.16
[Backport 2.16] Fix misuse of MD API in SSL constant-flow HMAC
2021-06-07 20:53:53 +02:00
Manuel Pégourié-Gonnard
449c177469 Merge pull request #829 from mpg/ecp-gen-privkey-ct-compare-2.16-restricted
[Backport 2.16] Fix small timing side channel in ECDSA ephemeral key generation
2021-06-07 09:10:15 +02:00
Gilles Peskine
806281a663 Merge pull request #4598 from gilles-peskine-arm/ecp_muladd-tests_not_executed-2.16
Backport 2.16: Fix null pointer arithmetic in NIST_KW
2021-06-01 16:40:11 +02:00
Gilles Peskine
995d89c9f2 Fix null pointer arithmetic in error case
When mbedtls_nist_kw_wrap was called with output=NULL and out_size=0, it
performed arithmetic on the null pointer before detecting that the output
buffer is too small and returning an error code. This was unlikely to have
consequences on real-world hardware today, but it is undefined behavior and
UBSan with Clang 10 flagged it. So fix it (fix #4025).

Fix a similar-looking pattern in unwrap, though I haven't verified that it's
reachable there.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-01 13:03:34 +02:00
Manuel Pégourié-Gonnard
ac12767ff3 Fix non-constant-time comparison in mbedtls_ecp_gen_privkey
Calling mbedtls_mpi_cmp_int reveals the number of leading zero limbs
to an adversary who is capable of very fine-grained timing
measurements. This is very little information, but could be practical
with secp521r1 (1/512 chance of the leading limb being 0) if the
adversary can measure the precise timing of a large number of
signature operations.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-06-01 12:06:57 +02:00
Gilles Peskine
8e7d7ee1ae Fix ecp_muladd test cases never getting executed
These test cases had been backported from Mbed TLS 2.x with a dependency
symbol that didn't exist in 2.16. Declare that symbol.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-31 20:25:26 +02:00
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
Manuel Pégourié-Gonnard
7f0d193c94 Fix misuse of MD API in SSL constant-flow HMAC
The sequence of calls starts-update-starts-update-finish is not a
guaranteed valid way to abort an operation and start a new one. Our
software implementation just happens to support it, but alt
implementations may very well not support it.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-05-19 10:44:43 +02: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