Skip to content

Conversation

@lstipakov
Copy link
Member

No description provided.

Introduce OvpnAcquire/ReleaseSpinLock(), which
acquire/release spinlock taking into account dpc
and shared/exclusive.

Signed-off-by: Lev Stipakov <[email protected]>
@lstipakov
Copy link
Member Author

lstipakov commented Sep 25, 2025

@mfil it would be nice if you could check (at least) the crypto part. It mirrors the userspace implementation.

@lstipakov lstipakov force-pushed the multipeer branch 5 times, most recently from 6d8e3c3 to 44f8e07 Compare September 26, 2025 11:45
This implements epoch data channel format for
AEAD ciphers, based on RFC and userspace implementation.

 - https://openvpn.github.io/openvpn-rfc/openvpn-wire-protocol.html#name-openvpn-epoch-data-channel-
 - https://gerrit.openvpn.net/c/openvpn/+/806

The differences with userspace implemenation are:

 - use BCrypt key derivation API instead of own implementation
 - receive key usage limits are ignored

Note that this lacks proper locking on updating epoch keys,
this will be implemented in follow-up commit.

Driver version is bumped to 2.8.0.

GitHub: OpenVPN#104

Signed-off-by: Lev Stipakov <[email protected]>
AEAD needs to tweak its epoch keys whenever we hit the usage limit (TX)
or see a packet from a new epoch (RX). That update isn’t
atomic: we rebuild send/recv contexts, refresh future keys,
and advance nonce counters. The code used to do this while the
peer spin lock was held in shared mode, so another thread
could see half-written state.

Introduce OvpnCryptoCallWithRetry() plus small invoke helpers.
The crypto routines keep working under the shared lock on the fast path,
but they return STATUS_OVPN_CRYPTO_RETRY when a real mutation is required.
The caller then upgrades to the exclusive lock, retries with allowRekey = TRUE,
and commits the changes once they’re consistent. That keeps normal traffic
on the cheap shared lock while epoch rotations happen safely under exclusive ownership.

Signed-off-by: Lev Stipakov <[email protected]>
Uninit key slot, set keId/peerId and reset crypto options.

Signed-off-by: Lev Stipakov <[email protected]>
The common function OvpnCryptoAEADDoWork() has grown too large
and now it doesn't make sense to have it. Do encrypt/decrypt
in itn own functions.

While on it, improve comments.

Signed-off-by: Lev Stipakov <[email protected]>
@lstipakov lstipakov force-pushed the multipeer branch 2 times, most recently from 2883266 to 814a36b Compare October 3, 2025 06:18
Create a separate googletest-based project.
Move some of epoch crypto code into own compilation unit.
Add test run to GHA.

Signed-off-by: Lev Stipakov <[email protected]>
@mfil
Copy link
Contributor

mfil commented Oct 8, 2025

The crypto code looks good to me, but I don't feel like I understand the Windows driver stuff enough to approve. Can we get someone else to take another look?

@lstipakov lstipakov merged commit ee04d29 into OpenVPN:multipeer Oct 9, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants