]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
3 years agoAdd mtu paramter to --fragment and change fragment calculation
Arne Schwabe [Sat, 12 Feb 2022 00:33:31 +0000 (01:33 +0100)] 
Add mtu paramter to --fragment and change fragment calculation

Instead relying on the link_mtu_dynamic field and its calculation
in the frame struct, add a new field max_fragment_size and add
a calculation of it similar to mssfix.

Also whenever mssfix value is calculated, we also want to calculate
the values for fragment as both options need to be calculated from
the real overhead.

Patch v2: Fix syntax in rst man page
Patch v5: fix segfault when get_ip_encap_overhead gets called early in
          init_instance and note that these calls will always be
          overwritten by NCP in tls_session_update_crypto_params

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220212003331.3483107-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23764.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoChange the default for mssfix to mssfix 1492 mtu
Arne Schwabe [Thu, 10 Feb 2022 16:26:26 +0000 (17:26 +0100)] 
Change the default for mssfix to mssfix 1492 mtu

The current default is 1450, which translates to 1478 byte packets for udp4
and 1498 byte packets for udp6. This commit changes the mssfix default
to take the outer IP overhead into account as well and changes the target
to
1492. 1492 was picked in our community meeting for being a very common
encapsulation upper bound.

The change also disables an mssfix default if tun-mtu is set to a value
different than 1500.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220210162632.3309974-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23754.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoReplace TUN_MTU_SIZE with frame->tun_mtu
Arne Schwabe [Thu, 10 Feb 2022 16:26:25 +0000 (17:26 +0100)] 
Replace TUN_MTU_SIZE with frame->tun_mtu

This always uses the configured MTU size instead relying on the calculated
MTU size.

Patch v4: Fix a few overlooked TUN_MTU_SIZE.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220210162632.3309974-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23752.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodoc/Makefile: rebuild rst docs if input files change
Frank Lichtenheld [Thu, 9 Dec 2021 17:11:36 +0000 (18:11 +0100)] 
doc/Makefile: rebuild rst docs if input files change

For now the dependencies are statically defined, which
should be fine and is still a much better solution than
to have no dependencies.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20211209171138.8589-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23369.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agomsvc: cleanup
Lev Stipakov [Tue, 8 Feb 2022 11:49:05 +0000 (13:49 +0200)] 
msvc: cleanup

Remove unused macros for dependency directories,
since dependencies are handled by vcpkg.

Remove unused .bat files.

Reported-by: Frank Lichtenheld <frank@lichtenheld.com>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220208114905.100-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23730.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRepair --inactive with 'bytes' argument larger 2Gbytes.
Gert Doering [Fri, 4 Feb 2022 11:42:01 +0000 (12:42 +0100)] 
Repair --inactive with 'bytes' argument larger 2Gbytes.

--inactive has an optional 2nd parameter specifiying the number of
bytes that need to be sent/received in the given time window.  This
was parsed with atoi(), stored in an 32bit int.  atoi() overflows at
2Gbyte (signed int), which makes gcc return "0" and MSVC "2^31-1"
for the value reported in the ticket (10G) - so on gcc, this was
behaving like "not set", while windows builds after 2.5.4 honoured
this setting, and aborted (unexpectedly) due to "not enough traffic".

Fix by increasing word length of all involved variables to int64_t.

While add it, add option printer SHOW_LONG(), and print variable.

This has the potential to break existing setups where this value is
set unreasonably high, thus "impossible to achieve in the interval",
but which was never noticed before due to "overflow, 0, ignored".
Thus, print WARNING if a value >INT_MAX (2Gbyte) is configured.

v2: use atoll(), as atol() is limited to INT_MAX on MSVC, and PRi64
for format string.  Rename SHOW_LONG() to SHOW_INT64().

Trac: #1448

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20220204114201.5632-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23720.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agocrypto: move OpenSSL specific FIPS check to its backend
Antonio Quartulli [Thu, 3 Feb 2022 19:36:55 +0000 (20:36 +0100)] 
crypto: move OpenSSL specific FIPS check to its backend

Our crypto API already provides a function performing a validity check
on the specified ciphername. The OpenSSL counterpart also checks for the
cipher being FIPS-enabled.

This API is cipher_valid(). Extend it so that it can provide a reason
whenever the cipher is not valid and use it in crypto.c.

This way we move any OpenSSL specific bit to its own
backend and directly use the new cipher_valid_reason() API in the
generic code.

This patch fixes compilations with mbedTLS when some OpenSSL is also
installed. The issue was introduced with:
544330fe ("crypto: Fix OPENSSL_FIPS enabled builds")

Cc: David Sommerseth <davids@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20220203193655.28791-2-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23714.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agocrypto: move validation logic from cipher_get to cipher_valid
Antonio Quartulli [Thu, 3 Feb 2022 19:36:54 +0000 (20:36 +0100)] 
crypto: move validation logic from cipher_get to cipher_valid

With cipher validation performed in cipher_get(), a cipher is never
returned in any case if some check fails.

This prevents OpenVPN from operating on all ciphers provided by the SSL
library, like printing them to the user.

Move the validation logic to cipher_valid() so that checks are performed
only when OpenVPN really want to know if a cipher is usable or not.

