31#ifndef ASYNC_ENCRYPTED_UDP_SOCKET_INCLUDED
32#define ASYNC_ENCRYPTED_UDP_SOCKET_INCLUDED
41#include <openssl/evp.h>
313 const void *buf,
int count)
override;
325 const void *aad,
int aadlen,
const void *buf,
int cnt);
334 sigc::signal<bool,
const IpAddress&, uint16_t,
345 sigc::signal<void,
const IpAddress&, uint16_t,
353 EVP_CIPHER_CTX* m_cipher_ctx =
nullptr;
354 std::vector<uint8_t> m_cipher_iv;
355 std::vector<uint8_t> m_cipher_key;
Contains a class for using UDP sockets.
A class for sending encrypted UDP datagrams.
~EncryptedUdpSocket(void) override
Disallow copy construction.
sigc::signal< void, const IpAddress &, uint16_t, void *, void *, int > dataReceived
A signal that is emitted when cipher data has been decrypted.
void setCipherAADLength(int aadlen)
Set the length of the associated data for AEAD ciphers.
bool write(const IpAddress &remote_ip, int remote_port, const void *aad, int aadlen, const void *buf, int cnt)
Write data to the remote host.
const std::vector< uint8_t > cipherIV(void) const
Get a previously set initialization vector (IV)
static const std::string cipherName(const Cipher *cipher)
Get the name of a cipher from a cipher object.
void onDataReceived(const IpAddress &ip, uint16_t port, void *buf, int count) override
bool setCipher(const Cipher *cipher)
Set which cipher algorithm type to use.
bool initOk(void) const override
Check if the initialization was ok.
bool write(const IpAddress &remote_ip, int remote_port, const void *buf, int count) override
Write data to the remote host.
bool setCipher(const std::string &type)
Set which cipher algorithm type to use.
void setTagLength(int taglen)
Set the length of the AEAD tag.
EncryptedUdpSocket(uint16_t local_port=0, const IpAddress &bind_ip=IpAddress())
Constructor.
bool setCipherKey(void)
Set a random cipher key to use.
static const Cipher * fetchCipher(const std::string &name)
Fetch a named cipher object.
bool setCipherIV(std::vector< uint8_t > iv)
Set the initialization vector to use with the cipher.
static void freeCipher(Cipher *cipher)
Free memory for a previously allocated cipher object.
int tagLength(void) const
Get the currently set up tag length.
size_t cipherAADLength(void) const
The currently set up length of the additional associated data.
bool setCipherKey(std::vector< uint8_t > key)
Set the cipher key to use.
sigc::signal< bool, const IpAddress &, uint16_t, void *, int > cipherDataReceived
A signal that is emitted when cipher data has been received.
static bool randomBytes(std::vector< uint8_t > &bytes)
Fill a vector with random bytes.
const std::vector< uint8_t > cipherKey(void) const
Get the currently set cipher key.
A class for representing an IP address in an OS independent way.
A class for working with UDP sockets.
virtual bool initOk(void) const
Check if the initialization was ok.
Namespace for the asynchronous programming classes.