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

105 Commits

Author SHA1 Message Date
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
James Yonan
a000617b1d Simplified CryptoDCContext::Info by removing size members
which are redundant because size can easily be fetched
using CryptoAlgs::Type values.
2014-10-23 20:24:06 -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
27cc272bf7 DigestFactory now supports HMAC.
NTLM proxy auth methods now use DigestFactory
for their digest/HMAC needs.

HTTPProxyTransport is no longer a class template.
2014-10-22 09:52:36 -06:00
James Yonan
255b71958f Reversed polymorphic ProtoContext performance degradation.
* Performance degradation from recent commit was occurring
  in PRNG.

* Allow RNG to be used in place of PRNG.  For PolarSSL
  at least, this change completely reverses the
  polymorphic ProtoContext performance degradation
  and turns it into a net performance gain.

* Added bool prng to RNG constructors to allow
  the implementation to optimize for PRNG
  (only PolarSSL currently supports this).

Documented different use-cases for RNG vs. PRNG
in ProtoContext:

  RNG -- Random number generator.
  Use-cases demand highest cryptographic strength
  such as key generation.

  PRNG -- Pseudo-random number generator.
  Use-cases demand cryptographic strength
  combined with high performance.  Used for
  IV and ProtoSessionID generation.
2014-10-21 16:45:20 -06:00
James Yonan
243fd3feaa Updated test/ssl/proto.cpp to work with new dynamically
polymorphic ProtoContext.

Benchmarks show that polymorphic changes to ProtoContext
have produced a slowdown of 1.64%.
2014-10-20 20:30:13 -06:00
James Yonan
ed272d4e29 Implemented OvpnHMAC wrapper API using dynamic polymorphism
for tls-auth and HMAC/CBC integrity checking.
2014-10-20 12:29:30 -06:00
James Yonan
59c947f723 Renamed HMACContext to OvpnHMAC to reflect the fact
that it contains OpenVPN-specific logic.
2014-10-20 09:16:39 -06:00
James Yonan
bf5afea53f Removed CRYPTO_API template argument from types that no
longer need it.
2014-10-19 21:14:51 -06:00
James Yonan
5f85652033 For client, replaced all instances of PRNG to new dynamic type. 2014-10-19 19:59:48 -06:00
James Yonan
5102cff6f1 Added polymorphic classes for message digest algorithms.
Converted PRNG from static to dynamic polymorphism.
Did not fix PRNG users yet.
2014-10-19 19:14:56 -06:00
James Yonan
e8ca0c47f3 Added "chm" tag to CBC/HMAC encrypt/decrypt class names and
source filenames to distinguish from new modes such as AEAD.
2014-10-19 15:19:14 -06:00
James Yonan
677cd039c4 Defer data channel initialization until after client-side
options pull, so that cipher/digest can be pushed by server.
Note: incomplete, see fixmes.
2014-10-18 20:37:08 -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