]> git.ipfire.org Git - thirdparty/gnutls.git/log
thirdparty/gnutls.git
5 years agotests: remove shell-script wrapper for tls13/prf-early
Daiki Ueno [Thu, 29 Apr 2021 16:09:01 +0000 (18:09 +0200)] 
tests: remove shell-script wrapper for tls13/prf-early

The wrapper (tls13/prf-early.sh) was merely for running
tls13/prf-early under datefudge.  The same thing can now be done with
virt_time_init_at.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agotests: virt-time: add virt_time_init_at
Daiki Ueno [Thu, 29 Apr 2021 15:56:37 +0000 (17:56 +0200)] 
tests: virt-time: add virt_time_init_at

This allows the tests to set the current time to arbitrary point,
instead of the current time; useful for the tests checking the traces
such as tls13/prf-early.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agognutls_init: add flag to omit EndOfEarlyData messages
Daiki Ueno [Thu, 29 Apr 2021 06:35:02 +0000 (08:35 +0200)] 
gnutls_init: add flag to omit EndOfEarlyData messages

The message is prohibited in QUIC:
https://tools.ietf.org/html/draft-ietf-quic-tls-34#section-8.3

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agognutls_init: redefine GNUTLS_ENABLE_EARLY_DATA flag for client
Daiki Ueno [Thu, 29 Apr 2021 06:26:46 +0000 (08:26 +0200)] 
gnutls_init: redefine GNUTLS_ENABLE_EARLY_DATA flag for client

The flag was only for the server, but it turned out to be useful for
client to explicitly indicate early data, when 0-RTT is handled
out-of-band as in QUIC.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agostate: call secret_func on early write key change as well
Daiki Ueno [Thu, 29 Apr 2021 06:23:15 +0000 (08:23 +0200)] 
state: call secret_func on early write key change as well

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'wip/dueno/build-fixes' into 'master'
Daiki Ueno [Thu, 13 May 2021 09:12:18 +0000 (09:12 +0000)] 
Merge branch 'wip/dueno/build-fixes' into 'master'

CI updates and build fixes spotted by GCC 11

See merge request gnutls/gnutls!1430

5 years ago.gitlab-ci.yml: doc-dist.Fedora: invoke "texconfig rehash"
Daiki Ueno [Thu, 13 May 2021 06:38:20 +0000 (08:38 +0200)] 
.gitlab-ci.yml: doc-dist.Fedora: invoke "texconfig rehash"

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agosystemkey: remove unused --inder and --infile options
Daiki Ueno [Thu, 13 May 2021 06:01:27 +0000 (08:01 +0200)] 
systemkey: remove unused --inder and --infile options

While those options have no effect, the command previously tried to
open a file for reading and leaked file descriptor.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agokeylog: suppress -Wanalyzer-file-leak warnings
Daiki Ueno [Wed, 12 May 2021 14:55:37 +0000 (16:55 +0200)] 
keylog: suppress -Wanalyzer-file-leak warnings

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>
5 years ago.gitlab-ci.yml: update build images to Fedora 34 and Alpine 3.13
Daiki Ueno [Wed, 12 May 2021 12:46:56 +0000 (14:46 +0200)] 
.gitlab-ci.yml: update build images to Fedora 34 and Alpine 3.13

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agodevel: regenerate abidw dump files
Daiki Ueno [Wed, 12 May 2021 12:44:37 +0000 (14:44 +0200)] 
devel: regenerate abidw dump files

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years ago.gitlab-ci.yml: bump cache version
Daiki Ueno [Tue, 11 May 2021 13:29:03 +0000 (15:29 +0200)] 
.gitlab-ci.yml: bump cache version

This should fix the nettle_streebog512_update detection.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agosrptool: add missing fclose on error path
Daiki Ueno [Tue, 11 May 2021 12:25:38 +0000 (14:25 +0200)] 
srptool: add missing fclose on error path

Spotted by gcc analyzer:
  srptool.c:113:32: warning: leak of FILE 'fp' [CWE-775] [-Wanalyzer-file-leak]
    113 |                         return -1;
        |                                ^
also:
  srptool.c:560:32: warning: leak of FILE 'fp' [CWE-775] [-Wanalyzer-file-leak]
    560 |                         return -1;
        |                                ^

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agotests: _check_wait_status: use only async-thread-safe function
Daiki Ueno [Thu, 13 May 2021 06:40:59 +0000 (08:40 +0200)] 
tests: _check_wait_status: use only async-thread-safe function

As this function shall be called in a signal handler, it shouldn't use
'exit' as it's not async-thread-safe.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agognutls-serv: use only async-signal-safe functions in signal handler
Daiki Ueno [Tue, 11 May 2021 12:23:45 +0000 (14:23 +0200)] 
gnutls-serv: use only async-signal-safe functions in signal handler

