The userspace conntrack implementation currently derives its hash basis
and selects tuples using a xorshift-based PRNG. This generator is
predictable given enough observed outputs, which allows an attacker to
infer the internal seed details, and by extension, predict future values.
For a NAT implementation this is frequently exposed to untrusted networks,
this is not an acceptable entropy source.
This series introduces a new CSPRNG so that the hash-basis and tuple
selection can draw from an appropriately secure entropy stream. The
implementation includes two backends:
1. An internally maintained ChaCha20 stream cipher which conforms
to RFC 8439, that draws from the global entropy pool and uses
that to build a stream of bytes. This is for instances where
openvswitch is built without OpenSSL available.
2. An OpenSSL EVP backend (preferred) that uses the EVP stream
cipher framework to generate a ChaCha20 stream instead.
Internal benchmarking was compared across the following:
a. get_entropy_or_die() / uint32
b. get_entropy_or_die() / stream block
c. openssl evp
d. internal implementation of chacha20
d. openssl rand_bytes
The microbenchmarking code originally showed get_entropy_or_die() performing
at the same level as an internal implementation - however, that may be due to
the translation unit having all implementation details available. After
porting it to openvswitch random.c, the internal implementation of chacha20
was 30% faster.
Aaron Conole (4):
byte-order: Add le32 conversion routines.
random: Implement a ChaCha20 based CSPRNG.
random: Provide OpenSSL EVP cipher as a CSPRNG source.
conntrack: Use a cryptographic PRNG for NAT tuple selection.
lib/byte-order.h | 34 ++++++
lib/conntrack.c | 17 ++-
lib/random.c | 256 ++++++++++++++++++++++++++++++++++++++++++++
lib/random.h | 15 +++
tests/library.at | 1 +
tests/test-random.c | 72 +++++++++++++
6 files changed, 392 insertions(+), 3 deletions(-)
--
2.55.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev