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

121 Commits

Author SHA1 Message Date
David Sommerseth
3fbe0a2701
Update copyrights
Signed-off-by: David Sommerseth <davids@openvpn.net>
2020-03-18 19:37:32 +01:00
Arne Schwabe
a1250b9bed Announce Chacha20-poly1305 in IV_CIPHER if supported
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-02-18 18:50:27 +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
Arne Schwabe
424d9b34af Rename GCM classes and files to AEAD
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
Arne Schwabe
8c79c06d94 Make tls-crypt/tls-cryptv2 compile with multiple compilation units
This changes the the non constexpr expression to constexpr so that
they can be used in multiple compilation units
2019-08-29 16:59:33 +02:00
Antonio Quartulli
9814079944
tls-crypt-v2: implement abstract metadata parser
The metadata that may be possibly be contained in the WKc has to be
verified by means of a user implemented behaviour.

Implement an abstract class that exports a verify() method to be
used for this purpose.

Users can extend this class and override the verify() method with
their own.

A basic implementation is also provided: it will just ignore the
metadata (if any) and report success to the core.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-06 09:19:22 +10:00
Antonio Quartulli
60fcf374fb
tls-crypt-v2: implement WKc appending/unwrapping logic
The client reads the WKc from the key file and appends it to
the HARD_RESET_CLIENT_V3 packet when starting a connection.

The server reads the WKc from the received HARD_RESET_CLIENT_V3 packet,
decrypts and authenticates it (it is encrypted and signed with the
server keys upon generation) and finally extracts the client key.

The client key is then used to initialize the server tls-crypt.
At this point every packet is treated as a standard tls-crypt framed
message (HARD_RESET_CLIENT_V3 included).

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-06 09:19:22 +10:00
Antonio Quartulli
156a6e58ba
tls-crypt-v2: implement client key parser and renderer
The client key used for tls-crypt-v2 is stored in PEM format
and it is made up by the actual client key (Kc) and the
wrapped client key (WKc). The latter is an envelope containing
Kc (and some optional metadata) encrypted by the server with
its own key. It is sent upon connection to allow the server to
extract the actual Kc to be used for the tls-crypt session.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-06 09:19:21 +10:00
Antonio Quartulli
f090fcda4a
tls-crypt: make HMAC API more generic
In order to make the HMAC API in the TLCrypt class
re-usable by tls-crypt-v2, avoid using the hard-coded
header size of the standard tls-crypt packet.

Instead, let the caller specify the header size via
argument.

Note that the header size is also expected to be the offset
where it is possible to find the Authentication tag to be
used during the packet authentication.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-06 09:19:21 +10:00
James Yonan
f9fc2f54e6
BufferAllocated: improve movability
Added BufferAllocated move constructor for foreign
BufferAllocated template classes.

In order to make this work, we need to:

(a) generally friend BufferType and BufferAllocatedType
    to all BufferAllocatedType template classes, and

(b) require typename R (thread_unsafe_refcount or
    thread_safe_refcount) to be specified for
    BufferAllocatedType (previously it was optional
    and defaulted to thread_unsafe_refcount).

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:31 +08: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
8379b0a319 CryptoDCInstance: added new RekeyType PRIMARY_SECONDARY_SWAP
and use it in ProtoContext::promote_secondary_to_primary()
since it more accurately reflects the underlying
implementation.

Note that this only affects DCO (data channel offload)
implementations.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
4e11a6c89c StaticKey: added render_to_base64() and init_from_rng()
methods.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +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
74c5f4f38f [OVPN3-5] tls-crypt: introduce tls-crypt support
backported from OpenVPN 2.4.x

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-09-27 16:16:18 +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
faf8f8fd51 StaticKey: added parse_from_base64() method
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:17 +08:00
James Yonan
d11f250e76 HashString: added final_base64() method
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:17 +08:00
James Yonan
691a641a43 Added i/o abstraction layer.
Created a lightweight abstraction layer so that another i/o
reactor can be dropped in place of asio.

The basic approach is to rename all references to asio::xxx
types to openvpn_io::xxx and then make openvpn_io a
preprocessor variable that points to the top-level namespace
of the i/o reactor implementation.

All of the source files that currently include <asio.hpp> now
include <openvpn/io/io.hpp> instead:

This gives us a lightweight abstraction layer that allows us
to define openvpn_io to be something other than asio.

Other changes:

* Inclusion of asio by scripts/build is now optional, and is
  enabled by passing ASIO=1 or ASIO_DIR=<dir>.

* Refactored openvpn/common/socktypes.hpp to no longer
  require asio.

* Refactored openvpn/log/logthread.hpp to no longer require
  asio.

* Added openvpn::get_hostname() method as alternative to
  calling asio directly.

* openvpn/openssl/util/init.hpp will now #error
  if USE_ASIO is undefined.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-30 15:48:14 -06:00
