UDP-WG Implementation
|
This namespace includes the WireGuard implementation,. More...
Classes | |
struct | config |
A WireGuard Configuration. More... | |
class | CookiePacket |
class | InitPacket |
The initial packet sent from initiator to responder. More... | |
class | Packet |
For both security and ease of use, we want to use crypto::string as much as possible. This makes it easy to run all our cryptographic functions on the handshake and transport, but it raises an issue in that these objects are not contiguous values in memory (Or, they are, but casting it into a character array isn't going to get you the bytes). If you tried to just cast the string and send it across the wire, you'd get garbage. Instead, we need to Serialize and Expand from a collection of crypto::strings making up a packet (Whether that be the handshake packets or transport packets), so that we can work with crypto::string, but be able to serialize it down when we need to send it, and construct it back from bytes when receiving it. To unify this functionality, the Packet object contains a list of crypto::string's in a vector and will serialize the contents of it, and construct a itself from bytes. Other objects derive from this class, and specify the size of the vector and its elements, and values to access specific parts. More... | |
class | ResponsePacket |
The packet sent by the responder to the initiator during the handshake. More... | |
class | Rm |
A controlled wrapper for the secret random value used for the WireGuard cookies. More... | |
class | TransportPacket |
A WireGuard packet for sending Transport Messages. More... | |
Typedefs | |
typedef struct wireguard::config | config |
A WireGuard Configuration. | |
Functions | |
void | Handshake1 (crypto::keypair &ephemeral, const crypto::string &remote_pub, config &con, InitPacket &msg, const bool &init, crypto::string &C, crypto::string &H) |
The first half of the Handshake process. | |
void | Handshake2 (const crypto::keypair &init_ephemeral, const crypto::string &remote_pub, config &con, ResponsePacket &msg, const bool &init, crypto::string &C, crypto::string &H) |
Complete the Handshake. | |
template<typename Q > | |
config | Handshake (const crypto::string &remote_pub, const connection &peer, const bool &init, Q &in, Q &out, config conf={}, const bool &cookie=false) |
Perform a WireGuard Handshake. | |
void | test () |
Test the WireGuard Cryptographic Functions. | |
Variables | |
auto | pair = crypto::DH_GENERATE() |
const crypto::string | EPSILON = 32 |
const crypto::string | CONSTRUCTION = ("Noise_IKpsk2_25519_ChaChaPoly_BLAKE2s", 32) |
const crypto::string | IDENTIFIER = ("WireGuard v1 zx2c4 Jason@zx2c4.com", 34) |
const crypto::string | LABEL_MAC1 = ("mac1----", 8) |
const crypto::string | LABEL_COOKIE = ("cookie--", 8) |
const uint64_t | REKEY_MSGS = 1152921504606846976 |
const uint64_t | RJECT_MSGS = 1.844674407370954e19 |
const uint64_t | REKEY_TIME = 120 |
const uint64_t | RJECT_TIME = 180 |
const uint64_t | REKEY_TOUT = 5 |
const uint64_t | KEEPALIVE = 10 |
Rm | cookie_random |
This namespace includes the WireGuard implementation,.
typedef struct wireguard::config wireguard::config |
A WireGuard Configuration.
config wireguard::Handshake | ( | const crypto::string & | remote_pub, |
const connection & | peer, | ||
const bool & | init, | ||
Q & | in, | ||
Q & | out, | ||
config | conf = {}, | ||
const bool & | cookie = false ) |
Perform a WireGuard Handshake.
The | queue ;) |
remote_pub | The remote's public key |
peer | The connection to the peer. |
init | Whether we are the initiator. |
in | The in queue |
out | The out queue. |
conf | The wireguard configuration to built. |
cookie | Whether we are sending a cookie. |
void wireguard::Handshake1 | ( | crypto::keypair & | ephemeral, |
const crypto::string & | remote_pub, | ||
config & | con, | ||
InitPacket & | msg, | ||
const bool & | init, | ||
crypto::string & | C, | ||
crypto::string & | H ) |
The first half of the Handshake process.
ephemeral | The ephemeral keypairs of the peer. |
remote_pub | The peer's public key. |
con | The configuration that we populate for subsequent communication. |
msg | The InitPacket. The initiator builds this Packet, and then sends it to the responder, who uses the pre-populated Packet for this function. |
init | Whether this is the initiator. |
C | The chaining key value. |
H | The hash result value. |
std::runtime_error | If the handshake fails. |
void wireguard::Handshake2 | ( | const crypto::keypair & | init_ephemeral, |
const crypto::string & | remote_pub, | ||
config & | con, | ||
ResponsePacket & | msg, | ||
const bool & | init, | ||
crypto::string & | C, | ||
crypto::string & | H ) |
Complete the Handshake.
init_ephemeral | The ephemeral keys the initiator created. If this is the responder, we only know the public component. |
remote_pub | The other peer's public key. |
con | The WireGuard configuration we're building. |
msg | The packet to send back. If we are the initiator, this is already populated. If we're the responder, we build this before returning, and then sending it to the initiator. |
init | Whether we are the initiator. |
C | The chaining key value. |
H | The hash result value. |
void wireguard::test | ( | ) |
Test the WireGuard Cryptographic Functions.