ovpn: add epoch data channel keys
Subsystems (5)
Ralf Lici
reviewercover ovpn: add epoch data channel keys
Hi,
This series adds support for OpenVPN epoch data channel keys to the ovpn kernel module.
Epoch keys are described in the OpenVPN wire protocol draft:
https://openvpn.github.io/openvpn-rfc/openvpn-wire-protocol.html#section-7.2
https://openvpn.github.io/openvpn-rfc/openvpn-wire-protocol.html#section-7.5
At a high level, epoch keys allow OpenVPN to rotate data-channel AEAD keys without requiring a full userspace renegotiation whenever a data-channel key reaches a usage or packet-ID limit. Instead of installing one concrete AEAD key and nonce tail per direction, userspace installs per-direction epoch PRKs. The kernel derives the concrete AEAD key and implicit IV for each epoch using the OpenVPN HKDF-Expand-Label construction, and can then move between pre-derived epochs in the data path.
The DATA_V2 opcode is still used, but epoch packets use the extended packet ID layout defined by the draft: a 64-bit packet ID carrying a 16-bit epoch and a 48-bit sequence number, an XOR-based IV construction, and the AEAD tag at the end of the packet.
The series is structured in three parts. The first adds packet-ID and AES-GCM usage-limit accounting. TX now notifies userspace before packet-ID wrap or AES-GCM hard exhaustion, and stops before the hard limit. RX accounts authenticated packets and reports threshold crossings without dropping packets solely because the peer crossed a local usage threshold. The series also limits AEAD decrypt verification failures.
The middle part moves per-direction key state into explicit key contexts, makes those contexts refcounted for async crypto completion, and makes packet layout handling explicit. This keeps the epoch implementation from adding more special cases to the direct-key path.
The epoch implementation keeps current TX/RX key contexts, one retiring RX key for reordered packets, and bounded rings of future TX/RX keys. TX rotates to a future key before hard packet-ID or AEAD usage exhaustion, and also rotates on the soft AEAD threshold. RX authenticates a packet with a future key before promoting that key to current, then refills consumed future-key slots from workqueue context.
Selftest coverage is intentionally limited: the tests install epoch keys and verify steady-state UDP/TCP packet layout, including the epoch field in captured DATA_V2 packets. They do not exercise rotation or future-key refill because the production thresholds are cryptographic safety limits, so reaching them needs an enormous packet-ID/AEAD budget and lowering them would mean test-only knobs in security-sensitive data-path policy.
Thanks,
Ralf Lici
Mandelbit Srl
---
Ralf Lici (14):
ovpn: prepare packet ID state for usage limits
ovpn: enforce AES-GCM usage limits
ovpn: limit AEAD decrypt verification failures
ovpn: make direct-key AEAD layout explicit
ovpn: move key slot lifecycle out of AEAD
ovpn: move direct key state into key contexts
ovpn: make key contexts refcounted
ovpn: generalize AEAD packet ID handling
ovpn: add epoch key derivation support
ovpn: add epoch key slot state
ovpn: handle epoch AEAD packet format
ovpn: rotate epoch data keys
ovpn: accept epoch keys from netlink
selftests: ovpn: exercise epoch keys
Documentation/netlink/specs/ovpn.yaml | 31 + drivers/net/Kconfig | 2 + drivers/net/ovpn/Makefile | 2 + drivers/net/ovpn/crypto.c | 7 +- drivers/net/ovpn/crypto.h | 121 +++- drivers/net/ovpn/crypto_aead.c | 584 +++++++++++------- drivers/net/ovpn/crypto_aead.h | 9 +- drivers/net/ovpn/crypto_epoch.c | 200 ++++++ drivers/net/ovpn/crypto_epoch.h | 54 ++ drivers/net/ovpn/crypto_key.c | 522 ++++++++++++++++ drivers/net/ovpn/crypto_limits.h | 125 ++++ drivers/net/ovpn/io.c | 254 +++++++- drivers/net/ovpn/io.h | 8 +- drivers/net/ovpn/netlink-gen.c | 9 +- drivers/net/ovpn/netlink-gen.h | 3 +- drivers/net/ovpn/netlink.c | 112 +++- drivers/net/ovpn/pktid.c | 13 +- drivers/net/ovpn/pktid.h | 164 ++++- drivers/net/ovpn/proto.h | 38 ++ drivers/net/ovpn/skb.h | 2 + include/uapi/linux/ovpn.h | 11 + tools/testing/selftests/net/ovpn/Makefile | 2 + tools/testing/selftests/net/ovpn/common.sh | 30 +- tools/testing/selftests/net/ovpn/ovpn-cli.c | 116 +++- .../selftests/net/ovpn/test-epoch-tcp.sh | 11 + .../testing/selftests/net/ovpn/test-epoch.sh | 10 + tools/testing/selftests/net/ovpn/test-mark.sh | 3 +- tools/testing/selftests/net/ovpn/test.sh | 12 +- 28 files changed, 2140 insertions(+), 315 deletions(-) create mode 100644 drivers/net/ovpn/crypto_epoch.c create mode 100644 drivers/net/ovpn/crypto_epoch.h create mode 100644 drivers/net/ovpn/crypto_key.c create mode 100644 drivers/net/ovpn/crypto_limits.h create mode 100755 tools/testing/selftests/net/ovpn/test-epoch-tcp.sh create mode 100755 tools/testing/selftests/net/ovpn/test-epoch.sh
base-commit: 903db046d5579bef0ea699eae4b279dd6455fc9f
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 1/14 ovpn: prepare packet ID state for usage limits
OpenVPN needs packet-ID and cipher usage thresholds to decide when a data-channel key should be renewed or stopped. The existing transmit packet-ID helper only returns the next ID and has no way to request a threshold notification.
Teach the transmit packet-ID helper to return 1 when the fixed OpenVPN packet-ID soft threshold is crossed. The counter is monotonic, so the exact crossing is naturally reported only once. The hard packet-ID wrap check still stops TX; this only gives userspace a chance to rekey while packet-ID space is still available.
--- drivers/net/ovpn/crypto_aead.c | 3 +++ drivers/net/ovpn/netlink.c | 4 ++-- drivers/net/ovpn/pktid.h | 31 +++++++++++++++++++++++++------ 3 files changed, 30 insertions(+), 8 deletions(-)
drivers/net/ovpn/crypto_aead.c +3 -0
@@ -19,6 +19,7 @@#include "pktid.h" #include "crypto_aead.h" #include "crypto.h" +#include "netlink.h" #include "peer.h" #include "proto.h" #include "skb.h"
@@ -207,6 +208,8 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks, ret =ovpn_pktid_xmit_next (&ks->pid_xmit, &pktid);if (unlikely (ret <0 ))return ret; +if (unlikely (ret >0 )) +ovpn_nl_key_swap_notify (peer, ks->key_id);/* concat 4 bytes packet id and 8 bytes nonce tail into 12 bytes * nonce
drivers/net/ovpn/netlink.c +2 -2
@@ -1312,8 +1312,8 @@ int ovpn_nl_key_swap_notify(struct ovpn_peer *peer, u8 key_id)int ret = -EMSGSIZE ;void *hdr; -netdev_info (peer->ovpn->dev,"peer with id %u must rekey - primary key unusable.\n" , - peer->id); +netdev_info (peer->ovpn->dev,"peer with id %u should rekey key %u\n" , + peer->id, key_id); msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_ATOMIC );if (!msg)
drivers/net/ovpn/pktid.h +25 -6
@@ -17,6 +17,9 @@*/ #define PKTID_RECV_EXPIRE (30 * HZ) +/* notify userspace when the packet ID space is close to wrapping */ +#define PKTID_XMIT_REKEY_NOTIFY 0xff000000U +/* Packet-ID state for transmitter */ struct ovpn_pktid_xmit {atomic_t seq_num;
@@ -52,20 +55,36 @@ struct ovpn_pktid_recv {spinlock_t lock; }; -/* Get the next packet ID for xmit */ +/** +* ovpn_pktid_xmit_next - allocate a transmit packet ID +* @pid: transmit packet ID state +* @pktid: location where the generated packet ID is stored +* +* The returned packet ID becomes part of the AEAD nonce, so the helper rejects +* the packet before the 32-bit packet-ID space wraps. +* +* The packet-ID soft threshold does not reject the packet. It returns 1 once +* so the caller can notify userspace to rekey while packet-ID space remains. +* +* Return: 1 if userspace should be notified, 0 if no notification is needed, +* or a negative error code otherwise. +*/ static inline int ovpn_pktid_xmit_next (struct ovpn_pktid_xmit *pid,u32 *pktid) {const u32 seq_num =atomic_fetch_add_unless (&pid->seq_num,1 ,0 ); -/* when the 32bit space is over, we return an error because the packet -* ID is used to create the cipher IV and we do not want to reuse the -* same value more than once -*/ +int ret =0 ; + +/* packet IDs are used to create cipher IVs and must not wrap */ if (unlikely (!seq_num))return -ERANGE ; +/* notify userspace before the packet ID space is close to wrapping */ +if (unlikely (seq_num ==PKTID_XMIT_REKEY_NOTIFY )) + ret =1 ; + *pktid = seq_num; -return 0 ; +return ret; }/* Write 12-byte AEAD IV to dest */
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 3/14 ovpn: limit AEAD decrypt verification failures
In reply to Ralf LiciOpenVPN userspace tracks AEAD tag verification failures per decrypt key. It asks for a new key after more than 2^35 failures and stops attempting AEAD decryption with that key after more than 2^36 failures.
Mirror that behavior in ovpn. Count only crypto_aead_decrypt authentication failures, reported by the crypto API as -EBADMSG, and notify userspace once when the soft threshold is crossed. Once the hard threshold is exceeded, reject new decrypt attempts with the same key before submitting more crypto work.
This applies to all ovpn AEAD ciphers, not only AES-GCM, and is independent from the AES-GCM packet/block usage limits.
--- drivers/net/ovpn/crypto.h | 2 ++ drivers/net/ovpn/crypto_aead.c | 24 ++++++++++++++++++++++++ drivers/net/ovpn/crypto_aead.h | 1 + drivers/net/ovpn/io.c | 6 ++++++ 4 files changed, 33 insertions(+)
drivers/net/ovpn/crypto.h +2 -0
@@ -43,6 +43,8 @@ struct ovpn_crypto_key_slot {struct crypto_aead *encrypt;struct crypto_aead *decrypt; +atomic64_t decrypt_failures; +unsigned long decrypt_failure_flags;u8 nonce_tail_xmit[OVPN_NONCE_TAIL_SIZE ];u8 nonce_tail_recv[OVPN_NONCE_TAIL_SIZE ];
drivers/net/ovpn/crypto_aead.c +24 -0
@@ -29,6 +29,25 @@#define ALG_NAME_AES "gcm(aes)"#define ALG_NAME_CHACHAPOLY "rfc7539(chacha20,poly1305)" +#define OVPN_AEAD_DECRYPT_FAILURE_NOTIFY BIT_ULL(35) +#define OVPN_AEAD_DECRYPT_FAILURE_LIMIT BIT_ULL(36) +#define OVPN_AEAD_DECRYPT_FAILURE_NOTIFY_BIT 0 + +static bool +ovpn_aead_decrypt_failure_exceeded (const struct ovpn_crypto_key_slot *ks) +{ +return atomic64_read (&ks->decrypt_failures) > +OVPN_AEAD_DECRYPT_FAILURE_LIMIT ; +} + +bool ovpn_aead_decrypt_failure_record (struct ovpn_crypto_key_slot *ks) +{ +u64 failures =atomic64_inc_return (&ks->decrypt_failures); + +return failures >OVPN_AEAD_DECRYPT_FAILURE_NOTIFY && + !test_and_set_bit (OVPN_AEAD_DECRYPT_FAILURE_NOTIFY_BIT , + &ks->decrypt_failure_flags); +}static int ovpn_aead_encap_overhead (const struct ovpn_crypto_key_slot *ks) {
@@ -270,6 +289,9 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,if (unlikely (payload_len <0 ))return -EINVAL ; +if (unlikely (ovpn_aead_decrypt_failure_exceeded (ks))) +return -EKEYREJECTED ; +/* Prepare the skb data buffer to be accessed up until the auth tag. * This is required because this area is directly mapped into the sg * list.
@@ -436,6 +458,8 @@ ovpn_aead_crypto_key_slot_new(const struct ovpn_key_config *kc)ovpn_key_usage_limit_init (&ks->usage_limit, kc->cipher_alg);ovpn_key_usage_init (&ks->usage_xmit);ovpn_key_usage_init (&ks->usage_recv); +atomic64_set (&ks->decrypt_failures,0 ); + ks->decrypt_failure_flags =0 ; ks->encrypt = ovpn_aead_init("encrypt", alg_name, kc->encrypt.cipher_key,
drivers/net/ovpn/crypto_aead.h +1 -0
@@ -25,5 +25,6 @@ ovpn_aead_crypto_key_slot_new(const struct ovpn_key_config *kc);void ovpn_aead_crypto_key_slot_destroy (struct ovpn_crypto_key_slot *ks);enum ovpn_cipher_alg ovpn_aead_crypto_alg (struct ovpn_crypto_key_slot *ks); +bool ovpn_aead_decrypt_failure_record (struct ovpn_crypto_key_slot *ks);#endif /* _NET_OVPN_OVPNAEAD_H_ */
drivers/net/ovpn/io.c +6 -0
@@ -129,6 +129,12 @@ void ovpn_decrypt_post(void *data, int ret)/* crypto is done, cleanup skb CB and its members */ kfree (ovpn_skb_cb (skb)->crypto_tmp); +if (unlikely (ret == -EBADMSG )) { +if (unlikely (ovpn_aead_decrypt_failure_record (ks))) +ovpn_nl_key_swap_notify (peer, ks->key_id); + goto drop; + } +if (unlikely (ret <0 )) goto drop;
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 2/14 ovpn: enforce AES-GCM usage limits
In reply to Ralf LiciAES-GCM has a finite per-key usage bound in terms of GCM block operations. ovpn already stops before packet-ID wrap, but it did not account for this tighter limit, so a large-volume key could exceed the AES-GCM usage budget without any kernel-side action.
Keep the configured cipher in the key slot and convert authenticated data and plaintext length to AES block units for AES-GCM. The block helper is cipher-specific rather than based on crypto_aead_blocksize, since GCM implementations can advertise a provider block size that is not the GCM accounting block.
On TX, reserve the blocks with packet ID allocation and fail once the combined invocation/block budget would be exceeded, which drives the existing key-kill notification path. Also notify userspace once when TX or RX usage crosses 7/8 of the fixed hard limit, so userspace can rekey before the hard limit is reached.
RX counts only authenticated, non-replayed packets and does not drop solely because the peer crossed a local usage threshold.
--- drivers/net/ovpn/crypto.h | 5 ++ drivers/net/ovpn/crypto_aead.c | 13 +++- drivers/net/ovpn/crypto_limits.h | 125 +++++++++++++++++++++++++++++++ drivers/net/ovpn/io.c | 11 +++ drivers/net/ovpn/pktid.h | 57 ++++++++++++-- 5 files changed, 202 insertions(+), 9 deletions(-) create mode 100644 drivers/net/ovpn/crypto_limits.h
drivers/net/ovpn/crypto.h +5 -0
@@ -10,6 +10,7 @@#ifndef _NET_OVPN_OVPNCRYPTO_H_#define _NET_OVPN_OVPNCRYPTO_H_ +#include "crypto_limits.h" #include "pktid.h" #include "proto.h"
@@ -37,6 +38,8 @@ struct ovpn_peer_key_reset {struct ovpn_crypto_key_slot {u8 key_id; +enum ovpn_cipher_alg cipher_alg; +struct ovpn_limit usage_limit;struct crypto_aead *encrypt;struct crypto_aead *decrypt;
@@ -44,7 +47,9 @@ struct ovpn_crypto_key_slot {u8 nonce_tail_recv[OVPN_NONCE_TAIL_SIZE ];struct ovpn_pktid_recv pid_recv____cacheline_aligned_in_smp ; +struct ovpn_key_usage usage_recv;struct ovpn_pktid_xmit pid_xmit____cacheline_aligned_in_smp ; +struct ovpn_key_usage usage_xmit;struct kref refcount;struct rcu_head rcu; };
drivers/net/ovpn/crypto_aead.c +12 -1
@@ -139,6 +139,7 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks, struct sk_buff *skb) {const unsigned int tag_size =crypto_aead_authsize (ks->encrypt); +unsigned int plaintext_len;struct aead_request *req;struct sk_buff *trailer;struct scatterlist *sg;
@@ -149,6 +150,7 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,ovpn_skb_cb (skb)->peer = peer;ovpn_skb_cb (skb)->ks = ks; + plaintext_len = skb->len;/* Sample AEAD header format: * 48000001 00000005 7e7046bd 444a7e28 cc6387b1 64a4d6c1 380275a...
@@ -205,7 +207,12 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,/* obtain packet ID, which is used both as a first * 4 bytes of nonce and last 4 bytes of associated data. */ - ret =ovpn_pktid_xmit_next (&ks->pid_xmit, &pktid); + ret =ovpn_pktid_xmit_next (&ks->pid_xmit, &ks->usage_xmit, + &ks->usage_limit, +ovpn_aead_limit_blocks (ks->cipher_alg, +OVPN_AAD_SIZE , + plaintext_len), + &pktid);if (unlikely (ret <0 ))return ret;if (unlikely (ret >0 ))
@@ -425,6 +432,10 @@ ovpn_aead_crypto_key_slot_new(const struct ovpn_key_config *kc) ks->decrypt =NULL ;kref_init (&ks->refcount); ks->key_id = kc->key_id; + ks->cipher_alg = kc->cipher_alg; +ovpn_key_usage_limit_init (&ks->usage_limit, kc->cipher_alg); +ovpn_key_usage_init (&ks->usage_xmit); +ovpn_key_usage_init (&ks->usage_recv); ks->encrypt = ovpn_aead_init("encrypt", alg_name, kc->encrypt.cipher_key,
drivers/net/ovpn/crypto_limits.h new file +125 -0
125 lines not on this page · raw message
drivers/net/ovpn/io.c +11 -0
@@ -112,6 +112,7 @@ void ovpn_decrypt_post(void *data, int ret)struct sk_buff *skb = data;struct ovpn_socket *sock;struct ovpn_peer *peer; +u64 aead_blocks;__be16 proto;__be32 *pid;
@@ -141,6 +142,16 @@ void ovpn_decrypt_post(void *data, int ret) goto drop; } + aead_blocks =ovpn_aead_limit_blocks (ks->cipher_alg, +OVPN_OPCODE_SIZE + +OVPN_NONCE_WIRE_SIZE , + skb->len - payload_offset); +if (unlikely (ovpn_pktid_recv_update_aead (&ks->pid_recv, + &ks->usage_recv, + &ks->usage_limit, + aead_blocks))) +ovpn_nl_key_swap_notify (peer, ks->key_id); +/* keep track of last received authenticated packet for keepalive */ WRITE_ONCE (peer->last_recv,ktime_get_real_seconds ());
drivers/net/ovpn/pktid.h +49 -8
90 lines not on this page · raw message
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 4/14 ovpn: make direct-key AEAD layout explicit
In reply to Ralf LiciSome AEAD packet layout constants are currently named as DATA_V2 helpers. DATA_V2 is the opcode used by OpenVPN data packets, but the layout represented by these constants is the direct-key AEAD layout:
opcode, 32-bit packet ID, prepended authentication tag, and payload.
Rename the helpers after the direct-key format they describe. This gives the direct layout clear scope before adding another data-channel key format that keeps the DATA_V2 opcode but uses different packet fields.
--- drivers/net/ovpn/crypto_aead.c | 38 +++++++++++++++------------------- drivers/net/ovpn/io.c | 10 ++++----- drivers/net/ovpn/io.h | 8 +++---- drivers/net/ovpn/proto.h | 30 +++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 31 deletions(-)
drivers/net/ovpn/crypto_aead.c +17 -21
@@ -24,9 +24,6 @@#include "proto.h" #include "skb.h" -#define OVPN_AUTH_TAG_SIZE 16 -#define OVPN_AAD_SIZE (OVPN_OPCODE_SIZE + OVPN_NONCE_WIRE_SIZE) -#define ALG_NAME_AES "gcm(aes)"#define ALG_NAME_CHACHAPOLY "rfc7539(chacha20,poly1305)"#define OVPN_AEAD_DECRYPT_FAILURE_NOTIFY BIT_ULL(35)
@@ -51,9 +48,7 @@ bool ovpn_aead_decrypt_failure_record(struct ovpn_crypto_key_slot *ks)static int ovpn_aead_encap_overhead (const struct ovpn_crypto_key_slot *ks) { -return OVPN_OPCODE_SIZE +/* OP header size */ -sizeof (u32) +/* Packet ID */ -crypto_aead_authsize (ks->encrypt);/* Auth Tag */ +return OVPN_AEAD_DIRECT_AAD_SIZE +crypto_aead_authsize (ks->encrypt); }/**
@@ -163,6 +158,7 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,struct sk_buff *trailer;struct scatterlist *sg;int nfrags, ret; +u64 aead_blocks;u32 pktid, op;void *tmp;u8 *iv;
@@ -205,7 +201,7 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks, sg =ovpn_aead_crypto_req_sg (ks->encrypt, req);/* sg table: -* 0: op, wire nonce (AD, len=OVPN_OP_SIZE_V2+OVPN_NONCE_WIRE_SIZE), +* 0: op, wire nonce (AD, len=OVPN_AEAD_DIRECT_AAD_SIZE), * 1, 2, 3, ..., n: payload, * n+1: auth_tag (len=tag_size) */
@@ -226,12 +222,11 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,/* obtain packet ID, which is used both as a first * 4 bytes of nonce and last 4 bytes of associated data. */ + aead_blocks =ovpn_aead_limit_blocks (ks->cipher_alg, +OVPN_AEAD_DIRECT_AAD_SIZE , + plaintext_len); ret =ovpn_pktid_xmit_next (&ks->pid_xmit, &ks->usage_xmit, - &ks->usage_limit, -ovpn_aead_limit_blocks (ks->cipher_alg, -OVPN_AAD_SIZE , - plaintext_len), - &pktid); + &ks->usage_limit, aead_blocks, &pktid);if (unlikely (ret <0 ))return ret;if (unlikely (ret >0 ))
@@ -253,14 +248,14 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks, *((__force __be32 *)skb->data) =htonl (op);/* AEAD Additional data */ -sg_set_buf (sg, skb->data,OVPN_AAD_SIZE ); +sg_set_buf (sg, skb->data,OVPN_AEAD_DIRECT_AAD_SIZE );/* setup async crypto operation */ aead_request_set_tfm (req, ks->encrypt);aead_request_set_callback (req,0 , ovpn_encrypt_post, skb);aead_request_set_crypt (req, sg, sg, skb->len -ovpn_aead_encap_overhead (ks), iv); -aead_request_set_ad (req,OVPN_AAD_SIZE ); +aead_request_set_ad (req,OVPN_AEAD_DIRECT_AAD_SIZE );/* encrypt it */ return crypto_aead_encrypt (req);
@@ -278,7 +273,7 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,void *tmp;u8 *iv; - payload_offset =OVPN_AAD_SIZE + tag_size; + payload_offset =ovpn_aead_direct_payload_offset (tag_size); payload_len = skb->len - payload_offset;ovpn_skb_cb (skb)->payload_offset = payload_offset;
@@ -320,14 +315,14 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks, sg =ovpn_aead_crypto_req_sg (ks->decrypt, req);/* sg table: -* 0: op, wire nonce (AD, len=OVPN_OPCODE_SIZE+OVPN_NONCE_WIRE_SIZE), +* 0: op, wire nonce (AD, len=OVPN_AEAD_DIRECT_AAD_SIZE), * 1, 2, 3, ..., n: payload, * n+1: auth_tag (len=tag_size) */ sg_init_table (sg, nfrags +2 );/* packet op is head of additional data */ -sg_set_buf (sg, skb->data,OVPN_AAD_SIZE ); +sg_set_buf (sg, skb->data,OVPN_AEAD_DIRECT_AAD_SIZE );/* build scatterlist to decrypt packet payload */ ret =skb_to_sgvec_nomark (skb, sg +1 , payload_offset, payload_len);
@@ -338,10 +333,11 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks, }/* append auth_tag onto scatterlist */ -sg_set_buf (sg + ret +1 , skb->data +OVPN_AAD_SIZE , tag_size); +sg_set_buf (sg + ret +1 , skb->data +OVPN_AEAD_DIRECT_TAG_OFFSET , + tag_size);/* copy nonce into IV buffer */ -memcpy (iv, skb->data +OVPN_OPCODE_SIZE ,OVPN_NONCE_WIRE_SIZE ); +memcpy (iv,ovpn_aead_direct_wire_nonce (skb),OVPN_NONCE_WIRE_SIZE );memcpy (iv +OVPN_NONCE_WIRE_SIZE , ks->nonce_tail_recv,OVPN_NONCE_TAIL_SIZE );
@@ -350,7 +346,7 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,aead_request_set_callback (req,0 , ovpn_decrypt_post, skb);aead_request_set_crypt (req, sg, sg, payload_len + tag_size, iv); -aead_request_set_ad (req,OVPN_AAD_SIZE ); +aead_request_set_ad (req,OVPN_AEAD_DIRECT_AAD_SIZE );/* decrypt it */ return crypto_aead_decrypt (req);
@@ -380,7 +376,7 @@ static struct crypto_aead *ovpn_aead_init(const char *title, goto error; } - ret =crypto_aead_setauthsize (aead,OVPN_AUTH_TAG_SIZE ); + ret =crypto_aead_setauthsize (aead,OVPN_AEAD_TAG_SIZE );if (ret) {pr_err ("%s crypto_aead_setauthsize failed, err=%d\n" , title, ret);
drivers/net/ovpn/io.c +4 -6
@@ -114,7 +114,7 @@ void ovpn_decrypt_post(void *data, int ret)struct ovpn_peer *peer;u64 aead_blocks;__be16 proto; -__be32 *pid; +u32 pktid;/* crypto is happening asynchronously. this function will be called * again later by the crypto callback with a proper return code
@@ -138,9 +138,8 @@ void ovpn_decrypt_post(void *data, int ret)if (unlikely (ret <0 )) goto drop; -/* PID sits after the op */ - pid = (__force __be32 *)(skb->data +OVPN_OPCODE_SIZE ); - ret =ovpn_pktid_recv (&ks->pid_recv,ntohl (*pid),0 ); + pktid =ovpn_aead_direct_pktid (skb); + ret =ovpn_pktid_recv (&ks->pid_recv, pktid,0 );if (unlikely (ret <0 )) { net_err_ratelimited("%s: PKT ID RX error for peer %u: %d\n", netdev_name(peer->ovpn->dev), peer->id,
@@ -149,8 +148,7 @@ void ovpn_decrypt_post(void *data, int ret) } aead_blocks =ovpn_aead_limit_blocks (ks->cipher_alg, -OVPN_OPCODE_SIZE + -OVPN_NONCE_WIRE_SIZE , +OVPN_AEAD_DIRECT_AAD_SIZE , skb->len - payload_offset); if (unlikely(ovpn_pktid_recv_update_aead(&ks->pid_recv, &ks->usage_recv,
drivers/net/ovpn/io.h +4 -4
@@ -10,10 +10,10 @@#ifndef _NET_OVPN_OVPN_H_#define _NET_OVPN_OVPN_H_ -/* DATA_V2 header size with AEAD encryption */ -#define OVPN_HEAD_ROOM (OVPN_OPCODE_SIZE + OVPN_NONCE_WIRE_SIZE + \ - 16/* AEAD TAG length */ + \ -max (sizeof (struct udphdr ),sizeof (struct tcphdr )) +\ +/* headroom needed by directly installed AEAD keys */ +#define OVPN_HEAD_ROOM (OVPN_AEAD_DIRECT_AAD_SIZE + \ + OVPN_AEAD_TAG_SIZE + \ + max(sizeof(struct udphdr), sizeof(struct tcphdr)) + \ max(sizeof(struct ipv6hdr), sizeof(struct iphdr)))/* max padding required by encryption */
drivers/net/ovpn/proto.h +30 -0
@@ -47,8 +47,38 @@#define OVPN_DATA_V1 6/* data channel v1 packet */ #define OVPN_DATA_V2 9/* data channel v2 packet */ +/* direct-key AEAD packet layout */ +#define OVPN_AEAD_TAG_SIZE 16 +#define OVPN_AEAD_DIRECT_OP_OFFSET 0 +#define OVPN_AEAD_DIRECT_PKTID_OFFSET (OVPN_AEAD_DIRECT_OP_OFFSET + \ + OVPN_OPCODE_SIZE) +#define OVPN_AEAD_DIRECT_TAG_OFFSET (OVPN_AEAD_DIRECT_PKTID_OFFSET + \ + OVPN_NONCE_WIRE_SIZE) +#define OVPN_AEAD_DIRECT_AAD_SIZE OVPN_AEAD_DIRECT_TAG_OFFSET +#define OVPN_PEER_ID_UNDEF 0x00FFFFFF +static inline unsigned int +ovpn_aead_direct_payload_offset (unsigned int tag_size) +{ +return OVPN_AEAD_DIRECT_TAG_OFFSET + tag_size; +} + +static inline u32 ovpn_aead_direct_pktid (const struct sk_buff *skb) +{ +const __be32 *pktid; + + pktid = (__force const __be32 *)(skb->data + +OVPN_AEAD_DIRECT_PKTID_OFFSET ); + +return be32_to_cpu (*pktid); +} + +static inline u8 *ovpn_aead_direct_wire_nonce (struct sk_buff *skb) +{ +return skb->data +OVPN_AEAD_DIRECT_PKTID_OFFSET ; +} +/** * ovpn_opcode_from_skb - extract OP code from skb at specified offset * @skb: the packet to extract the OP code from
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 5/14 ovpn: move key slot lifecycle out of AEAD
In reply to Ralf Licicrypto_aead.c now contains both AEAD packet operations and key slot setup, destruction and cipher introspection. Those lifecycle helpers are used by the generic crypto state code and do not need to live with the per-packet encrypt and decrypt path.
Move key slot lifecycle code into crypto_key.c and expose it through ovpn_crypto_key_slot helpers. This leaves crypto_aead.c focused on AEAD packet processing without changing key allocation, validation or teardown behavior.
--- drivers/net/ovpn/Makefile | 1 + drivers/net/ovpn/crypto.c | 7 +- drivers/net/ovpn/crypto.h | 7 ++ drivers/net/ovpn/crypto_aead.c | 158 ------------------------------ drivers/net/ovpn/crypto_aead.h | 5 - drivers/net/ovpn/crypto_key.c | 172 +++++++++++++++++++++++++++++++++ 6 files changed, 183 insertions(+), 167 deletions(-) create mode 100644 drivers/net/ovpn/crypto_key.c
drivers/net/ovpn/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_OVPN) := ovpn.o ovpn-y += bind.o ovpn-y += crypto.o ovpn-y += crypto_aead.o +ovpn-y += crypto_key.o ovpn-y += main.o ovpn-y += io.o ovpn-y += netlink.o
drivers/net/ovpn/crypto.c +3 -4
@@ -15,7 +15,6 @@#include "ovpnpriv.h" #include "main.h" #include "pktid.h" -#include "crypto_aead.h" #include "crypto.h" static void ovpn_ks_destroy_rcu (struct rcu_head *head)
@@ -23,7 +22,7 @@ static void ovpn_ks_destroy_rcu(struct rcu_head *head)struct ovpn_crypto_key_slot *ks; ks = container_of(head, struct ovpn_crypto_key_slot, rcu); -ovpn_aead_crypto_key_slot_destroy (ks); +ovpn_crypto_key_slot_destroy (ks); }void ovpn_crypto_key_slot_release (struct kref *kref)
@@ -89,7 +88,7 @@ int ovpn_crypto_state_reset(struct ovpn_crypto_state *cs, pkr->slot != OVPN_KEY_SLOT_SECONDARY)return -EINVAL ; - new =ovpn_aead_crypto_key_slot_new (&pkr->key); + new =ovpn_crypto_key_slot_new (&pkr->key);if (IS_ERR (new))return PTR_ERR (new);
@@ -202,7 +201,7 @@ int ovpn_crypto_config_get(struct ovpn_crypto_state *cs,return -ENOENT ; } - keyconf->cipher_alg =ovpn_aead_crypto_alg (ks); + keyconf->cipher_alg =ovpn_crypto_key_slot_alg (ks); keyconf->key_id = ks->key_id;rcu_read_unlock ();
drivers/net/ovpn/crypto.h +7 -0
@@ -136,6 +136,13 @@ static inline void ovpn_crypto_key_slot_put(struct ovpn_crypto_key_slot *ks)int ovpn_crypto_state_reset (struct ovpn_crypto_state *cs,const struct ovpn_peer_key_reset *pkr); +struct ovpn_crypto_key_slot * +ovpn_crypto_key_slot_new (const struct ovpn_key_config *kc); + +void ovpn_crypto_key_slot_destroy (struct ovpn_crypto_key_slot *ks); + +enum ovpn_cipher_alg ovpn_crypto_key_slot_alg (struct ovpn_crypto_key_slot *ks); +void ovpn_crypto_key_slot_delete (struct ovpn_crypto_state *cs,enum ovpn_key_slot slot);
drivers/net/ovpn/crypto_aead.c +0 -158
167 lines not on this page · raw message
drivers/net/ovpn/crypto_aead.h +0 -5
@@ -20,11 +20,6 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,int ovpn_aead_decrypt (struct ovpn_peer *peer,struct ovpn_crypto_key_slot *ks,struct sk_buff *skb); -struct ovpn_crypto_key_slot * -ovpn_aead_crypto_key_slot_new (const struct ovpn_key_config *kc); -void ovpn_aead_crypto_key_slot_destroy (struct ovpn_crypto_key_slot *ks); - -enum ovpn_cipher_alg ovpn_aead_crypto_alg (struct ovpn_crypto_key_slot *ks);bool ovpn_aead_decrypt_failure_record (struct ovpn_crypto_key_slot *ks);#endif /* _NET_OVPN_OVPNAEAD_H_ */
drivers/net/ovpn/crypto_key.c new file +172 -0
172 lines not on this page · raw message
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 6/14 ovpn: move direct key state into key contexts
In reply to Ralf LiciKey slots currently mix slot-wide state with per-direction runtime state. That includes AEAD transforms, implicit IV material, packet ID state, usage accounting and decrypt failure tracking.
Move those per-direction pieces into struct ovpn_key_ctx. Keep the slot focused on key id, cipher selection and shared usage limits. This gives directly installed keys a cleaner state boundary before adding derived key formats.
--- drivers/net/ovpn/crypto.h | 28 ++++++----- drivers/net/ovpn/crypto_aead.c | 56 +++++++++++----------- drivers/net/ovpn/crypto_aead.h | 2 +- drivers/net/ovpn/crypto_key.c | 85 ++++++++++++++++++++++++---------- drivers/net/ovpn/io.c | 9 ++-- drivers/net/ovpn/pktid.h | 10 ++-- 6 files changed, 119 insertions(+), 71 deletions(-)
drivers/net/ovpn/crypto.h +16 -12
@@ -22,7 +22,7 @@ struct ovpn_key_direction {size_t nonce_tail_size;/* only needed for GCM modes */ }; -/* all info for a particular symmetric key (primary or secondary) */ +/* direct-key material for a primary or secondary slot */ struct ovpn_key_config {enum ovpn_cipher_alg cipher_alg;u8 key_id;
@@ -36,22 +36,26 @@ struct ovpn_peer_key_reset {struct ovpn_key_config key; }; +/* state for one concrete AEAD key direction */ +struct ovpn_key_ctx { +struct crypto_aead *tfm; +u8 implicit_iv[OVPN_NONCE_SIZE ]; +union { +struct ovpn_pktid_recv recv; +struct ovpn_pktid_xmit xmit; + } pid____cacheline_aligned_in_smp ; +struct ovpn_key_usage usage; +atomic64_t decrypt_failures; +unsigned long decrypt_failure_flags; +}; +struct ovpn_crypto_key_slot {u8 key_id;enum ovpn_cipher_alg cipher_alg;struct ovpn_limit usage_limit; -struct crypto_aead *encrypt; -struct crypto_aead *decrypt; -atomic64_t decrypt_failures; -unsigned long decrypt_failure_flags; -u8 nonce_tail_xmit[OVPN_NONCE_TAIL_SIZE ]; -u8 nonce_tail_recv[OVPN_NONCE_TAIL_SIZE ]; - -struct ovpn_pktid_recv pid_recv____cacheline_aligned_in_smp ; -struct ovpn_key_usage usage_recv; -struct ovpn_pktid_xmit pid_xmit____cacheline_aligned_in_smp ; -struct ovpn_key_usage usage_xmit; +struct ovpn_key_ctx *encrypt; +struct ovpn_key_ctx *decrypt;struct kref refcount;struct rcu_head rcu; };
drivers/net/ovpn/crypto_aead.c +30 -26
160 lines not on this page · raw message
drivers/net/ovpn/crypto_aead.h +1 -1
@@ -20,6 +20,6 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,int ovpn_aead_decrypt (struct ovpn_peer *peer,struct ovpn_crypto_key_slot *ks,struct sk_buff *skb); -bool ovpn_aead_decrypt_failure_record (struct ovpn_crypto_key_slot *ks); +bool ovpn_aead_decrypt_failure_record (struct ovpn_key_ctx *key);#endif /* _NET_OVPN_OVPNAEAD_H_ */
drivers/net/ovpn/crypto_key.c +61 -24
122 lines not on this page · raw message
drivers/net/ovpn/io.c +5 -4
@@ -110,6 +110,7 @@ void ovpn_decrypt_post(void *data, int ret)struct ovpn_crypto_key_slot *ks;unsigned int payload_offset =0 ;struct sk_buff *skb = data; +struct ovpn_key_ctx *key;struct ovpn_socket *sock;struct ovpn_peer *peer;u64 aead_blocks;
@@ -124,13 +125,14 @@ void ovpn_decrypt_post(void *data, int ret) payload_offset =ovpn_skb_cb (skb)->payload_offset; ks =ovpn_skb_cb (skb)->ks; + key = ks->decrypt; peer =ovpn_skb_cb (skb)->peer;/* crypto is done, cleanup skb CB and its members */ kfree (ovpn_skb_cb (skb)->crypto_tmp);if (unlikely (ret == -EBADMSG )) { -if (unlikely (ovpn_aead_decrypt_failure_record (ks))) +if (unlikely (ovpn_aead_decrypt_failure_record (key)))ovpn_nl_key_swap_notify (peer, ks->key_id); goto drop; }
@@ -139,7 +141,7 @@ void ovpn_decrypt_post(void *data, int ret) goto drop; pktid =ovpn_aead_direct_pktid (skb); - ret =ovpn_pktid_recv (&ks->pid_recv, pktid,0 ); + ret =ovpn_pktid_recv (&key->pid.recv, pktid,0 );if (unlikely (ret <0 )) { net_err_ratelimited("%s: PKT ID RX error for peer %u: %d\n", netdev_name(peer->ovpn->dev), peer->id,
@@ -150,8 +152,7 @@ void ovpn_decrypt_post(void *data, int ret) aead_blocks =ovpn_aead_limit_blocks (ks->cipher_alg,OVPN_AEAD_DIRECT_AAD_SIZE , skb->len - payload_offset); -if (unlikely (ovpn_pktid_recv_update_aead (&ks->pid_recv, - &ks->usage_recv, +if (unlikely (ovpn_pktid_recv_update_aead (&key->pid.recv, &key->usage, &ks->usage_limit, aead_blocks)))ovpn_nl_key_swap_notify (peer, ks->key_id);
drivers/net/ovpn/pktid.h +6 -4
@@ -128,14 +128,16 @@ ovpn_pktid_recv_update_aead(struct ovpn_pktid_recv *pr,return ret; } -/* Write 12-byte AEAD IV to dest */ +/* write the direct-key AEAD IV to dest */ static inline void ovpn_pktid_aead_write (const u32 pktid, -const u8 nt[], +const u8 implicit_iv[],unsigned char *dest) { *(__force __be32 *)(dest) =htonl (pktid); -BUILD_BUG_ON (4 +OVPN_NONCE_TAIL_SIZE !=OVPN_NONCE_SIZE ); -memcpy (dest +4 , nt,OVPN_NONCE_TAIL_SIZE ); +BUILD_BUG_ON (OVPN_NONCE_WIRE_SIZE +OVPN_NONCE_TAIL_SIZE != +OVPN_NONCE_SIZE ); +memcpy (dest +OVPN_NONCE_WIRE_SIZE , + implicit_iv +OVPN_NONCE_WIRE_SIZE ,OVPN_NONCE_TAIL_SIZE ); }void ovpn_pktid_xmit_init (struct ovpn_pktid_xmit *pid);
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 7/14 ovpn: make key contexts refcounted
In reply to Ralf LiciEpoch key rotation needs to replace encrypt and decrypt key contexts while packets may still hold references from the async AEAD path.
Publish key contexts through RCU, add a per-context kref, and let encrypt and decrypt requests hold a context until their completion callback runs. Direct-key behavior is otherwise unchanged.
--- drivers/net/ovpn/crypto.h | 34 ++++++++++++++++++++-- drivers/net/ovpn/crypto_aead.c | 20 ++++++++++--- drivers/net/ovpn/crypto_key.c | 53 +++++++++++++++++++--------------- drivers/net/ovpn/io.c | 8 +++-- drivers/net/ovpn/skb.h | 2 ++ 5 files changed, 86 insertions(+), 31 deletions(-)
drivers/net/ovpn/crypto.h +32 -2
@@ -10,6 +10,9 @@#ifndef _NET_OVPN_OVPNCRYPTO_H_#define _NET_OVPN_OVPNCRYPTO_H_ +#include <linux/kref.h> +#include <linux/rcupdate.h> +#include "crypto_limits.h" #include "pktid.h" #include "proto.h"
@@ -47,6 +50,8 @@ struct ovpn_key_ctx {struct ovpn_key_usage usage;atomic64_t decrypt_failures;unsigned long decrypt_failure_flags; +struct kref refcount; +struct rcu_head rcu; };struct ovpn_crypto_key_slot {
@@ -54,8 +59,8 @@ struct ovpn_crypto_key_slot {enum ovpn_cipher_alg cipher_alg;struct ovpn_limit usage_limit; -struct ovpn_key_ctx *encrypt; -struct ovpn_key_ctx *decrypt; +struct ovpn_key_ctx __rcu *encrypt; +struct ovpn_key_ctx __rcu *decrypt;struct kref refcount;struct rcu_head rcu; };
@@ -137,6 +142,31 @@ static inline void ovpn_crypto_key_slot_put(struct ovpn_crypto_key_slot *ks)kref_put (&ks->refcount, ovpn_crypto_key_slot_release); } +void ovpn_key_ctx_release (struct kref *kref); + +static inline void ovpn_key_ctx_put (struct ovpn_key_ctx *key) +{ +if (key) +kref_put (&key->refcount, ovpn_key_ctx_release); +} + +static inline int ovpn_key_ctx_get (struct ovpn_key_ctx **out, +struct ovpn_key_ctx __rcu **rcu_ptr) +{ +struct ovpn_key_ctx *key; + +rcu_read_lock (); + key =rcu_dereference (*rcu_ptr); +if (unlikely (!key || !kref_get_unless_zero (&key->refcount))) { +rcu_read_unlock (); +return -ENOKEY ; + } +rcu_read_unlock (); + + *out = key; +return 0 ; +} +int ovpn_crypto_state_reset (struct ovpn_crypto_state *cs,const struct ovpn_peer_key_reset *pkr);
drivers/net/ovpn/crypto_aead.c +16 -4
@@ -150,7 +150,7 @@ static struct scatterlist *ovpn_aead_crypto_req_sg(struct crypto_aead *aead,int ovpn_aead_encrypt (struct ovpn_peer *peer,struct ovpn_crypto_key_slot *ks,struct sk_buff *skb) { -struct ovpn_key_ctx *key = ks->encrypt; +struct ovpn_key_ctx *key =NULL ;unsigned int plaintext_len;struct aead_request *req;struct sk_buff *trailer;
@@ -165,6 +165,12 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,ovpn_skb_cb (skb)->peer = peer;ovpn_skb_cb (skb)->ks = ks; plaintext_len = skb->len; + + ret =ovpn_key_ctx_get (&key, &ks->encrypt); +if (unlikely (ret)) +return ret; +ovpn_skb_cb (skb)->key = key; + tag_size =crypto_aead_authsize (key->tfm);/* Sample AEAD header format:
@@ -264,7 +270,7 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,int ovpn_aead_decrypt (struct ovpn_peer *peer,struct ovpn_crypto_key_slot *ks,struct sk_buff *skb) { -struct ovpn_key_ctx *key = ks->decrypt; +struct ovpn_key_ctx *key =NULL ;unsigned int payload_offset;int ret, payload_len, nfrags;struct aead_request *req;
@@ -274,13 +280,19 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,void *tmp;u8 *iv; +ovpn_skb_cb (skb)->peer = peer; +ovpn_skb_cb (skb)->ks = ks; + + ret =ovpn_key_ctx_get (&key, &ks->decrypt); +if (unlikely (ret)) +return ret; +ovpn_skb_cb (skb)->key = key; + tag_size =crypto_aead_authsize (key->tfm); payload_offset =ovpn_aead_direct_payload_offset (tag_size); payload_len = skb->len - payload_offset;ovpn_skb_cb (skb)->payload_offset = payload_offset; -ovpn_skb_cb (skb)->peer = peer; -ovpn_skb_cb (skb)->ks = ks;/* sanity check on packet size, payload size must be >= 0 */ if (unlikely (payload_len <0 ))
drivers/net/ovpn/crypto_key.c +30 -23
94 lines not on this page · raw message
drivers/net/ovpn/io.c +6 -2
@@ -125,14 +125,14 @@ void ovpn_decrypt_post(void *data, int ret) payload_offset =ovpn_skb_cb (skb)->payload_offset; ks =ovpn_skb_cb (skb)->ks; - key = ks->decrypt; + key =ovpn_skb_cb (skb)->key; peer =ovpn_skb_cb (skb)->peer;/* crypto is done, cleanup skb CB and its members */ kfree (ovpn_skb_cb (skb)->crypto_tmp);if (unlikely (ret == -EBADMSG )) { -if (unlikely (ovpn_aead_decrypt_failure_record (key))) +if (key &&unlikely (ovpn_aead_decrypt_failure_record (key)))ovpn_nl_key_swap_notify (peer, ks->key_id); goto drop; }
@@ -224,6 +224,7 @@ void ovpn_decrypt_post(void *data, int ret)ovpn_peer_put (peer);if (likely (ks))ovpn_crypto_key_slot_put (ks); +ovpn_key_ctx_put (key); }/* RX path entry point: decrypt packet and forward it to the device */
@@ -256,6 +257,7 @@ void ovpn_encrypt_post(void *data, int ret)struct ovpn_crypto_key_slot *ks;struct sk_buff *skb = data;struct ovpn_socket *sock; +struct ovpn_key_ctx *key;struct ovpn_peer *peer;unsigned int orig_len;
@@ -267,6 +269,7 @@ void ovpn_encrypt_post(void *data, int ret) ks =ovpn_skb_cb (skb)->ks; peer =ovpn_skb_cb (skb)->peer; + key =ovpn_skb_cb (skb)->key;/* crypto is done, cleanup skb CB and its members */ kfree (ovpn_skb_cb (skb)->crypto_tmp);
@@ -322,6 +325,7 @@ void ovpn_encrypt_post(void *data, int ret)ovpn_peer_put (peer);if (likely (ks))ovpn_crypto_key_slot_put (ks); +ovpn_key_ctx_put (key);kfree_skb (skb); }
drivers/net/ovpn/skb.h +2 -0
@@ -22,6 +22,7 @@* struct ovpn_cb - ovpn skb control block * @peer: the peer this skb was received from/sent to * @ks: the crypto key slot used to encrypt/decrypt this skb +* @key: the key context used to encrypt/decrypt this skb * @crypto_tmp: pointer to temporary memory used for crypto operations * containing the IV, the scatter gather list and the aead request * @payload_offset: offset in the skb where the payload starts
@@ -30,6 +31,7 @@struct ovpn_cb {struct ovpn_peer *peer;struct ovpn_crypto_key_slot *ks; +struct ovpn_key_ctx *key;void *crypto_tmp;unsigned int payload_offset;bool nosignal;
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 8/14 ovpn: generalize AEAD packet ID handling
In reply to Ralf LiciPrepare the data path for packet ID spaces larger than the direct-key 32-bit counter.
Widen packet ID accounting to u64 and store packet-ID soft and hard limits in the transmit packet-ID state. This keeps wrap and rekey-notification policy with the packet-ID allocator instead of passing raw thresholds through the AEAD path.
Make AES-GCM usage accounting include the packet layout's AAD length. Add shared packet ID read/write helpers and direct-key slot layout fields that later epoch support can reuse.
--- drivers/net/ovpn/crypto.h | 3 + drivers/net/ovpn/crypto_aead.c | 32 +++++---- drivers/net/ovpn/crypto_key.c | 12 +++- drivers/net/ovpn/io.c | 9 +-- drivers/net/ovpn/pktid.c | 13 ++-- drivers/net/ovpn/pktid.h | 126 +++++++++++++++++++++++---------- drivers/net/ovpn/proto.h | 8 +++ 7 files changed, 142 insertions(+), 61 deletions(-)
drivers/net/ovpn/crypto.h +3 -0
@@ -58,6 +58,9 @@ struct ovpn_crypto_key_slot {u8 key_id;enum ovpn_cipher_alg cipher_alg;struct ovpn_limit usage_limit; +bool epoch_format; +unsigned int aad_size; +unsigned int pktid_size;struct ovpn_key_ctx __rcu *encrypt;struct ovpn_key_ctx __rcu *decrypt;
drivers/net/ovpn/crypto_aead.c +19 -13
@@ -156,10 +156,12 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,struct sk_buff *trailer;struct scatterlist *sg;unsigned int tag_size; -int nfrags, ret; +bool pktid_notify;u64 aead_blocks; -u32 pktid, op; +int nfrags, ret; +u64 pktid;void *tmp; +u32 op;u8 *iv;ovpn_skb_cb (skb)->peer = peer;
@@ -228,11 +230,15 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,/* obtain packet ID, which is used both as a first * 4 bytes of nonce and last 4 bytes of associated data. */ - aead_blocks =ovpn_aead_limit_blocks (ks->cipher_alg, -OVPN_AEAD_DIRECT_AAD_SIZE , + ret =ovpn_pktid_xmit_next (&key->pid.xmit, &pktid); +if (unlikely (ret <0 )) +return ret; + pktid_notify = ret >0 ; + + aead_blocks =ovpn_aead_limit_blocks (ks->cipher_alg, ks->aad_size, plaintext_len); - ret =ovpn_pktid_xmit_next (&key->pid.xmit, &key->usage, - &ks->usage_limit, aead_blocks, &pktid); + ret =ovpn_key_usage_xmit (&key->usage, &ks->usage_limit, pktid, + aead_blocks, pktid_notify);if (unlikely (ret <0 ))return ret;if (unlikely (ret >0 ))
@@ -241,11 +247,11 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,/* concat 4 bytes packet id and 8 bytes nonce tail into 12 bytes * nonce */ -ovpn_pktid_aead_write (pktid, key->implicit_iv, iv); + pktid =ovpn_pktid_aead_write (0 , pktid, key->implicit_iv, iv);/* make space for packet id and push it to the front */ -__skb_push (skb,OVPN_NONCE_WIRE_SIZE ); -memcpy (skb->data, iv,OVPN_NONCE_WIRE_SIZE ); +__skb_push (skb, ks->pktid_size); +ovpn_pktid_wire_write (skb->data, false, pktid);/* add packet op as head of additional data */ op =ovpn_opcode_compose (OVPN_DATA_V2 , ks->key_id, peer->tx_id);
@@ -254,14 +260,14 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks, *((__force __be32 *)skb->data) =htonl (op);/* AEAD Additional data */ -sg_set_buf (sg, skb->data,OVPN_AEAD_DIRECT_AAD_SIZE ); +sg_set_buf (sg, skb->data, ks->aad_size);/* setup async crypto operation */ aead_request_set_tfm (req, key->tfm);aead_request_set_callback (req,0 , ovpn_encrypt_post, skb);aead_request_set_crypt (req, sg, sg, skb->len -ovpn_aead_encap_overhead (key), iv); -aead_request_set_ad (req,OVPN_AEAD_DIRECT_AAD_SIZE ); +aead_request_set_ad (req, ks->aad_size);/* encrypt it */ return crypto_aead_encrypt (req);
@@ -336,7 +342,7 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,sg_init_table (sg, nfrags +2 );/* packet op is head of additional data */ -sg_set_buf (sg, skb->data,OVPN_AEAD_DIRECT_AAD_SIZE ); +sg_set_buf (sg, skb->data, ks->aad_size);/* build scatterlist to decrypt packet payload */ ret =skb_to_sgvec_nomark (skb, sg +1 , payload_offset, payload_len);
@@ -360,7 +366,7 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,aead_request_set_callback (req,0 , ovpn_decrypt_post, skb);aead_request_set_crypt (req, sg, sg, payload_len + tag_size, iv); -aead_request_set_ad (req,OVPN_AEAD_DIRECT_AAD_SIZE ); +aead_request_set_ad (req, ks->aad_size);/* decrypt it */ return crypto_aead_decrypt (req);
drivers/net/ovpn/crypto_key.c +9 -3
@@ -102,6 +102,7 @@ static struct ovpn_key_ctx * ovpn_key_ctx_new(const char *title, const char *alg_name, const struct ovpn_key_direction *dir, bool encrypt) { + struct ovpn_limit pktid_limit;struct ovpn_key_ctx *key;size_t tail_offset;int ret;
@@ -132,10 +133,12 @@ ovpn_key_ctx_new(const char *title, const char *alg_name,kref_init (&key->refcount);/* initialize only the packet ID direction this context owns */ -if (encrypt) -ovpn_pktid_xmit_init (&key->pid.xmit); -else +if (encrypt) { +ovpn_pktid_xmit_limit_init (&pktid_limit, false); +ovpn_pktid_xmit_init (&key->pid.xmit, &pktid_limit); + }else {ovpn_pktid_recv_init (&key->pid.recv); + }return key; }
@@ -184,6 +187,9 @@ ovpn_crypto_key_slot_new(const struct ovpn_key_config *kc)kref_init (&ks->refcount); ks->key_id = kc->key_id; ks->cipher_alg = kc->cipher_alg; + ks->epoch_format = false; + ks->aad_size =OVPN_AEAD_DIRECT_AAD_SIZE ; + ks->pktid_size =OVPN_NONCE_WIRE_SIZE ;ovpn_key_usage_limit_init (&ks->usage_limit, kc->cipher_alg); key =ovpn_key_ctx_new ("encrypt" , alg_name, &kc->encrypt, true);
drivers/net/ovpn/io.c +5 -4
@@ -114,8 +114,9 @@ void ovpn_decrypt_post(void *data, int ret)struct ovpn_socket *sock;struct ovpn_peer *peer;u64 aead_blocks; +u16 pkt_epoch;__be16 proto; -u32 pktid; +u64 pktid;/* crypto is happening asynchronously. this function will be called * again later by the crypto callback with a proper return code
@@ -140,7 +141,8 @@ void ovpn_decrypt_post(void *data, int ret)if (unlikely (ret <0 )) goto drop; - pktid =ovpn_aead_direct_pktid (skb); + pktid =ovpn_pktid_read (skb->data +OVPN_OPCODE_SIZE , false, + &pkt_epoch); ret =ovpn_pktid_recv (&key->pid.recv, pktid,0 );if (unlikely (ret <0 )) { net_err_ratelimited("%s: PKT ID RX error for peer %u: %d\n",
@@ -149,8 +151,7 @@ void ovpn_decrypt_post(void *data, int ret) goto drop; } - aead_blocks =ovpn_aead_limit_blocks (ks->cipher_alg, -OVPN_AEAD_DIRECT_AAD_SIZE , + aead_blocks =ovpn_aead_limit_blocks (ks->cipher_alg, ks->aad_size, skb->len - payload_offset); if (unlikely(ovpn_pktid_recv_update_aead(&key->pid.recv, &key->usage, &ks->usage_limit,
drivers/net/ovpn/pktid.c +8 -5
@@ -17,9 +17,12 @@#include "main.h" #include "pktid.h" -void ovpn_pktid_xmit_init (struct ovpn_pktid_xmit *pid) +void ovpn_pktid_xmit_init (struct ovpn_pktid_xmit *pid, +const struct ovpn_limit *limit) { -atomic_set (&pid->seq_num,1 ); + pid->seq_num =1 ; + pid->limit = *limit; +spin_lock_init (&pid->lock); }void ovpn_pktid_recv_init (struct ovpn_pktid_recv *pr)
@@ -31,7 +34,7 @@ void ovpn_pktid_recv_init(struct ovpn_pktid_recv *pr)/* Packet replay detection. * Allows ID backtrack of up to REPLAY_WINDOW_SIZE - 1. */ -int ovpn_pktid_recv (struct ovpn_pktid_recv *pr,u32 pkt_id,u32 pkt_time) +int ovpn_pktid_recv (struct ovpn_pktid_recv *pr,u64 pkt_id,u32 pkt_time) {const unsigned long now = jiffies;int ret;
@@ -71,7 +74,7 @@ int ovpn_pktid_recv(struct ovpn_pktid_recv *pr, u32 pkt_id, u32 pkt_time) pr->id = pkt_id; }else if (pkt_id > pr->id) {/* ID jumped forward by more than one */ -const unsigned int delta = pkt_id - pr->id; +const u64 delta = pkt_id - pr->id;if (delta <REPLAY_WINDOW_SIZE ) {unsigned int i;
@@ -95,7 +98,7 @@ int ovpn_pktid_recv(struct ovpn_pktid_recv *pr, u32 pkt_id, u32 pkt_time) pr->id = pkt_id; }else {/* ID backtrack */ -const unsigned int delta = pr->id - pkt_id; +const u64 delta = pr->id - pkt_id;if (delta > pr->max_backtrack) pr->max_backtrack = delta;
drivers/net/ovpn/pktid.h +90 -36
183 lines not on this page · raw message
drivers/net/ovpn/proto.h +8 -0
@@ -37,6 +37,7 @@* and is normally the head of the IV */ #define OVPN_NONCE_WIRE_SIZE (OVPN_NONCE_SIZE - OVPN_NONCE_TAIL_SIZE) +#define OVPN_EPOCH_NONCE_WIRE_SIZE 8#define OVPN_OPCODE_SIZE 4/* DATA_V2 opcode size */ #define OVPN_OPCODE_KEYID_MASK 0x07000000
@@ -56,6 +57,13 @@ OVPN_NONCE_WIRE_SIZE)#define OVPN_AEAD_DIRECT_AAD_SIZE OVPN_AEAD_DIRECT_TAG_OFFSET +/* epoch-key AEAD packet layout */ +#define OVPN_AEAD_EPOCH_OP_OFFSET 0 +#define OVPN_AEAD_EPOCH_PKTID_OFFSET (OVPN_AEAD_EPOCH_OP_OFFSET + \ + OVPN_OPCODE_SIZE) +#define OVPN_AEAD_EPOCH_AAD_SIZE (OVPN_AEAD_EPOCH_PKTID_OFFSET + \ + OVPN_EPOCH_NONCE_WIRE_SIZE) +#define OVPN_PEER_ID_UNDEF 0x00FFFFFF static inline unsigned int
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 9/14 ovpn: add epoch key derivation support
In reply to Ralf LiciAdd the HKDF-Expand-Label helper used to derive per-epoch data keys and implicit IVs from an imported epoch PRK. OpenVPN currently uses the labels "datakey upd", "data_key" and "data_iv" for this derivation.
Epoch derivation uses HMAC-SHA256, so the PRK is fixed at 32 bytes. Keep that size internal until the netlink key format is introduced.
--- drivers/net/Kconfig | 2 + drivers/net/ovpn/Makefile | 1 + drivers/net/ovpn/crypto_epoch.c | 200 ++++++++++++++++++++++++++++++++ drivers/net/ovpn/crypto_epoch.h | 55 +++++++++ 4 files changed, 258 insertions(+) create mode 100644 drivers/net/ovpn/crypto_epoch.c create mode 100644 drivers/net/ovpn/crypto_epoch.h
drivers/net/Kconfig +2 -0
@@ -109,6 +109,8 @@ config OVPN select CRYPTO_AES select CRYPTO_GCM select CRYPTO_CHACHA20POLY1305 + select CRYPTO_HMAC + select CRYPTO_SHA256 select STREAM_PARSER help This module enhances the performance of the OpenVPN userspace software
drivers/net/ovpn/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_OVPN) := ovpn.o ovpn-y += bind.o ovpn-y += crypto.o ovpn-y += crypto_aead.o +ovpn-y += crypto_epoch.o ovpn-y += crypto_key.o ovpn-y += main.o ovpn-y += io.o
drivers/net/ovpn/crypto_epoch.c new file +200 -0
200 lines not on this page · raw message
drivers/net/ovpn/crypto_epoch.h new file +55 -0
55 lines not on this page · raw message
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 11/14 ovpn: handle epoch AEAD packet format
In reply to Ralf LiciTeach the AEAD path to build and parse the epoch packet layout. Epoch packets carry the authentication tag at the tail and use the epoch-aware packet ID encoding.
Direct packets keep the existing layout. Epoch keys are still not accepted through netlink, and key promotion is added separately.
--- drivers/net/ovpn/crypto.h | 2 + drivers/net/ovpn/crypto_aead.c | 243 +++++++++++++++++++++++---------- drivers/net/ovpn/crypto_key.c | 8 ++ drivers/net/ovpn/io.c | 28 +++- 4 files changed, 206 insertions(+), 75 deletions(-)
drivers/net/ovpn/crypto.h +2 -0
@@ -81,6 +81,8 @@ struct ovpn_crypto_key_slot {bool epoch_format;unsigned int aad_size;unsigned int pktid_size; +unsigned int payload_offset; +unsigned int tail_tag_size;struct ovpn_epoch_key epoch_key_send;struct ovpn_epoch_key epoch_key_recv;
drivers/net/ovpn/crypto_aead.c +173 -70
362 lines not on this page · raw message
drivers/net/ovpn/crypto_key.c +8 -0
@@ -394,6 +394,7 @@ struct ovpn_crypto_key_slot * ovpn_crypto_key_slot_new(const struct ovpn_key_config *kc) {struct ovpn_crypto_key_slot *ks =NULL ; +unsigned int direct_payload_offset;struct ovpn_key_ctx *key;const char *alg_name;int ret;
@@ -427,6 +428,9 @@ ovpn_crypto_key_slot_new(const struct ovpn_key_config *kc)if (!ks)return ERR_PTR (-ENOMEM ); + direct_payload_offset = +ovpn_aead_direct_payload_offset (OVPN_AEAD_TAG_SIZE ); + ks->encrypt =NULL ; ks->decrypt =NULL ;kref_init (&ks->refcount);
@@ -438,6 +442,10 @@ ovpn_crypto_key_slot_new(const struct ovpn_key_config *kc)OVPN_AEAD_DIRECT_AAD_SIZE ; ks->pktid_size = kc->use_epoch_keys ?OVPN_EPOCH_NONCE_WIRE_SIZE :OVPN_NONCE_WIRE_SIZE ; + ks->payload_offset = kc->use_epoch_keys ? +OVPN_AEAD_EPOCH_AAD_SIZE : + direct_payload_offset; + ks->tail_tag_size = kc->use_epoch_keys ?OVPN_AEAD_TAG_SIZE :0 ;ovpn_key_usage_limit_init (&ks->usage_limit, kc->cipher_alg);if (kc->use_epoch_keys) {
drivers/net/ovpn/io.c +23 -5
@@ -113,6 +113,7 @@ void ovpn_decrypt_post(void *data, int ret)struct ovpn_key_ctx *key;struct ovpn_socket *sock;struct ovpn_peer *peer; +int payload_len;u64 aead_blocks;u16 pkt_epoch;__be16 proto;
@@ -133,7 +134,8 @@ void ovpn_decrypt_post(void *data, int ret)kfree (ovpn_skb_cb (skb)->crypto_tmp);if (unlikely (ret == -EBADMSG )) { -if (key &&unlikely (ovpn_aead_decrypt_failure_record (key))) +if (key &&unlikely (ovpn_aead_decrypt_failure_record (key)) && +likely (!ks->epoch_format))ovpn_nl_key_swap_notify (peer, ks->key_id); goto drop; }
@@ -141,8 +143,8 @@ void ovpn_decrypt_post(void *data, int ret)if (unlikely (ret <0 )) goto drop; - pktid =ovpn_pktid_read (skb->data +OVPN_OPCODE_SIZE , false, - &pkt_epoch); + pktid =ovpn_pktid_read (skb->data +OVPN_OPCODE_SIZE , + ks->epoch_format, &pkt_epoch); ret =ovpn_pktid_recv (&key->pid.recv, pktid,0 );if (unlikely (ret <0 )) { net_err_ratelimited("%s: PKT ID RX error for peer %u: %d\n",
@@ -151,13 +153,29 @@ void ovpn_decrypt_post(void *data, int ret) goto drop; } +if (unlikely (skb->len < payload_offset)) + goto drop; + payload_len = skb->len - payload_offset; +if (unlikely (ks->tail_tag_size)) { +if (unlikely (payload_len < ks->tail_tag_size)) + goto drop; + payload_len -= ks->tail_tag_size; + } +if (unlikely (payload_len <0 )) + goto drop; + aead_blocks =ovpn_aead_limit_blocks (ks->cipher_alg, ks->aad_size, - skb->len - payload_offset); + payload_len);if (unlikely (ovpn_pktid_recv_update_aead (&key->pid.recv, &key->usage, &ks->usage_limit, - aead_blocks))) + aead_blocks) && + !ks->epoch_format))ovpn_nl_key_swap_notify (peer, ks->key_id); +if (unlikely (ks->tail_tag_size && +pskb_trim (skb, skb->len - ks->tail_tag_size))) + goto drop; +/* keep track of last received authenticated packet for keepalive */ WRITE_ONCE (peer->last_recv,ktime_get_real_seconds ());
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 10/14 ovpn: add epoch key slot state
In reply to Ralf LiciEpoch keys do not import concrete AEAD keys for direct packet processing. Userspace provides per-direction PRKs, and the kernel derives the concrete AEAD key context and implicit IV for each epoch.
Add the slot state needed to keep TX and RX epoch derivation separate, track the current encrypt/decrypt key contexts, and prederive future key rings for both directions. The future rings let the data path advance to a new epoch without deriving keys in the fast path.
Direct keys continue to create one concrete AEAD context per direction. Name that constructor explicitly as the direct-key path so the later epoch constructor can share the same key-context boundary without hiding which key format is being installed.
Packet layout handling and promotion between epoch keys are added by later patches.
--- drivers/net/ovpn/crypto.h | 52 +++++- drivers/net/ovpn/crypto_key.c | 325 ++++++++++++++++++++++++++++++++-- drivers/net/ovpn/netlink.c | 8 +- 3 files changed, 362 insertions(+), 23 deletions(-)
drivers/net/ovpn/crypto.h +49 -3
@@ -12,7 +12,9 @@#include <linux/kref.h> #include <linux/rcupdate.h> +#include <linux/workqueue_types.h> +#include "crypto_epoch.h" #include "crypto_limits.h" #include "pktid.h" #include "proto.h"
@@ -25,12 +27,28 @@ struct ovpn_key_direction {size_t nonce_tail_size;/* only needed for GCM modes */ }; -/* direct-key material for a primary or secondary slot */ +/* PRK material imported from userspace to derive epoch data keys */ +struct ovpn_epoch_prk { +const u8 *key; +size_t key_size; +unsigned int cipher_key_len; +}; + +/* key material for a primary or secondary slot */ struct ovpn_key_config {enum ovpn_cipher_alg cipher_alg;u8 key_id; -struct ovpn_key_direction encrypt; -struct ovpn_key_direction decrypt; +bool use_epoch_keys; +union { +struct { +struct ovpn_key_direction encrypt; +struct ovpn_key_direction decrypt; + } direct; +struct { +struct ovpn_epoch_prk encrypt; +struct ovpn_epoch_prk decrypt; + } epoch; + }; };/* used to pass settings from netlink to the crypto engine */
@@ -41,6 +59,7 @@ struct ovpn_peer_key_reset {/* state for one concrete AEAD key direction */ struct ovpn_key_ctx { +u16 epoch;struct crypto_aead *tfm;u8 implicit_iv[OVPN_NONCE_SIZE ];union {
@@ -58,12 +77,29 @@ struct ovpn_crypto_key_slot {u8 key_id;enum ovpn_cipher_alg cipher_alg;struct ovpn_limit usage_limit; +const char *alg_name;bool epoch_format;unsigned int aad_size;unsigned int pktid_size; +struct ovpn_epoch_key epoch_key_send; +struct ovpn_epoch_key epoch_key_recv; +struct ovpn_key_ctx __rcu *encrypt;struct ovpn_key_ctx __rcu *decrypt; +struct ovpn_key_ctx __rcu *retiring_key; + +struct ovpn_future_keys future_tx_keys; +struct ovpn_future_keys future_rx_keys; + +struct work_struct tx_refill; +struct work_struct rx_refill; + +/* protects encrypt and future_tx_keys */ +spinlock_t tx_lock; +/* protects decrypt, retiring_key and future_rx_keys */ +spinlock_t rx_lock; +struct kref refcount;struct rcu_head rcu; };
@@ -193,4 +229,14 @@ int ovpn_crypto_config_get(struct ovpn_crypto_state *cs,bool ovpn_crypto_kill_key (struct ovpn_crypto_state *cs,u8 key_id); +void ovpn_schedule_refill (struct ovpn_crypto_key_slot *ks,bool encrypt); + +struct ovpn_key_ctx * +ovpn_key_ctx_create_direct (bool encrypt,const char *alg_name, +const struct ovpn_key_direction *dir); + +struct ovpn_key_ctx * +ovpn_key_ctx_create_epoch (bool encrypt,const char *alg_name, +struct ovpn_epoch_key *epoch_key); +#endif /* _NET_OVPN_OVPNCRYPTO_H_ */
drivers/net/ovpn/crypto_key.c +308 -17
399 lines not on this page · raw message
drivers/net/ovpn/netlink.c +5 -3
@@ -888,7 +888,7 @@ int ovpn_nl_key_new_doit(struct sk_buff *skb, struct genl_info *info) {struct nlattr *attrs[OVPN_A_KEYCONF_MAX +1 ];struct ovpn_priv *ovpn = info->user_ptr[0 ]; -struct ovpn_peer_key_reset pkr; +struct ovpn_peer_key_reset pkr = {};struct ovpn_peer *peer;u32 peer_id;int ret;
@@ -923,12 +923,14 @@ int ovpn_nl_key_new_doit(struct sk_buff *skb, struct genl_info *info) pkr.key.cipher_alg =nla_get_u32 (attrs[OVPN_A_KEYCONF_CIPHER_ALG ]); ret =ovpn_nl_get_key_dir (info, attrs[OVPN_A_KEYCONF_ENCRYPT_DIR ], - pkr.key.cipher_alg, &pkr.key.encrypt); + pkr.key.cipher_alg, + &pkr.key.direct.encrypt);if (ret <0 )return ret; ret =ovpn_nl_get_key_dir (info, attrs[OVPN_A_KEYCONF_DECRYPT_DIR ], - pkr.key.cipher_alg, &pkr.key.decrypt); + pkr.key.cipher_alg, + &pkr.key.direct.decrypt);if (ret <0 )return ret;
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 14/14 selftests: ovpn: exercise epoch keys
In reply to Ralf LiciExtend ovpn-cli's key installation command with an explicit key type so that the tests can install either direct keys or epoch keys. Use the same selector for the TCP connect helper when it auto-installs a key.
Add epoch wrappers around the existing UDP and TCP data-path tests. The packet capture filter also checks epoch 1 in DATA_V2 packet IDs, so the tests verify netlink key installation and the epoch packet layout without adding a separate topology.
This intentionally does not cover epoch rotation or future-key refill:
the selftests use normal production limits, so the short traffic run does not consume enough packet-ID or AEAD budget to advance epochs.
--- tools/testing/selftests/net/ovpn/Makefile | 2 + tools/testing/selftests/net/ovpn/common.sh | 30 +++-- tools/testing/selftests/net/ovpn/ovpn-cli.c | 116 +++++++++++++++--- .../selftests/net/ovpn/test-epoch-tcp.sh | 11 ++ .../testing/selftests/net/ovpn/test-epoch.sh | 10 ++ tools/testing/selftests/net/ovpn/test-mark.sh | 3 +- tools/testing/selftests/net/ovpn/test.sh | 12 +- 7 files changed, 154 insertions(+), 30 deletions(-) create mode 100755 tools/testing/selftests/net/ovpn/test-epoch-tcp.sh create mode 100755 tools/testing/selftests/net/ovpn/test-epoch.sh
tools/testing/selftests/net/ovpn/Makefile +2 -0
@@ -36,6 +36,8 @@ TEST_PROGS := \ test-chachapoly.sh \ test-close-socket-tcp.sh \ test-close-socket.sh \ + test-epoch-tcp.sh \ + test-epoch.sh \ test-float.sh \ test-large-mtu.sh \ test-mark.sh \
tools/testing/selftests/net/ovpn/common.sh +23 -7
@@ -12,6 +12,7 @@ OVPN_TCP_PEERS_FILE=${OVPN_TCP_PEERS_FILE:-tcp_peers.txt} OVPN_CLI=${OVPN_CLI:-${OVPN_COMMON_DIR}/ovpn-cli} OVPN_YNL=${OVPN_YNL:-${OVPN_COMMON_DIR}/../../../../net/ynl/pyynl/cli.py} OVPN_ALG=${OVPN_ALG:-aes} +OVPN_KEY_TYPE=${OVPN_KEY_TYPE:-direct} OVPN_PROTO=${OVPN_PROTO:-UDP} OVPN_FLOAT=${OVPN_FLOAT:-0} OVPN_SYMMETRIC_ID=${OVPN_SYMMETRIC_ID:-0}
@@ -184,14 +185,26 @@ ovpn_build_capture_filter() { # address. The IPv6 branch assumes there are no extension # headers in the outer packet. if [[ "${2}" == *:* ]]; then - printf "ip6 and ip6[6] = 17 and ip6[48:4] = %s" "${1}" + printf "ip6 and ip6[6] = 17 and ip6[48:4] = %s" \ + "${1}" + if [ "${OVPN_KEY_TYPE}" == "epoch" ]; then + printf " and ip6[52:2] = 0x0001" + fi else printf "ip and udp[8:4] = %s" "${1}" + if [ "${OVPN_KEY_TYPE}" == "epoch" ]; then + printf " and udp[12:2] = 0x0001" + fi fi else # openvpn over TCP prepends a 2-byte packet length ahead of the # DATA_V2 opcode, so skip it before matching the payload header - printf "ip and tcp[(((tcp[12] & 0xf0) >> 2) + 2):4] = %s" "${1}" + printf "ip and tcp[(((tcp[12] & 0xf0) >> 2) + 2):4] = %s" \ + "${1}" + if [ "${OVPN_KEY_TYPE}" == "epoch" ]; then + printf " and tcp[(((tcp[12] & 0xf0) >> 2) + 6):2] = " + printf "0x0001" + fi fi }
@@ -222,8 +235,8 @@ ovpn_add_peer() { for p in $(seq 1 ${OVPN_NUM_PEERS}); do ip netns exec "${server_ns}" ${OVPN_CLI} \ - new_key tun0 ${p} 1 0 ${OVPN_ALG} 0 \ - data64.key + new_key tun0 ${p} 1 0 ${OVPN_ALG} \ + ${OVPN_KEY_TYPE} 0 data64.key done else peer_ns="ovpn_peer${1}"
@@ -245,7 +258,8 @@ ovpn_add_peer() { tun${1} ${PEER_ID} ${TX_ID} ${LPORT} ${RADDR} \ ${RPORT} ip netns exec "${peer_ns}" ${OVPN_CLI} new_key tun${1} \ - ${PEER_ID} 1 0 ${OVPN_ALG} 1 data64.key + ${PEER_ID} 1 0 ${OVPN_ALG} ${OVPN_KEY_TYPE} \ + 1 data64.key fi else if [ ${1} -eq 0 ]; then
@@ -254,7 +268,8 @@ ovpn_add_peer() { for p in $(seq 1 ${OVPN_NUM_PEERS}); do ip netns exec "${server_ns}" \ ${OVPN_CLI} new_key tun0 ${p} \ - 1 0 ${OVPN_ALG} 0 data64.key + 1 0 ${OVPN_ALG} \ + ${OVPN_KEY_TYPE} 0 data64.key done }) & sleep 5
@@ -269,7 +284,8 @@ ovpn_add_peer() { TX_ID=${1} fi ip netns exec "${peer_ns}" ${OVPN_CLI} connect tun${1} \ - ${PEER_ID} ${TX_ID} 10.10.${1}.1 1 data64.key + ${PEER_ID} ${TX_ID} 10.10.${1}.1 1 \ + ${OVPN_KEY_TYPE} data64.key fi fi }
tools/testing/selftests/net/ovpn/ovpn-cli.c +99 -17
205 lines not on this page · raw message
tools/testing/selftests/net/ovpn/test-epoch-tcp.sh new file +11 -0
@@ -0,0 +1,11 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026 OpenVPN, Inc. +# +# Author: Ralf Lici <[email protected]> +# Antonio Quartulli <[email protected]> + +OVPN_KEY_TYPE="epoch" +OVPN_PROTO="TCP" + +source test.sh
tools/testing/selftests/net/ovpn/test-epoch.sh new file +10 -0
@@ -0,0 +1,10 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026 OpenVPN, Inc. +# +# Author: Ralf Lici <[email protected]> +# Antonio Quartulli <[email protected]> + +OVPN_KEY_TYPE="epoch" + +source test.sh
tools/testing/selftests/net/ovpn/test-mark.sh +2 -1
@@ -43,7 +43,8 @@ ovpn_mark_prepare_network() { for p in $(seq 1 3); do ovpn_cmd_ok "install server key for peer ${p}" \ ip netns exec ovpn_peer0 "${OVPN_CLI}" new_key tun0 \ - "${p}" 1 0 "${OVPN_ALG}" 0 data64.key + "${p}" 1 0 "${OVPN_ALG}" "${OVPN_KEY_TYPE}" \ + 0 data64.key done for p in $(seq 1 3); do
tools/testing/selftests/net/ovpn/test.sh +7 -5
@@ -67,14 +67,15 @@ ovpn_run_basic_traffic() { local tcpdump_timeout="1.5s" for p in $(seq 1 ${OVPN_NUM_PEERS}); do - # The first part of the data packet header consists of: + # The tcpdump filters match the cleartext data packet prefix: # - TCP only: 2 bytes for the packet length # - 5 bits for opcode ("9" for DATA_V2) # - 3 bits for key-id ("0" at this point) - # - 12 bytes for peer-id: + # - 24 bits for peer-id: # - with asymmetric ID: "${p}" one way and "${p} + 9" the # other way # - with symmetric ID: "${p}" both ways + # - epoch keys only: 2 bytes for epoch ("1" at this point) header1=$(printf "0x4800000%x" ${p}) header2=$(printf "0x4800000%x" $((p + OVPN_ID_OFFSET))) raddr=""
@@ -152,11 +153,12 @@ ovpn_run_key_rollover() { peer_ns="ovpn_peer${p}" ovpn_cmd_ok "add secondary key on peer0 for peer ${p}" \ ip netns exec ovpn_peer0 ${OVPN_CLI} new_key tun0 \ - ${p} 2 1 ${OVPN_ALG} 0 data64.key + ${p} 2 1 ${OVPN_ALG} ${OVPN_KEY_TYPE} \ + 0 data64.key ovpn_cmd_ok "add secondary key on peer${p} for peer ${p}" \ ip netns exec "${peer_ns}" ${OVPN_CLI} new_key tun${p} \ - $((p + OVPN_ID_OFFSET)) 2 1 ${OVPN_ALG} 1 \ - data64.key + $((p + OVPN_ID_OFFSET)) 2 1 ${OVPN_ALG} \ + ${OVPN_KEY_TYPE} 1 data64.key ovpn_cmd_ok "swap keys on peer${p}" \ ip netns exec "${peer_ns}" ${OVPN_CLI} swap_keys \ tun${p} $((p + OVPN_ID_OFFSET))
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 12/14 ovpn: rotate epoch data keys
In reply to Ralf LiciEpoch keys derive concrete AEAD keys for individual epochs. TX must move to a fresh epoch before the current sequence space or AEAD usage budget is exhausted; otherwise it would either reuse nonces or exceed the cipher usage limit.
Add TX promotion from the prederived future-key ring and retry encryption with the new key when rotation succeeds. Required rotations stop the packet if refill cannot provide the next key. Optional rotations are requested when TX crosses the soft AEAD limit or RX asks the peer to leave an exhausted or failing current decrypt epoch; the pending request is kept on the slot so TX can retry without sampling RX state on every packet.
On RX, promote to a future key only after a packet from that epoch has authenticated. Keep the closest previous epoch as retiring key so reordered packets can still be accepted after multi-epoch jumps, and refill consumed future-key slots in workqueue context.
When RX observes that the peer has moved forward, advance local TX as well so outbound packets signal the peer to leave the old epoch.
--- drivers/net/ovpn/crypto.h | 4 + drivers/net/ovpn/crypto_aead.c | 181 +++++++++++++++++++++++++-- drivers/net/ovpn/crypto_aead.h | 3 + drivers/net/ovpn/crypto_key.c | 9 +- drivers/net/ovpn/io.c | 221 +++++++++++++++++++++++++++++++-- drivers/net/ovpn/pktid.h | 6 +- 6 files changed, 399 insertions(+), 25 deletions(-)
drivers/net/ovpn/crypto.h +4 -0
@@ -10,6 +10,7 @@#ifndef _NET_OVPN_OVPNCRYPTO_H_#define _NET_OVPN_OVPNCRYPTO_H_ +#include <linux/bitops.h> #include <linux/kref.h> #include <linux/rcupdate.h> #include <linux/workqueue_types.h>
@@ -57,6 +58,8 @@ struct ovpn_peer_key_reset {struct ovpn_key_config key; }; +#define OVPN_CRYPTO_TX_ROTATE_PENDING 0 +/* state for one concrete AEAD key direction */ struct ovpn_key_ctx {u16 epoch;
@@ -83,6 +86,7 @@ struct ovpn_crypto_key_slot {unsigned int pktid_size;unsigned int payload_offset;unsigned int tail_tag_size; +unsigned long flags;struct ovpn_epoch_key epoch_key_send;struct ovpn_epoch_key epoch_key_recv;
drivers/net/ovpn/crypto_aead.c +168 -13
207 lines not on this page · raw message
drivers/net/ovpn/crypto_aead.h +3 -0
@@ -15,6 +15,9 @@#include <asm/types.h> #include <linux/skbuff.h> +int ovpn_advance_encrypt_key (struct ovpn_crypto_key_slot *ks,u16 target_epoch, +bool required); +int ovpn_aead_encrypt (struct ovpn_peer *peer,struct ovpn_crypto_key_slot *ks,struct sk_buff *skb); int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,
drivers/net/ovpn/crypto_key.c +5 -4
@@ -104,7 +104,8 @@ void ovpn_key_ctx_release(struct kref *kref)static struct ovpn_key_ctx *ovpn_key_ctx_new (const char *title,const char *alg_name,const u8 *cipher_key,unsigned int cipher_key_len, -const u8 *implicit_iv,u16 epoch,bool encrypt) +const u8 *implicit_iv,u16 epoch,bool epoch_format, +bool encrypt) {struct ovpn_limit pktid_limit;struct ovpn_key_ctx *key;
@@ -134,7 +135,7 @@ ovpn_key_ctx_new(const char *title, const char *alg_name,/* initialize only the packet ID direction this context owns */ if (encrypt) { -ovpn_pktid_xmit_limit_init (&pktid_limit, false); +ovpn_pktid_xmit_limit_init (&pktid_limit, epoch_format);ovpn_pktid_xmit_init (&key->pid.xmit, &pktid_limit); }else {ovpn_pktid_recv_init (&key->pid.recv);
@@ -158,7 +159,7 @@ ovpn_key_ctx_create_direct(bool encrypt, const char *alg_name, key =ovpn_key_ctx_new (encrypt ?"encrypt" :"decrypt" , alg_name, dir->cipher_key, dir->cipher_key_size, - implicit_iv,0 , encrypt); + implicit_iv,0 , false, encrypt);memzero_explicit (implicit_iv,sizeof (implicit_iv));return key;
@@ -179,7 +180,7 @@ ovpn_key_ctx_create_epoch(bool encrypt, const char *alg_name, key =ovpn_key_ctx_new (encrypt ?"encrypt" :"decrypt" , alg_name, cipher_key, epoch_key->cipher_key_len, - implicit_iv, epoch_key->epoch, encrypt); + implicit_iv, epoch_key->epoch, true, encrypt);memzero_explicit (cipher_key,sizeof (cipher_key));memzero_explicit (implicit_iv,sizeof (implicit_iv));
drivers/net/ovpn/io.c +214 -7
249 lines not on this page · raw message
drivers/net/ovpn/pktid.h +5 -1
@@ -121,6 +121,7 @@ static inline int ovpn_pktid_xmit_next(struct ovpn_pktid_xmit *pid, u64 *pktid)* @usage: key usage state * @limit: key usage limits * @aead_blocks: AEAD usage blocks consumed by this packet +* @hard_exceeded: set to true if RX has crossed the hard usage limit * * RX AEAD accounting is only informational for the local userspace process. * The peer's packets that already passed authentication and replay checks are
@@ -132,12 +133,15 @@ static inline bool ovpn_pktid_recv_update_aead(struct ovpn_pktid_recv *pr, struct ovpn_key_usage *usage, const struct ovpn_limit *limit, - u64 aead_blocks) + u64 aead_blocks, bool *hard_exceeded) { bool ret;spin_lock_bh (&pr->lock); ret =ovpn_key_usage_recv (usage, limit, pr->id, aead_blocks); + *hard_exceeded = +ovpn_key_usage_over_limit (limit->hard, pr->id, +atomic64_read (&usage->blocks));spin_unlock_bh (&pr->lock);return ret;
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Ralf Lici
reviewerRFC 13/14 ovpn: accept epoch keys from netlink
In reply to Ralf LiciAllow KEY_NEW to receive either direct key material or epoch PRK material. Userspace must provide exactly one key format: the existing encrypt/decrypt direction attributes select direct keys, while the new epoch attributes select epoch-derived keys.
Parse epoch key attributes into the common key configuration used by crypto slot setup. Direct key attributes keep the existing UAPI shape, so current userspace continues to install direct keys without any new format attribute.
--- Documentation/netlink/specs/ovpn.yaml | 31 ++++++++ drivers/net/ovpn/crypto_epoch.h | 1 - drivers/net/ovpn/netlink-gen.c | 9 ++- drivers/net/ovpn/netlink-gen.h | 3 +- drivers/net/ovpn/netlink.c | 110 ++++++++++++++++++++++---- include/uapi/linux/ovpn.h | 11 +++ 6 files changed, 146 insertions(+), 19 deletions(-)
Documentation/netlink/specs/ovpn.yaml +31 -0
@@ -16,6 +16,10 @@ definitions: type: const name: nonce-tail-size value: 8 + - + type: const + name: epoch-prk-size + value: 32 - type: enum name: cipher-alg
@@ -274,6 +278,16 @@ attribute-sets: type: nest doc: Key material for decrypt direction nested-attributes: keydir + - + name: encrypt-epoch + type: nest + doc: Epoch PRK material used to derive encrypt data keys + nested-attributes: epoch + - + name: decrypt-epoch + type: nest + doc: Epoch PRK material used to derive decrypt data keys + nested-attributes: epoch - name: keydir attributes:
@@ -291,6 +305,23 @@ attribute-sets: obtain the actual cipher IV checks: exact-len: nonce-tail-size + - + name: epoch + attributes: + - + name: key + type: binary + doc: >- + The epoch PRK used to derive cipher keys and implicit IVs + checks: + exact-len: epoch-prk-size + - + name: cipher-key-len + type: u32 + doc: Length in bytes of the AEAD cipher key derived from the epoch PRK + checks: + min: 1 + max: epoch-prk-size - name: keyconf-get
drivers/net/ovpn/crypto_epoch.h +0 -1
@@ -16,7 +16,6 @@#include <linux/types.h> #include <uapi/linux/ovpn.h> -#define OVPN_EPOCH_PRK_SIZE 32#define OVPN_MAX_EPOCH U16_MAX#define OVPN_EPOCH_FUTURE_KEYS_COUNT 16
drivers/net/ovpn/netlink-gen.c +8 -1
@@ -25,13 +25,20 @@ static const struct netlink_range_validation ovpn_a_keyconf_peer_id_range = { };/* Common nested types */ -const struct nla_policy ovpn_keyconf_nl_policy[OVPN_A_KEYCONF_DECRYPT_DIR +1 ] = { +const struct nla_policy ovpn_epoch_nl_policy[OVPN_A_EPOCH_CIPHER_KEY_LEN +1 ] = { + [OVPN_A_EPOCH_KEY ] =NLA_POLICY_EXACT_LEN (OVPN_EPOCH_PRK_SIZE ), + [OVPN_A_EPOCH_CIPHER_KEY_LEN ] =NLA_POLICY_RANGE (NLA_U32 ,1 ,OVPN_EPOCH_PRK_SIZE ), +}; + +const struct nla_policy ovpn_keyconf_nl_policy[OVPN_A_KEYCONF_DECRYPT_EPOCH +1 ] = { [OVPN_A_KEYCONF_PEER_ID ] =NLA_POLICY_FULL_RANGE (NLA_U32 , &ovpn_a_keyconf_peer_id_range), [OVPN_A_KEYCONF_SLOT ] =NLA_POLICY_MAX (NLA_U32 ,1 ), [OVPN_A_KEYCONF_KEY_ID ] =NLA_POLICY_MAX (NLA_U32 ,7 ), [OVPN_A_KEYCONF_CIPHER_ALG ] =NLA_POLICY_MAX (NLA_U32 ,2 ), [OVPN_A_KEYCONF_ENCRYPT_DIR ] =NLA_POLICY_NESTED (ovpn_keydir_nl_policy), [OVPN_A_KEYCONF_DECRYPT_DIR ] =NLA_POLICY_NESTED (ovpn_keydir_nl_policy), + [OVPN_A_KEYCONF_ENCRYPT_EPOCH ] =NLA_POLICY_NESTED (ovpn_epoch_nl_policy), + [OVPN_A_KEYCONF_DECRYPT_EPOCH ] =NLA_POLICY_NESTED (ovpn_epoch_nl_policy), };const struct nla_policy ovpn_keyconf_del_input_nl_policy[OVPN_A_KEYCONF_SLOT +1 ] = {
drivers/net/ovpn/netlink-gen.h +2 -1
@@ -13,7 +13,8 @@#include <uapi/linux/ovpn.h> /* Common nested types */ -extern const struct nla_policy ovpn_keyconf_nl_policy[OVPN_A_KEYCONF_DECRYPT_DIR +1 ]; +extern const struct nla_policy ovpn_epoch_nl_policy[OVPN_A_EPOCH_CIPHER_KEY_LEN +1 ]; +extern const struct nla_policy ovpn_keyconf_nl_policy[OVPN_A_KEYCONF_DECRYPT_EPOCH +1 ];extern const struct nla_policy ovpn_keyconf_del_input_nl_policy[OVPN_A_KEYCONF_SLOT +1 ];extern const struct nla_policy ovpn_keyconf_get_nl_policy[OVPN_A_KEYCONF_CIPHER_ALG +1 ];extern const struct nla_policy ovpn_keyconf_swap_input_nl_policy[OVPN_A_KEYCONF_PEER_ID +1 ];
drivers/net/ovpn/netlink.c +94 -16
137 lines not on this page · raw message
include/uapi/linux/ovpn.h +11 -0
@@ -11,6 +11,7 @@#define OVPN_FAMILY_VERSION 1#define OVPN_NONCE_TAIL_SIZE 8 +#define OVPN_EPOCH_PRK_SIZE 32enum ovpn_cipher_alg {OVPN_CIPHER_ALG_NONE ,
@@ -68,6 +69,8 @@ enum {OVPN_A_KEYCONF_CIPHER_ALG ,OVPN_A_KEYCONF_ENCRYPT_DIR ,OVPN_A_KEYCONF_DECRYPT_DIR , +OVPN_A_KEYCONF_ENCRYPT_EPOCH , +OVPN_A_KEYCONF_DECRYPT_EPOCH , __OVPN_A_KEYCONF_MAX,OVPN_A_KEYCONF_MAX = (__OVPN_A_KEYCONF_MAX -1 )
@@ -81,6 +84,14 @@ enum {OVPN_A_KEYDIR_MAX = (__OVPN_A_KEYDIR_MAX -1 ) }; +enum { +OVPN_A_EPOCH_KEY =1 , +OVPN_A_EPOCH_CIPHER_KEY_LEN , + + __OVPN_A_EPOCH_MAX, +OVPN_A_EPOCH_MAX = (__OVPN_A_EPOCH_MAX -1 ) +}; +enum {OVPN_A_IFINDEX =1 ,OVPN_A_PEER ,
Signature · 8 lines
2.54.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel