Daiki Ueno [Wed, 3 Feb 2021 14:50:08 +0000 (15:50 +0100)]
gnutls_session_is_resumed: don't check session ID in TLS 1.3
In middlebox compatibiltiy mode, TLS 1.3 client simulates the TLS 1.2
resumption handshake, so checking session ID for resumption is
pointless. This worked previously because the client always generated
new random value even in a true resumption handshake, but didn't
update the session parameters properly.
Previously, the test used to launch multiple tests in background and
then join them using shell primitives. That approach makes the test
slower as it cannot benefit from the automake's parallel test harness,
as well as it makes diagnostic harder because the lines in the log
file mix up.
Previously, the test used to launch multiple tests in background and
then join them using shell primitives. That approach makes the test
slower as it cannot benefit from the automake's parallel test harness,
as well as it makes diagnostic harder because the lines in the log
file mix up.
Daiki Ueno [Fri, 22 Jan 2021 13:37:47 +0000 (14:37 +0100)]
fips: avoid memleak in (EC)DH internal APIs
There were some confusions of gnutls_pk_params_clear and
gnutls_pk_params_release, as well as the number of parameters to scan
in the gnutls_pk_params_st structure.
Flagged by address sanitizer:
==354688==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 192 byte(s) in 12 object(s) allocated from:
#0 0x7f13506163cf in __interceptor_malloc (/lib64/libasan.so.6+0xab3cf)
#1 0x7f13503b94de in wrap_nettle_mpi_init /home/ueno/devel/gnutls/lib/nettle/mpi.c:79
#2 0x7ffcb8495f07 ([stack]+0x1ef07)
Direct leak of 160 byte(s) in 10 object(s) allocated from:
#0 0x7f13506163cf in __interceptor_malloc (/lib64/libasan.so.6+0xab3cf)
#1 0x7f13503b94de in wrap_nettle_mpi_init /home/ueno/devel/gnutls/lib/nettle/mpi.c:79
Tom Carroll [Mon, 11 Jan 2021 05:40:52 +0000 (21:40 -0800)]
Ensure ca_list != NULL and ca_list_size > 0.
As ca_list_size is used in malloc, ensure that ca_list_size > 0.
If ca_list_size > 0, then ca_list cannot be NULL. Make these
assumptions explicit with argument condition check.
Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
Tom Carroll [Mon, 11 Jan 2021 05:31:19 +0000 (21:31 -0800)]
Verify that cert_list != NULL and cert_list_size > 0.
gnutls_certificate_set_x509_key() assumes that cert_list != NULL and
cert_list_size > 0. These assumptions are evident as cert_list_size is
used for malloc and cert_list[0] is accessed. Make those assumptions
explicit with argument condition check.
Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
This makes sure that when targeting a version of macOS less than
10.12, we won't pick up and unconditionally use functions that
only appeared later, when building with Xcode 11.4 or newer.
(With Xcode 11.4 or newer, the fix from 945a48993dcdd9 caused
-no_weak_links not be added, affecting the function availability
tests.)
Daiki Ueno [Mon, 28 Dec 2020 15:16:53 +0000 (16:16 +0100)]
testpkcs11: use datefudge to trick certificate expiry
The certificates stored in tests/testpkcs11-certs expired on
2020-12-13. To avoid verification failure due to that, use datefudge
to set custom date when calling gnutls-cli, gnutls-serv, and certtool.
Based on the patch by Andreas Metzler:
https://gitlab.com/gnutls/gnutls/-/issues/1135#note_469682121
Stefan Berger [Mon, 21 Dec 2020 14:36:47 +0000 (09:36 -0500)]
tests: Fix tpmtool_test due to changes in trousers
Recent changes to trousers now require an ownership of root:tss for
the tcsd config file, older ones requires tss:tss. So, start tcsd
using trial and error with either one of these ownership configurations
until one works.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
x509: Improve documentation of new set_getissuer_function
Since gnutls!1354, some of this information is now obsolete. The caller
is no longer responsible for verifying the certificate or adding it to
the trust list. GnuTLS will now handle that. Instead, the callback
should always import the missing certificate and return success if the
certificate was imported, or failure otherwise.
Also, let's point to gnutls_x509_crt_get_authority_info_access(), since
it is useful in combination with this function.
Finally, since this callback is emitted once for each missing
intermediate certificate, it's probably less confusing if we talk about
only a single missing intermediate here. Yes, there could be multiple
missing certificates, but a single invocation of this callback can only
deal with one.
Signed-off-by: Michael Catanzaro <mcatanzaro@gnome.org>
Daiki Ueno [Fri, 21 Feb 2020 16:48:37 +0000 (17:48 +0100)]
handshake: add callback to get notified with traffic secret change
For the use with QUIC, the change of traffic secrets must be notified
_after_ a new epoch is set up for reading or writing, and we can't
simply reuse the keylog mechanism.
Daiki Ueno [Wed, 19 Feb 2020 13:35:04 +0000 (14:35 +0100)]
handshake: add functions to read/write handshake messages directly
This adds a couple of functions, gnutls_handshake_set_read_function()
and gnutls_handshake_write(), to allow QUIC implementations to
directly interact with the TLS state machine.
Daiki Ueno [Wed, 11 Nov 2020 18:15:13 +0000 (19:15 +0100)]
x509: rework issuer callback
The previous issuer callback API had a drawback: the callback is
supposed to add CA to the trust list by itself. This was error-prone,
because the callback must check the new CA is trusted by the already
added CA. This instead moves the responsibility to the library.
This also rewrites the chain amendment logic in a side-effect free
manner. The application can assume that the trust information stored
on gnutls_x509_trust_list_t shouldn't change after the verification.
The missingissuer test has been extended to cover all the possible
patterns exhaustively.
gnutls_pkcs11_obj_set_info() fails to call pkcs11_close_session() after
a successful pkcs11_open_session() if called with an invalid itype
parameter. That would be programmer error, of course, but better not
forget to close the session regardless.
Signed-off-by: Michael Catanzaro <mcatanzaro@gnome.org>
Adds a new API gnutls_session_set_verify_output_function() that allows TLS applications
to have a way to pass the gnutls_verify_output_function() as a callback so that the full
path of the certificate chain to the trusted root can be avaiable as output.
Daiki Ueno [Fri, 6 Nov 2020 08:54:54 +0000 (09:54 +0100)]
tls-sig: defer allowed sigalg check to gnutls_pubkey_verify_data2
This reverts 485f2551e68d1b4ee70be2960f0a241b4a2b9fb9. After the new
configuration file has been introduced, the allowed algorithms are
checked after this part.
Daiki Ueno [Wed, 4 Nov 2020 18:05:58 +0000 (19:05 +0100)]
gostdsa: fix memleak in _gnutls_gostdsa_unmask_key
Spotted by valgrind:
==5721== 40 bytes in 1 blocks are definitely lost in loss record 1 of 3
==5721== at 0x4839809: malloc (vg_replace_malloc.c:307)
==5721== by 0x4DC3E59: __gmp_default_allocate (in /usr/lib64/libgmp.so.10.4.0)
==5721== by 0x4DD26A3: __gmpz_realloc (in /usr/lib64/libgmp.so.10.4.0)
==5721== by 0x4DD8B9D: __gmpz_set_str (in /usr/lib64/libgmp.so.10.4.0)
==5721== by 0x499339D: _gnutls_gostdsa_unmask_key (gostdsa-mask.c:68)