Spotted by gcc analyzer:
  serv.c:1138:9: warning: call to 'exit' from within signal handler [CWE-479] [-Wanalyzer-unsafe-call-within-signal-handler]
   1138 |         exit(1);
        |         ^~~~~~~

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agocerttool: tighten allocation check
Daiki Ueno [Tue, 11 May 2021 12:13:45 +0000 (14:13 +0200)] 
certtool: tighten allocation check

Spotted by gcc analyzer:
  certtool-cfg.c:856:24: warning: use of possibly-NULL 'copy' where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument]
    856 |                 while (strcmp(pass, copy) != 0
        |                        ^~~~~~~~~~~~~~~~~~

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agopsktool: tighten allocation check
Daiki Ueno [Tue, 11 May 2021 12:08:33 +0000 (14:08 +0200)] 
psktool: tighten allocation check

Spotted by gcc analyzer:
  psk.c:275:21: warning: use of possibly-NULL '_username.data' where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument]
    275 |                 if (strncmp(p, (const char *) _username.data,
        |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years ago.gitignore: ignore more files
Daiki Ueno [Tue, 11 May 2021 11:16:51 +0000 (13:16 +0200)] 
.gitignore: ignore more files

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years ago_tls13_{derive,expand}_secret2: fix array parameter mismatch
Daiki Ueno [Tue, 11 May 2021 09:08:59 +0000 (11:08 +0200)] 
_tls13_{derive,expand}_secret2: fix array parameter mismatch

This suppresses the warning with -Warray-parameter
  secrets.c:85:40: warning: argument 6 of type 'const uint8_t[64]' {aka 'const unsigned char[64]'} with mismatched bound [-Warray-parameter=]
     85 |                          const uint8_t secret[MAX_HASH_SIZE],
        |                          ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
  In file included from secrets.c:28:
  secrets.h:43:41: note: previously declared as 'const uint8_t[32]' {aka 'const unsigned char[32]'}
     43 |                           const uint8_t secret[MAX_CIPHER_KEY_SIZE],
        |                           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years ago_gnutls_retrieve_pin: remove array declarator in function argument
Daiki Ueno [Tue, 11 May 2021 09:04:54 +0000 (11:04 +0200)] 
_gnutls_retrieve_pin: remove array declarator in function argument

This was originally to eliminate the warnings with -Warray-parameter:

  pin.c:70:27: warning: argument 5 of type 'char[256]' with mismatched bound [-Warray-parameter=]
     70 |                      char pin[GNUTLS_PKCS11_MAX_PIN_LEN], unsigned pin_size)
        |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from pin.c:23:
  ./pin.h:9:48: note: previously declared as 'char *'
      9 |                      unsigned pin_flags, char *pin, unsigned pin_size);
        |                                          ~~~~~~^~~

though it turned out to be unnecessary because the function merely
delegate the call to the user-supplied callbacks.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'its-spelling' into 'master'
Daiki Ueno [Thu, 6 May 2021 07:10:42 +0000 (07:10 +0000)] 
Merge branch 'its-spelling' into 'master'

spelling: The possessive pronoun "its" has no apostrophe.

See merge request gnutls/gnutls!1426

5 years agospelling: The possessive pronoun "its" has no apostrophe.
Daniel Kahn Gillmor [Wed, 5 May 2021 22:05:29 +0000 (18:05 -0400)] 
spelling: The possessive pronoun "its" has no apostrophe.

"it's" is for contractions like "it is" or "it has".  "its" is a
possessive pronoun, like "his" or "hers" or "theirs", none of which
have an apostrophe in them either.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
5 years agoMerge branch 'fix-provable-constraints' into 'master'
Daiki Ueno [Wed, 5 May 2021 06:04:37 +0000 (06:04 +0000)] 
Merge branch 'fix-provable-constraints' into 'master'

certtool: Align warning about --provable with actual code

See merge request gnutls/gnutls!1425

5 years agocerttool: Align warning about --provable with actual code
Daniel Kahn Gillmor [Tue, 4 May 2021 19:08:08 +0000 (15:08 -0400)] 
certtool: Align warning about --provable with actual code

If I try to generate an ed25519 key, it is *not* an ECDSA key.  But I
see this warning:

    0 dkg@host:~$ certtool --generate-privkey --provable --key-type ed25519
    Generating a 256 bit EdDSA (Ed25519) private key ...
    The --provable parameter cannot be used with ECDSA keys.
    1 dkg@host:~$

