Commit Graph

3104 Commits

Author SHA1 Message Date
Selva Nair
cf704eef47 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>
2022-01-20 16:22:22 +01:00
Selva Nair
199df03bf5 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>
2022-01-20 15:54:11 +01:00
Selva Nair
57abdcfc38 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>
2022-01-20 15:47:33 +01:00
Selva Nair
c279986bf4 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>
2022-01-20 15:38:33 +01:00
Selva Nair
4b85c488ec 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>
2022-01-20 15:19:03 +01:00
Selva Nair
ab3a8e5c28 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>
2022-01-20 15:09:07 +01:00
Selva Nair
25f9c47127 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>
2022-01-20 14:55:15 +01:00
Selva Nair
44509116da 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>
2022-01-20 14:49:50 +01:00
Selva Nair
5910eb6cd5 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>
2022-01-20 13:35:40 +01:00
Antonio Quartulli
943fb256de 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>
2022-01-18 13:51:45 +01:00
Arne Schwabe
3272a04a36 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>
2022-01-14 18:21:50 +01:00
Antonio Quartulli
eb3e849e63 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>
2022-01-14 14:19:32 +01:00
Antonio Quartulli
6445bf30c1 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>
2022-01-14 14:16:39 +01:00
Antonio Quartulli
508ee74a96 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>
2022-01-14 07:59:26 +01:00
Antonio Quartulli
3c0b2770a3 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>
2022-01-14 07:40:58 +01:00
Antonio Quartulli
19835c940d 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>
2022-01-10 18:00:05 +01:00
Lev Stipakov
4b6073b825 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>
2022-01-10 17:50:12 +01:00
Camille Guérin
c2c8128ad5 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>
2022-01-10 13:33:18 +01:00
Arne Schwabe
2b6fcdc028 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>
2021-12-31 12:36:59 +01:00
Arne Schwabe
01b7cd4466 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>
2021-12-31 12:08:35 +01:00
Arne Schwabe
d4458eed0c 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>
2021-12-30 16:35:31 +01:00
Arne Schwabe
de018b5e93 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>
2021-12-30 12:29:37 +01:00
Antonio Quartulli
7747e0bcdb 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>
2021-12-29 20:47:27 +01:00
Arne Schwabe
919d10ad4a 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>
2021-12-29 11:37:51 +01:00
Arne Schwabe
c27868bfc2 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>
2021-12-14 09:35:41 +01:00
Arne Schwabe
66c05aeabc 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>
2021-12-14 09:31:07 +01:00
Arne Schwabe
ce9c1990ba 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>
2021-12-14 08:24:46 +01:00
Arne Schwabe
053de4db59 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>
2021-12-14 08:07:25 +01:00
Arne Schwabe
02d8f79289 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>
2021-12-13 22:01:39 +01:00
Arne Schwabe
b39725cf81 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>
2021-12-13 19:43:28 +01:00
Arne Schwabe
985e9dbda4 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>
2021-12-13 18:49:44 +01:00
Arne Schwabe
7f2d7dbf98 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>
2021-12-13 18:44:48 +01:00
Arne Schwabe
ce2954a0ca 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>
2021-12-13 18:20:49 +01:00
Lev Stipakov
bae0945d59 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>
2021-12-13 15:38:42 +01:00
Gert Doering
b08b5f5df9 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>
2021-12-10 18:08:33 +01:00
Gert Doering
883cd6f403 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>
2021-12-10 12:02:53 +01:00
Arne Schwabe
cc39fc7f3b 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>
2021-12-09 12:14:00 +01:00
Max Fillinger
0e075c0e1b 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>
2021-12-08 14:49:31 +01:00
Arne Schwabe
61d2f918d5 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>
2021-12-07 19:50:46 +01:00
Arne Schwabe
2aef01df6c 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>
2021-12-07 18:13:29 +01:00
Arne Schwabe
de02c828f5 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>
2021-12-06 18:06:45 +01:00
Arne Schwabe
868433857f 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>
2021-12-06 16:42:49 +01:00
Arne Schwabe
459d9669d1 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>
2021-12-06 10:20:00 +01:00
Arne Schwabe
9cc7fdcf85 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>
2021-12-06 10:00:07 +01:00
Arne Schwabe
0b1c721e4f 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>
2021-12-06 09:25:11 +01:00
Lev Stipakov
e832658a6d 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>
2021-12-05 19:01:25 +01:00
Richard T Bonhomme
041c235955 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>
2021-12-05 18:55:30 +01:00
Arne Schwabe
5dcd9a7243 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>
2021-12-05 18:33:23 +01:00
Arne Schwabe
e82e338238 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>
2021-12-05 18:12:33 +01:00
Arne Schwabe
7660445074 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>
2021-12-05 17:51:23 +01:00