A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::QKDEncryptor Class Reference

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

#include "qkd-encryptor.h"

+ Inheritance diagram for ns3::QKDEncryptor:
+ Collaboration diagram for ns3::QKDEncryptor:

Public Types

enum  AuthenticationType { UNAUTHENTICATED , QKDCRYPTO_AUTH_VMAC , QKDCRYPTO_AUTH_MD5 , QKDCRYPTO_AUTH_SHA1 }
 Authentication type. More...
 
enum  EncryptionType { UNENCRYPTED , QKDCRYPTO_OTP , QKDCRYPTO_AES }
 Encryption type. More...
 

Public Member Functions

 QKDEncryptor ()
 
 QKDEncryptor (EncryptionType type1, AuthenticationType type2)
 Constructor.
 
 QKDEncryptor (EncryptionType type1, AuthenticationType type2, uint32_t authTagLength)
 Constructor.
 
 QKDEncryptor (uint32_t authTagLength)
 Constructor.
 
 ~QKDEncryptor () override
 Destructor.
 
std::string AESDecrypt (const std::string &key, const std::string &data)
 AES decryption.
 
std::string AESEncrypt (const std::string &key, const std::string &data)
 AES encryption.
 
std::string Authenticate (std::string &, std::string key="0")
 Help parent function used for calling child authentication functions.
 
std::string Base64Decode (std::string input)
 Base64 decoder.
 
std::string Base64Encode (std::string input)
 Base64 encoder.
 
void ChangeSettings (EncryptionType type1, AuthenticationType type2, uint32_t authTagLength)
 Constructor.
 
bool CheckAuthentication (std::string payload, std::string authTag, std::string key="0")
 Check Authentication on packet payload for authenticated packet.
 
std::string COTP (const std::string &key, const std::string &input)
 One-Time Pad cipher where output is alfabet/number symbols.
 
std::string DecryptMsg (std::string input, std::string key)
 Perform decryption of ciphertext.
 
std::string EncryptMsg (std::string input, std::string key)
 Perform encryption of plaintext.
 
uint32_t GetIndex () const
 Get internal index identifier in qkd encryptor container.
 
Ptr< NodeGetNode () const
 Get details about the node on which qkd encryptor is installed.
 
std::string HexDecode (const std::string &data)
 Help function used to decode string to HEX string.
 
std::string HexEncode (const std::string &data)
 Help function used to encode string to HEX string.
 
std::string MD5 (std::string &inputString)
 MD5 Authentication function.
 
std::string OTP (const std::string &key, const std::string &data)
 One-time cipher.
 
void SetIndex (uint32_t index)
 Set internal index identifier in qkd encryptor container.
 
void SetNode (Ptr< Node > node)
 Set node on which qkd encryptor is installed.
 
std::string SHA1 (std::string &inputString)
 SHA1 Authentication function.
 
std::string VMAC (std::string &key, std::string &inputString)
 Authentication function in Wegman-Carter fashion.
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

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

Private Attributes

uint32_t m_authenticationTagLengthInBits
 length of the authentication tag in bits(32 by default)
 
TracedCallback< Ptr< Packet >, std::string > m_authenticationTrace
 trace callback for authentication
 
AuthenticationType m_authenticationType
 
bool m_compressionEnabled
 should compression algorithms be used?
 
TracedCallback< Ptr< Packet >, std::string > m_deauthenticationTrace
 trace callback for authentication check
 
TracedCallback< Ptr< Packet > > m_decryptionTrace
 trace callback for decryption
 
bool m_encryptionEnabled
 real encryption used?
 
TracedCallback< Ptr< Packet > > m_encryptionTrace
 trace callback for encryption
 
EncryptionType m_encryptionType
 
uint32_t m_index
 index in the qkd encryptor container
 
unsigned char m_iv [CryptoPP::AES::BLOCKSIZE]
 
Ptr< Nodem_node
 pointer to node on which encryptor is installed
 

Additional Inherited Members

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

Detailed Description

Introspection did not find any typical Config paths.


Attributes

  • CompressionEnabled: Indicates whether a compression of packets is enabled.
    • Set with class: ns3::BooleanValue
    • Underlying type: bool
    • Initial value: false
    • Flags: constructwriteread
    • Support level: SUPPORTED
  • EncryptionEnabled: Indicates whether a real encryption of packets is enabled.
    • Set with class: ns3::BooleanValue
    • Underlying type: bool
    • Initial value: false
    • Flags: constructwriteread
    • Support level: SUPPORTED

