summaryrefslogtreecommitdiff
path: root/lib/kx.c
Commit message (Collapse)AuthorAgeFilesLines
* build: re-indent codeDaiki Ueno2023-04-241-180/+133
| | | | Signed-off-by: Daiki Ueno <ueno@gnu.org>
* Indent codeZoltan Fridrich2023-01-271-89/+71
| | | | | Co-authored-by: Simon Josefsson <simon@josefsson.org> Signed-off-by: Zoltan Fridrich <zfridric@redhat.com>
* locks: use once execution for on-demand initialization of globalsDaiki Ueno2021-11-171-9/+16
| | | | | | | | | | This makes sure that the global variables are initialized only once. Most of those variables are initialized at ELF constructor, though a couple of occasions they are initialized on-demand: the global keylog file pointer and TPM2 TCTI context. To properly protect the initialization this patch uses gl_once provided by Gnulib. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* locks: replace custom mutex wrappers with "glthread/lock.h"Daiki Ueno2021-11-171-2/+4
| | | | | | | As Gnulib provides portability wrappers of mutex implementations, we don't need to provide similar wrappers by ourselves. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* mem: instrument with ASan memory poisoning as well as valgrindDaiki Ueno2021-08-091-0/+10
| | | | | | | This makes it possible to catch undefined memory access in the more lightweight CI runs. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* keylog: suppress -Wanalyzer-file-leak warningsDaiki Ueno2021-05-131-0/+6
| | | | | | | | | | | | | | | This workarounds the following warnings with gcc analyzer: kx.c:156:69: error: leak of FILE '<unknown>' [CWE-775] [-Werror=analyzer-file-leak] 156 | _gnutls_bin2hex(session->security_parameters. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 157 | client_random, GNUTLS_RANDOM_SIZE, | ~~~~~~~~~~~~~ This should be harmless because the keylog file pointer is closed in the ELF destructor. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* handshake: replace RESUME_TRUE and RESUME_FALSE with <stdbool.h>Daiki Ueno2021-02-041-1/+1
| | | | | | | | | | | | | | | | | | Having those constants could cause wrong impression that there is a third possible value. To reproduce the changes other than lib/gnutls_int.h: for i in `git ls-files lib`; do sed -i -e 's/\(session->internals.\(resumed\|resumable\)\) *\(== *RESUME_FALSE\|!= *RESUME_TRUE\)/!\1/' \ -e 's/\(session->internals.\(resumed\|resumable\)\) *\(== *RESUME_TRUE\|!= *RESUME_FALSE\)/\1/' \ -e 's/RESUME_TRUE/true/' \ -e 's/RESUME_FALSE/false/' \ $i done Signed-off-by: Daiki Ueno <ueno@gnu.org>
* lib: avoid file descriptor leak when application forksDaiki Ueno2020-05-301-1/+1
| | | | | | | | | | | This makes use of the "e" flag of fopen, provided by the Gnulib's fopen-gnu module. Reported by Remi Denis-Courmont in: https://gitlab.com/gnutls/gnutls/-/issues/985 and fix suggested by Tim Rühsen. Signed-off-by: Daiki Ueno <ueno@gnu.org>
* gnutls_session_get_keylog_function: new functiontmp-get-keylog-funcDaiki Ueno2020-03-221-0/+17
| | | | | | | | This adds a way to retrieve the keylog function set by gnutls_session_set_keylog_function() to allow application protocols to implement custom logging facility. Signed-off-by: Daiki Ueno <dueno@redhat.com>
* keylogfile: simplify the callback mechanismtmp-keylog-funcDaiki Ueno2020-02-221-44/+12
| | | | | | | | | | This partially reverts commit 97117556 with a simpler interface. The original intention of having the callback mechanism was to reuse it for monitoring QUIC encryption changes. However, it turned out to be insufficient because such changes must be emitted after a new epoch is ready. Signed-off-by: Daiki Ueno <dueno@redhat.com>
* keylogfile: generalize with a callbacktmp-keylog-hookDaiki Ueno2020-02-071-4/+83
| | | | | | | | | This refactors the keylogfile mechanism by adding a callback to get notified when a new secret is derived and installed. That way, consumers can implement custom logging feature per session, which is particularly useful in QUIC implementation. Signed-off-by: Daiki Ueno <dueno@redhat.com>
* Use https:// for www.gnu.org and www.example.comTim Rühsen2019-03-131-1/+1
| | | | Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
* kx: for uniformity print master secret sizeDmitry Eremin-Solenikov2018-07-231-1/+2
| | | | | | | | During keys setup phase debug log will contain sizes of all keys and secrets, except master secret. Dump MS length (48) to log for uniformity. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
* handshake: use hsk_flags in TLS1.2 and TLS1.3Nikos Mavrogiannopoulos2018-02-191-4/+4
| | | | | | | The flags provide a more transparent view of the received and expected messages. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* _gnutls_nss_keylog_write: define new internal APIDaiki Ueno2018-02-191-20/+36
| | | | | | | | This patch turns the write_nss_key_log function to an internal API (with a different name) so that it can be called from other places implementing TLS 1.3 key scheduling. Signed-off-by: Daiki Ueno <dueno@redhat.com>
* kx: moved to new buffer APINikos Mavrogiannopoulos2018-02-191-94/+76
| | | | Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* handshake: reset cert request state on handshake initNikos Mavrogiannopoulos2017-03-211-4/+4
| | | | | | | | That addresses a bug which on client side on case of an initial handshake with a client certificate, we continue to send this certificate even if on rehandshake we were not requested with on. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
* write_nss_key_log: write the premaster secret while it is still validNikos Mavrogiannopoulos2016-07-071-2/+2
|
* keylogfile: only consider the SSLKEYLOGFILE variableNikos Mavrogiannopoulos2016-06-061-2/+9
| | | | | | | In addition do not check the environment in the constructor but instead use static variables to save the key file name. The GNUTLS_KEYLOGFILE environment variable is no longer used since there is no reason to have a separate one.
* Append keys on keylogfileNikos Mavrogiannopoulos2016-05-271-24/+6
| | | | | Also consider the SSLKEYLOGFILE variable, since the format is identical and we are always appending keys.
* Amend the "Allow for conditional compilation of SSL 3.0 protocol patch"Nikos Mavrogiannopoulos2016-05-241-4/+4
| | | | | | | That is fix bug introduced by an incorrect #ifdef, and unconditionally provide access to certificate callbacks. This amends 89faab9e9e9123f39e8c0c6f8da1f67de423254a
* Amend: Allow for conditional compilation of SSL 3.0 protocolNikos Mavrogiannopoulos2016-05-201-4/+12
| | | | This patch makes conditional several more SSL 3.0-only parts of codebase.
* Write session keys into a file when GNUTLS_KEYLOGFILE is exportedNikos Mavrogiannopoulos2016-05-181-0/+43
| | | | | | | | | | | | | That is the file pointed from the variable is written to, and contain the session parameters in the following format (identical to NSS key log format): CLIENT_RANDOM <space> <64 bytes of hex encoded client_random> <space> <96 bytes of hex encoded master secret> and for the old RSA ciphersuites also in the format: RSA <space> <16 bytes of hex encoded encrypted pre master secret> <space> <96 bytes of hex encoded master secret> Resolves #64
* Allow for conditional compilation of SSL 3.0 protocolNikos Mavrogiannopoulos2016-05-141-2/+3
| | | | | | | This allows to completely remove SSL 3.0 support by calling configure with the '--disable-ssl3' option. Resolves #93
* Removed the 'gnutls_' prefix from files to simplify file namingNikos Mavrogiannopoulos2015-08-231-0/+705