1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-04-21 23:05:55 +03:00

7128 Commits

Author SHA1 Message Date
Gilles Peskine
250a612969
Merge pull request #6212 from tom-cosgrove-arm/explicit-warning-re-ct-conditions-not-0-or-1-2.28
Backport 2.28: Be explicit about constant time bignum functions that must take a 0 or 1 condition value
2022-08-22 17:24:10 +02:00
Leonid Rozenboim
81e742333e ssl_tls12_server: fix potential NULL-dereferencing if local certificate was not set.
Signed-off-by: Leonid Rozenboim <leonid.rozenboim@oracle.com>
2022-08-19 13:42:08 +01:00
Tom Cosgrove
f211d824d7 Be explicit about constant time bignum functions that must take a 0 or 1 condition value
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-08-18 14:56:00 +01:00
Gilles Peskine
f222b8e041
Merge pull request #6161 from daverodgman/backport-cert-symlink
Backport 2.28: x509_crt: handle properly broken links when looking for certificates
2022-08-03 13:05:31 +02:00
Gilles Peskine
ddc3845782
Merge pull request #6168 from mman/mbedtls-2.28
Use double quotes to include private header file psa_crypto_cipher.h
2022-08-03 13:05:00 +02:00
Martin Man
43dedd8afe Use double quotes to include private header file psa_crypto_cipher.h
Signed-off-by: Martin Man <mman@martinman.net>
Co-authored-by: Tom Cosgrove <81633263+tom-cosgrove-arm@users.noreply.github.com>
2022-08-02 13:36:18 +02:00
Dave Rodgman
6f227ee8e8 Remove use of lstat
lstat is not available on some platforms (e.g. Ubuntu 16.04). In this
particular case stat is sufficient.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-07-29 14:27:52 +01:00
Dave Rodgman
2958bb3761 Spelling and grammar improvements
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-07-29 14:27:52 +01:00
Dave Rodgman
168bcd684b Don't increase failure count for dangling symlinks
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-07-29 14:27:52 +01:00
Eduardo Silva
32ffb2b8bc x509_crt: handle properly broken links when looking for certificates
On non-windows environments, when loading certificates from a given
path through mbedtls_x509_crt_parse_path() function, if a symbolic
link is found and is broken (meaning the target file don't exists),
the function is returning MBEDTLS_ERR_X509_FILE_IO_ERROR which is
not honoring the default behavior of just skip the bad certificate file
and increase the counter of wrong files.

The problem have been raised many times in our open source project
called Fluent Bit which depends on MbedTLS:

https://github.com/fluent/fluent-bit/issues/843#issuecomment-486388209

The expected behavior is that if a simple certificate cannot be processed,
it should just be skipped.

This patch implements a workaround with lstat(2) and stat(2) to determinate
first if the entry found in the directory is a symbolic link or not, if is
a simbolic link, do a proper stat(2) for the target file, otherwise process
normally. Upon find a broken symbolic link it will increase the counter of
not processed certificates.

Signed-off-by: Eduardo Silva <eduardo@treaure-data.com>
2022-07-29 14:27:50 +01:00
Tom Cosgrove
5205c976da Fix a/an typos in doxygen and other comments
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-07-28 06:12:08 +01:00
Dave Rodgman
fe9d08fd12 Bump version
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-07-11 10:43:55 +01:00
Dave Rodgman
df275c4227 Merge remote-tracking branch 'restricted/mbedtls-2.28-restricted' into mbedtls-2.28.1rc0-pr 2022-07-11 10:42:55 +01:00
Andrzej Kurek
77473eba5d Clarify the need for calling mbedtls_ssl_derive_keys after extension parsing
Use a more straightforward condition to note that session resumption
is happening.
Co-authored-by: Ronald Cron <ronald.cron@arm.com>
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-07-06 06:43:22 -04:00
Andrzej Kurek
c87d97b2ac Rearrange the session resumption code
Previously, the transforms were populated before extension
parsing, which resulted in the client rejecting a server
hello that contained a connection ID.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-07-06 06:43:00 -04:00
Paul Elliott
06986de4ea
Merge pull request #6066 from AndrzejKurek/fix-some-resource-leaks-2-28
Fix `mbedtls_pk_parse_public_key` resource leaks
2022-07-05 23:12:11 +01:00
Andrzej Kurek
cd5e671b5a Add a changelog entry for pkparse bugs
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-07-05 10:32:38 -04:00
Paul Elliott
b39b499932 Add pem_free() to other error paths in pk_parse_public_key()
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2022-07-05 10:27:34 -04:00
Leonid Rozenboim
763ee3c6b4 Fix resource leaks
These potential leaks were flagged by the Coverity static analyzer.

Signed-off-by: Leonid Rozenboim <leonid.rozenboim@oracle.com>
2022-07-05 06:07:43 -04:00
Ronald Cron
0ae1c1c49c
Merge pull request #5991 from gilles-peskine-arm/asn1write-0-fix-2.28
Backport 2.28: Improve ASN.1 write tests
2022-06-30 15:42:31 +02:00
Paul Elliott
24ed2caaff Fix the wrong variable being used for TLS record size checks
Fix an issue whereby a variable was used to check the size of incoming
TLS records against the configured maximum prior to it being set to the
right value.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2022-06-30 12:37:15 +01:00
Gilles Peskine
bb34feea0d Fix bug whereby 0 was written as 0200 rather than 020100
0200 is not just non-DER, it's completely invalid, since there has to be a
sign bit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-29 11:04:48 +02:00
Gilles Peskine
06c5e929ba
Merge pull request #5863 from wernerlewis/csr_subject_comma_2.28
[Backport 2.28] Fix output of commas and other special characters in X509 DN values
2022-06-28 21:00:47 +02:00
Gilles Peskine
c9529f9649 Fix null pointer dereference in mpi_mod_int(0, 2)
Fix a null pointer dereference when performing some operations on zero
represented with 0 limbs: mbedtls_mpi_mod_int() dividing by 2, or
mbedtls_mpi_write_string() in base 2.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-27 14:48:44 +02:00
Dave Rodgman
4118092105
Merge pull request #5825 from polhenarejos/mbedtls-2.28
Backport 2.28: Fix for order value for curve448
2022-06-27 13:47:31 +01:00
Werner Lewis
1421efa25e Fix case where final special char exceeds buffer
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-06-27 12:04:43 +01:00
Manuel Pégourié-Gonnard
d904d66639 Mark static int SSL functions CHECK_RETURN_CRITICAL
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-06-20 21:06:12 +02:00
Manuel Pégourié-Gonnard
06e1fcdb45 Add comments when can_do() is safe to use
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-06-20 21:04:31 +02:00
Manuel Pégourié-Gonnard
d80d8a40ee Add negative tests for opaque mixed-PSK (server)
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-06-20 21:04:31 +02:00
Manuel Pégourié-Gonnard
a49a00cc24 Add negative tests for opaque mixed-PSK (client)
ssl_client2.c used to check that we force a ciphersuite that worked;
that would have prevented testing so I removed it. The library should be
robust even when the application tries something that doesn't work.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-06-20 21:04:31 +02:00
Manuel Pégourié-Gonnard
b9c7ea459e Improve a comment.
ECDSA keys work with mbedtls_pk_ec() too, but we don't want to accept
them here, so the comment should reflect that the check is not just
about ensuring pk_ec() works.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-06-20 21:04:31 +02:00
Manuel Pégourié-Gonnard
5b3f24f214 Fix unchecked return value from internal function
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-06-20 21:04:31 +02:00
Manuel Pégourié-Gonnard
37e5999ac3 Fix potential buffer overread with USE_PSA
Using opaque keys for static ECDH is not supported in this branch (will
be introduced in 3.2). In case we reach that point, error out cleanly
instead of miscasting a pointer. Since opaque keys were introduced,
mbedtls_pk_can_do() was no longer a precise enough check.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2022-06-20 21:04:31 +02:00
Andrzej Kurek
4353d3d593 Split a debug message into two - for clarity
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-06-17 07:37:14 -04:00
Andrzej Kurek
33f41a8fa8 Add the mbedtls prefix to ssl_check_dtls_clihlo_cookie
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-06-17 07:37:02 -04:00
Andrzej Kurek
862acb8403 Add cookie parsing tests to test_suite_ssl
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-06-17 07:36:42 -04:00
Andrzej Kurek
e5af9fabf7 Add missing sid_len in calculations of cookie sizes
This could lead to a potential buffer overread with small
MBEDTLS_SSL_IN_CONTENT_LEN.
Change the bound calculations so that it is apparent
what lengths and sizes are used.

Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2022-06-17 07:36:35 -04:00
Gilles Peskine
f333dfab4a More SSL debug messages for ClientHello parsing
In particular, be verbose when checking the ClientHello cookie in a possible
DTLS reconnection.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-06-17 07:36:26 -04:00
Werner Lewis
02c9d3b9c2 Fix parsing of special chars in X509 DN values
Use escape mechanism defined in RFC 1779 when parsing commas and other
special characters in X509 DN values. Resolves failures when generating
a certificate with a CSR containing a comma in subject value.
Fixes #769.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-06-08 14:38:38 +01:00
Dave Rodgman
ce02537b0c
Merge pull request #5828 from wernerlewis/time_utc_2.28
[Backport 2.28] Use ASN1 UTC tags for dates before 2000
2022-06-08 13:55:38 +01:00
Werner Lewis
1b54a05f77 Use ASN1 UTC tags for dates before 2000
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-06-01 16:28:10 +01:00
Paul Elliott
b830028314 Fix uninitialised memory access in constant time functions
Fix an issue reported by Coverity whereby some constant time functions
called from the ssl decrypt code could potentially access uninitialised
memory.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2022-05-19 18:31:35 +01:00
Dave Rodgman
bdd6905a5c
Merge pull request #5850 from bootstrap-prime/mbedtls-2.28
Fix typos in documentation and constants with typo finding tool
2022-05-19 16:53:37 +01:00
bootstrap-prime
7ef96ea856
Fix typos in documentation and constants with typo finding tool
Signed-off-by: bootstrap-prime <bootstrap.prime@gmail.com>
2022-05-18 14:08:33 -04:00
Gilles Peskine
42313fbfcc psa_raw_key_agreement: return BUFFER_TOO_SMALL when warranted
psa_raw_key_agreement() returned PSA_ERROR_INVALID_ARGUMENT instead of
PSA_ERROR_BUFFER_TOO_SMALL when the output buffer was too small for ECDH,
the only algorithm that is currently implemented. Make it return the correct
error code.

The reason for the wrong error code is that ecdh.c returns
MBEDTLS_ERR_ECP_BAD_INPUT_DATA, presumably for similarith with dhm.c. It
might make sense to change ecdh.c to use MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL,
but dhm.c doesn't have an existing BUFFER_TOO_SMALL error. To minimize the
impact of the fix, handle this in the PSA layer.

Fixes #5735.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-05-17 16:29:55 +02:00
Dave Rodgman
a0026604a2
Merge pull request #5733 from daverodgman/warmsocks_spellingfixes_2.28
Backport 2.28: Fixed spelling and typographical errors found by CodeSpell
2022-05-12 09:26:43 +01:00
Pol Henarejos
c46a2f6c61
Remove spaces.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-05-09 11:03:26 +02:00
Pol Henarejos
a93442e884
Fix for order value for curve448.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
2022-05-09 10:08:46 +02:00
Werner Lewis
12ddae870c Fix memcpy() UB in mbedtls_asn1_named_data()
Removes a case in mbedtls_asn1_named_data() where memcpy() could be
called with a null pointer and zero length. A test case is added for
this code path, to catch the undefined behavior when running tests with
UBSan.

Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-05-04 12:23:26 +01:00
Shaun Case
0e7791ff07 Redo of PR#5345. Fixed spelling and typographical errors found by CodeSpell.
Signed-off-by: Shaun Case <warmsocks@gmail.com>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2022-04-28 18:22:20 +01:00