TraceSources

  • PacketAuthenticated: The change trance for currenly authenticated packet
    • Callback signature: ns3::QKDEncryptor::PacketAuthenticated
    • Support level: SUPPORTED
  • PacketDeAuthenticated: The change trance for currenly deauthenticated packet
    • Callback signature: ns3::QKDEncryptor::PacketDeAuthenticated
    • Support level: SUPPORTED
  • PacketDecrypted: The change trance for currenly decrypted packet
    • Callback signature: ns3::QKDEncryptor::PacketDecrypted
    • Support level: SUPPORTED
  • PacketEncrypted: The change trance for currenly ecrypted packet
    • Callback signature: ns3::QKDEncryptor::PacketEncrypted
    • Support level: SUPPORTED

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

Definition at line 77 of file qkd-encryptor.h.

Member Enumeration Documentation

◆ AuthenticationType

Authentication type.

Enumerator
UNAUTHENTICATED 
QKDCRYPTO_AUTH_VMAC 
QKDCRYPTO_AUTH_MD5 
QKDCRYPTO_AUTH_SHA1 

Definition at line 93 of file qkd-encryptor.h.

◆ EncryptionType

Encryption type.

Enumerator
UNENCRYPTED 
QKDCRYPTO_OTP 
QKDCRYPTO_AES 

Definition at line 84 of file qkd-encryptor.h.

Constructor & Destructor Documentation

◆ QKDEncryptor() [1/4]

ns3::QKDEncryptor::QKDEncryptor ( )

Definition at line 74 of file qkd-encryptor.cc.

References NS_LOG_FUNCTION.

◆ QKDEncryptor() [2/4]

ns3::QKDEncryptor::QKDEncryptor ( uint32_t  authTagLength)

Constructor.

Definition at line 79 of file qkd-encryptor.cc.

References ns3::Create(), m_authenticationTagLengthInBits, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ QKDEncryptor() [3/4]

ns3::QKDEncryptor::QKDEncryptor ( EncryptionType  type1,
AuthenticationType  type2 
)

Constructor.

Definition at line 85 of file qkd-encryptor.cc.

References ChangeSettings(), ns3::Create(), m_iv, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ QKDEncryptor() [4/4]

ns3::QKDEncryptor::QKDEncryptor ( EncryptionType  type1,
AuthenticationType  type2,
uint32_t  authTagLength 
)

Constructor.

Definition at line 94 of file qkd-encryptor.cc.