Looking at the code and documentation, it's clear that --provable only
works for RSA and DSA.  This fix aligns the warning message with the
underlying mechanism.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
5 years agoMerge branch 'wip/dueno/trusted-ca-sha1' into 'master'
Daiki Ueno [Tue, 4 May 2021 18:45:03 +0000 (18:45 +0000)] 
Merge branch 'wip/dueno/trusted-ca-sha1' into 'master'

x509/verify: treat SHA-1 signed CA in the trusted set differently

Closes #1202

See merge request gnutls/gnutls!1423

5 years agox509/verify: treat SHA-1 signed CA in the trusted set differently
Daiki Ueno [Mon, 3 May 2021 14:35:43 +0000 (16:35 +0200)] 
x509/verify: treat SHA-1 signed CA in the trusted set differently

Suppose there is a certificate chain ending with an intermediate CA:
EE → ICA1 → ICA2.  If the system trust store contains a root CA
generated with the same key as ICA2 but signed with a prohibited
algorithm, such as SHA-1, the library previously reported a
verification failure, though the situation is not uncommon during a
transition period of root CA.

This changes the library behavior such that the check on signature
algorithm will be skipped when examining the trusted root CA.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'wip/dueno/implicit-init' into 'master'
Daiki Ueno [Tue, 4 May 2021 08:58:04 +0000 (08:58 +0000)] 
Merge branch 'wip/dueno/implicit-init' into 'master'

global: rename GNUTLS_NO_EXPLICIT_INIT to GNUTLS_NO_IMPLICIT_INIT

Closes #1178

See merge request gnutls/gnutls!1424

5 years agoglobal: rename GNUTLS_NO_EXPLICIT_INIT to GNUTLS_NO_IMPLICIT_INIT
Daiki Ueno [Mon, 3 May 2021 15:27:56 +0000 (17:27 +0200)] 
global: rename GNUTLS_NO_EXPLICIT_INIT to GNUTLS_NO_IMPLICIT_INIT

The old envvar still has effect but has been marked as deprecated.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'tlsv1.3-cb' into 'master'
Daiki Ueno [Mon, 3 May 2021 12:33:12 +0000 (12:33 +0000)] 
Merge branch 'tlsv1.3-cb' into 'master'

Implement new tls channel biding types

Closes #1214 and #1041

See merge request gnutls/gnutls!1422

5 years agocerttool: fix parsing of --verify-profile option
Daiki Ueno [Mon, 3 May 2021 12:19:22 +0000 (14:19 +0200)] 
certtool: fix parsing of --verify-profile option

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoAdd tests for call gnutls_session_channel_binding
Ruslan N. Marchenko [Sun, 2 May 2021 21:29:39 +0000 (23:29 +0200)] 
Add tests for call gnutls_session_channel_binding

 Add test unit which executes positive and negative test scenarios
 using standard gnutls testing framework.

Signed-off-by: Ruslan N. Marchenko <me@ruff.mobi>
5 years agoAdd tls-server-end-point tls channel binding implementation.
Ruslan N. Marchenko [Sat, 1 May 2021 21:05:54 +0000 (23:05 +0200)] 
Add tls-server-end-point tls channel binding implementation.

 Add server-end-point tls channel binding into gnutls_session_channel_binding
 method. The implementation extracts session's certificate, its signature
 algorithm, and calculates digest of the extracted certificate using
 the function based on extracted algorithm, as per RFC5929.

Signed-off-by: Ruslan N. Marchenko <me@ruff.mobi>
5 years agoRestructure gnutls_session_channel_binding and add tls-exporter
Ruslan N. Marchenko [Sat, 1 May 2021 08:16:37 +0000 (10:16 +0200)] 
Restructure gnutls_session_channel_binding and add tls-exporter

 The restructure removes explicit pre-check for supported binding
 type(s) and instead relies now on catch-all return which returns
 UNIMPLEMENTED_FEATURE if no type was handled. In addition to that
 it returns UNIMPLEMENTED_FEATURE for tls-unique request on TLSv1.3
 session, since that is not supposed to work hence requires explicit
 error. Finally new binding type tls-exporter implementation is
 added.

Signed-off-by: Ruslan N. Marchenko <me@ruff.mobi>
5 years agoIntroduce new tls channel binding types into gnutls_channel_binding_t
Ruslan N. Marchenko [Sat, 1 May 2021 08:22:14 +0000 (10:22 +0200)] 
Introduce new tls channel binding types into gnutls_channel_binding_t

 This commit adds two new tls channel binding types into enum
 gnutls_channel_binding_t:
 * tls-server-end-point
 * tls-exporter

