29 static_assert(
sizeof(
wg_common_header) == 4,
"wg_common_header size is not 4 bytes");
69 return (portSrc == 51820 || portDst == 51820);
131 #pragma pack(push, 1)
137 uint32_t senderIndex;
139 uint8_t initiatorEphemeral[32];
141 uint8_t encryptedInitiatorStatic[48];
143 uint8_t encryptedTimestamp[28];
148 } wg_handshake_initiation;
150 wg_handshake_initiation* getHandshakeInitiationHeader()
const
152 return reinterpret_cast<wg_handshake_initiation*
>(getBasicHeader());
173 const uint8_t encryptedInitiatorStatic[48],
174 const uint8_t encryptedTimestamp[28],
const uint8_t mac1[16],
175 const uint8_t mac2[16]);
208 void setMac1(
const std::array<uint8_t, 16>& mac1);
211 void setMac2(
const std::array<uint8_t, 16>& mac2);
227 #pragma pack(push, 1)
233 uint32_t senderIndex;
235 uint32_t receiverIndex;
237 uint8_t responderEphemeral[32];
239 uint8_t encryptedEmpty[16];
244 } wg_handshake_response;
247 wg_handshake_response* getHandshakeResponseHeader()
const
249 return reinterpret_cast<wg_handshake_response*
>(getBasicHeader());
270 const uint8_t responderEphemeral[32],
const uint8_t encryptedEmpty[16],
271 const uint8_t mac1[16],
const uint8_t mac2[16]);
304 void setMac1(
const std::array<uint8_t, 16>& mac1);
307 void setMac2(
const std::array<uint8_t, 16>& mac2);
323 #pragma pack(push, 1)
329 uint32_t receiverIndex;
333 uint8_t encryptedCookie[32];
337 wg_cookie_reply* getCookieReplyHeader()
const
339 return reinterpret_cast<wg_cookie_reply*
>(getBasicHeader());
371 void setNonce(
const std::array<uint8_t, 24>& nonce);
390 #pragma pack(push, 1)
396 uint32_t receiverIndex;
400 uint8_t encryptedData[0];
404 wg_transport_data* getTransportHeader()
const
406 return reinterpret_cast<wg_transport_data*
>(getBasicHeader());
425 size_t encryptedDataLen);
Definition: WireGuardLayer.h:321
std::array< uint8_t, 32 > getEncryptedCookie() const
std::array< uint8_t, 24 > getNonce() const
WireGuardMessageType getWireGuardMessageType() const override
Definition: WireGuardLayer.h:379
WireGuardCookieReplyLayer(uint32_t receiverIndex, const uint8_t nonce[24], const uint8_t encryptedCookie[32])
void setReceiverIndex(uint32_t receiverIndex)
void setNonce(const std::array< uint8_t, 24 > &nonce)
WireGuardCookieReplyLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: WireGuardLayer.h:348
uint32_t getReceiverIndex() const
void setEncryptedCookie(const std::array< uint8_t, 32 > &encryptedCookie)
Definition: WireGuardLayer.h:129
void setMac2(const std::array< uint8_t, 16 > &mac2)
WireGuardMessageType getWireGuardMessageType() const override
Definition: WireGuardLayer.h:216
void setMac1(const std::array< uint8_t, 16 > &mac1)
std::array< uint8_t, 48 > getEncryptedInitiatorStatic() const
std::array< uint8_t, 16 > getMac1() const
WireGuardHandshakeInitiationLayer(uint32_t senderIndex, const uint8_t initiatorEphemeral[32], const uint8_t encryptedInitiatorStatic[48], const uint8_t encryptedTimestamp[28], const uint8_t mac1[16], const uint8_t mac2[16])
uint32_t getSenderIndex() const
std::array< uint8_t, 16 > getMac2() const
std::array< uint8_t, 28 > getEncryptedTimestamp() const
void setEncryptedInitiatorStatic(const std::array< uint8_t, 48 > &encryptedInitiatorStatic)
WireGuardHandshakeInitiationLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: WireGuardLayer.h:161
void setEncryptedTimestamp(const std::array< uint8_t, 28 > &encryptedTimestamp)
std::array< uint8_t, 32 > getInitiatorEphemeral() const
void setInitiatorEphemeral(const std::array< uint8_t, 32 > &initiatorEphemeral)
void setSenderIndex(uint32_t senderIndex)
Definition: WireGuardLayer.h:225
uint32_t getSenderIndex() const
std::array< uint8_t, 16 > getMac1() const
WireGuardHandshakeResponseLayer(uint32_t senderIndex, uint32_t receiverIndex, const uint8_t responderEphemeral[32], const uint8_t encryptedEmpty[16], const uint8_t mac1[16], const uint8_t mac2[16])
void setResponderEphemeral(const std::array< uint8_t, 32 > &responderEphemeral)
uint32_t getReceiverIndex() const
void setMac2(const std::array< uint8_t, 16 > &mac2)
void setReceiverIndex(uint32_t receiverIndex)
WireGuardMessageType getWireGuardMessageType() const override
Definition: WireGuardLayer.h:312
void setEncryptedEmpty(const std::array< uint8_t, 16 > &encryptedEmpty)
WireGuardHandshakeResponseLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: WireGuardLayer.h:258
void setMac1(const std::array< uint8_t, 16 > &mac1)
std::array< uint8_t, 16 > getMac2() const
void setSenderIndex(uint32_t senderIndex)
std::array< uint8_t, 32 > getResponderEphemeral() const
std::array< uint8_t, 16 > getEncryptedEmpty() const
Definition: WireGuardLayer.h:16
void setReserved(const std::array< uint8_t, 3 > &reserved)
OsiModelLayer getOsiModelLayer() const override
Definition: WireGuardLayer.h:114
size_t getHeaderLen() const override
static bool isWireGuardPorts(uint16_t portSrc, uint16_t portDst)
Definition: WireGuardLayer.h:67
virtual WireGuardMessageType getWireGuardMessageType() const
Definition: WireGuardLayer.h:120
WireGuardMessageType
WireGuard message types.
Definition: WireGuardLayer.h:41
@ HandshakeInitiation
Handshake Initiation message.
@ HandshakeResponse
Handshake Response message.
@ CookieReply
Cookie Reply message.
@ TransportData
Transport Data message.
@ Unknown
Unknown Initiation message.
static bool isDataValid(const uint8_t *data, size_t dataLen)
std::string toString() const override
uint32_t getReserved() const
std::string getMessageTypeAsString() const
static WireGuardLayer * parseWireGuardLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
void parseNextLayer() override
Does nothing for this layer (WireGuard layer is always last)
Definition: WireGuardLayer.h:99
void computeCalculateFields() override
No fields to compute or update, so this method is left empty.
Definition: WireGuardLayer.h:106
WireGuardLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: WireGuardLayer.h:59
uint8_t getMessageType() const
Definition: WireGuardLayer.h:388
void setEncryptedData(const uint8_t *encryptedData, size_t encryptedDataLen)
void setCounter(uint64_t counter)
uint32_t getReceiverIndex() const
uint64_t getCounter() const
WireGuardTransportDataLayer(uint32_t receiverIndex, uint64_t counter, const uint8_t *encryptedData, size_t encryptedDataLen)
WireGuardTransportDataLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: WireGuardLayer.h:415
const uint8_t * getEncryptedData() const
void setReceiverIndex(uint32_t receiverIndex)
WireGuardMessageType getWireGuardMessageType() const override
Definition: WireGuardLayer.h:449
The main namespace for the PcapPlusPlus lib.
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:225
@ OsiModelNetworkLayer
Network layer (layer 3)
Definition: ProtocolType.h:231
const ProtocolType WireGuard
WireGuard protocol.
Definition: ProtocolType.h:215