173 Commits

Author SHA1 Message Date
Manuel Pégourié-Gonnard
652e035ea1 Assemble ChangeLog
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-12-14 11:08:55 +01:00
Manuel Pégourié-Gonnard
b0c54a7d46 Fix misleading ChangeLog entry formatting.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-12-14 09:55:10 +01:00
Manuel Pégourié-Gonnard
1f65e31e73 Double-free goes under security, not bugfix.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-12-14 09:49:32 +01:00
Manuel Pégourié-Gonnard
fef64d5de9 Merge branch 'mbedtls-2.16-restricted' into mbedtls-2.16.12rc0-pr
* mbedtls-2.16-restricted:
  Add changelog entry for session copy bugfix
  [session] fix a session copy bug fix a possible double reference on 'ticket' when peer_cert/peer_cert_digest calloc failed.
2021-12-14 09:27:48 +01:00
Gilles Peskine
7b9cd91587
Merge pull request #5328 from gilles-peskine-arm/zeroize-tag-2.16
Backport 2.16: Zeroize expected MAC/tag intermediate variables
2021-12-13 19:09:34 +01:00
Gilles Peskine
e72ab7767f
Merge pull request #5311 from paul-elliott-arm/pkcs12_fix_2.16
Backport 2.16: Fixes for pkcs12 with NULL and/or zero length password
2021-12-13 14:52:47 +01:00
Gilles Peskine
746cfb1e9b Generalize MAC zeroization changelog entry
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-13 14:28:26 +01:00
Gilles Peskine
a89bdf03ba Catch failures of md_hmac operations
Check the return values of mbedtls_md_xx functions in our code. We were
already doing that everywhere for hash calculations, but not for HMAC
calculations.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-11 17:37:47 +01:00
Gilles Peskine
95f869c9fb Move changelog entry file that was in the wrong directory
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-11 17:37:47 +01:00
Gilles Peskine
957e383f87 Zeroize local MAC variables
Zeroize local MAC variables used for CBC+HMAC cipher suites. In encryption,
this is just good hygiene but probably not needed for security since the
data protected by the MAC that could leak is about to be transmitted anyway.
In DTLS decryption, this could be a security issue since an adversary could
learn the MAC of data that they were trying to inject. At least with
encrypt-then-MAC, the adversary could then easily inject a datagram with
a corrected packet. TLS would still be safe since the receiver would close
the connection after the bad MAC.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-11 17:37:47 +01:00
Paul Elliott
2cd6590040 Delete unneccesary changelog entry
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
a87f009e30 Make changelog more specific
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-12-10 17:49:21 +00:00
Paul Elliott
4d44341369 Fix for pkcs12 with NULL or zero length password
Previously passing a NULL or zero length password into either
mbedtls_pkcs12_pbe() or mbedtls_pkcs12_derive() could cause an infinate
loop, and it was also possible to pass a NULL password, with a non-zero
length, which would cause memory corruption.
I have fixed these errors, and improved the documentation to reflect the
changes and further explain what is expected of the inputs.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2021-12-10 17:49:21 +00:00
David Horstmann
18504f4b20 Add changelog entry for session copy bugfix
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2021-12-08 13:28:12 +00:00
Gilles Peskine
942f8b6854 Add changelog entry for build error fixes
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-12-06 20:56:55 +01:00
openluopworld
ed798a9092 An initialization vector IV can have any number of bits between 1 and
2^64. So it should be filled to the lower 64-bit in the last step
when computing ghash.

Signed-off-by: openluopworld <wuhanluop@163.com>
2021-11-05 19:40:40 +08:00
Manuel Pégourié-Gonnard
70227d217d
Merge pull request #4819 from gilles-peskine-arm/base64-no-table-2.16
Backport 2.16: range-based constant-flow base64
2021-10-27 12:18:42 +02:00
Gilles Peskine
8e82c78954 Fix typo in documentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-25 21:14:06 +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
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
Gilles Peskine
29d29c208e Fix the build of sample programs without mbedtls_strerror
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-06 14:37:32 +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
Gilles Peskine
32e9530531 Base64 range-based constant-flow code: changelog entry
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-07-28 14:37:14 +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