Signed-off-by: Ruslan N. Marchenko <me@ruff.mobi>
5 years agoMerge branch 'wip/dueno/certtool-cdp' into 'master'
Daiki Ueno [Wed, 28 Apr 2021 14:50:02 +0000 (14:50 +0000)] 
Merge branch 'wip/dueno/certtool-cdp' into 'master'

certtool: don't copy CRL distribution point from CA cert

Closes #1126

See merge request gnutls/gnutls!1420

5 years agocerttool: don't copy CRL distribution point from CA cert
Daiki Ueno [Wed, 28 Apr 2021 09:04:20 +0000 (11:04 +0200)] 
certtool: don't copy CRL distribution point from CA cert

Suggested by Thomas Karlsson in:
https://gitlab.com/gnutls/gnutls/-/issues/1126

While this changes the default behavior, CDP can always be set through
the template or interactive input.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'wip/dueno/gitignore' into 'master' 1419/head
Daiki Ueno [Sun, 25 Apr 2021 17:31:59 +0000 (17:31 +0000)] 
Merge branch 'wip/dueno/gitignore' into 'master'

gnutls_x509_crt_get_dn: clarify null-termination of the output

Closes #1191 and #1187

See merge request gnutls/gnutls!1418

5 years agognutls_x509_crt_get_dn: clarify null-termination of the output
Daiki Ueno [Sun, 25 Apr 2021 15:04:46 +0000 (17:04 +0200)] 
gnutls_x509_crt_get_dn: clarify null-termination of the output

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agobuild: do not install .hmac files
Daiki Ueno [Sun, 25 Apr 2021 08:48:09 +0000 (10:48 +0200)] 
build: do not install .hmac files

It turned out that distro package building process might perform
post-processing (e.g., strip) of the shared libraries after install,
and that may cause inconsistency with the installed .hmac files.

Let's not try too hard on this but defer the final hmac calculation to
distributions.  It is still useful to keep our own fipshmac as it
makes it easier to run FIPS tests.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agotests: fix test script file name in distribution
Daiki Ueno [Sun, 25 Apr 2021 04:51:20 +0000 (06:51 +0200)] 
tests: fix test script file name in distribution

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years ago.gitignore: ignore ctags, etags, and GNU global files
Daiki Ueno [Sun, 25 Apr 2021 04:50:03 +0000 (06:50 +0200)] 
.gitignore: ignore ctags, etags, and GNU global files

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'wip/dueno/earlydata' into 'master'
Daiki Ueno [Sun, 25 Apr 2021 07:49:32 +0000 (07:49 +0000)] 
Merge branch 'wip/dueno/earlydata' into 'master'

handshake: fix timing of sending early data

Closes #1146

See merge request gnutls/gnutls!1416

5 years agohandshake: fix timing of sending early data
Daiki Ueno [Fri, 23 Apr 2021 13:36:37 +0000 (15:36 +0200)] 
handshake: fix timing of sending early data

Previously, the client was sending early data after receiving a Server
Hello message, which not only negates the benefit of 0-RTT, but also
was a logic error as it can only be decrypted by the server when the
initial handshake and the resuming handshake agree on the same
ciphersuites.  This fixes that behavior in the following ways:

- extend the session data format to include the selected ciphersuites,
  even in TLS 1.3
- setup the epoch for early data, right before the client sending
  early data (also right after the server deciding to accept early
  data).
- extend the test case to use different ciphersuites in the initial
  and resuming handshakes

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'wip-guile-fixes' into 'master'
Daiki Ueno [Sun, 25 Apr 2021 04:21:11 +0000 (04:21 +0000)] 
Merge branch 'wip-guile-fixes' into 'master'

Minor Guile bindings improvements.

See merge request gnutls/gnutls!1413

5 years agoguile: Tests show their PID upon uncaught exceptions.
Ludovic Courtès [Fri, 23 Apr 2021 07:44:20 +0000 (09:44 +0200)] 
guile: Tests show their PID upon uncaught exceptions.

* guile/modules/gnutls/build/tests.scm (run-test): Display the PID when
throwing an exception.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
5 years agoguile: Avoid the deprecated 'scm_t_uint8' type.
Ludovic Courtès [Fri, 5 Feb 2021 11:28:35 +0000 (12:28 +0100)] 
guile: Avoid the deprecated 'scm_t_uint8' type.

* guile/src/core.c: Use 'uint8_t' instead of 'scm_t_uint8', which is
deprecated in Guile 3.0.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
5 years agoguile: Avoid potentially missed reference.
Ludovic Courtès [Tue, 22 Dec 2020 09:30:43 +0000 (10:30 +0100)] 
guile: Avoid potentially missed reference.

There's one case where 'register_weak_reference' is called several times
on the same object, in 'set-certificate-credentials-x509-keys!', where
PRIVKEY could have been GC'd before CRED.

