30#include <tins/config.h>
32#if !defined(TINS_CRYPTO_H) && defined(TINS_HAVE_DOT11)
38#ifdef TINS_HAVE_WPA2_CALLBACKS
41#include <tins/macros.h>
42#include <tins/handshake_capturer.h>
54#ifdef TINS_HAVE_WPA2_DECRYPTION
60class TINS_API SessionKeys {
65 static const size_t PMK_SIZE;
70 static const size_t PTK_SIZE;
75 typedef std::vector<uint8_t> ptk_type;
80 typedef std::vector<uint8_t> pmk_type;
94 SessionKeys(
const ptk_type& ptk,
bool is_ccmp);
104 SessionKeys(
const RSNHandshake& hs,
const pmk_type& pmk);
114 SNAP* decrypt_unicast(
const Dot11Data& dot11, RawPDU& raw)
const;
120 const ptk_type& get_ptk()
const;
126 bool uses_ccmp()
const;
128 SNAP* ccmp_decrypt_unicast(
const Dot11Data& dot11, RawPDU& raw)
const;
129 SNAP* tkip_decrypt_unicast(
const Dot11Data& dot11, RawPDU& raw)
const;
142class TINS_API SupplicantData {
147 typedef SessionKeys::pmk_type pmk_type;
154 SupplicantData(
const std::string& psk,
const std::string& ssid);
160 const pmk_type& pmk()
const;
166 const std::string& ssid()
const;
217 bool decrypt(
PDU& pdu);
219 typedef std::map<address_type, std::string> passwords_type;
223 passwords_type passwords_;
224 std::vector<uint8_t> key_buffer_;
227#ifdef TINS_HAVE_WPA2_DECRYPTION
250 typedef std::pair<address_type, address_type>
addr_pair;
260 typedef std::map<addr_pair, WPA2::SessionKeys>
keys_map;
262 #ifdef TINS_HAVE_WPA2_CALLBACKS
271 typedef std::function<
void(
const std::string&,
282 typedef std::function<
void(
const std::string&,
306 void add_ap_data(
const std::string&
psk,
const std::string& ssid);
323 const std::string& ssid,
324 const address_type&
addr);
364 bool decrypt(
PDU& pdu);
366 #ifdef TINS_HAVE_WPA2_CALLBACKS
400 typedef std::map<std::string, WPA2::SupplicantData>
pmks_map;
401 typedef std::map<address_type, WPA2::SupplicantData>
bssids_map;
405 return (addr1 < addr2) ?
406 std::make_pair(addr1, addr2) :
407 std::make_pair(addr2, addr1);
418 #ifdef TINS_HAVE_WPA2_CALLBACKS
433template<
typename Functor,
typename Decrypter>
483template<
typename Functor>
486#ifdef TINS_HAVE_WPA2_DECRYPTION
494template<
typename Functor>
504template<
typename Functor,
typename Decrypter>
511template<
typename Functor,
typename Decrypter>
517template<
typename Functor,
typename Decrypter>
523template<
typename Functor,
typename Decrypter>
525 return decrypter_.decrypt(pdu) ? functor_(pdu) :
true;
528template<
typename Functor>
Represents a range of addresses.
Definition address_range.h:167
Pluggable decrypter object which can be used to decrypt data on sniffing sessions.
Definition crypto.h:434
Decrypter decrypter_type
Definition crypto.h:444
decrypter_type & decrypter()
Retrieves a reference to the decrypter object.
Definition crypto.h:513
bool operator()(PDU &pdu)
The operator() which decrypts packets and forwards them to the functor.
Definition crypto.h:524
Functor functor_type
Definition crypto.h:439
DecrypterProxy(const functor_type &func, const decrypter_type &decr=decrypter_type())
Constructs an object from a functor and a decrypter.
Definition crypto.h:505
Decrypts WEP-encrypted traffic.
Definition crypto.h:178
Represents an IEEE 802.11 data frame.
Definition dot11_data.h:43
Base class for protocol data units.
Definition pdu.h:107
Definition handshake_capturer.h:109
The Tins namespace.
Definition address_range.h:38