A Discrete-Event Network Simulator
API
ns3::QKDCrypto Class Reference

Introspection did not find any typical Config paths. More...

#include "qkd-crypto.h"

+ Inheritance diagram for ns3::QKDCrypto:
+ Collaboration diagram for ns3::QKDCrypto:

Public Member Functions

 QKDCrypto ()
 Constructor. More...
 
virtual ~QKDCrypto ()
 Destructor. More...
 
bool CheckForResourcesToProcessThePacket (Ptr< Packet > p, uint32_t TOSBand, Ptr< QKDBuffer > QKDbuffer)
 Check whether there is enough resources (key material) to process (encrypt or decrypt) the packet. More...
 
Ptr< PacketDecrypt (Ptr< Packet > p, Ptr< QKDBuffer > QKDBuffer)
 This functions is used for real decryption process. More...
 
std::vector< Ptr< Packet > > ProcessIncomingPacket (Ptr< Packet > p, Ptr< QKDBuffer > QKDBuffer, uint32_t channelID)
 This functions is an entry point toward deencryption/authentication-check of the packet Packet is deserialized from string in case when packet was previously encrypted or authentication, otherwise, the packet is kept in "Packet" form and only QKDCommandHeader and QKDHeader are removed. More...
 
std::vector< Ptr< Packet > > ProcessOutgoingPacket (Ptr< Packet > p, Ptr< QKDBuffer > QKDBuffer, uint32_t channelID)
 This functions is an entry point toward encryption/authentication of the packet Packet is serialized to string in case when encryption or authentication is required, otherwise, the packet is kept in "Packet" form and only QKDCommandHeader and QKDHeader is added. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose (void)
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator (void) const
 Get an iterator to the Objects aggregated to this one. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Get the most derived TypeId for this Object. More...
 
template<typename T >
Ptr< T > GetObject (void) const
 Get a pointer to the requested aggregated Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
void Initialize (void)
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized (void) const
 Check if the object has been initialized. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising erros. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

Static Public Member Functions

static TypeId GetTypeId (void)
 Get the TypeId. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Private Member Functions

std::string AESDecrypt (const std::string &data, Ptr< QKDKey > key)
 AES decryption. More...
 
std::string AESEncrypt (const std::string &data, Ptr< QKDKey > key)
 AES encryption. More...
 
std::string Authenticate (std::string &, Ptr< QKDKey > key, uint8_t authenticationType)
 Help parent function used for calling child authentication functions. More...
 
std::string base64_decode (std::string const &s)
 Help function - base64_decode. More...
 
std::string base64_encode (std::string &s)
 Help function - base64_encode. More...
 
Ptr< PacketCheckAuthentication (Ptr< Packet > p, Ptr< QKDKey > key, uint8_t authenticationType)
 Help parent function used for calling child authentication functions for authentication check. More...
 
std::vector< Ptr< Packet > > CheckForFragmentation (Ptr< Packet > p, Ptr< QKDBuffer > QKDBuffer)
 Check for reassembly of packet fragments. More...
 
QKDCommandHeader CreateQKDCommandHeader (Ptr< Packet > p)
 Help function used to create QKDCommandHeader by analyzing tags of the packet. More...
 
std::string HexDecode (const std::string &data)
 Help function used to decode string to HEX string. More...
 
std::string HexEncode (const std::string &data)
 Help function used to encode string to HEX string. More...
 
std::string MD5 (std::string &inputString)
 MD5 Authentication function. More...
 
std::string OTP (const std::string &data, Ptr< QKDKey > key)
 One-time cipher. More...
 
std::string PacketToString (Ptr< Packet > p)
 Help function used to serialize packet to std::string which is later used for encryption. More...
 
std::vector< uint8_t > QKDDelimiterHeaderToVector (QKDDelimiterHeader &qkdHeader)
 Help function used to covert QKDDelimiterHeader to vector<uint8_t> which is suitable for encryption. More...
 
std::vector< uint8_t > QKDHeaderToVector (QKDHeader &qkdHeader)
 Help function used to covert QKDHeader to vector<uint8_t> which is suitable for encryption. More...
 
std::string SHA1 (std::string &inputString)
 SHA1 Authentication function. More...
 
std::string StringCompressEncode (const std::string &data)
 Help function used to compress string. More...
 
std::string StringDecompressDecode (const std::string &data)
 Help function used to decompress string. More...
 
QKDDelimiterHeader StringToQKDDelimiterHeader (std::string &input)
 Help function used to covert std::string to QKDDelimiterHeader Function is used in decryption (deserialize process) More...
 
QKDHeader StringToQKDHeader (std::string &input)
 Help function used to covert std::string to QKDHeader Function is used in decryption (deserialize process) More...
 
std::vector< uint8_t > StringToVector (std::string &input)
 Help function used to convert string to vector<uint8_t> More...
 
std::string VectorToString (std::vector< uint8_t > inputVector)
 Help function used to vector<uint8_t> to convert string. More...
 
std::string VMAC (std::string &inputString, Ptr< QKDKey > key)
 Authentication function in Wegman-Carter fashion. More...
 

Private Attributes

uint32_t m_aodvqRerrHeaderSize
 
uint32_t m_aodvqRrepAckHeaderSize
 