* guile/src/core.c (register_weak_reference): Add TO to the weak
references of FROM instead of overriding them.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
5 years agoMerge branch 'wip/dueno/hash-copy-selftests' into 'master'
Daiki Ueno [Fri, 23 Apr 2021 10:11:35 +0000 (10:11 +0000)] 
Merge branch 'wip/dueno/hash-copy-selftests' into 'master'

crypto-selftests: tolerate errors of gnutls_{hash,hmac}_copy

See merge request gnutls/gnutls!1412

5 years agoMerge branch 'wip/dueno/afalg-fixes' into 'master'
Daiki Ueno [Fri, 23 Apr 2021 09:40:09 +0000 (09:40 +0000)] 
Merge branch 'wip/dueno/afalg-fixes' into 'master'

afalg: minor follow-up fixes

Closes #1209 and #1207

See merge request gnutls/gnutls!1414

5 years agoafalg: use pkg-config to detect libkcapi
Daiki Ueno [Fri, 23 Apr 2021 08:28:03 +0000 (10:28 +0200)] 
afalg: use pkg-config to detect libkcapi

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoafalg: support AES-XTS algorithms
Daiki Ueno [Fri, 23 Apr 2021 08:03:47 +0000 (10:03 +0200)] 
afalg: support AES-XTS algorithms

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoafalg: cleanup header inclusion
Daiki Ueno [Fri, 23 Apr 2021 07:56:40 +0000 (09:56 +0200)] 
afalg: cleanup header inclusion

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoguile: Remove leftover comment about allocation routines.
Ludovic Courtès [Mon, 21 Dec 2020 17:22:14 +0000 (18:22 +0100)] 
guile: Remove leftover comment about allocation routines.

This is a followup to 872409857351f28b1e3c21526bfa6606c918b176.

* guile/src/core.c (scm_init_gnutls): Remove leftover comment.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
5 years agoafalg: remove unnecessary initialization
Daiki Ueno [Fri, 23 Apr 2021 07:50:16 +0000 (09:50 +0200)] 
afalg: remove unnecessary initialization

That would make it easier to spot any uninitialized memory access with
valgrind.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoafalg: assert IV size returned from the kernel is in the range
Daiki Ueno [Fri, 23 Apr 2021 07:45:51 +0000 (09:45 +0200)] 
afalg: assert IV size returned from the kernel is in the range

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoNEWS: mention AF_ALG support
Daiki Ueno [Fri, 23 Apr 2021 07:42:03 +0000 (09:42 +0200)] 
NEWS: mention AF_ALG support

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agocrypto-selftests: tolerate errors of gnutls_{hash,hmac}_copy
Daiki Ueno [Wed, 14 Apr 2021 15:27:43 +0000 (17:27 +0200)] 
crypto-selftests: tolerate errors of gnutls_{hash,hmac}_copy

Some hardware accelerated implementations, such as afalg, cannot
support the copy operation.  This patch turns it a soft-error, as the
code below is already checking if the copy is non-NULL, before
performing any operation on it.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'wip/dueno/hrr-session-id' into 'master'
Daiki Ueno [Fri, 23 Apr 2021 04:09:10 +0000 (04:09 +0000)] 
Merge branch 'wip/dueno/hrr-session-id' into 'master'

handshake: don't regenerate legacy_session_id in second CH after HRR

Closes #1210

See merge request gnutls/gnutls!1411

5 years agohandshake: don't regenerate legacy_session_id in second CH after HRR
Daiki Ueno [Thu, 22 Apr 2021 14:42:01 +0000 (16:42 +0200)] 
handshake: don't regenerate legacy_session_id in second CH after HRR

According to RFC 8446 4.1.2, the client must send the same Client
Hello after Hello Retry Request, except for the certain extensions,
and thus legacy_session_id must be preserved.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'af_alg' into 'master'
Daiki Ueno [Tue, 20 Apr 2021 15:15:52 +0000 (15:15 +0000)] 
Merge branch 'af_alg' into 'master'

Add Linux kernel AF_ALG backend

See merge request gnutls/gnutls!1404

5 years ago_gnutls_cipher_init: fallback if setiv is not implemented for AEAD
Daiki Ueno [Wed, 14 Apr 2021 14:50:28 +0000 (16:50 +0200)] 
_gnutls_cipher_init: fallback if setiv is not implemented for AEAD

The _gnutls_cipher_init function currently assumes that all the cipher
implementations have .setiv method.  This is not the case for
AEAD-only implementations such as afalg.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoAdd AF_ALG acceleration
Stephan Mueller [Sat, 14 Oct 2017 18:46:09 +0000 (20:46 +0200)] 
Add AF_ALG acceleration