References ChangeSettings(), ns3::Create(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ ~QKDEncryptor()

ns3::QKDEncryptor::~QKDEncryptor ( )
override

Destructor.

Definition at line 119 of file qkd-encryptor.cc.

Member Function Documentation

◆ AESDecrypt()

std::string ns3::QKDEncryptor::AESDecrypt ( const std::string &  key,
const std::string &  data 
)

AES decryption.

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

Definition at line 326 of file qkd-encryptor.cc.

References ns3::Create(), data, m_iv, and NS_LOG_FUNCTION.

Referenced by DecryptMsg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AESEncrypt()

std::string ns3::QKDEncryptor::AESEncrypt ( const std::string &  key,
const std::string &  data 
)

AES encryption.

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

Definition at line 306 of file qkd-encryptor.cc.

References ns3::Create(), data, m_iv, and NS_LOG_FUNCTION.

Referenced by EncryptMsg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Authenticate()

std::string ns3::QKDEncryptor::Authenticate ( std::string &  inputString,
std::string  key = "0" 
)

Help parent function used for calling child authentication functions.

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

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

References ns3::Create(), m_authenticationType, MD5(), NS_LOG_FUNCTION, QKDCRYPTO_AUTH_MD5, QKDCRYPTO_AUTH_SHA1, QKDCRYPTO_AUTH_VMAC, SHA1(), UNAUTHENTICATED, and VMAC().

Referenced by CheckAuthentication().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Base64Decode()

std::string ns3::QKDEncryptor::Base64Decode ( std::string  input)

Base64 decoder.

Parameters
inputinput data
Returns
string decoded input

Definition at line 235 of file qkd-encryptor.cc.

References ns3::Create().

+ Here is the call graph for this function:

◆ Base64Encode()

std::string ns3::QKDEncryptor::Base64Encode ( std::string  input)

Base64 encoder.

Parameters
inputinput data
Returns
string base64 encoded input

Definition at line 223 of file qkd-encryptor.cc.

References ns3::Create().

+ Here is the call graph for this function:

◆ ChangeSettings()

void ns3::QKDEncryptor::ChangeSettings ( EncryptionType  type1,
AuthenticationType  type2,
uint32_t  authTagLength 
)

Constructor.

Definition at line 104 of file qkd-encryptor.cc.

References ns3::Create(), m_authenticationTagLengthInBits, m_authenticationType, m_encryptionType, and NS_FATAL_ERROR.

Referenced by QKDEncryptor(), and QKDEncryptor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckAuthentication()

bool ns3::QKDEncryptor::CheckAuthentication ( std::string  payload,
std::string  authTag,
std::string  key = "0" 
)

Check Authentication on packet payload for authenticated packet.

Parameters
payloadpayload data
keykey for authentication
Returns
bool authentication check result

Definition at line 209 of file qkd-encryptor.cc.

References Authenticate(), ns3::Create(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ COTP()

std::string ns3::QKDEncryptor::COTP ( const std::string &  key,
const std::string &  input 
)

One-Time Pad cipher where output is alfabet/number symbols.

Parameters
keysymmetric key
inputinput message
Returns
string encrypted/decrypted message

Solution adapted from: https://stackoverflow.com/questions/12671510/xor-on-two-hexadeicmal-values-stored-as-string-in-c

Definition at line 278 of file qkd-encryptor.cc.

References ns3::Create(), NS_ASSERT, NS_FATAL_ERROR, NS_LOG_FUNCTION, and ns3::value().

+ Here is the call graph for this function:

◆ DecryptMsg()

std::string ns3::QKDEncryptor::DecryptMsg ( std::string  input,
std::string  key 
)

Perform decryption of ciphertext.

Parameters
inputciphertext
keyencryption key
Returns
string plaintext

Definition at line 166 of file qkd-encryptor.cc.

References AESDecrypt(), ns3::Create(), m_encryptionType, NS_LOG_FUNCTION, OTP(), QKDCRYPTO_AES, QKDCRYPTO_OTP, and UNENCRYPTED.

+ Here is the call graph for this function:

◆ EncryptMsg()

std::string ns3::QKDEncryptor::EncryptMsg ( std::string  input,
std::string  key 
)

Perform encryption of plaintext.

Parameters
inputplaintext
keyencryption key
Returns
string ciphertext

Definition at line 145 of file qkd-encryptor.cc.

References AESEncrypt(), ns3::Create(), m_encryptionType, NS_LOG_FUNCTION, OTP(), QKDCRYPTO_AES, QKDCRYPTO_OTP, and UNENCRYPTED.

+ Here is the call graph for this function:

◆ GetIndex()

uint32_t ns3::QKDEncryptor::GetIndex ( ) const

Get internal index identifier in qkd encryptor container.

@featureTask

Returns
uint32_t index

Definition at line 139 of file qkd-encryptor.cc.

References m_index.

◆ GetNode()

Ptr< Node > ns3::QKDEncryptor::GetNode ( ) const

Get details about the node on which qkd encryptor is installed.

Returns
Ptr<Node> node

Definition at line 129 of file qkd-encryptor.cc.

References m_node.

◆ GetTypeId()

TypeId ns3::QKDEncryptor::GetTypeId ( )
static

◆ HexDecode()

std::string ns3::QKDEncryptor::HexDecode ( const std::string &  data)

Help function used to decode string to HEX string.

Parameters
std::stringdata
Returns
std::string

Definition at line 359 of file qkd-encryptor.cc.

References ns3::Create(), data, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ HexEncode()

std::string ns3::QKDEncryptor::HexEncode ( const std::string &  data)

Help function used to encode string to HEX string.

Parameters
std::stringdata
Returns
std::string

Definition at line 346 of file qkd-encryptor.cc.

References ns3::Create(), data, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ MD5()

std::string ns3::QKDEncryptor::MD5 ( std::string &  inputString)

MD5 Authentication function.

Parameters
std::stringdata
Returns
std::string

Definition at line 404 of file qkd-encryptor.cc.

References ns3::Create(), m_authenticationTagLengthInBits, and NS_LOG_FUNCTION.

Referenced by Authenticate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OTP()

std::string ns3::QKDEncryptor::OTP ( const std::string &  key,
const std::string &  data 
)

One-time cipher.

Parameters
keykey for encryption
datamessage to encrypt/decrypt
Returns
string encypted/decrypted message

Definition at line 247 of file qkd-encryptor.cc.

References ns3::Create(), NS_FATAL_ERROR, and NS_LOG_FUNCTION.

Referenced by DecryptMsg(), and EncryptMsg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetIndex()

void ns3::QKDEncryptor::SetIndex ( uint32_t  index)

Set internal index identifier in qkd encryptor container.

@featureTask

Parameters
uint32_tindex

Definition at line 135 of file qkd-encryptor.cc.

References m_index.

◆ SetNode()

void ns3::QKDEncryptor::SetNode ( Ptr< Node node)

Set node on which qkd encryptor is installed.

Parameters
Ptr<Node>node

Definition at line 125 of file qkd-encryptor.cc.

References m_node.

◆ SHA1()

std::string ns3::QKDEncryptor::SHA1 ( std::string &  inputString)

SHA1 Authentication function.

Parameters
std::stringdata
Returns
std::string

Definition at line 425 of file qkd-encryptor.cc.

References ns3::Create(), m_authenticationTagLengthInBits, and NS_LOG_FUNCTION.

Referenced by Authenticate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VMAC()

std::string ns3::QKDEncryptor::VMAC ( std::string &  key,
std::string &  inputString 
)

Authentication function in Wegman-Carter fashion.

Parameters
std::stringdata
std::stringdata
uint32_tlength of auth tag
Returns
std::string

Definition at line 372 of file qkd-encryptor.cc.

References ns3::Create(), m_iv, and NS_LOG_FUNCTION.

Referenced by Authenticate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_authenticationTagLengthInBits

uint32_t ns3::QKDEncryptor::m_authenticationTagLengthInBits
private

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

Definition at line 282 of file qkd-encryptor.h.

Referenced by QKDEncryptor(), ChangeSettings(), MD5(), and SHA1().

◆ m_authenticationTrace

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

trace callback for authentication

Definition at line 290 of file qkd-encryptor.h.

Referenced by GetTypeId().

◆ m_authenticationType

AuthenticationType ns3::QKDEncryptor::m_authenticationType
private

Definition at line 285 of file qkd-encryptor.h.

Referenced by Authenticate(), and ChangeSettings().

◆ m_compressionEnabled

bool ns3::QKDEncryptor::m_compressionEnabled
private

should compression algorithms be used?

Definition at line 281 of file qkd-encryptor.h.

Referenced by GetTypeId().

◆ m_deauthenticationTrace

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

trace callback for authentication check

Definition at line 291 of file qkd-encryptor.h.

Referenced by GetTypeId().

◆ m_decryptionTrace

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

trace callback for decryption

Definition at line 288 of file qkd-encryptor.h.

Referenced by GetTypeId().

◆ m_encryptionEnabled

bool ns3::QKDEncryptor::m_encryptionEnabled
private

real encryption used?

Definition at line 280 of file qkd-encryptor.h.

Referenced by GetTypeId().

◆ m_encryptionTrace

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

trace callback for encryption

Definition at line 287 of file qkd-encryptor.h.

Referenced by GetTypeId().

◆ m_encryptionType

EncryptionType ns3::QKDEncryptor::m_encryptionType
private

Definition at line 284 of file qkd-encryptor.h.

Referenced by ChangeSettings(), DecryptMsg(), and EncryptMsg().

◆ m_index

uint32_t ns3::QKDEncryptor::m_index
private

index in the qkd encryptor container

Definition at line 278 of file qkd-encryptor.h.

Referenced by GetIndex(), and SetIndex().

◆ m_iv

unsigned char ns3::QKDEncryptor::m_iv[CryptoPP::AES::BLOCKSIZE]
private

Definition at line 275 of file qkd-encryptor.h.

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

◆ m_node

Ptr<Node> ns3::QKDEncryptor::m_node
private

pointer to node on which encryptor is installed

Definition at line 277 of file qkd-encryptor.h.

Referenced by GetNode(), and SetNode().


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