uint32_t m_aodvqRrepHeaderSize
 
uint32_t m_aodvqRreqHeaderSize
 
uint32_t m_aodvqTypeHeaderSize
 
uint32_t m_aodvRerrHeaderSize
 
uint32_t m_aodvRrepAckHeaderSize
 
uint32_t m_aodvRrepHeaderSize
 
uint32_t m_aodvRreqHeaderSize
 
uint32_t m_aodvTypeHeaderSize
 
uint32_t m_authenticationTagLengthInBits
 length of the authentication tag in bits (32 by default) More...
 
TracedCallback< Ptr< Packet >, std::string > m_authenticationTrace
 trace callback for authentication More...
 
std::map< uint32_t, std::string > m_cacheFlowValues
 map used to hold info about fragmented packets More...
 
bool m_compressionEnabled
 encryption (ZIP or similar) enabled? More...
 
TracedCallback< Ptr< Packet >, std::string > m_deauthenticationTrace
 trace callback for authentication check More...
 
TracedCallback< Ptr< Packet > > m_decryptionTrace
 trace callback for decryption More...
 
uint32_t m_dsdvHeaderSize
 
uint32_t m_dsdvqHeaderSize
 
bool m_encryptionEnabled
 real encryption used? More...
 
TracedCallback< Ptr< Packet > > m_encryptionTrace
 trace callback for encryption More...
 
uint32_t m_icmpv4DestinationUnreachableHeaderSize
 
uint32_t m_icmpv4EchoHeaderSize
 
uint32_t m_icmpv4HeaderSize
 
uint32_t m_icmpv4TimeExceededHeaderSize
 
uint32_t m_ipv4HeaderSize
 we store details about the ipv4 header size which is later used in decryption More...
 
byte m_iv [CryptoPP::AES::BLOCKSIZE]
 
uint32_t m_olsrPacketHeaderSize
 
uint32_t m_qkdDHeaderSize
 qkd delimiter header size More...
 
uint32_t m_qkdHeaderSize
 qkd header size More...
 
uint32_t m_udpHeaderSize
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void DoDispose (void)
 Destructor implementation. More...
 
virtual void DoInitialize (void)
 Initialize() implementation. More...
 
virtual void NotifyNewAggregate (void)
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted (void)
 Notifier called once the ObjectBase is fully constructed. More...
 

Detailed Description

Introspection did not find any typical Config paths.

QKD crypto is a class used to perform encryption, decryption, authentication, atuhentication-check operations and reassembly of previously fragmented packets.


Attributes

  • CompressionEnabled: Indicates whether a compression of packets is enabled.
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: false
    • Flags: construct write read
  • EncryptionEnabled: Indicates whether a real encryption of packets is enabled.
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: false
    • Flags: construct write read

TraceSources

  • PacketEncrypted: The change trance for currenly ecrypted packet
    Callback signature: ns3::QKDCrypto::PacketEncrypted
  • PacketDecrypted: The change trance for currenly decrypted packet
    Callback signature: ns3::QKDCrypto::PacketDecrypted
  • PacketAuthenticated: The change trance for currenly authenticated packet
    Callback signature: ns3::QKDCrypto::PacketAuthenticated
  • PacketDeAuthenticated: The change trance for currenly deauthenticated packet
    Callback signature: ns3::QKDCrypto::PacketDeAuthenticated

Size of this type is 280 bytes (on a 64-bit architecture).

QKD crypto uses cryptographic algorithms and schemes from Crypto++ free and open source C++ class cryptographic library. Currently, QKDCrypto supports following crypto-graphic algorithms and schemes: • One-Time Pad (OTP) cipher, • Advanced Encryption Standard (AES) block cipher, • VMAC message authentication code (MAC) algorithm, • MD5 MAC algorithm, • SHA1 MAC algorithm. QKD crypto implements functions for serialization and deserialization of the packet into a byte array which is used as the input in cryptographic algorithms and schemes.

QKD crypto is a class used to perform encryption, decryption, authentication, authentication-check operations and reassembly of previously fragmented packets. QKD crypto uses cryptographic algorithms and schemes from Crypto++ open-source C++ class cryptographic library. Currently, QKD crypto supports several cryptographic algorithms and cryptographic hashes including One-Time Pad (OTP) cipher, Advanced Encryption Standard (AES) block cipher, VMAC message authentication code (MAC) algorithm and other. Also, QKD crypto implements functions for serialization and deserialization of the packet into a byte array which is used as the input in cryptographic algorithms and schemes.

The main idea behind QKDCrypto is to convert packet payload and its header to string and perform cryptographic operations over that string. Since some headers have variable length, like TCP or OLSR, then and there is no field indicating the size of these headers (there is only field indicating whole packet size in IPv4 header) it is difficult to distinguish between packet payload and end of packet's header. Therefore, we use a small trick to add a QKDDelimiterHeader to help us in this process. This header sits between the packets and it contains only one field (m_delimiter) which is actually the size of next header. For example, in case of TCP, QKDDelimiterHeader sits between IPv4 and TCP indicating the size of TCP header. The order of packets in this case is IPv4, QKDDelimiterHeader, TCP, payload... In case of OLSR it sits between OlsrPacketHeader and OLSRMessageHEader indicating the size of OLSRMessageHeader which can vary. The order of packets in this case is IPv4, UPD, OLSRPacketHeader, QKDDelimiterHeader, OLSRMessageHeader, OLSRPacketHeader, QKDDelimiterHeader, OLSRMessageHeader and etc.