The patch set adds the backend implementation to use the Linux kernel
crypto API via the AF_ALG interface. The GnuTLS AF_ALG extension uses
libkcapi [1] as the backend library which implements the actual kernel
communication.

[1] http://www.chronox.de/libkcapi.html

The symmetric cipher support, the hashing and the MAC support are
validated to work correctly using NIST CAVS test vectors.

The AEAD cipher support was tested by connecting to a remote host using
gnutls-cli (the following log strips out unrelated information):

Processed 143 CA certificate(s).
...
- Certificate type: X.509
- Got a certificate list of 1 certificates.
- Certificate[0] info:
...
- Description: (TLS1.2)-(ECDHE-SECP384R1)-(RSA-SHA512)-(AES-256-GCM)
- Session ID: 9E:5E:FC:09:2A:4E:2A:3D:22:44:68:42:C3:F6:2D:AB:F9:67:08:CE:6D:EE:E4:A2:EF:80:43:FE:3B:D9:1E:FE
- Ephemeral EC Diffie-Hellman parameters
 - Using curve: SECP384R1
 - Curve size: 384 bits
- Version: TLS1.2
- Key Exchange: ECDHE-RSA
- Server Signature: RSA-SHA512
- Cipher: AES-256-GCM
- MAC: AEAD
- Options: extended master secret, safe renegotiation,
- Handshake was completed

- Simple Client Mode:

Signed-off-by: Stephan Mueller <smueller@chronox.de>
Co-authored-by: Daiki Ueno <ueno@gnu.org>
Co-authored-by: Hedgehog5040 <krenzelok.frantisek@gmail.com>
5 years agoMerge branch 'wip/dueno/tls13-compat' into 'master'
Daiki Ueno [Sun, 18 Apr 2021 05:16:25 +0000 (05:16 +0000)] 
Merge branch 'wip/dueno/tls13-compat' into 'master'

priority: add option to disable TLS 1.3 middlebox compatibility mode

Closes #1208

See merge request gnutls/gnutls!1410

5 years agopriority: add option to disable TLS 1.3 middlebox compatibility mode
Daiki Ueno [Fri, 16 Apr 2021 11:56:40 +0000 (13:56 +0200)] 
priority: add option to disable TLS 1.3 middlebox compatibility mode

This adds a new option %DISABLE_TLS13_COMPAT_MODE to disable TLS 1.3
compatibility mode at run-time.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'wip/dueno/reallocarray' into 'master'
Daiki Ueno [Tue, 30 Mar 2021 12:54:04 +0000 (12:54 +0000)] 
Merge branch 'wip/dueno/reallocarray' into 'master'

build: avoid potential integer overflow in array allocation

Closes #1179

See merge request gnutls/gnutls!1392

5 years ago_gnutls_calloc: remove unused function
Daiki Ueno [Tue, 30 Mar 2021 11:39:46 +0000 (13:39 +0200)] 
_gnutls_calloc: remove unused function

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'wip/dueno/system-keys-w32' into 'master'
Daiki Ueno [Mon, 29 Mar 2021 16:12:28 +0000 (16:12 +0000)] 
Merge branch 'wip/dueno/system-keys-w32' into 'master'

keys-win: free certificate context in gnutls_system_key_iter_deinit

Closes #1197

See merge request gnutls/gnutls!1406

5 years agokeys-win: free certificate context in gnutls_system_key_iter_deinit
Daiki Ueno [Mon, 29 Mar 2021 12:09:51 +0000 (14:09 +0200)] 
keys-win: free certificate context in gnutls_system_key_iter_deinit

Suggested by Bjørn Christensen in:
https://gitlab.com/gnutls/gnutls/-/issues/1197

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agobuild: avoid integer overflow in additions
Daiki Ueno [Mon, 29 Mar 2021 09:06:37 +0000 (11:06 +0200)] 
build: avoid integer overflow in additions

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agobuild: avoid potential integer overflow in array allocation
Daiki Ueno [Sun, 21 Feb 2021 07:43:26 +0000 (08:43 +0100)] 
build: avoid potential integer overflow in array allocation

This relies on _gnutls_reallocarray for all occasions of array
allocations, so that they can benefit from the built-in overflow
checks.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agopkcs11x: find_ext_cb: fix error propagation
Daiki Ueno [Mon, 29 Mar 2021 11:08:23 +0000 (13:08 +0200)] 
pkcs11x: find_ext_cb: fix error propagation

