0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00
Commit Graph

39 Commits

Author SHA1 Message Date
Leonard Ossa
3646265d15 Refactor nested namespace to C++17 style
Signed-off-by: Leonard Ossa <leonard.ossa@openvpn.com>
2024-07-03 10:20:11 +00:00
Arne Schwabe
2780eb9581 Spell none cipher with lowercase
OpenVPN uses a idiosyncrasy that all ciphers are uppercase but none is
spelt lowercase and excepts this idiosyncrasy also in IV_CIPHERS

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-05-08 16:39:25 +00:00
Arne Schwabe
2219ccfb8d
Use inline to ensure only one copy of crypto::algs is present
We need to ensure that there is only one copy of these algorithms defined
as we modify them with the method allow_default_dc_algs to set the
F_DC_ALLOW flag on. Having more than one copy means that we have different
copies with different flags which we want to avoid.

The use of inline to a normal variable is a C++17 feature.

From https://en.cppreference.com/w/cpp/language/inline

An inline function or variable (since C++17) with external linkage
(e.g. not declared static) has the following additional properties:

There may be more than one definition of an inline function or variable
(since C++17) in the program as long as each definition appears in a
different translation unit and (for non-static inline functions and
variables (since C++17)) all definitions are identical. For example,
an inline function or an inline variable (since C++17) may be defined
in a header file that is included in multiple source files.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-07-18 14:54:00 +02:00
Arne Schwabe
ccf7972ba2
Use static inline to ensure only one copy of crypto::algs is present
While there should be no problem of having these basically static
definition multiple times, avoiding multiple copies of it is a good
thing.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-06-07 17:14:17 +02:00
David Sommerseth
dde1574596
Reformatting source code to new coding style
This is the result after running 'clang-format -i' on all C++ files and
headers, with the defined formatting rules in .clang-format.

Only the openvpn/common/unicode-impl.hpp has been excluded, as that is
mostly a copy of an external project.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-01-18 19:24:15 +01:00
David Sommerseth
4996c38ed4
Merge lastest changes from Core v3.7.2 2022-12-14 17:34:29 +01:00
David Sommerseth
8c94a8f774
copyright: Update to 2022
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-09-29 12:00:26 +02:00
Lev Stipakov
1d4334c701 dco-win: support for ChaCha20-Poly1305
Probe cipher support in runtime (works in Windows Server 2022 and Windows 11)
and add it to the list of allowed ciphers.

White on it, add missing halt check in dco-win client code.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-05-04 18:15:07 +03:00
Arne Schwabe
d0a9b61b4b
Do not allow SWEET32 vulnerable algorithms and MD4 without enableLegacyAlgorithm
With OpenSSL3, these algorithms are no longer allowed. With this change
we do the same regardless of the crypto library. Note that in contrast
to OpenSSL3, we include here 3DES into the legacy algorithms.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-01-12 18:30:04 +01:00
Arne Schwabe
3f90304154
Allow controlling usage of non preferred DC ciphers via option
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:46 +01:00
Arne Schwabe
9fe7a29148
Implement allowing only data channel ciphers that are actually available by the library
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:37 +01:00
Heiko Hund
f58ad6b739 remove CryptoAlgs::F_NO_CIPHER_DIGEST flag
Checking for AEAD cipher mode is sufficient.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-23 17:50:18 +02:00
Heiko Hund
efd7e01289 add dc_cipher/digest functions to CryptoAlgs::Alg
Moving interpretation of the flags into the class in preparation
of submitting only supported data channel ciphers in IV_CIPHERS.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-23 17:49:59 +02:00
Heiko Hund
2975585761 add CryptoAlgs::for_each() to interate algs
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-18 15:10:03 +02:00
Heiko Hund
dd104e8392 make it possible to specify dc algorithms
DCO only supports a limited set of ciphers, currently it is
discovered quite late if a unsupported algorithm is configured
(or pushed).

This introduces CryptoAlgs::allow_dc_algs() with which the
supported set of data channel algorithms can be specified.

The DCO code makes use of this, at the time a new_controller()
is created.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-18 15:09:35 +02:00
Heiko Hund
84c8b4aca6 convert CryptoAlgs::algs array to std::array
Remove constexpr in preparation for making it possible to modify the
data channel ciphers. Use std::array so the SIZE can be specified.

Remove the unused CryptoAlgs:get_index_ptr() function.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-17 20:32:21 +02:00
Heiko Hund
d28b241380 combine the two CryptoAlgs::name functions
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-17 20:16:51 +02:00
Arne Schwabe
285474a6dc Implement TLS Keying Material Export data key derivation
Tested against OpenVPN 2.x server

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-08-27 13:00:11 +02:00
David Sommerseth
3fbe0a2701
Update copyrights
Signed-off-by: David Sommerseth <davids@openvpn.net>
2020-03-18 19:37:32 +01:00
Arne Schwabe
80399075d4 Implement CHACHA20-Poly1305 support for data channel
This also changes the mbed TLS implementation from using the AES GCM
specific API to the generic AEAD API in mbed TLS. As result we can
refactor the commonly used parts of AEAD and normal cipher into a
common class.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-02-18 18:50:27 +01:00
David Sommerseth
29e060ffb3
CryptoAlgs: Don't report any digests for ciphers not using them
The CryptoDCSettings::digest() method returns SHA1 digest when the
cipher is an AEAD cipher.  This is incorrect, as AEAD ciphers does not
use digests for authentication at all; the authentication is an
integral part of the AEAD cipher itself.

