A Discrete-Event Network Simulator
API
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 (EncryptionType type1, AuthenticationType type2)
 Constructor. More...
 
 QKDEncryptor (EncryptionType type1, AuthenticationType type2, uint32_t authTagLength)
 Constructor. More...
 
virtual ~QKDEncryptor ()
 Destructor. More...
 
std::string AESDecrypt (const std::string &key, const std::string &data)
 Decrypt data using AES algorithm. More...
 
std::string AESEncrypt (const std::string &key, const std::string &data)
 Encrypt data using AES algorithm. More...
 
std::string Authenticate (std::string &data, std::string key="0")
 Calculate an authentication tag on a message. More...
 
std::string Base64Decode (std::string input)
 Base64 decoder. More...
 
std::string Base64Encode (std::string input)
 Base64 encoder. More...
 
void ChangeSettings (EncryptionType type1, AuthenticationType type2, uint32_t authTagLength)
 Constructor. More...
 
bool CheckAuthentication (std::string payload, std::string authTag, std::string key="0")
 Authenticate the packet. More...
 
std::string DecryptMsg (std::string input, std::string key)
 Decrypt a ciphertext. More...
 
std::string EncryptMsg (std::string input, std::string key)
 Encrypt a plaintext. More...
 
uint32_t GetIndex ()
 Get the internal index identifier in the qkd encryptor container. More...
 
Ptr< NodeGetNode ()
 Get details about the node on which qkd encryptor is installed. More...
 
std::string HexDecode (const std::string &data)
 Decode the HEX string. More...
 
std::string HexEncode (const std::string &data)
 Encode the string to the HEX string. More...
 
std::string MD5 (std::string &inputString)
 Calculate MD5 authentication tag. More...
 
std::string OTP (const std::string &key, const std::string &data)
 Apply the One-Time Pad cipher. More...
 
void SetIndex (uint32_t index)
 Set the internal index identifier in the qkd encryptor container. More...
 
void SetNode (Ptr< Node > node)
 Set node on which qkd encryptor is installed. More...
 
std::string SHA1 (std::string &inputString)
 Calucale SHA1 authentication tag. More...
 