Fixes: ce2954a0 ("Remove cipher_kt_t and change type to const char* in
API")
Cc: Arne Schwabe <arne@rfc2549.org>
Cc: David Sommerseth <davids@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20220203193655.28791-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23713.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove link_mtu parameter when running up/down scripts
Arne Schwabe [Sat, 1 Jan 2022 16:25:26 +0000 (17:25 +0100)] 
Remove link_mtu parameter when running up/down scripts

The link mtu is no longer used and calculating a compatibility link
MTU just for scripts makes little sense as well. Replace the parameter
instead with a fixed parameter 0.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220101162532.2251835-9-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23493.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agokeyingmaterialexporter.c: include strings.h
Antonio Quartulli [Thu, 3 Feb 2022 08:26:20 +0000 (09:26 +0100)] 
keyingmaterialexporter.c: include strings.h

strcasecmp() was initially declared in string.h and subsequently moved
to strings.h. For historical reasons it still exists in string.h, but
would require _DEFAULT_SOURCE to be defined.

Due to the above, just include strings.h as currently dictated by the
manpage.

Fixes the following warning:

keying-material-exporter-demo/keyingmaterialexporter.c:155:14: warning:
implicit declaration of function  strncasecmp’; did you mean ‘strncmp’?
[-Wimplicit-function-declaration]
  155 |         if (!strncasecmp(objbuf, "CN", 2))
      |              ^~~~~~~~~~~
      |              strncmp

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220203082620.8186-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23702.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agopkcs11_openssl.c: check EVP_get_digestbyname() != NULL
Selva Nair [Thu, 27 Jan 2022 00:14:10 +0000 (19:14 -0500)] 
pkcs11_openssl.c: check EVP_get_digestbyname() != NULL

Reported-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20220127001410.7587-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23680.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoImplement optional mtu parameter for mssfix
Arne Schwabe [Sat, 1 Jan 2022 16:25:23 +0000 (17:25 +0100)] 
Implement optional mtu parameter for mssfix

The current mssfix parameter is a bit difficult to use as it needs
manual calculation of the allowable packet size and also the resulting
MSS value does not take into account if IPv4 or IPv6 is used on the
outer tunnel.  Add 'mtu' parameter to fix both of these problem by
dynamically including the real overhead.

The syntax and naming of the parameter is chosen for compatiblity with
OpenVPN3.

Patch V2: document mssfix 0 disabling mssfix, fix rst syntax

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220101162532.2251835-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23495.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agomsvc: switch to openssl3
Lev Stipakov [Wed, 26 Jan 2022 12:35:02 +0000 (14:35 +0200)] 
msvc: switch to openssl3

Add openssl3 vcpkg port, which is slightly modified version of
openssl1.1.1 port from official vcpkg repo.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20220126123502.403-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23662.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix datagram_overhead and assorted functions
Arne Schwabe [Sat, 1 Jan 2022 16:25:22 +0000 (17:25 +0100)] 
Fix datagram_overhead and assorted functions

This function is supposed to calculate the overhead of the protocol
header (IP/IPv6 + TCP/UDP). But at some point the index that used
to index the array proto_overhead and the associated PROTO_N went
completely out of sync. This fixed the function and related caller
to again calculate the overhead as intended.

Note that IPv6 mapped IPv4 addresses still have the wrong overhead
calculated as they treated are as IPv6 addresses (0:0:0:0:0:ffff::/96)

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220101162532.2251835-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23504.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoChange buffer allocation calculation and checks to be more static
Arne Schwabe [Mon, 24 Jan 2022 02:54:59 +0000 (03:54 +0100)] 
Change buffer allocation calculation and checks to be more static

Currently we use half dynamic buffer sizes where we use have a fixed
overhead for crypto (crypto_max_overhead) but use a dynamic overhead
for the the other small header sizes.

Patch v3: rebase
Patch v4: add size of ack array to control channel frame size
Patch v5: fix calculation of compression overhead calculated over 0 instead
          of payload size

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220124025459.1042317-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23638.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix mssfix and frame calculation in CBC mode
Arne Schwabe [Sat, 1 Jan 2022 16:25:20 +0000 (17:25 +0100)] 
Fix mssfix and frame calculation in CBC mode

This commit fixes the MSS calculation in CBC mode. This fix has two parts:

- Added rounding to a multiple of block size during calculation of overhead
- In CBC mode the packet ID is part of the plaintext (or payload) rather
  than part of the header (like for AEAD), adjust the functions to
  correctly reflect this.

OCC link calculation is not affected since it ignores rounding of CBC
block size completely.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220101162532.2251835-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23494.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoDeprecate link-mtu
Arne Schwabe [Sat, 1 Jan 2022 16:25:19 +0000 (17:25 +0100)] 
Deprecate link-mtu

This options might have been useful in the past but nowadays it has a very
unclear semantics, so better remove/deprecate it.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220101162532.2251835-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23496.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix a potential memory leak in tls_ctx_use_management_external_key
Selva Nair [Thu, 20 Jan 2022 16:26:45 +0000 (11:26 -0500)] 
Fix a potential memory leak in tls_ctx_use_management_external_key

Reported-By: Gert Doering <gert@greenie.muc.de>
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220120162645.13881-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23610.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoDo not error when md_kt_size() is called with mdname="none"
Selva Nair [Fri, 21 Jan 2022 18:57:52 +0000 (13:57 -0500)] 
Do not error when md_kt_size() is called with mdname="none"

An easy way to trigger this error is to run an otherwise working setup
(at say verb = 4) with increased verbosity of verb >= 7 and using a GCM
cipher (e.g., AES-256-GCM). It will cause a fatal exit while printing the
cipher and hmac in key2_print().

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220121185752.14138-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23631.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoxkey: fix msvc build
Lev Stipakov [Fri, 21 Jan 2022 05:22:58 +0000 (07:22 +0200)] 
xkey: fix msvc build

 - use sizeof(void *) since msvc doesn't support sizeof of function ptr

 - use XKEY_PROV_PROPS macro instead of props since msvc
  requires constant expression in aggregate initializers

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20220121052259.508-2-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23643.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoSupport PSS signing using pkcs11-helper >= 1.28
Selva Nair [Tue, 25 Jan 2022 02:51:28 +0000 (21:51 -0500)] 
Support PSS signing using pkcs11-helper >= 1.28

- Call pkcs11h_certificate_signAny_ex() when available
  so that the signature mechanism parameters can be pased.
  (Required for RSA-PSS signature).

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220125025128.2117-3-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23647.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix max saltlen calculation in cryptoapi.c
Selva Nair [Tue, 25 Jan 2022 02:51:27 +0000 (21:51 -0500)] 
Fix max saltlen calculation in cryptoapi.c

(nbits - 1)/8 should have been rounded up. Fix and move it to
an inlined function for reuse in pkcs11_openssl.c (used in the
next commit).

Note: The error is not triggered in normal use as OpenSSL
always seems to use saltlen="digest" for signing.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220125025128.2117-2-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23648.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoxkey: Use a custom error level for debug messages
Selva Nair [Tue, 25 Jan 2022 02:51:26 +0000 (21:51 -0500)] 
xkey: Use a custom error level for debug messages

D_XKEY = loglev(6, 69, M_DEBUG) is defined and used for
all low level debug messages  from xkey_provider.c and
xkey_helper.c

As suggested by Arne Schwabe <arne@rfc2549.org>

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220125025128.2117-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23649.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoupdate copyright year to 2022
Antonio Quartulli [Tue, 25 Jan 2022 14:24:56 +0000 (15:24 +0100)] 
update copyright year to 2022

Update performed by means of: dev-tools/update-copyright.sh

Cc: David Sommerseth <davids@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20220125142456.18176-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23650.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agounit-test: fix test_crypto when USE_COMP is not defined
Antonio Quartulli [Fri, 21 Jan 2022 14:43:13 +0000 (15:43 +0100)] 
unit-test: fix test_crypto when USE_COMP is not defined

This unit-test did not consider the case when USE_COMP is not defined,
thus generating a compiler error.

Adapt the test to the case when no compression is available.

Cc: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220121144313.24961-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23628.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoGitHub Actions: add other config flavours
Antonio Quartulli [Fri, 21 Jan 2022 13:39:00 +0000 (14:39 +0100)] 
GitHub Actions: add other config flavours

In the past we had issues with patches accidentally breaking less common
OpenVPN configurations. For this reason it makes sense to some of those
configurations build via CI.

Adding:
* --enable-iproute2
* --enable-async-push
* --disable-management
* --enable-small
* --disable-lzo --disable-lz4

These flavours are all built on Ubuntu 20.04 with OpenSSL 1.1.1

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220121133900.14567-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23624.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agovcpkg-ports/pkcs11-helper: indicate OpenSSL EC support
Lev Stipakov [Tue, 11 Jan 2022 15:06:47 +0000 (17:06 +0200)] 
vcpkg-ports/pkcs11-helper: indicate OpenSSL EC support

We always build with OpenSSL >= 1.1.1, which has EC support.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220111150647.267-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23527.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agovcpkg-ports/pkcs11-helper: bump to release 1.28
Lev Stipakov [Tue, 11 Jan 2022 15:06:05 +0000 (17:06 +0200)] 
vcpkg-ports/pkcs11-helper: bump to release 1.28

This release has merged openssl 1.1.1 support patch,
so our own patch could be removed from the port.

Remove unconditional /release flag, which is added by vcpkg
for release builds. Having this flag unconditionally breaks vcpkg
debug builds.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220111150605.208-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23526.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agotun: remove tun_finalize()
Lev Stipakov [Mon, 17 Jan 2022 09:49:17 +0000 (11:49 +0200)] 
tun: remove tun_finalize()

tun_finalize() is essentially subset of socket_finalize() apart from:

 - using WSAFoo() functions instead of Foo()

 - "from" address is not returned

There is no clear official statement that one can use non-WSA
API on handles, so let's be on a safe side and use both.

Introduce sockethandle_t abstraction, which represents
socket and handle. Add SocketHandle* routines which call
proper API depends on underlying type in abstraction.

Rename socket_finalize() to sockethandle_finalize(), take
sockethandle_t and new routines into use and kick tun_finalize().

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20220117094917.178-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23555.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agocrypto: Fix OPENSSL_FIPS enabled builds
David Sommerseth [Wed, 19 Jan 2022 18:21:26 +0000 (19:21 +0100)] 
crypto: Fix OPENSSL_FIPS enabled builds

On Fedora and RHEL/CentOS, the standard OpenSSL library has the FIPS
module enabled by default.  On these platforms, the OPENSSL_FIPS macro
is always defined via /usr/include/openssl/opensslconf-*.h.

Without this fix, the following compilation error appears:

  ./src/openvpn/crypto.c: In function ‘print_cipher’:
  ./src/openvpn/crypto.c:1707:43: error: ‘cipher’ undeclared (first use in
this function); did you mean ‘iphdr’?
       if (FIPS_mode() && !(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_FIPS))
                                           ^~~~~~
The EVP_CIPHER_fetch() and EVP_CIPHER_free() methods are also provided
via the openssl_compat.h for older than OpenSSL 3.0.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220119182126.56880-1-openvpn@sf.lists.topphemmelig.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23570.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAdd a unit test for external key provider
Selva Nair [Thu, 20 Jan 2022 16:16:16 +0000 (11:16 -0500)] 
Add a unit test for external key provider

Tests:
- Check SIGNATURE and KEYMGMT methods can be fetched
  from the provider
- Load sample RSA and EC keys as management-external-key
  and check that their sign callbacks are correctly exercised:
  with and without digest support mocked in the client
  capability flag.
 -Test generic key load and signature

v4: 16/18 and 17/18 of v3 squashed into one patch

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220120161616.13447-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23608.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoEnable signing using CNG through xkey provider
Selva Nair [Tue, 14 Dec 2021 16:59:25 +0000 (11:59 -0500)] 
Enable signing using CNG through xkey provider

- Add xkey_cng_sign() as sign_op for the provider
  and load the key using xkey_generic_load.

- Enable/Disable old code when provider is available or not.

- xkey_digest is made non-static for use in cryptoapi.c

One function cng_padding_type() is moved down to reduce number
of ifdef's.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-16-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23444.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agopkcs11: Interface the xkey provider with pkcs11-helper
Selva Nair [Tue, 14 Dec 2021 16:59:24 +0000 (11:59 -0500)] 
pkcs11: Interface the xkey provider with pkcs11-helper

- Load the 'private key' handle through the provider and set it in
  SSL_CTX
- Add a sign op function to interface provider with pkcs11-helper.
  Previously we used its "OpenSSL Session" which internally sets up
  callbacks in RSA and EC key methods. Not useful for the provider
  interface, so, we directly call the PKCS#11 sign operation
  as done with mbedTLS.
- tls_libctx is made global for accessing from pkcs11_openssl.c

  Supports ECDSA and RSA_PKCS1_PADDING signatures. PSS support
  will be added when pkcs11-helper with our PR for specifying
  CK_MECHANISM variable in sign operations is released.
  (i.e., next release of pkcs11-helper).

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-15-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23442.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAdd a generic key loading helper function for xkey provider
Selva Nair [Tue, 14 Dec 2021 16:59:23 +0000 (11:59 -0500)] 
Add a generic key loading helper function for xkey provider

- Load keys by specifying the opaque private key handle,
  public key, sign-op and free-op required for loading keys
  from Windows store and pkcs11.

- xkey_load_management_key is refactored to use the new function

- Also make xkey_digest non-static

Used in following commits to load CNG and pkcs11 keys

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-14-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23436.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoIncrease ERR_BUF_SIZE when management interface support is enabled
Selva Nair [Tue, 14 Dec 2021 16:59:22 +0000 (11:59 -0500)] 
Increase ERR_BUF_SIZE when management interface support is enabled

Sending largish messages to the management interface errors due to
the limited size used for the "error" buffer in x_msg_va(). Although
all intermediate steps allocate required space for the data to
send, it gets truncated at the last step.

This really requires a smarter fix. As a quick relief, we just increase
the buffer size to 10240 when management support is compiled in. Should
be enough for PK_SIGN with undigested message.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-13-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23440.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoSupport sending DigestSign request to management client
Selva Nair [Tue, 14 Dec 2021 16:59:21 +0000 (11:59 -0500)] 
Support sending DigestSign request to management client

To receive undigested message for signing, indicate support
for handling message digesting in the client using an argument
"digest" to --management-external-key.

For example, to announce pkcs1 padding and digesting support use:

--management-external-key pkcs1 pss digest

In PK_SIGN, the algorithm string will get data=message
in addition to other relevant options.

Note that it is not guaranteed that the client will be prompted
with undigested message. This is possible only when OpenSSL
calls our provider for DigestSign() as opposed to Sign(). In
practice, signature operation always appears to result in
a DigestSign() call through the provider interface.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-12-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23435.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRespect algorithm support announced by management client
Selva Nair [Tue, 14 Dec 2021 16:59:20 +0000 (11:59 -0500)] 
Respect algorithm support announced by management client

Support for padding algorithms in management-client is indicated
in the optional argument to --management-external-key as "pkcs1",
"pss" etc. We currently use it only for an early exit based on heuristics
that a required algorithm may not be handled by the client. When
signature is requested we do not check whether the padding is indeed
supported by the client. This leads to situations like the client
announcing "nopadding" support but we request "pss" signature.

Here we add a check while requesting signature as well. If the padding
treat it as an error instead of submitting the request to the
management-interface regardless.

This change is made only when xkey provider is in use, though such a check
would be appropriate always.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-11-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23441.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAllow management client to announce pss padding support
Selva Nair [Tue, 14 Dec 2021 16:59:19 +0000 (11:59 -0500)] 
Allow management client to announce pss padding support

The --management-external-key option can currently indicate support
for 'nopadding' or 'pkcs1' signatures in the client. Add 'pss' as an
option to announce that PSS signing requests are accepted.

To match, extend the algorithm string in PK_SIGN request to
include the following format:

- RSA_PKCS1_PSS_PADDING,hashalg=name,saltlen=[max|digest]

Here 'name' is the short common name of the hash algorithm.
E.g., SHA1, SHA256 etc.

Existing formats 'ECDSA' and 'RSA_PKCS1_PADDING' are unchanged.

v2 changes: Fix typos and other sloppiness in documentation and
commit message.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-10-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23430.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAdd a function to encode digests with PKCS1 DigestInfo wrapper
Selva Nair [Tue, 14 Dec 2021 16:59:18 +0000 (11:59 -0500)] 
Add a function to encode digests with PKCS1 DigestInfo wrapper

The EVP_PKEY interface as well as provider passes the raw
digest to the sign() function. In case of RSA_PKCS1,
our management interface expects an encoded hash, which
has the DigestInfo header added as per PKCSv1.5 specs,
unless the hash algorithm is legacy MD5_SHA1.

Fix this by
 - add a function to perform the pkcs1 encoding before passing the
   data to sign to the management interface. The implementation
   is not pretty, but should work.
   (Unfortunately OpenSSL does not expose a function for this).

Note:
1. cryptoki interface used by pkcs11-helper also requires this to be
   done before calling the Sign op. This will come handy there too.
2. We have a similar function in ssl_mbedtls.c but its not prettier,
   and require porting.

v2 changes: Use hard-coded headers for known hash algorithms instead
of assembling it from the ASN.1 objects.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-9-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23433.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoEnable signing via provider for management-external-key
Selva Nair [Tue, 14 Dec 2021 16:59:17 +0000 (11:59 -0500)] 
Enable signing via provider for management-external-key

- Add a function to set as sign_op during key import. The
  function passes the signature request to management interface,
  and returns the result to the provider.

v2 changes: Method to do digest added to match the changes in
            the provider signature callback.
TODO:
 - Allow passing the undigested message to management interface
 - Add pkcs1 DigestInfo header when required

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-8-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23428.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAdd xkey_provider sources and includes to MSVC project
Selva Nair [Tue, 14 Dec 2021 16:59:28 +0000 (11:59 -0500)] 
Add xkey_provider sources and includes to MSVC project

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-19-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23445.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoA helper function to import private key for management-external-key
Selva Nair [Tue, 14 Dec 2021 16:59:16 +0000 (11:59 -0500)] 
A helper function to import private key for management-external-key

- Leverage keymgmt_import through EVP_PKEY_new_fromdata() to
  import "management-external-key"

- When required, use this to set SSL_CTX_use_PrivateKey

The sign_op is not implemented yet. This will error out while
signing with --management-external-key. The next commit
fixes that.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-7-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23443.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoInitialize the xkey provider and use it in SSL context
Selva Nair [Tue, 14 Dec 2021 16:59:15 +0000 (11:59 -0500)] 
Initialize the xkey provider and use it in SSL context

- Add function to check when external key is in use

- Load xkey provider into a custom library context when required

- Use the custom libctx in SSL CTX when external key is in use

As no keys are yet loaded through the provider,
no functionality gets delegated to it as yet.

v2 changes: Provider loading is reworked to activate only when external
            keys are in use
            This was 2/9 in v1

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-6-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23432.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoImplement import of custom external keys
Selva Nair [Tue, 14 Dec 2021 16:59:14 +0000 (11:59 -0500)] 
Implement import of custom external keys

  Our key object retains info about the external
  key as an opaque handle to the backend. We also
  need the public key as an EVP_PKEY *.

  For native keys we use OpenSSL API to import
  data into the key. The 'handle' representing the
  private key in that case is the OpenSSL EVP_PKEY
  object itself.

  For importing custom keys, we define custom
  parameters describing the key using OSSL_PARAM
  structure. We define 4 required and 1 optional
  parameters for loading the key:

  Required params of type OSSL_PARAM:

  {.key="xkey-origin", .data_type = OSSL_PARAM_UTF8_STRING
   .data = "foobar", .data_size = 0 }

  Note: data_size = 0 refer to NUL terminated string in OpenSSL.
  This parameter is only used to identify that the key as non-native
  with an opaque handle. We really do not check the content of
  the string. Should not be NULL.

  {.key="handle", .data_type = OSSL_PARAM_OCTET_PTR,
   .data = &handle, .data_size = sizeof(handle)}

  {.key="pubkey", .data_type = OSSL_PARAM_OCTET_STRING,
   .data = &pubkey, .data_size = sizeof(pubkey)}

  {.key="sign_op", .data_type = OSSL_PARAM_OCTET_PTR,
   .data = &sign_op_ptr, .data_size = sizeof(sign_op_ptr)}

  Optional param:

  {.key="free_op", .data_type = OSSL_PARAM_OCTET_PTR,
   .data = &free_op_ptr, .data_size = sizeof(free_op_ptr)}

  The 'handle' is opaque to us and is retained. The caller
  should not free it. We will free it when no longer required
  by calling 'free_op()', if provided. The 'handle' should
  not be NULL as that indicates missing private key.

  The 'pubkey' must be an 'EVP_PKEY *' variable, and is duplicated
  by us. The caller may free it after return from import.

  The 'sign_op' and 'free_op' function pointers should be of type
  'XKEY_EXTERNAL_SIGN_fn' and 'XKEY_PRIVKEY_FREE_fn' defined
  in xkey_common.h

For example, for management-external-key, we really do not
need any 'handle'. Pass anything that will live long and
won't dereference to NULL. We do not use it for any other
purpose. Pointer to a const string could be a choice.
In this case, free_op = NULL is the safest choice.

For a usage of keymgmt_import(), see the helper function
implemented using it to load the management key in the next commit.

v2 changes: "origin" --> "xkey-origin"
            This was 5/9 in v1

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-5-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23439.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoImplement SIGNATURE operations in xkey provider
Selva Nair [Tue, 14 Dec 2021 16:59:13 +0000 (11:59 -0500)] 
Implement SIGNATURE operations in xkey provider

- Basic frame work for announcing support for signature
  operations

- DigestSign and Sign functions for native keys are also
  implemented.  Though strictly not needed, these functions
  for native keys sets up the framework for signature operations.
  They also help loading an exportable key from a file through
  the provider for testing.

  Subsequent commits will add support for signing with
  external keys.

v2 changes:
  - Remove verify operations which are no longer
    required with proposed changes in OpenSSL 3.0.1 that we target.

  - Undigested message is passed to the backend sign operation when
    possible. This would allow more flexibility as some backends
    prefer to do the hash operation internally.

  This was 4/9 in v1

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-4-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23437.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoImplement KEYMGMT in the xkey provider
Selva Nair [Tue, 14 Dec 2021 16:59:12 +0000 (11:59 -0500)] 
Implement KEYMGMT in the xkey provider

A minimal set of functions for keymgmt are implemented.
No support for external key import as yet, only native
keys. Support for native keys is required as keys may
get imported into us for some operations as well as
for comparison with unexportable external keys that we hold.

Implementation of signature callbacks is in the next commit.

v2 changes: This was commit 3/9 in v1
v3 changes: When OpenSSL native key is imported instead of duplicating
the whole key, use only the public components for public key.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-3-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23438.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoA built-in provider for using external key with OpenSSL 3.0
Selva Nair [Tue, 14 Dec 2021 16:59:11 +0000 (11:59 -0500)] 
A built-in provider for using external key with OpenSSL 3.0

Hooking into callbacks in RSA_METHOD and EVP_PKEY_METHOD
structures is deprecated in OpenSSL 3.0. For signing with
external keys that are not exportable (tokens, stores, etc.)
requires a custom provider interface so that key operations
are done under its context.

A single provider is enough for handling all external keys
we support -- management-external-key, cryptoapicert(CNG) and
pkcs11-helper. The series of patches starting with this implement
such a provider.

This patch implements only the provider_init function so
that it can be loaded, but has no capabilities. The required
interfaces are added in following commits.

v2 changes:
 - Require OpenSSL 3.0.1 or newer: 3.0.0 is "buggy" as it
   does not preferentially fetch operations from the keymgmt
   of the key. This causes either an unsuccessful attempt at
   exporting unexportable keys or an onerous requirement that
   the external key's KEYMGMT should support a whole lot
   of unrelated functionalities including key generation and
   key exchange.
   Fixed by PR #16725 in OpenSSL.
 - Use a child libctx for internal use in the provider

v3 changes:
 - Move OpenSSL version check for 3.0.1+ from configure to
   xkey_common.h

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211214165928.30676-2-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23446.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agouse 'static inline' instead of 'inline static'
Antonio Quartulli [Mon, 17 Jan 2022 09:35:08 +0000 (10:35 +0100)] 
use 'static inline' instead of 'inline static'

There are 2 occurrences where the order 'inline static' is used when
defining a function, while the rest of the code uses the definitely
more common form 'static inline'.

Convert those 2 occurrences to the common format.

Reported-by: Lev Stipakov <lev@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20220117093508.17681-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23554.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove BUFFER_LIST_AGGREGATE_TEST test code
Arne Schwabe [Sat, 1 Jan 2022 16:06:32 +0000 (17:06 +0100)] 
Remove BUFFER_LIST_AGGREGATE_TEST test code

This code has been dead for years and also does not seem that
useful anymore since we already have a proper unit_test for the
buffer code.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220101160632.2250072-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23492.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agossl.c: use arrow operator to access object member
Antonio Quartulli [Mon, 10 Jan 2022 14:45:10 +0000 (15:45 +0100)] 
ssl.c: use arrow operator to access object member

The arrow operator exists exactly to perform a pointer dereference
implicitly
while accessing a member.

while at it, add whitespaces around the '-' operator on the same line.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220110144510.17769-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23521.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoGitHub Actions: ensure Ubuntu builds are made with the chosen SSL library
Antonio Quartulli [Fri, 14 Jan 2022 12:25:38 +0000 (13:25 +0100)] 
GitHub Actions: ensure Ubuntu builds are made with the chosen SSL library

The configure parameter was appended to the stage name but not to the
actual command. Fix this.

Cc: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220114122538.24662-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23539.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agosig.c: define signal_handler on non-windows only
Antonio Quartulli [Thu, 13 Jan 2022 10:14:34 +0000 (11:14 +0100)] 
sig.c: define signal_handler on non-windows only

signal_handler() is unused on Windows and generates a warning.
Confine it within "ifdef _WIN32" in order to reduce the compilation
noise.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220113101434.30223-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23530.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodoc: remove PF leftovers from documentation
Antonio Quartulli [Thu, 13 Jan 2022 20:00:30 +0000 (21:00 +0100)] 
doc: remove PF leftovers from documentation

PF (Packet Filter) has been dropped from the OpenVPN code base, however
some bits and pieces are left in the documentation.

Erase them all.

Reported-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220113200030.18656-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23531.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodoc/cipher-negotiation.rst: avoid warning by fixing indentation
Antonio Quartulli [Mon, 10 Jan 2022 14:40:13 +0000 (15:40 +0100)] 
doc/cipher-negotiation.rst: avoid warning by fixing indentation

Indentation is wrong and triggers the following:

rst2man.py openvpn.8.rst > openvpn.8
man-sections/cipher-negotiation.rst:20: (WARNING/2) Definition list ends
without a blank line; unexpected unindent.
rst2man.py openvpn-examples.5.rst > openvpn-examples.5
rst2html.py openvpn.8.rst > openvpn.8.html
man-sections/cipher-negotiation.rst:20: (WARNING/2) Definition list ends
without a blank line; unexpected unindent.

Get rid of it.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220110144013.7233-1-a@unstable.cc>
URL: https://www.mail-archive.com/search?l=mid&q=20220110144013.7233-1-a@unstable.cc
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoauth_token.c: add NULL initialization
Lev Stipakov [Fri, 7 Jan 2022 12:35:50 +0000 (14:35 +0200)] 
auth_token.c: add NULL initialization

This fixes

  error C4703: potentially uninitialized local pointer variable
'b64output' used

found by arm64 msvc compiler with SDL enabled.

Not sure why this is not triggered on x86/x64.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220107123550.188-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23511.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemoved error message for an option flag not supported with --server-ipv6
Camille Guérin [Wed, 29 Dec 2021 10:29:24 +0000 (11:29 +0100)] 
Removed error message for an option flag not supported with --server-ipv6

Signed-off-by: Camille Guerin <guerincamille56@gmail.com>
Closes: OpenVPN/openvpn#164
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20211229102924.8901-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23471.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove pointless do_init_frame_tls function
Arne Schwabe [Tue, 7 Dec 2021 17:02:01 +0000 (18:02 +0100)] 
Remove pointless do_init_frame_tls function

This function is static and just calls another functions.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20211207170211.3275837-12-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23337.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRework occ link-mtu calculation
Arne Schwabe [Thu, 30 Dec 2021 17:21:36 +0000 (18:21 +0100)] 
Rework occ link-mtu calculation

Use the functions that directly compute the link mtu instead relying on the
frame logic.

Patch V2: rebase on master

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211230172136.2017215-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20211230172136.2017215-1-arne@rfc2549.org
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoDecouple MSS fix calculation from frame calculation
Arne Schwabe [Tue, 14 Dec 2021 15:09:01 +0000 (16:09 +0100)] 
Decouple MSS fix calculation from frame calculation

This consolidates the MSS fix calculation into a single function
instead having it distributed all over the code. It also calculates
the real wire overhead without extra sizes for buffer etc.

Patch v2: improve comment

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20211214150901.4118886-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23423.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAdd helper functions to calculate header/payload sizes
Arne Schwabe [Wed, 29 Dec 2021 16:34:45 +0000 (17:34 +0100)] 
Add helper functions to calculate header/payload sizes

These functions are intended to lay the groundwork to later replace
the distributed frame calculations and centralise the calculation in
one place.

Patch v2.2: clarify that the socks comments is assuming IPv4 and improve
            other comments

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211229163445.1893687-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23476.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agooptions.c: fix version reported in --cipher warning message
Antonio Quartulli [Wed, 29 Dec 2021 17:27:14 +0000 (18:27 +0100)] 
options.c: fix version reported in --cipher warning message

BF-CBC is the default value for the --cipher option in OpenVPN <2.5
and not <2.6. However, the warning printed to screen talks about
"OpenVPN before 2.6", which is wrong and needs to be fixed.

Fix message by saying ".. before 2.5"

Cc: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211229172714.6424-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23477.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoMake github actions names nicer, include Ubuntu18+OpenSSL 1.0.2
Arne Schwabe [Wed, 15 Dec 2021 12:34:49 +0000 (13:34 +0100)] 
Make github actions names nicer, include Ubuntu18+OpenSSL 1.0.2

Also let other variants finish if one fails (fail-fast: false)

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211215123449.53818-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23452.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove post_open_mtu code
Arne Schwabe [Tue, 7 Dec 2021 17:01:56 +0000 (18:01 +0100)] 
Remove post_open_mtu code

This code is probably from a time when we could not set the MTU on
the Windows tap6 driver. Nowadays we can set the MTU on this device,
so this code is a noop now.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211207170211.3275837-7-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23327.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoDocument frame related function and variables a bit more
Arne Schwabe [Tue, 7 Dec 2021 17:01:55 +0000 (18:01 +0100)] 
Document frame related function and variables a bit more

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20211207170211.3275837-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23332.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix triggering assertion of ks->authenticated after tls_deauthenticate
Arne Schwabe [Tue, 7 Dec 2021 17:01:54 +0000 (18:01 +0100)] 
Fix triggering assertion of ks->authenticated after tls_deauthenticate

When tls_deauthenticate is called (e.g. by management kicking of a client)
the key auth state is changed to KS_AUTH_FALSE while the key state is
still in S_GENERATED_KEYS. This triggers the assertion.

Remove the assertions and instead check that the auth state is KS_AUTH_TRUE

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211207170211.3275837-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23340.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove align_adjust frame code
Arne Schwabe [Tue, 7 Dec 2021 17:01:53 +0000 (18:01 +0100)] 
Remove align_adjust frame code

The align_adjust variable was only set to a non-zero value when
no cipher was used for the data channel. Since we no longer want to
optimise non encrypted data channel traffic, remove this optimisation
and simplify the code.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211207170211.3275837-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23331.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoInitialise kt_cipher even when no crypto is enabled
Arne Schwabe [Wed, 1 Dec 2021 18:07:27 +0000 (19:07 +0100)] 
Initialise kt_cipher even when no crypto is enabled

This avoids special casing the cipher none/auth none case in other
parts, e.g. in the upcoming buffer/frame rework.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211201180727.2496903-9-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23272.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove md_kt_t and change crypto API to use const char*
Arne Schwabe [Mon, 13 Dec 2021 15:06:54 +0000 (16:06 +0100)] 
Remove md_kt_t and change crypto API to use const char*

As with the removal of cipher_kt_t, this is allows better support of
OpenSSL 3.0 and mbed TLS 3.0

Patch v2: rebase

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211213150654.3993358-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20211213150654.3993358-2-arne@rfc2549.org
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAdjust cipher-negotiation.rst with compat-mode changes
Arne Schwabe [Mon, 13 Dec 2021 15:25:29 +0000 (16:25 +0100)] 
Adjust cipher-negotiation.rst with compat-mode changes

This explains that 2.6 will ignore --cipher without --compat-mode and
restructures the whole paragraph to better readable.

Patch V2: Adjust grammar, use consistently "and later"

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20211213152529.3995394-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23403.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoMove deprecation of SWEET32/64bit block size ciphers to 2.7
Arne Schwabe [Mon, 13 Dec 2021 15:09:50 +0000 (16:09 +0100)] 
Move deprecation of SWEET32/64bit block size ciphers to 2.7

We originally wanted to deprecated these ciphers (especially BF-CBC) with
2.6 but currently these ciphers are still too widespread to make this
transition for 2.6.

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211213150950.3993881-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23402.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove cipher_kt_t and change type to const char* in API
Arne Schwabe [Mon, 13 Dec 2021 15:06:53 +0000 (16:06 +0100)] 
Remove cipher_kt_t and change type to const char* in API

Make the external crypto consumer oblivious to the internal cipher
type that both mbed TLS and OpenSSL use. This change is mainly done
so the cipher type that is used can be stay a const type but instead
of an SSL library type, we now use a simple string to identify a
cipher. This has the disadvantages that we do a cipher lookup every
time a function is called that needs to query properties of a cipher.
But none of these queries are in a critical path.

This patch also fixes the memory leaks introduced by the
EVP_fetch_cipher commit by always freeing the EVP_CIPHER.

This also changes kt->cipher to be always defined with the name of
the cipher. This only affects the "none" cipher cipher which was
previously represented by kt->cipher to be NULL.

Patch v2: rebase on master

Patch v3: fix errors with mbed TLS without having md_kt to const char *
          patch also applied, fix logic inversion in tls_crypt_tk

Patch v4: fix issue if cipher does not get changed by NCP that null cipher
          is then used

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211213150654.3993358-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20211213150654.3993358-1-arne@rfc2549.org
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoconfig-msvc.h: indicate key material export support
Lev Stipakov [Mon, 13 Dec 2021 13:52:53 +0000 (15:52 +0200)] 
config-msvc.h: indicate key material export support

MSVC build uses OpenSSL from vcpkg, which at the moment
is 1.1.1l. Key material export was added to 1.1.1, so it is safe
to indicate its support unconditionally.

This enables Windows releases to benefit from tls-ekm
data channel keys derivation.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211213135253.212-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23394.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoadd test case(s) to notice 'openvpn --show-cipher' crashing
Gert Doering [Fri, 10 Dec 2021 16:55:43 +0000 (17:55 +0100)] 
add test case(s) to notice 'openvpn --show-cipher' crashing

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20211210165543.77587-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23381.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoMove '--push-peer-info' documentation from 'server' to 'client options'
Gert Doering [Tue, 7 Dec 2021 13:04:36 +0000 (14:04 +0100)] 
Move '--push-peer-info' documentation from 'server' to 'client options'

While --push-peer-info can be configured on the server, it's not really
intended for that, and it ended in the "SERVER OPTIONS" section by
mishap.  Fix that.

Reported-by: Stella Ashburne <rewefie@gmx.com>
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20211207130436.22187-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23325.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAdd argv_insert_head__empty_argv__head_only to argv tests
Arne Schwabe [Wed, 8 Dec 2021 17:06:14 +0000 (18:06 +0100)] 
Add argv_insert_head__empty_argv__head_only to argv tests

The unit test argv_insert_head__empty_argv__head_only was defined
but never used. Add it to the array of unit tests.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211208170614.3404821-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23359.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoDon't use BF-CBC in unit tests if we don't have it
Max Fillinger [Wed, 8 Dec 2021 13:46:55 +0000 (14:46 +0100)] 
Don't use BF-CBC in unit tests if we don't have it

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211208134655.28905-1-maximilian.fillinger@foxcrypto.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23354.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove max_size from buffer_list_new
Arne Schwabe [Tue, 7 Dec 2021 17:01:51 +0000 (18:01 +0100)] 
Remove max_size from buffer_list_new

This argument is never used apart from a unit test. Remove this
argument as a small cleanup.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211207170211.3275837-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23329.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove ENABLE_CRYPTO_OPENSSL ifdef inside ENABLE_CRYPTO_OPENSSL ifdef
Arne Schwabe [Tue, 7 Dec 2021 16:50:35 +0000 (17:50 +0100)] 
Remove ENABLE_CRYPTO_OPENSSL ifdef inside ENABLE_CRYPTO_OPENSSL ifdef

This ifdef is redundant.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211207165035.3274728-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23326.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoMake --nobind default for --pull
Arne Schwabe [Mon, 6 Dec 2021 01:00:07 +0000 (02:00 +0100)] 
Make --nobind default for --pull

Currently we default to local binding with udp. But the majority of
configuration files actually uses --nobind in the configuration to
change the default for --client. And client protocols should normally
use a random source port. This changes the default. Local binding with
--client can still be done using --bind.

This commit refactors the current code to be more easy to add to understand
and adds the the o->pull condition as additional option to opt into setting
local binding to false.

Patch v2: add more commments

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20211206010007.3072528-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23303.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix handling an optional invalid cipher at the end of data-ciphers
Arne Schwabe [Mon, 6 Dec 2021 15:08:52 +0000 (16:08 +0100)] 
Fix handling an optional invalid cipher at the end of data-ciphers

If an optional cipher was found at the end of --data-cipher that was
not available, it would reset the error and allow non optional ciphers
to be ignored.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211206150852.3142891-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20211206150852.3142891-1-arne@rfc2549.org
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove key_type->hmac_length
Arne Schwabe [Wed, 1 Dec 2021 18:07:24 +0000 (19:07 +0100)] 
Remove key_type->hmac_length

This field is only set once with md_kt_size and then only read. Remove this
field and replace the read accesses with md_kt_size.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211201180727.2496903-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23274.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove key_type->cipher_length field
Arne Schwabe [Mon, 6 Dec 2021 01:01:51 +0000 (02:01 +0100)] 
Remove key_type->cipher_length field

This field is only set once to cipher_kt_key_size(kt.cipher) at the same
time that kt.cipher is set and therefore completely redundant.

This field was useful in the past when we supported cipher with variable
key length as this field would then store the key length that we would use.
Now that we do not support this anymore, we can simplify the code.

Patch v2: correct print message that would print bytes instead bits.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211206010151.3072787-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23304.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove cipher_ctx_get_cipher_kt and replace with direct context calls
Arne Schwabe [Wed, 1 Dec 2021 18:07:21 +0000 (19:07 +0100)] 
Remove cipher_ctx_get_cipher_kt and replace with direct context calls

We currently have a number of calls that fetch the cipher_kt from a
cipher_ctx to then do a query on the cipher_kt. Directly fetching the
desired property from the context is cleaner and helps for using the
proper APIs with OpenSSL 3.0 and mbed TLS 3.0

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211201180727.2496903-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23278.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agovcpkg/pkcs11-helper: compatibility with latest vcpkg
Lev Stipakov [Wed, 24 Nov 2021 10:08:38 +0000 (12:08 +0200)] 
vcpkg/pkcs11-helper: compatibility with latest vcpkg

Starting from commit 21b2dbd3 "[scripts-audit] nmake buildsystem"
vcpkg has removed NO_DEBUG support from nmake buildsystem
and now builds debug variant unconditionally. Debug flags contradict
build options hardcoded in pkcs11 nmake script (like /O2).

Remove hardcoded release options and other options which
are (also) set by vcpkg nmake buildsystem.

Bump vcpkg commit in GitHub actions.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211124100838.861-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23253.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodoc/protocol-options.rst: Correct default for --allow-compression
Richard T Bonhomme [Mon, 29 Nov 2021 16:55:38 +0000 (16:55 +0000)] 
doc/protocol-options.rst: Correct default for --allow-compression

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211129165538.2948077-1-tincantech@protonmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23268.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove cipher_kt_var_key_size and remaining --keysize documentation
Arne Schwabe [Wed, 1 Dec 2021 18:07:22 +0000 (19:07 +0100)] 
Remove cipher_kt_var_key_size and remaining --keysize documentation

Remove --keysize from the manual page and also remove mentioning
variable key size in output of ciphers as there is no longer a way to
change the keysize.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211201180727.2496903-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23275.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoDirectly use hardcoed OPENVPN_AEAD_TAG_LENGTH instead lookup
Arne Schwabe [Wed, 1 Dec 2021 18:07:20 +0000 (19:07 +0100)] 
Directly use hardcoed OPENVPN_AEAD_TAG_LENGTH instead lookup

We always use the same tag size for all AEAD cipher, so instead
of doing a lookup, use the tag size directly.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211201180727.2496903-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23273.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoImplement optional cipher in --data-ciphers prefixed with ?
Arne Schwabe [Wed, 1 Dec 2021 18:07:19 +0000 (19:07 +0100)] 
Implement optional cipher in --data-ciphers prefixed with ?

This allows to use the same configuration multiple platforms/ssl libraries
and include optional algorithms that are not available on all platforms

For example "AES-256-GCM:AES-128-GCM:?CHACHA20-POLY1305" can be used to
emulate the default behaviour of OpenVPN 2.6.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211201180727.2496903-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23279.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agossh_openssl.h: remove unused declaration
Lev Stipakov [Wed, 1 Dec 2021 09:20:02 +0000 (11:20 +0200)] 
ssh_openssl.h: remove unused declaration

Commit 95993a1df3 ("Refactored SSL initialisation functions")
has declared openssl_set_mydata_index(void) function but
hasn't added definition.

There hasn't been need in this function for 10 years,
so it can be safely removed.

Found by MSVC.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211201092002.162-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23269.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoring_buffer.h: fix GCC warning about unused function
Lev Stipakov [Wed, 24 Nov 2021 16:03:47 +0000 (18:03 +0200)] 
ring_buffer.h: fix GCC warning about unused function

With register_ring_buffers() being declared as "static" in header file,
all translation units, which include that header, got a copy of that
function.
This causes GCC warning

  warning: "register_ring_buffers" defined but not used [-Wunused-function]

when compiling C files which include header, but don't use function.

Add "inline" keyword to silence this warning.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211124160347.1245-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23260.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoLoad OpenSSL config on Windows from trusted location
Lev Stipakov [Fri, 19 Nov 2021 01:55:48 +0000 (03:55 +0200)] 
Load OpenSSL config on Windows from trusted location

Commits

 - 92535b6 ("contrib/vcpkg-ports: add openssl port with
             --no-autoload-config option set (CVE-2121-3606)")
 - 447cfb4 ("crypto_openssl.c: disable explicit initialization on Windows
             (CVE-2121-3606)")

disabled OpenSSL config loading functionality, which could be
exploited by loading config from untrusted locations.

This feature might be useful for some users. This brings it back
and sets OpenSSL enviroment variables

 OPENSSL_CONF, OPENSSL_ENGINES, OPENSSL_MODULES

which are used to load config, engines and modules, to a trusted location.
The location is constructed based on installation path, read from registry
on startup.
If installation path cannot be read, Windows\System32 is used as a
fallback.

While on it, remove unused "bool impersonate_as_system();" declaration.

Trac: #1296

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20211119015548.687-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23248.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodoc/man (vpn-network-options): fix foreign_option_{n} typo
Todd Zullinger [Mon, 22 Nov 2021 11:41:04 +0000 (12:41 +0100)] 
doc/man (vpn-network-options): fix foreign_option_{n} typo

In 2da29362 (Improve the documentation for --dhcp-option, 2020-08-16),
`foreign_option_{n}` became plural between the first and second versions
of the patch.  Correct it.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211122114104.4814-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23217.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoUpdate IRC information in CONTRIBUTING.rst
Todd Zullinger [Mon, 22 Nov 2021 11:40:18 +0000 (12:40 +0100)] 
Update IRC information in CONTRIBUTING.rst

The developer IRC channel is now on libera.chat.  Update
CONTRIBUTING.rst to match the wiki.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211122114018.4708-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23218.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodoc link-options.rst: Use free open-source dynamic-DNS provider URL
Richard T Bonhomme [Wed, 3 Nov 2021 20:20:14 +0000 (20:20 +0000)] 
doc link-options.rst: Use free open-source dynamic-DNS provider URL

Trac: #1417

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211103202014.1121244-2-tincantech@protonmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23095.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoInclude --push-remove in the output of --help.
Gert Doering [Wed, 17 Nov 2021 06:44:42 +0000 (07:44 +0100)] 
Include --push-remove in the output of --help.

"push-remove" has been in OpenVPN since 2.4, but managed to stay hidden
from the "--help" output.  Add.

Reported-by: mike tancsa <mike@sentex.net>
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20211117064442.15899-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23194.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoLog messages: Replace NCP with --data-ciphers (NFC)
Richard T Bonhomme [Tue, 16 Nov 2021 15:08:23 +0000 (15:08 +0000)] 
Log messages: Replace NCP with --data-ciphers (NFC)

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211116150823.631970-1-tincantech@protonmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23191.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoMove IV_TCPNL from comp_generate_peer_info_string to push_peer_info
Arne Schwabe [Sun, 14 Nov 2021 13:03:11 +0000 (14:03 +0100)] 
Move IV_TCPNL from comp_generate_peer_info_string to push_peer_info

This IV variable has nothing to do with compression and should not
depend if OpenVPN is compiled with USE_COMP. So move it to the
other generic IV variables.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211114130311.4043536-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23182.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoUse network address for emulated DHCP server as a default
Lev Stipakov [Tue, 9 Nov 2021 01:59:27 +0000 (03:59 +0200)] 
Use network address for emulated DHCP server as a default

This is the rebase of original Selva Nair's patch
which hasn't been merged:

  https://sourceforge.net/p/openvpn/mailman/message/34674818/

and documentation change to reflect code changes, which
is basically a revert of another Selva's patch (which got merged):

https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13387.h
tml

For subnet topology use "offset 0" as default for
calculating DHCP server address, which makes it equal
to the network address.

There is no know reason why non-zero default offset
is needed. Besides, offset -1 breaks subnet /30 case,
which in some cases is pushed by OpenVPN Cloud product.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211109015927.311-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23156.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAllow loading of non default providers
Arne Schwabe [Fri, 12 Nov 2021 13:02:31 +0000 (14:02 +0100)] 
Allow loading of non default providers

This allows OpenVPN to load non-default providers. This is mainly
useful for loading the legacy provider with --providers legacy default

Patch v4: use spaces to seperate providers, unload providers.
Patch v5: General cleanup, rename option to --providers, add
          option to usage() and add an entry to Changes.rst
Patch v6: allow --providers also to be used (and be ignored) with mbed TLS

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211112130231.3799480-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20211112130231.3799480-1-arne@rfc2549.org
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAdd macos OpenSSL 3.0 and ASAN builds
Arne Schwabe [Tue, 19 Oct 2021 18:31:26 +0000 (20:31 +0200)] 
Add macos OpenSSL 3.0 and ASAN builds

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20211019183127.614175-21-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23018.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>