Use explicit error value, as rv is not set in this code path.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agomem: add _gnutls_reallocarray and _gnutls_reallocarray_fast
Daiki Ueno [Sun, 21 Feb 2021 07:42:23 +0000 (08:42 +0100)] 
mem: add _gnutls_reallocarray and _gnutls_reallocarray_fast

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agobootstrap: pull in 'xalloc-oversized' module from Gnulib
Daiki Ueno [Sun, 21 Feb 2021 07:34:13 +0000 (08:34 +0100)] 
bootstrap: pull in 'xalloc-oversized' module from Gnulib

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'tmp-missing-gnutls-crypto-layers_png' into 'master'
Andreas Metzler [Sat, 20 Mar 2021 16:45:39 +0000 (16:45 +0000)] 
Merge branch 'tmp-missing-gnutls-crypto-layers_png' into 'master'

build: doc: install missing image file gnutls-crypto-layers.png

See merge request gnutls/gnutls!1405

5 years agobuild: doc: install missing image file gnutls-crypto-layers.png
Andreas Metzler [Sat, 20 Mar 2021 12:52:25 +0000 (13:52 +0100)] 
build: doc: install missing image file gnutls-crypto-layers.png

Signed-off-by: Andreas Metzler <ametzler@bebt.de>
5 years agoMerge branch 'wip/dueno/coverity' into 'master'
Daiki Ueno [Tue, 16 Mar 2021 05:42:45 +0000 (05:42 +0000)] 
Merge branch 'wip/dueno/coverity' into 'master'

Fix resource leaks spotted by coverity

See merge request gnutls/gnutls!1403

5 years agoMerge branch 'wip/dueno/tzalloc-tests' into 'master'
Daiki Ueno [Mon, 15 Mar 2021 12:47:36 +0000 (12:47 +0000)] 
Merge branch 'wip/dueno/tzalloc-tests' into 'master'

gnulib: update git submodule

Closes #1190

See merge request gnutls/gnutls!1402

5 years agoexamples: avoid memory leak in ex-verify
Daiki Ueno [Mon, 15 Mar 2021 10:03:44 +0000 (11:03 +0100)] 
examples: avoid memory leak in ex-verify

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoexamples: avoid memory leak in tlsproxy
Daiki Ueno [Mon, 15 Mar 2021 10:03:22 +0000 (11:03 +0100)] 
examples: avoid memory leak in tlsproxy

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agosrc: avoid file descriptor leak in socket_open2
Daiki Ueno [Mon, 15 Mar 2021 09:56:46 +0000 (10:56 +0100)] 
src: avoid file descriptor leak in socket_open2

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agognutls-cli-debug: avoid resource leak in saving DHE params
Daiki Ueno [Mon, 15 Mar 2021 09:48:49 +0000 (10:48 +0100)] 
gnutls-cli-debug: avoid resource leak in saving DHE params

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agosrptool: avoid FILE pointer leak on error
Daiki Ueno [Mon, 15 Mar 2021 09:47:50 +0000 (10:47 +0100)] 
srptool: avoid FILE pointer leak on error

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agognulib: update git submodule
Daiki Ueno [Mon, 15 Mar 2021 08:55:20 +0000 (09:55 +0100)] 
gnulib: update git submodule

This brings in the fix for parse-datetime test failures on NetBSD:
https://lists.gnu.org/archive/html/bug-gnulib/2021-03/msg00069.html
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commit;h=35f8ff2e1162bf3ee60d99b6812f2ae10f3f2898

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'oneshot-urandom' into 'master'
Daiki Ueno [Thu, 11 Mar 2021 06:23:03 +0000 (06:23 +0000)] 
Merge branch 'oneshot-urandom' into 'master'

sysrng-linux: re-open /dev/urandom every time

Closes #1188

See merge request gnutls/gnutls!1396

5 years agoMerge branch 'wip/dueno/aggressive-realloc-fixes' into 'master'
Daiki Ueno [Wed, 10 Mar 2021 19:02:59 +0000 (19:02 +0000)] 
Merge branch 'wip/dueno/aggressive-realloc-fixes' into 'master'

Fix issues with AGGRESSIVE_REALLOC

See merge request gnutls/gnutls!1401

5 years agostr: suppress -Wunused-function if AGGRESSIVE_REALLOC is defined
Daiki Ueno [Wed, 10 Mar 2021 15:12:23 +0000 (16:12 +0100)] 
str: suppress -Wunused-function if AGGRESSIVE_REALLOC is defined

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years ago_gnutls_buffer_resize: account for unused area if AGGRESSIVE_REALLOC
Daiki Ueno [Wed, 10 Mar 2021 15:11:29 +0000 (16:11 +0100)] 
_gnutls_buffer_resize: account for unused area if AGGRESSIVE_REALLOC

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoRelease 3.7.1 3.7.1
Daiki Ueno [Wed, 10 Mar 2021 04:06:13 +0000 (05:06 +0100)] 
Release 3.7.1

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agoMerge branch 'wip/dueno/realloc' into 'master'
Daiki Ueno [Wed, 10 Mar 2021 10:20:31 +0000 (10:20 +0000)] 
Merge branch 'wip/dueno/realloc' into 'master'