James Yonan
b2cd82a5bf copyright: updated to 2017.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 13:11:09 -06:00
James Yonan
f9af3c7910 crypto: in class CryptoDCInstance, added new virtual
method init_remote_peer_id().  This allows the DCO
layer (Data Channel Offload) to have access to the
remote peer ID.
2017-03-18 12:24:54 -06:00
James Yonan
050e8717f1 mbedTLS: Port from polarssl-1.3 to mbedtls-2.3 (symbol renames)
This patch renames internal OpenVPN 3 symbols
from polarssl -> mbedtls.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 12:24:54 -06:00
James Yonan
1fd81ebf96 random : because the RandomAPI interface now supports
both cryptographic and non-cryptographic algorithms, as
a failsafe, add a new virtual method assert_crypto()
that will throw an exception if the algorithm is not
crypto strength.  assert_crypto() should now be called
before any RNG is used for crypto purposes.
2017-03-18 12:24:54 -06:00
James Yonan
1deedbaef7 HashString : added void final(Buffer& output) method. 2017-03-18 12:24:54 -06:00
James Yonan
0b662bc284 C++ coding : for consistency, const strings should be passed as
const std::string&, not const std::string
2017-03-18 12:24:54 -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
07d37b0016 DCO : added explicit_exit_notify() client hook. 2016-09-06 11:31:57 -06:00
James Yonan
971abda88f copyright : updated to 2016 2016-09-03 23:29:23 -06:00
James Yonan
662bf7833e ovpn3 core : Added automatic data limits for Blowfish,
Triple DES, and other 64-bit block-size ciphers vulnerable
to "Sweet32" birthday attack (CVE-2016-6329).  Limit such
cipher keys to no more than 64 MB of data
encrypted/decrypted.  While our overall goal is to limit
data-limited keys to 64 MB, we trigger a renegotiation
at 48 MB to compensate for possible delays in renegotiation
and rollover to the new key.

This client-side implementation extends data limit
protection to the entire session, even when the server
doesn't implement data limits.

This capability is advertised to servers via the a
peer info setting:

  IV_BS64DL=1

meaning "Block-Size 64-bit Data Limit".  The "1" indicates
the implementation version.

The implementation currently has some limitations:

* Keys are renegotiated at a maximum rate of once per
  5 seconds to reduce the likelihood of loss of
  synchronization between peers.

* The maximum renegotiation rate may be further extended
  if the peer delays rollover from the old to new key
  after renegotiation.

Added N_KEY_LIMIT_RENEG stats counter to count the number
of data-limit-triggered renegotiations.

Added new stats counter KEY_STATE_ERROR which roughly
corresponds to the OpenVPN 2.x error "TLS Error:
local/remote TLS keys are out of sync".

Prevously, the TLS ack/retransmit timeout was hardcoded to
2 seconds.  Now we lower the default to 1 second and make
it variable using the (pushable) "tls-timeout" directive.
Additionally, the tls-timeout directive can be specified
in milliseconds instead of seconds by using the
"tls-timeout-ms" form of the directive.

Made the "become primary" time duration configurable via
the (pushable) "become-primary" directive which accepts
a number-of-seconds parameter.  become-primary indicates
the time delay between renegotiation and rollover to the
new key for encryption/transmission.  become-primary
defaults to the handshake-window which in turn defaults
to 60 seconds.

Incremented core version to 3.0.20.
2016-09-01 15:19:00 -06:00
James Yonan
636cd863ed ovpn3 SSL core: added rekey(CryptoDCInstance::NEW_SECONDARY)
method/type for initializing secondary key after a soft
renegotiation.
2016-08-23 19:36:24 -07:00
James Yonan
e3e903c3b6 Separated out class HashString from HTTPProxy::Digest, making
it standalone for use by other code.
2016-03-08 13:16:52 -07:00
James Yonan
134ba710f2 ovpn3 core globals cleanup:
1. move all const globals into anonymous namespace
2. make sure that all non-class functions are inline
3. refactor class static data members
2015-11-25 11:34:41 -07:00
James Yonan
0bac5d8990 Core: revamped packet ID code to use a much larger window size,
allowing backtracks of up to 2048 (previous limit was 64).
In addition, we now maintain the packet ID window as a bit
array (previously a byte array was used).
2015-06-18 01:55:52 -06:00
James Yonan
c6a21c827b Boost dependency elimination -- final removal of Boost
dependency.  Asio is now included as a standalone,
header-only dependency.
2015-06-06 10:59:18 -06:00
James Yonan
88518335c4 Boost dependency elimination -- change boost::algorithm
usage (for string algorithms) to use methods of our own
implementation in openvpn/common/string.hpp.
2015-06-04 19:22:59 -06:00
James Yonan
b75c780cab Renamed boost::intrusive_ptr<T> usage to RCPtr<T>. 2015-05-17 21:26:53 -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
0fde33173a C++11 update: mass replace of boost::uint/int to std::uint/int. 2015-04-23 17:55:07 -06:00
James Yonan
36550cd35e Update to C++11 noncopyable semantics.
Instead of inheriting from boost::noncopyable,
use the C++11 delete qualifier:

    Class(const Class&) = delete;
    Class& operator=(const Class&) = delete;
2015-04-23 15:10:43 -06:00
James Yonan
664b276716 render_hex() methods now take an optional caps argument to
control whether hex chars a-f are rendered as lowercase or
uppercase.

Renamed the template form of render_hex() to render_hex_generic(),
to avoid ambiguity from new caps parameter.
2015-04-21 00:42:15 -06:00
James Yonan
e2c90bf030 ServerProto::Session::stop() should reset the DC (data channel) factory. 2015-01-15 17:05:50 -07:00
James Yonan
c2c7292a70 Updated copyright to 2015. 2015-01-06 12:56:21 -07:00
James Yonan
3fe1a359c0 Added OpenSSL GCM support. 2014-12-31 00:24:54 -07:00
James Yonan
8482f7f76d Misc changes to dynamically support OpenVPN protocols V1 and V2:
1. force_aes_cbc_ciphersuites flag will disable V2.

2. Added class CryptoDCSettings to Manage cipher/digest settings,
   DC factory, and DC context.  A CryptoDCSettings instance is
   now declared as a member of ProtoContext::Config and is used
   to define the cipher/digest pair of the config.

3. ProtoContext::Config::load now parses the "tun-mtu" directive.

Server-side changes:

1. Parse "keepalive" directive, using the same logic
   as OpenVPN 2.x.

2. Added ProtoContext::init_data_channel() method for initializing
   the data channel after IV_x peer info received from client.
2014-12-29 22:20:50 -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