Commit Graph

152 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Janos Follath
7a8a0d7e3d Add ChangeLog entry
Signed-off-by: Janos Follath <janos.follath@arm.com>
2021-06-28 10:24:20 +01:00
Gilles Peskine
ab6ab6aaf0 Fix multiplication producing a negative zero
Fix mbedtls_mpi_mul_mpi() when one of the operands is zero and the
other is negative. The sign of the result must be 1, since some
library functions do not treat {-1, 0, NULL} or {-1, n, {0}} as
representing the value 0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-22 18:48:37 +02:00
Gilles Peskine
5504d1725b mbedtls_mpi_gcd: fix the case B==0
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-22 18:48:37 +02:00
Gilles Peskine
c559eac574 Fix null pointer dereference in mbedtls_mpi_exp_mod
Fix a null pointer dereference in mbedtls_mpi_exp_mod(X, A, N, E, _RR) when
A is the value 0 represented with 0 limbs.

Make the code a little more robust against similar bugs.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-22 18:48:37 +02:00
Manuel Pégourié-Gonnard
07941f45e6 Merge pull request #4690 from gilles-peskine-arm/debug-print-mpi-null-2.16
Backport 2.16: Fix mbedtls_debug_print_mpi crash on 0
2021-06-22 12:09:05 +02:00
Manuel Pégourié-Gonnard
fa719f7415 Merge branch 'mbedtls-2.16' into mbedtls-2.16-restricted
* mbedtls-2.16: (21 commits)
  Reword changelog - Test Resource Leak
  Update changelog formatting - Missing Free Context
  Fix fd range for select on Windows
  Refactor file descriptor checks into a common function
  Update changelog formatting - Missing Free Context
  Update changelog formatting - Missing Free Context
  Changelog entry for Free Context in test_suite_aes fix
  Free context at the end of aes_crypt_xts_size()
  Add changelog entry for non-uniform MPI random generation
  ecp: Fix bias in the generation of blinding values
  DHM: add test case with x_size < 0
  DHM tests: add some explanations
  DHM: add notes about leading zeros
  dhm: Fix bias in private key generation and blinding
  dhm_check_range: microoptimization
  DHM refactoring: use dhm_random_below in dhm_make_common
  DHM blinding: don't accept P-1 as a blinding value
  DHM refactoring: unify mbedtls_dhm_make_{params,public}
  Test mbedtls_dhm_make_params with different x_size
  Repeat a few DH tests
  ...
2021-06-22 10:57:13 +02:00
Dave Rodgman
b3b1d4d9b4 Merge pull request #4684 from JoeSubbiani/2.16FixedMissingContextFree
Backport 2.16: Add Free context at the end of aes_crypt_xts_size()
2021-06-22 09:24:19 +01:00
Manuel Pégourié-Gonnard
34666bb361 Merge pull request #836 from mpg/rsa-lookup-2.16-restricted
[Backport 2.16] Use constant-time look-up in modular exponentiation
2021-06-22 09:33:28 +02:00
Joe Subbiani
b047f99441 Reword changelog - Test Resource Leak
- “Fix an issue where X happens” → ”Fix X“
  the extra words are just a distraction.
- “resource” → “a resource”
- “where resource is never freed” has a name: it's a resource leak
- “when running one particular test suite” → “in a test suite”

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-06-21 16:59:25 +01:00
Joe Subbiani
c8031855d0 Update changelog formatting - Missing Free Context
Missing trailing full stop added to the end of the fixed issue number

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-06-21 09:30:50 +01:00
Gilles Peskine
e1a31284de Simplify mbedtls_debug_print_mpi and fix the case of empty bignums
Rewrite mbedtls_debug_print_mpi to be simpler and smaller. Leverage
mbedtls_mpi_bitlen() instead of manually looking for the leading
zeros.

Fix #4608: the old code made an invalid memory dereference when
X->n==0 (freshly initialized bignum with the value 0).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-21 10:14:41 +02:00
Gilles Peskine
8297657759 Fix fd range for select on Windows
Fix mbedtls_net_poll() and mbedtls_net_recv_timeout() often failing with
MBEDTLS_ERR_NET_POLL_FAILED on Windows: they were testing that the file
descriptor is in range for fd_set, but on Windows socket descriptors are not
limited to a small range. Fixes #4465.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-20 23:19:05 +02:00
Joe Subbiani
dcdb277f34 Update changelog formatting - Missing Free Context
Trailing white space causing check_files.py to fail
issue4176.txt was also in dos format - this has been
changed to unix

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-06-18 18:59:01 +01:00
Joe Subbiani
cbe60337e3 Update changelog formatting - Missing Free Context
The original formatting was in dos and the changelog
assembler would fail. The length of the description was
too long horizontally. This has been updated.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-06-18 15:23:34 +01:00
JoeSubbiani
402b1451c0 Changelog entry for Free Context in test_suite_aes fix
Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-06-18 11:47:08 +01:00
Manuel Pégourié-Gonnard
56efc52d6b Merge pull request #4628 from ronald-cron-arm/dhm-key-generation-bias
dhm: Fix bias in private key generation
2021-06-16 13:13:34 +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
3907bb9a7b Add ChangeLog entry about RSA side channel.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-06-11 10:22:56 +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
Gilles Peskine
ebe9ec448b Add changelog entry for non-uniform MPI random generation
Fix #4245.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-11 08:52:21 +02: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
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
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
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
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
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
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
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
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
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