Post taken from ns-3-users google group by Tommaso Pecorella: https://groups.google.com/forum/#!searchin/ns-3-users/A$20Buffer$20does$20NOT$20hold$20just$20the$20header$20(or$20packet)$20content$2C$20it$20contains$20also$20the$20packet$20metadata.%7Csort:relevance/ns-3-users/zfS7DBVs8RM/XUgaFlHABAAJ

"A Buffer does NOT hold just the header (or packet) content, it contains also the packet metadata. As a consequence it's often much longer than expected. The buffer size that you need to serialize something is (not a surprise) returned by GetSerializedSize. If you ask what's the serialized size of an IPv4 header, the answer is... 20 bytes (obvious). However, the Buffer you just serialized the header into... that's different, because THAT has some metadata to carry. Result: Buffer.GetSerializedSize() -> 32 bytes. You need a 32 Bytes long array (minimum) But wait, there's more ! You need to store the array size somewhere. Guess what ? If you serialize a Buffer with a GetSerializedSize equal to 32, you need a 32+4 Bytes array (minimum). Problem: what about the Deserialize ? Well, in that case too you should know the amount of bytes to deserialize. If you think it's less or more, an error will be thrown."

Definition at line 123 of file qkd-crypto.h.

Constructor & Destructor Documentation

ns3::QKDCrypto::QKDCrypto ( )

Constructor.

Definition at line 114 of file qkd-crypto.cc.

References m_authenticationTagLengthInBits, m_iv, m_qkdHeaderSize, and NS_LOG_FUNCTION.

ns3::QKDCrypto::~QKDCrypto ( )
virtual

Destructor.

Definition at line 122 of file qkd-crypto.cc.

Member Function Documentation

std::string ns3::QKDCrypto::AESDecrypt ( const std::string &  data,
Ptr< QKDKey key 
)
private

AES decryption.

Parameters
std::stringdata
Ptr<QKDKey>key
Returns
std::string

Definition at line 3279 of file qkd-crypto.cc.

References data, m_encryptionEnabled, m_iv, and NS_LOG_FUNCTION.

Referenced by Decrypt().

+ Here is the caller graph for this function:

std::string ns3::QKDCrypto::AESEncrypt ( const std::string &  data,
Ptr< QKDKey key 
)
private

AES encryption.

Parameters
std::stringdata
Ptr<QKDKey>key
Returns
std::string

Definition at line 3257 of file qkd-crypto.cc.

References data, m_encryptionEnabled, m_iv, and NS_LOG_FUNCTION.

Referenced by ProcessOutgoingPacket().

+ Here is the caller graph for this function:

std::string ns3::QKDCrypto::Authenticate ( std::string &  inputString,
Ptr< QKDKey key,
uint8_t  authenticationType 
)
private

Help parent function used for calling child authentication functions.

Parameters
std::stringdata
Ptr<QKDKey>key
uint8_tauthentic
Returns
std::string

Definition at line 3337 of file qkd-crypto.cc.

References MD5(), NS_LOG_FUNCTION, QKDCRYPTO_AUTH_MD5, QKDCRYPTO_AUTH_SHA1, QKDCRYPTO_AUTH_VMAC, SHA1(), and VMAC().

Referenced by ProcessOutgoingPacket().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string ns3::QKDCrypto::base64_decode ( std::string const &  s)
private

Help function - base64_decode.

Parameters
std::stringdata
Returns
std::string

Definition at line 3533 of file qkd-crypto.cc.

