UDP-WG Implementation
|
The cryptographic implementations for WireGuard. More...
Classes | |
class | keypair |
A simple private-public keypair. More... | |
class | string |
A cryptographically secure string. More... | |
Functions | |
string | DH (const string &priv, const string &pub) |
keypair | DH_GENERATE () |
Generate a Curve25519 keypair. | |
string | IV (uint64_t counter) |
Format the IV array given the WireGuard Counter. | |
string | ENCRYPT (string key, const uint64_t &counter, const string &plain, const string &data) |
Encrypt with ChaCha20-Poly1305. | |
string | DECRYPT (string key, const uint64_t &counter, const string &cipher, const string &data) |
Decrypt with ChaCha20-Poly1305. | |
keypair | XENCRYPT (string key, const string &plain, const string &data) |
Encrypt with XChaCha20-Poly1305. | |
string | XDECRYPT (string key, const keypair &pair, const string &data) |
Decrypt with XChaCha20-Poly1305. | |
string | HASH (const string &in) |
Generate a BLAKE2s256 Hash of the input. | |
string | HMAC (const string &key, const string &input, const size_t &size=32) |
Compute an HMAC using BLAKE and a key. | |
string | MAC (const string &key, const string &input) |
OpenSSL makes no difference between HMAC-BLAKE2s256 and Keyed BLAKE2s256 Besides setting the size. Therefore, we can reuse the same code, and just return the required 16 bytes, as opposed to the 32 expected from HMAC proper. | |
std::vector< string > | KDF (const size_t &n, const string &key, const string &input) |
Perform the HKDF scheme on our HMAC function. | |
The cryptographic implementations for WireGuard.
string crypto::DECRYPT | ( | string | key, |
const uint64_t & | counter, | ||
const string & | cipher, | ||
const string & | data ) |
Decrypt with ChaCha20-Poly1305.
key | The 32 byte key. |
counter | The WireGuard counter. |
cipher | The ciphertext. |
data | The AAD |
std::runtime_error | If the key/data are invalid. |
Perform a Curve25519 point multiplication on the public and private key.
keypair | The 32 byte public key and private key |
keypair crypto::DH_GENERATE | ( | ) |
Generate a Curve25519 keypair.
string crypto::ENCRYPT | ( | string | key, |
const uint64_t & | counter, | ||
const string & | plain, | ||
const string & | data ) |
Encrypt with ChaCha20-Poly1305.
key | The 32 byte key key to use for encryption. |
counter | The WireGuard Counter, for a nonce. |
plain | The plaintext. |
data | The AAD. |
Generate a BLAKE2s256 Hash of the input.
in | The string to hash. |
Compute an HMAC using BLAKE and a key.
key | The 32 byte key |
input | The arbitrary sized input to hash. |
string crypto::IV | ( | uint64_t | counter | ) |
Format the IV array given the WireGuard Counter.
counter | The current WireGuard counter. |
Perform the HKDF scheme on our HMAC function.
n | The amount of rounds to run |
key | The 32 byte key to use for the HMAC |
input | The arbitrary sized input data for the HMAC. |
OpenSSL makes no difference between HMAC-BLAKE2s256 and Keyed BLAKE2s256 Besides setting the size. Therefore, we can reuse the same code, and just return the required 16 bytes, as opposed to the 32 expected from HMAC proper.
key | The 32-byte key |
input | The arbitrary input |
Decrypt with XChaCha20-Poly1305.
key | The 32 byte key. |
pair | The cipher + nonce |
data | The AAD |
Encrypt with XChaCha20-Poly1305.
key | The 32 byte key key to use for encryption. |
plain | The plaintext. |
data | The AAD. |