35 #include <tins/macros.h> 36 #include <tins/small_uint.h> 37 #include <tins/endianness.h> 42 class OutputMemoryStream;
78 static metadata extract_metadata(
const uint8_t *buffer, uint32_t total_sz);
92 static EAPOL* from_bytes(
const uint8_t* buffer, uint32_t total_sz);
101 return header_.version;
109 return header_.packet_type;
117 return Endian::be_to_host(header_.length);
134 void version(uint8_t value);
140 void packet_type(uint8_t value);
146 void length(uint16_t value);
152 void type(uint8_t value);
170 EAPOL(
const uint8_t* buffer, uint32_t total_sz);
174 uint8_t version, packet_type;
186 virtual void write_body(Memory::OutputMemoryStream& stream) = 0;
188 void write_serialization(uint8_t* buffer, uint32_t total_sz);
213 static const size_t key_iv_size = 16;
218 static const size_t key_sign_size = 16;
234 RC4EAPOL(
const uint8_t* buffer, uint32_t total_sz);
243 return Endian::be_to_host(header_.key_length);
251 return Endian::be_to_host(header_.replay_counter);
259 return header_.key_iv;
267 return header_.key_flag;
275 return header_.key_index;
283 return header_.key_sign;
290 const key_type&
key()
const {
300 void key_length(uint16_t value);
306 void replay_counter(uint64_t value);
312 void key_iv(
const uint8_t* value);
330 void key_sign(
const uint8_t* value);
336 void key(
const key_type& value);
348 uint32_t header_size()
const;
377 struct rc4_eapol_header {
379 uint64_t replay_counter;
380 uint8_t key_iv[key_iv_size];
383 uint8_t key_sign[16];
386 void write_body(Memory::OutputMemoryStream& stream);
390 rc4_eapol_header header_;
412 static const size_t key_iv_size = 16;
417 static const size_t nonce_size = 32;
422 static const size_t mic_size = 16;
427 static const size_t rsc_size = 8;
432 static const size_t id_size = 8;
448 RSNEAPOL(
const uint8_t* buffer, uint32_t total_sz);
457 return Endian::be_to_host(header_.key_length);
465 return Endian::be_to_host(header_.replay_counter);
473 return header_.key_iv;
481 return header_.nonce;
488 const uint8_t*
rsc()
const {
496 const uint8_t*
id()
const {
504 const uint8_t*
mic()
const {
513 return Endian::be_to_host(header_.wpa_length);
520 const key_type&
key()
const {
529 return header_.key_mic;
537 return header_.secure;
545 return header_.error;
553 return header_.request;
561 return header_.encrypted;
569 return header_.key_descriptor;
578 return header_.key_t;
586 return header_.key_index;
594 return header_.install;
602 return header_.key_ack;
613 uint32_t header_size()
const;
621 void key_length(uint16_t value);
627 void replay_counter(uint64_t value);
637 void key_iv(
const uint8_t* ptr);
647 void nonce(
const uint8_t* ptr);
657 void rsc(
const uint8_t* ptr);
667 void id(
const uint8_t* ptr);
677 void mic(
const uint8_t* ptr);
683 void wpa_length(uint16_t length);
689 void key(
const key_type& value);
778 struct rsn_eapol_header {
779 #if TINS_IS_LITTLE_ENDIAN 792 uint64_t replay_counter;
793 uint8_t nonce[nonce_size], key_iv[key_iv_size];
794 uint8_t rsc[rsc_size],
id[id_size];
795 uint8_t mic[mic_size];
810 uint64_t replay_counter;
811 uint8_t nonce[nonce_size], key_iv[key_iv_size];
812 uint8_t rsc[rsc_size],
id[id_size];
813 uint8_t mic[mic_size];
818 void write_body(Memory::OutputMemoryStream& stream);
821 rsn_eapol_header header_;
827 #endif // TINS_EAPOL_H const uint8_t * id() const
Getter for the id field.
Definition: eapol.h:496
virtual bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition: pdu.h:461
uint16_t key_length() const
Getter for the key length field.
Definition: eapol.h:456
PDUType pdu_type() const
Getter for the PDU's type.
Definition: eapol.h:755
const uint8_t * key_sign() const
Getter for the key signature field.
Definition: eapol.h:282
uint8_t type() const
Getter for the type field.
Definition: eapol.h:124
PDUType
Enum which identifies each type of PDU.
Definition: pdu.h:127
const uint8_t * key_iv() const
Getter for the key IV field.
Definition: eapol.h:472
RC4EAPOL * clone() const
Clones this PDU.
Definition: eapol.h:372
PDUType pdu_type() const
Getter for the PDU's type.
Definition: eapol.h:354
small_uint< 1 > error() const
Getter for the error field.
Definition: eapol.h:544
uint16_t key_length() const
Getter for the key length field.
Definition: eapol.h:242
RSNEAPOL * clone() const
Clones this PDU.
Definition: eapol.h:773
small_uint< 7 > key_index() const
Getter for the key index field.
Definition: eapol.h:274
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition: eapol.h:363
small_uint< 1 > key_t() const
Getter for the key type field.
Definition: eapol.h:577
uint16_t wpa_length() const
Getter for the wpa length field.
Definition: eapol.h:512
std::vector< uint8_t > key_type
Definition: eapol.h:402
small_uint< 2 > key_index() const
Getter for the key_index field.
Definition: eapol.h:585
small_uint< 1 > key_ack() const
Getter for the key_ack field.
Definition: eapol.h:601
const key_type & key() const
Getter for the key field.
Definition: eapol.h:520
std::vector< uint8_t > key_type
Definition: eapol.h:203
uint64_t replay_counter() const
Getter for the replay counter field.
Definition: eapol.h:464
small_uint< 1 > key_flag() const
Getter for the key flag field.
Definition: eapol.h:266
bool matches_flag(PDUType flag) const
Check whether this PDU matches the specified flag.
Definition: eapol.h:764
The Tins namespace.
Definition: address_range.h:38
small_uint< 1 > key_mic() const
Getter for the key mic field.
Definition: eapol.h:528
small_uint< 1 > secure() const
Getter for the secure field.
Definition: eapol.h:536
small_uint< 1 > request() const
Getter for the request field.
Definition: eapol.h:552
Class that represents the RC4 EAPOL PDU.
Definition: eapol.h:198
Class that represents the RSN EAPOL PDU.
Definition: eapol.h:397
const uint8_t * mic() const
Getter for the mic field.
Definition: eapol.h:504
const uint8_t * nonce() const
Getter for the nonce field.
Definition: eapol.h:480
const uint8_t * rsc() const
Getter for the rsc field.
Definition: eapol.h:488
EAPOLTYPE
Definition: eapol.h:66
small_uint< 3 > key_descriptor() const
Getter for the key descriptor field.
Definition: eapol.h:568
Represents the EAP encapsulation over LAN.
Definition: eapol.h:56
uint64_t replay_counter() const
Getter for the replay counter field.
Definition: eapol.h:250
small_uint< 1 > install() const
Getter for the install field.
Definition: eapol.h:593
uint8_t version() const
Getter for the version field.
Definition: eapol.h:100
uint16_t length() const
Getter for the length field.
Definition: eapol.h:116
small_uint< 1 > encrypted() const
Getter for the encrypted field.
Definition: eapol.h:560
PDUType pdu_type() const
Getter for the PDU's type.
Definition: eapol.h:158
Base class for protocol data units.
Definition: pdu.h:107
uint8_t packet_type() const
Getter for the packet type field.
Definition: eapol.h:108
const key_type & key() const
Getter for the key field.
Definition: eapol.h:290
const uint8_t * key_iv() const
Getter for the key IV field.
Definition: eapol.h:258