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());
172 return data !=
nullptr && dataLen >=
sizeof(wg_handshake_initiation);
183 const uint8_t encryptedInitiatorStatic[48],
184 const uint8_t encryptedTimestamp[28],
const uint8_t mac1[16],
185 const uint8_t mac2[16]);
218 void setMac1(
const std::array<uint8_t, 16>& mac1);
221 void setMac2(
const std::array<uint8_t, 16>& mac2);
237 #pragma pack(push, 1)
243 uint32_t senderIndex;
245 uint32_t receiverIndex;
247 uint8_t responderEphemeral[32];
249 uint8_t encryptedEmpty[16];
254 } wg_handshake_response;
257 wg_handshake_response* getHandshakeResponseHeader()
const
259 return reinterpret_cast<wg_handshake_response*
>(getBasicHeader());
279 return data !=
nullptr && dataLen >=
sizeof(wg_handshake_response);
290 const uint8_t responderEphemeral[32],
const uint8_t encryptedEmpty[16],
291 const uint8_t mac1[16],
const uint8_t mac2[16]);
324 void setMac1(
const std::array<uint8_t, 16>& mac1);
327 void setMac2(
const std::array<uint8_t, 16>& mac2);
343 #pragma pack(push, 1)
349 uint32_t receiverIndex;
353 uint8_t encryptedCookie[32];
357 wg_cookie_reply* getCookieReplyHeader()
const
359 return reinterpret_cast<wg_cookie_reply*
>(getBasicHeader());
378 return data !=
nullptr && dataLen >=
sizeof(wg_cookie_reply);
400 void setNonce(
const std::array<uint8_t, 24>& nonce);
419 #pragma pack(push, 1)
425 uint32_t receiverIndex;
429 uint8_t encryptedData[0];
433 wg_transport_data* getTransportHeader()
const
435 return reinterpret_cast<wg_transport_data*
>(getBasicHeader());
454 return data !=
nullptr && dataLen >=
sizeof(wg_transport_data);
463 size_t encryptedDataLen);
Definition: WireGuardLayer.h:341
std::array< uint8_t, 32 > getEncryptedCookie() const
std::array< uint8_t, 24 > getNonce() const
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: WireGuardLayer.h:376
WireGuardMessageType getWireGuardMessageType() const override
Definition: WireGuardLayer.h:408
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:368
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:226
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
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: WireGuardLayer.h:170
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:235
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:332
void setEncryptedEmpty(const std::array< uint8_t, 16 > &encryptedEmpty)
WireGuardHandshakeResponseLayer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: WireGuardLayer.h:268
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
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: WireGuardLayer.h:277
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:417
void setEncryptedData(const uint8_t *encryptedData, size_t encryptedDataLen)
void setCounter(uint64_t counter)
static bool isDataValid(const uint8_t *data, size_t dataLen)
Definition: WireGuardLayer.h:452
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:444
const uint8_t * getEncryptedData() const
void setReceiverIndex(uint32_t receiverIndex)
WireGuardMessageType getWireGuardMessageType() const override
Definition: WireGuardLayer.h:488
const ProtocolType WireGuard
WireGuard protocol.
Definition: ProtocolType.h:240
The main namespace for the PcapPlusPlus lib.
Definition: AssertionUtils.h:19
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:420
@ OsiModelNetworkLayer
Network layer (layer 3)
Definition: ProtocolType.h:426