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

60 Commits

Author SHA1 Message Date
Heiko Hund
8c8e96e138 streamline overriding virtual function syntax
In the code base three different syntaxes for overriding virtual member
functions could be found:

  1) virtual ... override
  2) virtual ...
  3) ... override

This converts all of them to the third syntax, as recommended by the ISO
C++ core guidelines in C.128

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2024-08-13 02:01:24 +02:00
Heiko Hund
c5d37c4184
add Doxygen comments to randapi.hpp
Document classes RandomAPI, StrongRandomAPI and WeakRandomAPI

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2023-11-29 22:17:49 +01:00
Heiko Hund
dfe26892b9 remove now unused RandomAPI::is_crypto function
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2023-11-22 16:29:46 +01:00
Heiko Hund
be3f20dc58 introduce base types for strong and weak RNGs
The need of having to call the assert_crypto() member function to ensure
that a cryptographically strong RNG is used where needed, was reported
as potentially insecure, since calling it manually can easily be missed.

In the commit the two new classes StrongRandomAPI and WeakRandomAPI are
introduced. They are to be used instead of just RandomAPI, unless it
doesn't matter what strength the RNG is.

All the places the assert_crypto() was called were converted to using
StrongRandomAPI instead. Also the RNGs for which assert_crypto() was not
throwing are now inheriting from StrongRandomAPI.

Variable names, which have the StrongRandomAPI type, but were called
prng, are changed to rng instead to follow the source code convention.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2023-11-22 04:49:31 +01:00
Charlie Vigue
b6b8282d33 Addressed 2nd set of -Wconversion warnings
- Used static_cast instead of direct type conversions in places where
it's safe
- Used numeric_cast where failure is possible
- Changed types of arguments and locals when practical

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2023-08-21 13:51:50 +00:00
Mark Deric
8b93eb0b0a Fix randapi UBSAN bug, signed T:min map to >= 0
The undefined behavior is unary negation of T:min of a signed type
attempting to get a positive value of the same signed type.

This commit adds a unit test that exposes the original bug and well as
a fix for it.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2023-08-15 07:28:35 -07: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
James Yonan
540f4cd72e RandomAPI: comment edit
Signed-off-by: James Yonan <james@openvpn.net>
2022-06-29 08:39:22 -06:00
James Yonan
07936aed4c Rand2: added defined() method
Signed-off-by: James Yonan <james@openvpn.net>
2022-04-11 09:08:47 -06:00
Frank Lichtenheld
e77069e29e
Rand2: Fix USE_AFTER_MOVE (CID 10990)
CID 10990 (#2 of 2): Using a moved object (USE_AFTER_MOVE)
2. use_after_move: rng_arg is used after it has been already moved.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-03-10 01:00:56 +01:00
James Yonan
7928d556f4
randapi: use #pragma once
Signed-off-by: James Yonan <james@openvpn.net>
2020-08-19 18:52:47 +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
984c601090
Fix multiple instances of comparison of signed with unsigned 2020-01-15 23:08:30 +01:00
Arne Schwabe
204d7e4a20 Replace OPENVPN_INSECURE_RANDOM with FakeRandom class
This avoids the mistake of using the insecure MTRand in anything but
a unit test and has the advantage that not all MTRand in a unit test
suite report being secure

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-11-07 09:58:54 +01:00
James Yonan
7ce7b52b7c MTRand: added OPENVPN_INSECURE_RANDOM compile flag that allows MTRand to masquerade as a secure RNG
This is useful for unit tests that must produce deterministic results.

You would never want to define this in production, because it turns off
the check that prevents non-crypto RNGs from being used for crypto
purposes.

Signed-off-by: James Yonan <james@openvpn.net>
2019-09-25 19:51:27 +02:00
James Yonan
85e7e49f72 MTRand: added constructor accepting an initialization seed
Initializing MTRand with a constant seed is useful for unit tests
that need to produce deterministic output.

Signed-off-by: James Yonan <james@openvpn.net>
2019-09-25 19:51:27 +02:00
James Yonan
115cb656b6 RandomAPI: added randbyte() and randbool() methods
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:56 -06:00
James Yonan
60501b4513 random: factor out rand32_distribute() from RandomAPI::randrange32()
This is done so that rand32_distribute() can be used for
hash seeds as well.

Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:56 -06:00
James Yonan
acd7af5e9a
RandomAPI: added randrange32() method
Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:35:20 +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
2486494bbe random: added helper class Rand2 containing a crypto and non-crypto RNG
Signed-off-by: James Yonan <james@openvpn.net>
2017-09-27 16:16:18 +08:00
James Yonan
79c789b8c8 RandomAPI: comment edit
Signed-off-by: James Yonan <james@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
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
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
ca5205b4f3 random : consolidate random functionality in RandomAPI. 2016-06-28 22:31:17 -06:00
James Yonan
b614d5c3e1 random : extended RandomAPI with range methods. 2016-06-27 16:39:30 -06:00
James Yonan
13abf1cf5c random : in MTRand, add clarifying comment on why gen_seed()
(and hence default constructor) is suboptimal.
2016-06-27 16:38:19 -06:00
James Yonan
e2662883ab Added MTRand, a random number generator based
on std::mt19937_64 but that exports the RandomAPI
interface.
2016-01-18 15:33:36 -07:00
James Yonan
3e4078c9a1 In RandomIntBase (mtrand.hpp), added operator()() to return
a reference to underlying std::mt19937 object.
2015-09-02 03:18:42 -07:00
James Yonan
f7edf3c5e1 In devurand.hpp, added leading "::" to global libc methods
open() and read().
2015-09-02 03:17:17 -07:00
James Yonan
23d55e6f5c Boost dependency elimination -- forgot to remove boost
reference in comment from openvpn/random/mtrand.hpp.
2015-06-05 00:46:30 -06:00
James Yonan
a00ed28204 Boost dependency elimination -- renamed boostrand.hpp to
mtrand.hpp and use std::random_device and std::mt19937.
2015-06-04 20:29:02 -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
592f6aeee1 Don't need to open /dev/urandom in read/write mode.
Read mode alone should suffice.
2015-04-15 22:12:37 -06:00
James Yonan
84e4b8878f Minor simplification to rand_type<> method to use the existing
RandomAPI::rand_fill method.
2015-02-03 17:33:09 -07:00
James Yonan
e4b8aa6b80 Added class DevURand, conforming to RandomAPI base,
that grabs entropy directly from /dev/urandom.
2015-01-24 20:09:17 -07:00
James Yonan
730f3d8718 In class RandomIntBase in boostrand.hpp, added rand()
method that simply returns raw random value.
2015-01-08 15:18:16 -07:00
James Yonan
c2c7292a70 Updated copyright to 2015. 2015-01-06 12:56:21 -07:00
James Yonan
6e6326905d In RandomAPI, add an implemented rand_fill() method. 2014-10-22 11:28:24 -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
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
8b71fa9800 Converted RAND_API from static to dynamic polymorphism
(using RandomAPI as base class).
2014-10-15 12:53:18 -06:00
James Yonan
d091ef6afc Support TransportMap seed randomization. This is to prevent
an attacker from using knowledge about the hash table
bucket hashing function to maliciously attempt to create
unbalanced hash buckets, which in turn could lead to DoS.
2014-08-19 16:46:56 -06:00