To solve this, the CryptoAlgs::AlgFlags has been extended with a new
F_NO_CIPHER_DIGEST flag which is expected to be set on ciphers not
depending on any digests for authentication, like AES-GCM/AEAD
ciphers.  A new method, use_cipher_digest(), will return True if
the cipher depends on a digest for authentication.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-10-24 14:48:22 +02:00
David Sommerseth
16b10559f2 [OVPN3-140] Update company names in copyrights
OpenVPN Technologies, Inc. change their name to OpenVPN Inc. during the
autumn of 2017.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2017-12-22 17:59:39 +08:00
David Sommerseth
6caca2c313 [OVPN3-140] Relicense back to AGPLv3
This is essentially a revert of commit 04b2a3c9b7 and commit
ef42e59e05.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2017-12-22 17:59:39 +08:00
James Yonan
190ece92d4 CryptoAlgs: added mode() method.
Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
76e65cf4c9 CryptoAlgs: added AEAD_NONCE_TAIL_SIZE constant (set to 8
bytes) to represent the size in bytes of AEAD "nonce tail"
normally taken from the HMAC key material.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
56a831f92a [OVPN3-5] crypto/ssl: add support for AES-256-CTR
Add support for AES-256-CTR (used by tls-crypt) in the crypto
layer and make sure that each SSL library plugin is aware of it.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-09-27 16:16:18 +08:00
James Yonan
b2cd82a5bf copyright: updated to 2017.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 13:11:09 -06:00
Samuli Seppänen
04b2a3c9b7 Switch from AGPLv3 to GPLv3
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
2017-03-16 14:43:55 +02:00
James Yonan
971abda88f copyright : updated to 2016 2016-09-03 23:29:23 -06:00
James Yonan
35ac9f6229 Renamed types.hpp to size.hpp since it now only defines
size_t and ssize_t.
2015-05-17 13:27:34 -06:00
James Yonan
5d1bc1c952 Moved array_size() function to its own header file. 2015-05-17 12:57:23 -06:00
James Yonan
c2c7292a70 Updated copyright to 2015. 2015-01-06 12:56:21 -07:00
James Yonan
7e1d159cee Major protocol upgrades:
* peer_id/DATA_V2/op32
  client -> server:
    IV_PROTO=2
  server -> client :
    push "peer-id 1234"
    push "peer-id -1"

* AEAD/GCM support
  client -> server:
    IV_NCP=2
  server -> client:
    push "cipher AES-256-GCM"

* Compression V2
  client -> server:
    IV_LZ4v2=1
    IV_COMP_STUBv2=1
  server -> client:
    push "compress stub-v2"
    push "compress lz4-v2"

* TCP non-linear packet ID
  client -> server:
    IV_TCPNL=1
  server -> client:
    [always enabled]
2014-12-21 10:32:37 -07:00
James Yonan
eb25f37d11 Route:
* Make class Route standalone, moving it out of namespace
  CIDRMap.

CryptoAlgs:

* Added comments

* For type-safety, mode() now returns a Mode rather than an
  int.

CryptoDC:

* Added CRYPTO_DEFINED flag to indicate when encrypt() and
  decrypt() methods are implemented by a data channel
  provider.

Manage:

* Implemented skeleton management API for server-side client
  authentication and managing client-instance properties.

Proto:

* Added Config::update_dc_factory() method.

* Support new CryptoDCInstance::CRYPTO_DEFINED flag.

* Updated server_auth() method to support SafeString transit
  of client-provided auth-user-pass password to management
  layer.

* control_send now does a reset() on the provided
  Ptr reference before returning to reflect the
  transfer-of-ownership of the underlying buffer.

* Implemented disable_keepalive() and override_dc_factory
  methods.

Transbase (server) new methods:

  // disable keepalive for rest of session
  virtual void disable_keepalive() = 0;

  // override the data channel factory
  virtual void override_dc_factory(const CryptoDCFactory::Ptr& dc_factory) = 0;

  // override the tun provider
  virtual TunClientInstanceRecv* override_tun(TunClientInstanceSend* tun) = 0;

ServProto:

* Added abstract base classes for Tun factories and client instance
  sender/receivers.

* Added Tun and Management linkages.

* Added new receiver methods for overriding the data channel
  factory, Tun factory, and keepalive config.

* Added AuthCreds support.
2014-10-30 10:41:53 -06:00
James Yonan
a36b95a165 Standardize on size_t for crypto attributes. 2014-10-23 19:20:59 -06:00
James Yonan
99fa118ad3 Removed CRYPTO_API::Cipher and CRYPTO_API::Digest from all crypto
implementations, replacing with general-purpose CryptoAlgs::Type.
2014-10-23 19:19:08 -06:00
James Yonan
287bfd71e9 Extend CryptoAlgs::Alg to contain all info about ciphers/digests
that we need, so we don't need to rely on crypto library for this.
2014-10-23 14:08:30 -06:00
James Yonan
1465964f21 Minor refactor of CryptoDC virtual methods to achieve
a better fit between users and providers.
2014-10-23 09:17:10 -06:00
James Yonan
bd04ed3755 Added CryptoAlgs for managing crypto algorithms independently of
underlying crypto implementation.

Modified proto.hpp to use the new CryptoAlgs types for
cipher/digest selection.

Added initial PolarSSL implementation for cipher/digest
selection using CryptoAlgs types.

Note: this implementation is incomplete, see fixmes.
2014-10-18 10:50:51 -06:00