The QKD key is an elementary class of QKDNetSim. More...
#include "qkd-key.h"
Public Types | |
enum | QKDKeyState_e { INIT , READY , SERVED , TRANSFORMED , USED , OBSOLETE , RESTORED , RESERVED } |
The QKD key states. More... | |
Public Member Functions | |
QKDKey (std::string keyId, std::string key) | |
Constructor. More... | |
QKDKey (std::string keyId, uint64_t keyIdnum, std::string key) | |
Constructor. More... | |
QKDKey (std::string keyId, uint64_t keyIdnum, uint64_t keySize) | |
Constructor. More... | |
QKDKey (uint64_t keySize) | |
Constructor. More... | |
std::string | ConsumeKeyString (void) |
Get the key value and switch the key state to SERVED. More... | |
Ptr< QKDKey > | Copy (void) const |
Copy the key. More... | |
std::string | GenerateRandomString (const int len) |
Get a random string. More... | |
std::string | GetId (void) const |
Get the key identifier. More... | |
uint8_t * | GetKey (void) |
Get key value in byte* format. More... | |
std::string | GetKeyBinary () |
Get key value in bit notation. More... | |
std::string | GetKeyString (void) |
Get QKD key value. More... | |
Time | GetKeyTimestamp () |
Get the key timestamp. More... | |
uint64_t | GetSize (void) const |
Get the key size in bytes. More... | |
uint64_t | GetSizeInBits (void) const |
Get the key size in bits. More... | |
QKDKeyState_e | GetState () const |
Get the current state of the key. More... | |
std::string | GetStateString () const |
Get the current state of the key in a string format. More... | |
void | MarkReady () |
Mark the key as ready. More... | |
void | MarkReserved () |
Mark the key as reserved. More... | |
void | MarkRestored () |
Mark the key as restored. More... | |
void | MarkServed () |
Mark the key as served. More... | |
void | MarkTransformed () |
Mark the key as transformed. More... | |
void | MarkUsed () |
Mark the key as used. More... | |
void | SetId (std::string value) |
Set the key identifier. More... | |
void | SetSize (uint64_t sizeInBytes) |
Set the key size. More... | |
void | SwitchToState (QKDKeyState_e state) |
Change the state of the key. More... | |
std::string | ToString (void) |
Get the key value. 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 std::string | GetStateString (QKDKeyState_e state) |
Get the given state in a string format. More... | |
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... | |
Public Attributes | |
ns3::TracedCallback< const std::string &, const std::string & > | m_stateTransitionTrace |
The StateTransition trace source. More... | |
Private Attributes | |
std::string | m_id |
uint64_t | m_internalID |
std::string | m_key |
Ptr< UniformRandomVariable > | m_random |
uint64_t | m_sizeInBits |
uint64_t | m_sizeInBytes |
QKDKeyState_e | m_state |
The key state. More... | |
Time | m_timestamp |
Static Private Attributes | |
static uint64_t | m_globalUid = 0 |
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... | |
The QKD key is an elementary class of QKDNetSim.
It is used to describe the key that is established in the QKD process.
\noteIn the QKD process, keys are stored as blocks. Each QKDKey is identified using a unique 32 long character identifier. The key is also marked with the timestamp of its origin, its length, and the condition in which the key is located. QKDKey can be found in one of the following states: INIT - the call for the establishment of the key record is initiated READY - the key is successfully created and stored SERVED - the key is served for usage on request TRANSFORMED - the key is generated as the result of transform operation USED - the key is used for cryptographic operations (under construction) OBSOLETE - the key validity has expired (under construction) RESTORED - the key is restored for further usage (under construction)
ns3::QKDKey::QKDKey | ( | uint64_t | keySize | ) |
Constructor.
Create a random QKD key.
keySize | The key size. |
Definition at line 68 of file qkd-key.cc.
References GenerateRandomString(), GetStateString(), m_globalUid, m_id, m_internalID, m_key, m_random, m_sizeInBits, m_sizeInBytes, m_timestamp, ns3::Simulator::Now(), NS_FATAL_ERROR, NS_LOG_FUNCTION, READY, and SwitchToState().
ns3::QKDKey::QKDKey | ( | std::string | keyId, |
uint64_t | keyIdnum, | ||
uint64_t | keySize | ||
) |
Constructor.
Create a QKD key.
keyId | The key identifier. |
KeyIdnum | The internal key identifier. |
keySize | The key size. |
Definition at line 106 of file qkd-key.cc.
References GenerateRandomString(), m_globalUid, m_id, m_internalID, m_key, m_random, m_sizeInBits, m_sizeInBytes, m_timestamp, ns3::Simulator::Now(), NS_FATAL_ERROR, NS_LOG_FUNCTION, READY, and SwitchToState().
ns3::QKDKey::QKDKey | ( | std::string | keyId, |
uint64_t | keyIdnum, | ||
std::string | key | ||
) |
Constructor.
Create a QKD key.
keyId | The key identifier. |
keyIdnum | The internal key identifier. |
key | The key value. |
Definition at line 134 of file qkd-key.cc.
References m_globalUid, m_id, m_internalID, m_key, m_random, m_sizeInBits, m_sizeInBytes, m_timestamp, ns3::Simulator::Now(), NS_LOG_FUNCTION, READY, and SwitchToState().
ns3::QKDKey::QKDKey | ( | std::string | keyId, |
std::string | key | ||
) |
Constructor.
Create a QKD key.
keyId | The key identifier. |
key | The key value. |
Definition at line 155 of file qkd-key.cc.
References m_key, m_random, m_sizeInBits, m_sizeInBytes, m_timestamp, ns3::Simulator::Now(), READY, and SwitchToState().
std::string ns3::QKDKey::ConsumeKeyString | ( | void | ) |
Get the key value and switch the key state to SERVED.
Definition at line 227 of file qkd-key.cc.
References m_id, m_key, NS_LOG_FUNCTION, SERVED, and SwitchToState().
std::string ns3::QKDKey::GenerateRandomString | ( | const int | len | ) |
Get a random string.
len | The length of the string. |
Definition at line 292 of file qkd-key.cc.
References ns3::UniformRandomVariable::GetValue(), m_internalID, m_random, and NS_LOG_FUNCTION.
Referenced by QKDKey().
std::string ns3::QKDKey::GetId | ( | void | ) | const |
Get the key identifier.
Definition at line 190 of file qkd-key.cc.
References m_id.
uint8_t * ns3::QKDKey::GetKey | ( | void | ) |
Get key value in byte* format.
Convert key from std::String to byte*.
Definition at line 242 of file qkd-key.cc.
References m_id, m_key, NS_LOG_FUNCTION, SERVED, and SwitchToState().
std::string ns3::QKDKey::GetKeyBinary | ( | ) |
Get key value in bit notation.
Definition at line 177 of file qkd-key.cc.
References m_key, and NS_LOG_FUNCTION.
std::string ns3::QKDKey::GetKeyString | ( | void | ) |
Get QKD key value.
Definition at line 170 of file qkd-key.cc.
References m_key, and NS_LOG_FUNCTION.
Time ns3::QKDKey::GetKeyTimestamp | ( | ) |
Get the key timestamp.
Definition at line 376 of file qkd-key.cc.
References m_timestamp.
uint64_t ns3::QKDKey::GetSize | ( | void | ) | const |
Get the key size in bytes.
Definition at line 202 of file qkd-key.cc.
References m_id, m_sizeInBytes, and NS_LOG_FUNCTION.
uint64_t ns3::QKDKey::GetSizeInBits | ( | void | ) | const |
Get the key size in bits.
Definition at line 209 of file qkd-key.cc.
References m_id, m_sizeInBytes, and NS_LOG_FUNCTION.
QKDKey::QKDKeyState_e ns3::QKDKey::GetState | ( | ) | const |
Get the current state of the key.
Definition at line 311 of file qkd-key.cc.
References m_state.
std::string ns3::QKDKey::GetStateString | ( | ) | const |
Get the current state of the key in a string format.
Definition at line 356 of file qkd-key.cc.
References m_state.
Referenced by QKDKey(), and SwitchToState().
|
static |
Get the given state in a string format.
state | The key state. |
Definition at line 319 of file qkd-key.cc.
References INIT, NS_FATAL_ERROR, OBSOLETE, READY, RESERVED, RESTORED, SERVED, TRANSFORMED, and USED.
|
static |
Get the TypeId.
Definition at line 40 of file qkd-key.cc.
References m_stateTransitionTrace, ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().
void ns3::QKDKey::MarkReady | ( | ) |
Mark the key as ready.
Definition at line 252 of file qkd-key.cc.
References m_id, m_key, m_state, NS_LOG_FUNCTION, READY, and SwitchToState().
void ns3::QKDKey::MarkReserved | ( | ) |
Mark the key as reserved.
Definition at line 280 of file qkd-key.cc.
References m_id, m_key, m_state, NS_LOG_FUNCTION, RESERVED, and SwitchToState().
void ns3::QKDKey::MarkRestored | ( | ) |
Mark the key as restored.
Definition at line 272 of file qkd-key.cc.
References m_id, m_key, m_state, NS_LOG_FUNCTION, RESTORED, and SwitchToState().
void ns3::QKDKey::MarkServed | ( | ) |
Mark the key as served.
Definition at line 258 of file qkd-key.cc.
References m_id, m_key, m_state, NS_LOG_FUNCTION, SERVED, and SwitchToState().
void ns3::QKDKey::MarkTransformed | ( | ) |
Mark the key as transformed.
Definition at line 286 of file qkd-key.cc.
References m_id, m_key, m_state, NS_LOG_FUNCTION, SwitchToState(), and TRANSFORMED.
void ns3::QKDKey::MarkUsed | ( | ) |
Mark the key as used.
Definition at line 265 of file qkd-key.cc.
References m_id, m_key, m_state, NS_LOG_FUNCTION, SwitchToState(), and USED.
void ns3::QKDKey::SetId | ( | std::string | value | ) |
Set the key identifier.
value | The key identifier. |
Definition at line 196 of file qkd-key.cc.
References m_id.
void ns3::QKDKey::SetSize | ( | uint64_t | sizeInBytes | ) |
Set the key size.
sizeInBytes | The key size in bytes. |
Definition at line 216 of file qkd-key.cc.
References m_id, m_sizeInBits, m_sizeInBytes, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
void ns3::QKDKey::SwitchToState | ( | QKDKey::QKDKeyState_e | state | ) |
Change the state of the key.
Fires the StateTransition
trace source.
state | The new state. |
Definition at line 362 of file qkd-key.cc.
References GetStateString(), m_state, m_stateTransitionTrace, NS_LOG_FUNCTION, and NS_LOG_INFO.
Referenced by QKDKey(), ConsumeKeyString(), GetKey(), MarkReady(), MarkReserved(), MarkRestored(), MarkServed(), MarkTransformed(), and MarkUsed().
std::string ns3::QKDKey::ToString | ( | void | ) |
Get the key value.
Definition at line 235 of file qkd-key.cc.
References m_id, m_key, and NS_LOG_FUNCTION.
|
staticprivate |
|
private |
Definition at line 264 of file qkd-key.h.
Referenced by QKDKey(), ConsumeKeyString(), GetId(), GetKey(), GetSize(), GetSizeInBits(), MarkReady(), MarkReserved(), MarkRestored(), MarkServed(), MarkTransformed(), MarkUsed(), SetId(), SetSize(), and ToString().
|
private |
Definition at line 263 of file qkd-key.h.
Referenced by QKDKey(), and GenerateRandomString().
|
private |
Definition at line 268 of file qkd-key.h.
Referenced by QKDKey(), ConsumeKeyString(), GetKey(), GetKeyBinary(), GetKeyString(), MarkReady(), MarkReserved(), MarkRestored(), MarkServed(), MarkTransformed(), MarkUsed(), and ToString().
|
private |
Definition at line 271 of file qkd-key.h.
Referenced by QKDKey(), and GenerateRandomString().
|
private |
|
private |
|
private |
The key state.
Definition at line 270 of file qkd-key.h.
Referenced by GetState(), GetStateString(), MarkReady(), MarkReserved(), MarkRestored(), MarkServed(), MarkTransformed(), MarkUsed(), and SwitchToState().
ns3::TracedCallback<const std::string &, const std::string &> ns3::QKDKey::m_stateTransitionTrace |
The StateTransition
trace source.
Definition at line 260 of file qkd-key.h.
Referenced by GetTypeId(), and SwitchToState().
|
private |
Definition at line 269 of file qkd-key.h.
Referenced by QKDKey(), and GetKeyTimestamp().