gnutls_buffer_append_data: avoid use-after-free in the callers

Closes #1151

See merge request gnutls/gnutls!1399

5 years agoMerge branch 'wip/dueno/getcpuid' into 'master'
Daiki Ueno [Wed, 10 Mar 2021 09:37:49 +0000 (09:37 +0000)] 
Merge branch 'wip/dueno/getcpuid' into 'master'

x86: toggle polarity of check_fast_pclmul

See merge request gnutls/gnutls!1400

5 years agopre_shared_key: avoid use-after-free around realloc
Daiki Ueno [Fri, 29 Jan 2021 13:06:50 +0000 (14:06 +0100)] 
pre_shared_key: avoid use-after-free around realloc

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agokey_share: avoid use-after-free around realloc
Daiki Ueno [Fri, 29 Jan 2021 13:06:32 +0000 (14:06 +0100)] 
key_share: avoid use-after-free around realloc

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years ago_gnutls_buffer_resize: add option to use allocation simpler logic
Daiki Ueno [Tue, 9 Mar 2021 12:41:59 +0000 (13:41 +0100)] 
_gnutls_buffer_resize: add option to use allocation simpler logic

This helps detect common mistakes[1] in realloc usage with valgrind,
where the caller assumes that the original ptr is always returned.

1. https://bugzilla.mozilla.org/show_bug.cgi?id=1377618

Signed-off-by: Daiki Ueno <ueno@gnu.org>
Co-authored-by: Alexander Sosedkin <asosedkin@redhat.com>
5 years agox86: flip polarity of check_fast_pclmul
Daiki Ueno [Tue, 9 Mar 2021 19:29:37 +0000 (20:29 +0100)] 
x86: flip polarity of check_fast_pclmul

Otherwise GCC produces the following warnings as the stub
__get_cpuid() is defined as '#define __get_cpuid(...) 0':

x86-common.c: In function 'register_x86_crypto':
x86-common.c:314:15: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
  314 |  family = ((a >> 8) & 0x0F);
      |            ~~~^~~~~
x86-common.c:308:15: note: 'a' was declared here
  308 |  unsigned int a,b,c,d;
      |               ^

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agognutls_buffer_append_data: remove duplicated code
Daiki Ueno [Tue, 9 Mar 2021 12:07:26 +0000 (13:07 +0100)] 
gnutls_buffer_append_data: remove duplicated code

The function shared the same logic as in _gnutls_buffer_resize.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
5 years agolib/nettle: get rid of _rnd_system_entropy_check
Alexander Sosedkin [Mon, 8 Mar 2021 13:56:32 +0000 (14:56 +0100)] 
lib/nettle: get rid of _rnd_system_entropy_check

Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
5 years agolib/global: don't call now-noop _gnutls_rnd_check
Alexander Sosedkin [Mon, 8 Mar 2021 10:54:16 +0000 (11:54 +0100)] 
lib/global: don't call now-noop _gnutls_rnd_check

Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
5 years agosysrng-linux: re-open /dev/urandom every time
Alexander Sosedkin [Thu, 4 Mar 2021 09:54:44 +0000 (10:54 +0100)] 
sysrng-linux: re-open /dev/urandom every time

Prompted by the following comment of Daiki Ueno:
> I also wonder why we keep the fd open for such a long time in the first
> place. Both OpenSSL and NSS have a similar fallback to /dev/urandom
> if getrandom is not available, but opens the device in one-shot,
> when reseeding is needed (and that's pretty rare).
https://gitlab.com/gnutls/gnutls/-/merge_requests/1383#note_521749519

Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
5 years agoMerge branch 'wip/dueno/duplicate-certs-pkcs11' into 'master'
Daiki Ueno [Sat, 6 Mar 2021 07:24:23 +0000 (07:24 +0000)] 
Merge branch 'wip/dueno/duplicate-certs-pkcs11' into 'master'

gnutls_x509_trust_list_verify_crt2: skip duplicated certs for PKCS#11 too

See merge request gnutls/gnutls!1398

5 years agoMerge branch 'fix-id-on-xmppAddr' into 'master'
Daiki Ueno [Fri, 5 Mar 2021 17:42:15 +0000 (17:42 +0000)] 
Merge branch 'fix-id-on-xmppAddr' into 'master'

output UTF-8 decoded id-on-xmppAddr SAN's

See merge request gnutls/gnutls!1397