References ns3::is_base64(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

std::string ns3::QKDCrypto::base64_encode ( std::string &  s)
private

Help function - base64_encode.

Parameters
std::stringdata
Returns
std::string

Definition at line 3483 of file qkd-crypto.cc.

References NS_LOG_FUNCTION.

Ptr< Packet > ns3::QKDCrypto::CheckAuthentication ( Ptr< Packet p,
Ptr< QKDKey key,
uint8_t  authenticationType 
)
private

Help parent function used for calling child authentication functions for authentication check.

Parameters
std::stringdata
Ptr<QKDKey>key
uint8_tauthentic
Returns
std::string

Definition at line 3358 of file qkd-crypto.cc.

References ns3::Packet::Copy(), ns3::Packet::CopyData(), ns3::Packet::GetSize(), ns3::Packet::GetUid(), m_deauthenticationTrace, MD5(), NS_LOG_FUNCTION, packetSize, ns3::Packet::PeekHeader(), QKDCRYPTO_AUTH_MD5, QKDCRYPTO_AUTH_SHA1, QKDCRYPTO_AUTH_VMAC, ns3::Packet::RemoveHeader(), SHA1(), and VMAC().

Referenced by Decrypt().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< Ptr< Packet > > ns3::QKDCrypto::CheckForFragmentation ( Ptr< Packet p,
Ptr< QKDBuffer QKDBuffer 
)
private

Check for reassembly of packet fragments.

Function needs to store in cache memory fragments until it receives whole packet. After receiving of whole packet, decryption can be performed

Parameters
Ptr<Packet>
Ptr<QKDBuffer>
Returns
std::vector<Ptr<Packet> >

Definition at line 1830 of file qkd-crypto.cc.

References ns3::Packet::AddHeader(), ns3::Packet::CopyData(), ns3::QKDHeader::GetLength(), ns3::Packet::GetSize(), ns3::Packet::GetUid(), HexEncode(), m_cacheFlowValues, m_qkdHeaderSize, NS_LOG_FUNCTION, NS_LOG_INFO, packetSize, and StringToQKDHeader().

Referenced by ProcessIncomingPacket().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ns3::QKDCrypto::CheckForResourcesToProcessThePacket ( Ptr< Packet p,
uint32_t  TOSBand,
Ptr< QKDBuffer QKDbuffer 
)

Check whether there is enough resources (key material) to process (encrypt or decrypt) the packet.

Parameters
Ptr<Packet>
uint32_t
Ptr<QKDBuffer>
Returns
bool

Definition at line 293 of file qkd-crypto.cc.

References ns3::QKDInternalTag::GetAuthenticateValue(), ns3::QKDInternalTag::GetEncryptValue(), ns3::Packet::GetSize(), m_authenticationTagLengthInBits, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::Packet::PeekPacketTag(), QKDCRYPTO_AES, QKDCRYPTO_AUTH_VMAC, QKDCRYPTO_OTP, and ns3::QKDBuffer::QKDSTATUS_EMPTY.

+ Here is the call graph for this function:

QKDCommandHeader ns3::QKDCrypto::CreateQKDCommandHeader ( Ptr< Packet p)
private

Help function used to create QKDCommandHeader by analyzing tags of the packet.

Parameters
Ptr<Packet>p
Returns
QKDCommandHeader

Definition at line 262 of file qkd-crypto.cc.

References ns3::QKDCommandTag::GetCommand(), ns3::QKDCommandTag::GetRoutingProtocolNumber(), NS_LOG_FUNCTION, ns3::Packet::PeekPacketTag(), and ns3::QKDCommandHeader::SetCommand().

Referenced by PacketToString().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Ptr< Packet > ns3::QKDCrypto::Decrypt ( Ptr< Packet p,
Ptr< QKDBuffer QKDBuffer 
)

This functions is used for real decryption process.

Parameters
Ptr<Packet>
Ptr<QKDBuffer>
Returns
<Ptr<Packet>

Definition at line 2045 of file qkd-crypto.cc.

References ns3::Packet::AddHeader(), ns3::Packet::AddPacketTag(), AESDecrypt(), AODV_RERR_HEADER_PROTOCOL_NUMBER, AODV_RREP_ACK_HEADER_PROTOCOL_NUMBER, AODV_RREP_HEADER_PROTOCOL_NUMBER, AODV_RREQ_HEADER_PROTOCOL_NUMBER, AODV_TYPE_HEADER_PROTOCOL_NUMBER, AODVQ_RERR_HEADER_PROTOCOL_NUMBER, AODVQ_RREP_ACK_HEADER_PROTOCOL_NUMBER, AODVQ_RREP_HEADER_PROTOCOL_NUMBER, AODVQ_RREQ_HEADER_PROTOCOL_NUMBER, AODVQ_TYPE_HEADER_PROTOCOL_NUMBER, ns3::Buffer::Begin(), CheckAuthentication(), ns3::Packet::CopyData(), ns3::dsdvq::DsdvqHeader::Deserialize(), ns3::QKDCommandHeader::Deserialize(), ns3::aodv::TypeHeader::Deserialize(), ns3::aodvq::TypeHeader::Deserialize(), ns3::dsdv::DsdvHeader::Deserialize(), ns3::Icmpv4Header::Deserialize(), ns3::olsr::PacketHeader::Deserialize(), ns3::Icmpv4Echo::Deserialize(), ns3::aodv::RreqHeader::Deserialize(), ns3::aodvq::RreqHeader::Deserialize(), ns3::Icmpv4DestinationUnreachable::Deserialize(), ns3::Ipv4Header::Deserialize(), ns3::Icmpv4TimeExceeded::Deserialize(), ns3::olsr::MessageHeader::Deserialize(), ns3::TcpHeader::Deserialize(), ns3::aodv::RrepHeader::Deserialize(), ns3::aodvq::RrepHeader::Deserialize(), ns3::aodv::RrepAckHeader::Deserialize(), ns3::aodvq::RrepAckHeader::Deserialize(), ns3::aodv::RerrHeader::Deserialize(), ns3::aodvq::RerrHeader::Deserialize(), ns3::Buffer::Deserialize(), DSDV_PACKET_HEADER_PROTOCOL_NUMBER, DSDVQ_PACKET_HEADER_PROTOCOL_NUMBER, ns3::QKDDelimiterHeader::GetDelimiterSize(), ns3::olsr::MessageHeader::GetMessageType(), ns3::QKDCommandHeader::GetProtocol(), ns3::Ipv4Header::GetProtocol(), ns3::Packet::GetSize(), ns3::Icmpv4Header::GetType(), ns3::Packet::GetUid(), ns3::Icmpv4Header::ICMPV4_DEST_UNREACH, ns3::Icmpv4Header::ICMPV4_ECHO, ns3::Icmpv4Header::ICMPV4_ECHO_REPLY, ns3::Icmpv4Header::ICMPV4_TIME_EXCEEDED, m_aodvqRerrHeaderSize, m_aodvqRrepAckHeaderSize, m_aodvqRrepHeaderSize, m_aodvqRreqHeaderSize, m_aodvqTypeHeaderSize, m_aodvRerrHeaderSize, m_aodvRrepAckHeaderSize, m_aodvRrepHeaderSize, m_aodvRreqHeaderSize, m_aodvTypeHeaderSize, m_authenticationTagLengthInBits, m_decryptionTrace, m_dsdvHeaderSize, m_dsdvqHeaderSize, m_icmpv4DestinationUnreachableHeaderSize, m_icmpv4EchoHeaderSize, m_icmpv4HeaderSize, m_icmpv4TimeExceededHeaderSize, m_ipv4HeaderSize, m_olsrPacketHeaderSize, m_qkdDHeaderSize, m_udpHeaderSize, NS_ASSERT, NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_WARN, OLSR_MESSAGE_HEADER_PROTOCOL_NUMBER, OLSR_PACKET_HEADER_PROTOCOL_NUMBER, OTP(), packetSize, ns3::Packet::PeekHeader(), QKDCRYPTO_AES, QKDCRYPTO_AUTH_VMAC, QKDCRYPTO_OTP, ns3::Packet::RemoveHeader(), ns3::QKDInternalTag::SetAuthenticateValue(), StringDecompressDecode(), and StringToQKDDelimiterHeader().

Referenced by ProcessIncomingPacket().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TypeId ns3::QKDCrypto::GetTypeId ( void  )
static
std::string ns3::QKDCrypto::HexDecode ( const std::string &  data)
private

Help function used to decode string to HEX string.

Parameters
std::stringdata
Returns
std::string

Definition at line 3319 of file qkd-crypto.cc.

References data, m_encryptionEnabled, and NS_LOG_FUNCTION.

std::string ns3::QKDCrypto::HexEncode ( const std::string &  data)
private

Help function used to encode string to HEX string.

Parameters
std::stringdata
Returns
std::string

Definition at line 3301 of file qkd-crypto.cc.

References data, m_encryptionEnabled, and NS_LOG_FUNCTION.

Referenced by CheckForFragmentation().

+ Here is the caller graph for this function:

std::string ns3::QKDCrypto::MD5 ( std::string &  inputString)
private

MD5 Authentication function.

Parameters
std::stringdata
Ptr<QKDKey>key
Returns
std::string

Definition at line 3437 of file qkd-crypto.cc.

References m_authenticationTagLengthInBits, m_encryptionEnabled, and NS_LOG_FUNCTION.

Referenced by Authenticate(), and CheckAuthentication().

+ Here is the caller graph for this function:

std::string ns3::QKDCrypto::OTP ( const std::string &  data,
Ptr< QKDKey key 
)
private

One-time cipher.

Parameters
std::stringdata
Ptr<QKDKey>key
Returns
std::string

Definition at line 3236 of file qkd-crypto.cc.

References data, m_encryptionEnabled, and NS_LOG_FUNCTION.

Referenced by Decrypt(), and ProcessOutgoingPacket().

+ Here is the caller graph for this function:

std::string ns3::QKDCrypto::PacketToString ( Ptr< Packet p)
private

Help function used to serialize packet to std::string which is later used for encryption.

Parameters
Ptr<Packet>p
Returns
std::string

Definition at line 578 of file qkd-crypto.cc.

References ns3::Buffer::AddAtStart(), AODV_RERR_HEADER_PROTOCOL_NUMBER, AODV_RREP_ACK_HEADER_PROTOCOL_NUMBER, AODV_RREP_HEADER_PROTOCOL_NUMBER, AODV_RREQ_HEADER_PROTOCOL_NUMBER, AODV_TYPE_HEADER_PROTOCOL_NUMBER, AODVQ_RERR_HEADER_PROTOCOL_NUMBER, AODVQ_RREP_ACK_HEADER_PROTOCOL_NUMBER, AODVQ_RREP_HEADER_PROTOCOL_NUMBER, AODVQ_RREQ_HEADER_PROTOCOL_NUMBER, AODVQ_TYPE_HEADER_PROTOCOL_NUMBER, ns3::Buffer::Begin(), ns3::Packet::BeginItem(), ns3::Packet::CopyData(), CreateQKDCommandHeader(), ns3::PacketMetadata::Item::current, ns3::dsdvq::DsdvqHeader::Deserialize(), ns3::aodvq::TypeHeader::Deserialize(), ns3::aodv::TypeHeader::Deserialize(), ns3::dsdv::DsdvHeader::Deserialize(), ns3::Icmpv4Header::Deserialize(), ns3::UdpHeader::Deserialize(), ns3::olsr::PacketHeader::Deserialize(), ns3::Icmpv4Echo::Deserialize(), ns3::aodvq::RreqHeader::Deserialize(), ns3::aodv::RreqHeader::Deserialize(), ns3::Icmpv4DestinationUnreachable::Deserialize(), ns3::Ipv4Header::Deserialize(), ns3::Icmpv4TimeExceeded::Deserialize(), ns3::olsr::MessageHeader::Deserialize(), ns3::TcpHeader::Deserialize(), ns3::aodvq::RrepHeader::Deserialize(), ns3::aodv::RrepHeader::Deserialize(), ns3::aodv::RrepAckHeader::Deserialize(), ns3::aodvq::RrepAckHeader::Deserialize(), ns3::aodv::RerrHeader::Deserialize(), ns3::aodvq::RerrHeader::Deserialize(), DSDV_PACKET_HEADER_PROTOCOL_NUMBER, DSDVQ_PACKET_HEADER_PROTOCOL_NUMBER, ns3::TypeId::GetConstructor(), ns3::olsr::MessageHeader::GetMessageType(), ns3::TypeId::GetName(), ns3::Ipv4Header::GetProtocol(), ns3::dsdvq::DsdvqHeader::GetSerializedSize(), ns3::aodvq::TypeHeader::GetSerializedSize(), ns3::aodv::TypeHeader::GetSerializedSize(), ns3::dsdv::DsdvHeader::GetSerializedSize(), ns3::Icmpv4Header::GetSerializedSize(), ns3::UdpHeader::GetSerializedSize(), ns3::olsr::PacketHeader::GetSerializedSize(), ns3::Icmpv4Echo::GetSerializedSize(), ns3::aodvq::RreqHeader::GetSerializedSize(), ns3::aodv::RreqHeader::GetSerializedSize(), ns3::Icmpv4DestinationUnreachable::GetSerializedSize(), ns3::Ipv4Header::GetSerializedSize(), ns3::Icmpv4TimeExceeded::GetSerializedSize(), ns3::olsr::MessageHeader::GetSerializedSize(), ns3::TcpHeader::GetSerializedSize(), ns3::aodvq::RrepHeader::GetSerializedSize(), ns3::aodv::RrepHeader::GetSerializedSize(), ns3::aodv::RrepAckHeader::GetSerializedSize(), ns3::aodvq::RrepAckHeader::GetSerializedSize(), ns3::Buffer::GetSerializedSize(), ns3::aodv::RerrHeader::GetSerializedSize(), ns3::aodvq::RerrHeader::GetSerializedSize(), ns3::TypeId::GetSize(), ns3::Packet::GetSize(), ns3::Packet::GetUid(), ns3::TypeId::GetUid(), ns3::PacketMetadata::ItemIterator::HasNext(), ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::IsNull(), m_aodvqRerrHeaderSize, m_aodvqRrepAckHeaderSize, m_aodvqRrepHeaderSize, m_aodvqRreqHeaderSize, m_aodvqTypeHeaderSize, m_aodvRerrHeaderSize, m_aodvRrepAckHeaderSize, m_aodvRrepHeaderSize, m_aodvRreqHeaderSize, m_aodvTypeHeaderSize, m_dsdvHeaderSize, m_dsdvqHeaderSize, m_icmpv4DestinationUnreachableHeaderSize, m_icmpv4EchoHeaderSize, m_icmpv4HeaderSize, m_icmpv4TimeExceededHeaderSize, m_ipv4HeaderSize, m_olsrPacketHeaderSize, m_udpHeaderSize, ns3::PacketMetadata::ItemIterator::Next(), NS_ASSERT, NS_ASSERT_MSG(), NS_LOG_FUNCTION, OLSR_MESSAGE_HEADER_PROTOCOL_NUMBER, OLSR_PACKET_HEADER_PROTOCOL_NUMBER, packetSize, ns3::Packet::PeekPacketTag(), QKDDelimiterHeaderToVector(), ns3::Packet::RemovePacketTag(), ns3::dsdvq::DsdvqHeader::Serialize(), ns3::aodv::TypeHeader::Serialize(), ns3::aodvq::TypeHeader::Serialize(), ns3::dsdv::DsdvHeader::Serialize(), ns3::Icmpv4Header::Serialize(), ns3::UdpHeader::Serialize(), ns3::olsr::PacketHeader::Serialize(), ns3::Icmpv4Echo::Serialize(), ns3::aodvq::RreqHeader::Serialize(), ns3::aodv::RreqHeader::Serialize(), ns3::Icmpv4DestinationUnreachable::Serialize(), ns3::Ipv4Header::Serialize(), ns3::Icmpv4TimeExceeded::Serialize(), ns3::olsr::MessageHeader::Serialize(), ns3::TcpHeader::Serialize(), ns3::aodv::RrepHeader::Serialize(), ns3::aodvq::RrepHeader::Serialize(), ns3::aodv::RrepAckHeader::Serialize(), ns3::aodvq::RrepAckHeader::Serialize(), ns3::aodv::RerrHeader::Serialize(), ns3::aodvq::RerrHeader::Serialize(), ns3::Buffer::Serialize(), ns3::QKDDelimiterHeader::SetDelimiterSize(), ns3::PacketMetadata::Item::tid, and VectorToString().

Referenced by ProcessOutgoingPacket().

+ Here is the caller graph for this function:

std::vector< Ptr< Packet > > ns3::QKDCrypto::ProcessIncomingPacket ( Ptr< Packet p,
Ptr< QKDBuffer QKDBuffer,
uint32_t  channelID 
)

This functions is an entry point toward deencryption/authentication-check of the packet Packet is deserialized from string in case when packet was previously encrypted or authentication, otherwise, the packet is kept in "Packet" form and only QKDCommandHeader and QKDHeader are removed.

Parameters
Ptr<Packet>
Ptr<QKDBuffer>
uint32_tchannelID
Returns
std::vector<Ptr<Packet> >

Definition at line 2015 of file qkd-crypto.cc.

References CheckForFragmentation(), Decrypt(), ns3::Packet::GetSize(), ns3::Packet::GetUid(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

std::vector< uint8_t > ns3::QKDCrypto::QKDDelimiterHeaderToVector ( QKDDelimiterHeader qkdHeader)
private

Help function used to covert QKDDelimiterHeader to vector<uint8_t> which is suitable for encryption.

Parameters
QKDDelimiterHeaderqkdheader
Returns
std::vector<uint8_t>

Definition at line 187 of file qkd-crypto.cc.

References ns3::Buffer::AddAtStart(), ns3::Buffer::Begin(), ns3::QKDDelimiterHeader::GetSerializedSize(), ns3::Buffer::GetSerializedSize(), m_qkdDHeaderSize, NS_ASSERT, NS_LOG_FUNCTION, ns3::QKDDelimiterHeader::Serialize(), and ns3::Buffer::Serialize().

Referenced by PacketToString().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< uint8_t > ns3::QKDCrypto::QKDHeaderToVector ( QKDHeader qkdHeader)
private

Help function used to covert QKDHeader to vector<uint8_t> which is suitable for encryption.

Parameters
QKDHeaderqkdheader
Returns
std::vector<uint8_t>

Definition at line 161 of file qkd-crypto.cc.

References ns3::Buffer::AddAtStart(), ns3::Buffer::Begin(), ns3::QKDHeader::GetSerializedSize(), ns3::Buffer::GetSerializedSize(), m_qkdHeaderSize, NS_ASSERT, NS_LOG_FUNCTION, ns3::QKDHeader::Serialize(), and ns3::Buffer::Serialize().

Referenced by ProcessOutgoingPacket().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string ns3::QKDCrypto::SHA1 ( std::string &  inputString)
private

SHA1 Authentication function.

Parameters
std::stringdata
Ptr<QKDKey>key
Returns
std::string

Definition at line 3460 of file qkd-crypto.cc.

References m_authenticationTagLengthInBits, m_encryptionEnabled, and NS_LOG_FUNCTION.

Referenced by Authenticate(), and CheckAuthentication().

+ Here is the caller graph for this function:

std::string ns3::QKDCrypto::StringCompressEncode ( const std::string &  data)
private

Help function used to compress string.

Parameters
std::stringdata
Returns
std::string

Definition at line 3578 of file qkd-crypto.cc.

References data, m_compressionEnabled, and NS_LOG_FUNCTION.

Referenced by ProcessOutgoingPacket().

+ Here is the caller graph for this function:

std::string ns3::QKDCrypto::StringDecompressDecode ( const std::string &  data)
private

Help function used to decompress string.

Parameters
std::stringdata
Returns
std::string

Definition at line 3601 of file qkd-crypto.cc.

References data, m_compressionEnabled, and NS_LOG_FUNCTION.

Referenced by Decrypt().

+ Here is the caller graph for this function:

QKDDelimiterHeader ns3::QKDCrypto::StringToQKDDelimiterHeader ( std::string &  input)
private

Help function used to covert std::string to QKDDelimiterHeader Function is used in decryption (deserialize process)

Parameters
std::stringinput
Returns
QKDDelimiterHeader

Definition at line 239 of file qkd-crypto.cc.

References ns3::Buffer::Begin(), ns3::QKDDelimiterHeader::Deserialize(), ns3::Buffer::Deserialize(), m_qkdDHeaderSize, and NS_LOG_FUNCTION.

Referenced by Decrypt().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QKDHeader ns3::QKDCrypto::StringToQKDHeader ( std::string &  input)
private

Help function used to covert std::string to QKDHeader Function is used in decryption (deserialize process)

Parameters
std::stringinput
Returns
QKDHeader

Definition at line 216 of file qkd-crypto.cc.

References ns3::Buffer::Begin(), ns3::QKDHeader::Deserialize(), ns3::Buffer::Deserialize(), m_qkdHeaderSize, and NS_LOG_FUNCTION.

Referenced by CheckForFragmentation().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< uint8_t > ns3::QKDCrypto::StringToVector ( std::string &  input)
private

Help function used to convert string to vector<uint8_t>

Parameters
std::stringinput
Returns
std::vector<uint8_t>

Definition at line 128 of file qkd-crypto.cc.

References NS_LOG_FUNCTION.

Referenced by ProcessOutgoingPacket().

+ Here is the caller graph for this function:

std::string ns3::QKDCrypto::VectorToString ( std::vector< uint8_t >  inputVector)
private

Help function used to vector<uint8_t> to convert string.

Returns
std::string input
Parameters
std::vector<uint8_t>

Definition at line 143 of file qkd-crypto.cc.

References NS_LOG_FUNCTION.

Referenced by PacketToString(), and ProcessOutgoingPacket().

+ Here is the caller graph for this function:

std::string ns3::QKDCrypto::VMAC ( std::string &  inputString,
Ptr< QKDKey key 
)
private

Authentication function in Wegman-Carter fashion.

Parameters
std::stringdata
Ptr<QKDKey>key
Returns
std::string

Definition at line 3410 of file qkd-crypto.cc.

References m_authenticationTagLengthInBits, m_encryptionEnabled, m_iv, and NS_LOG_FUNCTION.

Referenced by Authenticate(), and CheckAuthentication().

+ Here is the caller graph for this function:

Member Data Documentation

uint32_t ns3::QKDCrypto::m_aodvqRerrHeaderSize
private

Definition at line 432 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_aodvqRrepAckHeaderSize
private

Definition at line 431 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_aodvqRrepHeaderSize
private

Definition at line 429 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_aodvqRreqHeaderSize
private

Definition at line 430 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_aodvqTypeHeaderSize
private

Definition at line 428 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_aodvRerrHeaderSize
private

Definition at line 425 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_aodvRrepAckHeaderSize
private

Definition at line 424 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_aodvRrepHeaderSize
private

Definition at line 422 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_aodvRreqHeaderSize
private

Definition at line 423 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_aodvTypeHeaderSize
private

Definition at line 421 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_authenticationTagLengthInBits
private

length of the authentication tag in bits (32 by default)

Definition at line 378 of file qkd-crypto.h.

Referenced by CheckForResourcesToProcessThePacket(), Decrypt(), MD5(), ProcessOutgoingPacket(), QKDCrypto(), SHA1(), and VMAC().

TracedCallback<Ptr<Packet>, std::string > ns3::QKDCrypto::m_authenticationTrace
private

trace callback for authentication

Definition at line 383 of file qkd-crypto.h.

Referenced by GetTypeId(), and ProcessOutgoingPacket().

std::map<uint32_t, std::string> ns3::QKDCrypto::m_cacheFlowValues
private

map used to hold info about fragmented packets

Definition at line 386 of file qkd-crypto.h.

Referenced by CheckForFragmentation().

bool ns3::QKDCrypto::m_compressionEnabled
private

encryption (ZIP or similar) enabled?

Definition at line 391 of file qkd-crypto.h.

Referenced by GetTypeId(), ProcessOutgoingPacket(), StringCompressEncode(), and StringDecompressDecode().

TracedCallback<Ptr<Packet>, std::string > ns3::QKDCrypto::m_deauthenticationTrace
private

trace callback for authentication check

Definition at line 384 of file qkd-crypto.h.

Referenced by CheckAuthentication(), and GetTypeId().

TracedCallback<Ptr<Packet> > ns3::QKDCrypto::m_decryptionTrace
private

trace callback for decryption

Definition at line 381 of file qkd-crypto.h.

Referenced by Decrypt(), and GetTypeId().

uint32_t ns3::QKDCrypto::m_dsdvHeaderSize
private

Definition at line 418 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_dsdvqHeaderSize
private

Definition at line 415 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

bool ns3::QKDCrypto::m_encryptionEnabled
private

real encryption used?

Definition at line 392 of file qkd-crypto.h.

Referenced by AESDecrypt(), AESEncrypt(), GetTypeId(), HexDecode(), HexEncode(), MD5(), OTP(), SHA1(), and VMAC().

TracedCallback<Ptr<Packet> > ns3::QKDCrypto::m_encryptionTrace
private

trace callback for encryption

Definition at line 380 of file qkd-crypto.h.

Referenced by GetTypeId(), and ProcessOutgoingPacket().

uint32_t ns3::QKDCrypto::m_icmpv4DestinationUnreachableHeaderSize
private

Definition at line 406 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_icmpv4EchoHeaderSize
private

Definition at line 404 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_icmpv4HeaderSize
private

Definition at line 403 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_icmpv4TimeExceededHeaderSize
private

Definition at line 405 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_ipv4HeaderSize
private

we store details about the ipv4 header size which is later used in decryption

Definition at line 400 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

byte ns3::QKDCrypto::m_iv[CryptoPP::AES::BLOCKSIZE]
private

Definition at line 197 of file qkd-crypto.h.

Referenced by AESDecrypt(), AESEncrypt(), QKDCrypto(), and VMAC().

uint32_t ns3::QKDCrypto::m_olsrPacketHeaderSize
private

Definition at line 412 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().

uint32_t ns3::QKDCrypto::m_qkdDHeaderSize
private

qkd delimiter header size

Definition at line 389 of file qkd-crypto.h.

Referenced by Decrypt(), QKDDelimiterHeaderToVector(), and StringToQKDDelimiterHeader().

uint32_t ns3::QKDCrypto::m_qkdHeaderSize
private

qkd header size

Definition at line 388 of file qkd-crypto.h.

Referenced by CheckForFragmentation(), ProcessOutgoingPacket(), QKDCrypto(), QKDHeaderToVector(), and StringToQKDHeader().

uint32_t ns3::QKDCrypto::m_udpHeaderSize
private

Definition at line 409 of file qkd-crypto.h.

Referenced by Decrypt(), and PacketToString().


The documentation for this class was generated from the following files: