OpenVPN
dco_internal.h
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single TCP/UDP port, with support for SSL/TLS-based
4  * session authentication and key exchange,
5  * packet encryption, packet authentication, and
6  * packet compression.
7  *
8  * Copyright (C) 2022-2023 Antonio Quartulli <a@unstable.cc>
9  * Copyright (C) 2022-2023 OpenVPN Inc <sales@openvpn.net>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2
13  * as published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program (see the file COPYING included with this
22  * distribution); if not, write to the Free Software Foundation, Inc.,
23  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  */
25 #ifndef DCO_INTERNAL_H
26 #define DCO_INTERNAL_H
27 
28 #if defined(ENABLE_DCO)
29 
30 #include "dco_freebsd.h"
31 #include "dco_linux.h"
32 #include "dco_win.h"
33 
40 static inline dco_cipher_t
41 dco_get_cipher(const char *cipher)
42 {
43  if (strcmp(cipher, "AES-256-GCM") == 0 || strcmp(cipher, "AES-128-GCM") == 0
44  || strcmp(cipher, "AES-192-GCM") == 0)
45  {
47  }
48  else if (strcmp(cipher, "CHACHA20-POLY1305") == 0)
49  {
51  }
52  else
53  {
54  msg(M_FATAL, "DCO: provided unsupported cipher: %s", cipher);
55  }
56 }
57 
63 int dco_new_peer(dco_context_t *dco, unsigned int peerid, int sd,
64  struct sockaddr *localaddr, struct sockaddr *remoteaddr,
65  struct in_addr *remote_in4, struct in6_addr *remote_in6);
66 
67 int dco_del_peer(dco_context_t *dco, unsigned int peerid);
68 
69 int dco_new_key(dco_context_t *dco, unsigned int peerid, int keyid,
70  dco_key_slot_t slot,
71  const uint8_t *encrypt_key, const uint8_t *encrypt_iv,
72  const uint8_t *decrypt_key, const uint8_t *decrypt_iv,
73  const char *ciphername);
74 
75 int dco_del_key(dco_context_t *dco, unsigned int peerid, dco_key_slot_t slot);
76 
77 int dco_swap_keys(dco_context_t *dco, unsigned int peerid);
78 
79 #endif /* defined(ENABLE_DCO) */
80 #endif /* ifndef DCO_INTERNAL_H */
dco_new_key
int dco_new_key(dco_context_t *dco, unsigned int peerid, int keyid, dco_key_slot_t slot, const uint8_t *encrypt_key, const uint8_t *encrypt_iv, const uint8_t *decrypt_key, const uint8_t *decrypt_iv, const char *ciphername)
Definition: dco_win.c:295
M_FATAL
#define M_FATAL
Definition: error.h:95
dco_new_peer
int dco_new_peer(dco_context_t *dco, unsigned int peerid, int sd, struct sockaddr *localaddr, struct sockaddr *remoteaddr, struct in_addr *remote_in4, struct in6_addr *remote_in6)
Definition: dco_win.c:248
dco_linux.h
dco_context_t
void * dco_context_t
Definition: dco.h:254
dco_del_peer
int dco_del_peer(dco_context_t *dco, unsigned int peerid)
Definition: dco_win.c:257
dco_del_key
int dco_del_key(dco_context_t *dco, unsigned int peerid, dco_key_slot_t slot)
Definition: dco_win.c:336
dco_swap_keys
int dco_swap_keys(dco_context_t *dco, unsigned int peer_id)
Definition: dco_win.c:345
dco_freebsd.h
OVPN_CIPHER_ALG_AES_GCM
@ OVPN_CIPHER_ALG_AES_GCM
Definition: ovpn_dco_freebsd.h:54
OVPN_CIPHER_ALG_CHACHA20_POLY1305
@ OVPN_CIPHER_ALG_CHACHA20_POLY1305
Definition: ovpn_dco_freebsd.h:55
msg
#define msg(flags,...)
Definition: error.h:150
dco_win.h