std::string VMAC (std::string &key, std::string &inputString)
 Calculate authentication tag in Wegman-Carter fashion. 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<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (void) const
 Get a pointer to the requested aggregated Object. 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[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= ([[maybe_unused]] 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 Attributes

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

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.


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::QKDEncryptor::PacketEncrypted
  • PacketDecrypted: The change trance for currenly decrypted packet
    Callback signature: ns3::QKDEncryptor::PacketDecrypted
  • PacketAuthenticated: The change trance for currenly authenticated packet
    Callback signature: ns3::QKDEncryptor::PacketAuthenticated
  • PacketDeAuthenticated: The change trance for currenly deauthenticated packet
    Callback signature: ns3::QKDEncryptor::PacketDeAuthenticated

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

Definition at line 89 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 105 of file qkd-encryptor.h.

◆ EncryptionType

Encryption type.

Enumerator
UNENCRYPTED 
QKDCRYPTO_OTP 
QKDCRYPTO_AES 

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

Constructor & Destructor Documentation

◆ QKDEncryptor() [1/2]

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

Constructor.

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

References ChangeSettings(), m_iv, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ QKDEncryptor() [2/2]

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

Constructor.

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

References ChangeSettings(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ ~QKDEncryptor()

ns3::QKDEncryptor::~QKDEncryptor ( )
virtual

Destructor.

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

Member Function Documentation

◆ AESDecrypt()

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

Decrypt data using AES algorithm.

Parameters
keyThe decryption key.
dataThe ciphertext.
Returns
The plaintext.

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

References data, m_iv, and NS_LOG_FUNCTION.

Referenced by DecryptMsg().

+ Here is the caller graph for this function:

◆ AESEncrypt()

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

Encrypt data using AES algorithm.

Parameters
keyThe encryption key.
dataThe plaintext.
Returns
The ciphertext.

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

References data, m_iv, and NS_LOG_FUNCTION.

Referenced by EncryptMsg().

+ Here is the caller graph for this function:

◆ Authenticate()

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

Calculate an authentication tag on a message.

Parameters
dataThe message.
keyThe authentication key (if VMAC is applied).
Returns
The authentication tag.

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

References 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
inputThe input data.
Returns
The decoded input.

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

◆ Base64Encode()

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

Base64 encoder.

Parameters
inputThe input data.
Returns
The base64 encoded input.

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

◆ ChangeSettings()

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

Constructor.

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

References m_authenticationTagLengthInBits, m_authenticationType, m_encryptionType, and NS_FATAL_ERROR.

Referenced by QKDEncryptor().

+ Here is the caller graph for this function:

◆ CheckAuthentication()

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

Authenticate the packet.

Parameters
payloadThe packet payload.
authTagThe received authentication tag.
keyThe authentication key.
Returns
The authentication result.

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

References Authenticate(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ DecryptMsg()

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

Decrypt a ciphertext.

Parameters
inputThe ciphertext.
keyThe encryption key.
Returns
The plaintext.

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

References AESDecrypt(), 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 
)

Encrypt a plaintext.

Parameters
inputThe plaintext.
keyThe encryption key.
Returns
The ciphertext.

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

References AESEncrypt(), 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 ( )

Get the internal index identifier in the qkd encryptor container.

@featureTask

Returns
The internal index identifier.

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

References m_index.

◆ GetNode()

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

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

Returns
The node

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

References m_node.

◆ GetTypeId()

TypeId ns3::QKDEncryptor::GetTypeId ( void  )
static

◆ HexDecode()

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

Decode the HEX string.

Parameters
dataThe input HEX string.
Returns
The decoded string.

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

References data, and NS_LOG_FUNCTION.

◆ HexEncode()

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

Encode the string to the HEX string.

Parameters
dataThe input string.
Returns
The HEX encoded string.

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

References data, and NS_LOG_FUNCTION.

◆ MD5()

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

Calculate MD5 authentication tag.

Parameters
inputStringThe input message.
Returns
The authentication tag.

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

References m_authenticationTagLengthInBits, and NS_LOG_FUNCTION.

Referenced by Authenticate().

+ Here is the caller graph for this function:

◆ OTP()

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

Apply the One-Time Pad cipher.

Parameters
keyThe encryption/decryption key.
dataThe plaintext/ciphertext.
Returns
The ciphertext/plaintext.

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

References NS_FATAL_ERROR, and NS_LOG_FUNCTION.

Referenced by DecryptMsg(), and EncryptMsg().

+ Here is the caller graph for this function:

◆ SetIndex()

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

Set the internal index identifier in the qkd encryptor container.

@featureTask

Parameters
indexThe internal index identifier.

Definition at line 133 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
nodeThe node

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

References m_node.

◆ SHA1()

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

Calucale SHA1 authentication tag.

Parameters
inputStringThe input message.
Returns
The authentication tag.

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

References m_authenticationTagLengthInBits, and NS_LOG_FUNCTION.

Referenced by Authenticate().

+ Here is the caller graph for this function:

◆ VMAC()

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

Calculate authentication tag in Wegman-Carter fashion.

Parameters
keyThe authentication key.
inputStringThe input message.
Returns
The authentication tag.

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

References m_iv, and NS_LOG_FUNCTION.

Referenced by Authenticate().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_authenticationTagLengthInBits

uint32_t ns3::QKDEncryptor::m_authenticationTagLengthInBits
private

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

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

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

◆ m_authenticationTrace

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

A trace callback for the authentication.

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

Referenced by GetTypeId().

◆ m_authenticationType

AuthenticationType ns3::QKDEncryptor::m_authenticationType
private

The authentication algorithm.

Definition at line 278 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 274 of file qkd-encryptor.h.

Referenced by GetTypeId().

◆ m_deauthenticationTrace

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

A trace callback for the authentication check.

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

Referenced by GetTypeId().

◆ m_decryptionTrace

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

A trace callback for the decryption.

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

Referenced by GetTypeId().

◆ m_encryptionEnabled

bool ns3::QKDEncryptor::m_encryptionEnabled
private

Execute the actual encryption algorithm?

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

Referenced by GetTypeId().

◆ m_encryptionTrace

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

A trace callback for the encryption.

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

Referenced by GetTypeId().

◆ m_encryptionType

EncryptionType ns3::QKDEncryptor::m_encryptionType
private

The encryption algorithm.

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

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

◆ m_index

uint32_t ns3::QKDEncryptor::m_index
private

An index in the qkd encryptor container.

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

Referenced by GetIndex(), and SetIndex().

◆ m_iv

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

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

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

◆ m_node

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

A pointer to the node on which the encryptor is installed.

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

Referenced by GetNode(), and SetNode().


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