#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< Node > | GetNode () |
| 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... | |
| ~Object () override | |
| Destructor. More... | |
| void | AggregateObject (Ptr< Object > other) |
| Aggregate two Objects together. More... | |
| void | Dispose () |
| Dispose of this Object. More... | |
| AggregateIterator | GetAggregateIterator () const |
| Get an iterator to the Objects aggregated to this one. More... | |
| TypeId | GetInstanceTypeId () const override |
| Get the most derived TypeId for this Object. More... | |
| template<typename T > | |
| Ptr< T > | GetObject () const |
| Get a pointer to the requested aggregated Object. More... | |
| template<> | |
| Ptr< Object > | GetObject () 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< Object > | GetObject (TypeId tid) const |
| Specialization of (TypeId tid) for objects of type ns3::Object. More... | |
| void | Initialize () |
| Invoke DoInitialize on all Objects aggregated to this one. More... | |
| bool | IsInitialized () 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 () const |
| Get the reference count of the object. More... | |
| SimpleRefCount & | operator= (const SimpleRefCount &o[[maybe_unused]]) |
| Assignment operator. More... | |
| void | Ref () const |
| Increment the reference count. More... | |
| void | Unref () 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 errors. 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 () |
| Register this type. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
| static TypeId | GetTypeId () |
| 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< Node > | m_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 () |
| Destructor implementation. More... | |
| virtual void | DoInitialize () |
| Initialize() implementation. More... | |
| virtual void | NotifyNewAggregate () |
| 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 () |
| Notifier called once the ObjectBase is fully constructed. More... | |
Related Functions inherited from ns3::ObjectBase | |
| static TypeId | GetObjectIid () |
| Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
Definition at line 89 of file qkd-encryptor.h.
Authentication type.
| Enumerator | |
|---|---|
| UNAUTHENTICATED | |
| QKDCRYPTO_AUTH_VMAC | |
| QKDCRYPTO_AUTH_MD5 | |
| QKDCRYPTO_AUTH_SHA1 | |
Definition at line 105 of file qkd-encryptor.h.
Encryption type.
| Enumerator | |
|---|---|
| UNENCRYPTED | |
| QKDCRYPTO_OTP | |
| QKDCRYPTO_AES | |
Definition at line 96 of file qkd-encryptor.h.
| 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:| 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:
|
virtual |
Destructor.
Definition at line 118 of file qkd-encryptor.cc.
| std::string ns3::QKDEncryptor::AESDecrypt | ( | const std::string & | key, |
| const std::string & | data | ||
| ) |
Decrypt data using AES algorithm.
| key | The decryption key. |
| data | The ciphertext. |
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:| std::string ns3::QKDEncryptor::AESEncrypt | ( | const std::string & | key, |
| const std::string & | data | ||
| ) |
Encrypt data using AES algorithm.
| key | The encryption key. |
| data | The plaintext. |
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:| std::string ns3::QKDEncryptor::Authenticate | ( | std::string & | data, |
| std::string | key = "0" |
||
| ) |
Calculate an authentication tag on a message.
| data | The message. |
| key | The authentication key (if VMAC is applied). |
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:| std::string ns3::QKDEncryptor::Base64Decode | ( | std::string | input | ) |
Base64 decoder.
| input | The input data. |
Definition at line 235 of file qkd-encryptor.cc.
| std::string ns3::QKDEncryptor::Base64Encode | ( | std::string | input | ) |
Base64 encoder.
| input | The input data. |
Definition at line 223 of file qkd-encryptor.cc.
| 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:| bool ns3::QKDEncryptor::CheckAuthentication | ( | std::string | payload, |
| std::string | authTag, | ||
| std::string | key = "0" |
||
| ) |
Authenticate the packet.
| payload | The packet payload. |
| authTag | The received authentication tag. |
| key | The authentication key. |
Definition at line 206 of file qkd-encryptor.cc.
References Authenticate(), and NS_LOG_FUNCTION.
Here is the call graph for this function:| std::string ns3::QKDEncryptor::DecryptMsg | ( | std::string | input, |
| std::string | key | ||
| ) |
Decrypt a ciphertext.
| input | The ciphertext. |
| key | The encryption key. |
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:| std::string ns3::QKDEncryptor::EncryptMsg | ( | std::string | input, |
| std::string | key | ||
| ) |
Encrypt a plaintext.
| input | The plaintext. |
| key | The encryption key. |
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:| uint32_t ns3::QKDEncryptor::GetIndex | ( | ) |
Get the internal index identifier in the qkd encryptor container.
@featureTask
Definition at line 137 of file qkd-encryptor.cc.
References m_index.
Get details about the node on which qkd encryptor is installed.
Definition at line 128 of file qkd-encryptor.cc.
References m_node.
|
static |
Get the TypeId.
Definition at line 50 of file qkd-encryptor.cc.
References m_authenticationTrace, m_compressionEnabled, m_deauthenticationTrace, m_decryptionTrace, m_encryptionEnabled, m_encryptionTrace, ns3::MakeBooleanAccessor(), ns3::MakeBooleanChecker(), ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().
Here is the call graph for this function:| std::string ns3::QKDEncryptor::HexDecode | ( | const std::string & | data | ) |
Decode the HEX string.
| data | The input HEX string. |
Definition at line 321 of file qkd-encryptor.cc.
References data, and NS_LOG_FUNCTION.
| std::string ns3::QKDEncryptor::HexEncode | ( | const std::string & | data | ) |
Encode the string to the HEX string.
| data | The input string. |
Definition at line 308 of file qkd-encryptor.cc.
References data, and NS_LOG_FUNCTION.
| std::string ns3::QKDEncryptor::MD5 | ( | std::string & | inputString | ) |
Calculate MD5 authentication tag.
| inputString | The input message. |
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:| std::string ns3::QKDEncryptor::OTP | ( | const std::string & | key, |
| const std::string & | data | ||
| ) |
Apply the One-Time Pad cipher.
| key | The encryption/decryption key. |
| data | The plaintext/ciphertext. |
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:| void ns3::QKDEncryptor::SetIndex | ( | uint32_t | index | ) |
Set the internal index identifier in the qkd encryptor container.
@featureTask
| index | The internal index identifier. |
Definition at line 133 of file qkd-encryptor.cc.
References m_index.
Set node on which qkd encryptor is installed.
| node | The node |
Definition at line 124 of file qkd-encryptor.cc.
References m_node.
| std::string ns3::QKDEncryptor::SHA1 | ( | std::string & | inputString | ) |
Calucale SHA1 authentication tag.
| inputString | The input message. |
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:| std::string ns3::QKDEncryptor::VMAC | ( | std::string & | key, |
| std::string & | inputString | ||
| ) |
Calculate authentication tag in Wegman-Carter fashion.
| key | The authentication key. |
| inputString | The input message. |
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:
|
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().
|
private |
A trace callback for the authentication.
Definition at line 283 of file qkd-encryptor.h.
Referenced by GetTypeId().
|
private |
The authentication algorithm.
Definition at line 278 of file qkd-encryptor.h.
Referenced by Authenticate(), and ChangeSettings().
|
private |
Should compression algorithms be used?
Definition at line 274 of file qkd-encryptor.h.
Referenced by GetTypeId().
|
private |
A trace callback for the authentication check.
Definition at line 284 of file qkd-encryptor.h.
Referenced by GetTypeId().
|
private |
A trace callback for the decryption.
Definition at line 281 of file qkd-encryptor.h.
Referenced by GetTypeId().
|
private |
Execute the actual encryption algorithm?
Definition at line 273 of file qkd-encryptor.h.
Referenced by GetTypeId().
|
private |
A trace callback for the encryption.
Definition at line 280 of file qkd-encryptor.h.
Referenced by GetTypeId().
|
private |
The encryption algorithm.
Definition at line 277 of file qkd-encryptor.h.
Referenced by ChangeSettings(), DecryptMsg(), and EncryptMsg().
|
private |
An index in the qkd encryptor container.
Definition at line 271 of file qkd-encryptor.h.
Referenced by GetIndex(), and SetIndex().
|
private |
Definition at line 268 of file qkd-encryptor.h.
Referenced by QKDEncryptor(), AESDecrypt(), AESEncrypt(), and VMAC().
A pointer to the node on which the encryptor is installed.
Definition at line 270 of file qkd-encryptor.h.