LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Member Functions | Static Private Attributes | List of all members
logicalaccess::Key Class Referenceabstract

A Key base class. The key object is used to describe key chip information used for authentication on secured memory area or for restricted operation. More...

#include <key.hpp>

Inheritance diagram for logicalaccess::Key:
logicalaccess::XmlSerializable logicalaccess::AES128Key logicalaccess::BinaryFieldValue logicalaccess::DESFireKey logicalaccess::HMAC1Key logicalaccess::MifareKey logicalaccess::SeosKey logicalaccess::TripleDESKey

Public Member Functions

 Key ()
 Constructor.
 
virtual ~Key ()=default
 
virtual void clear ()
 Set the key to its default (only 0's).
 
virtual size_t getLength () const =0
 Get the key length.
 
virtual const unsigned char * getData () const =0
 Get the key data.
 
virtual unsigned char * getData ()=0
 Get the key data.
 
virtual void setData (const unsigned char *data)
 Set the key data.
 
virtual void setData (const ByteVector &data, size_t offset=0)
 Set the key data.
 
std::string getString (bool withSpace=true) const
 Get the string representation of the key.
 
bool isEmpty () const
 Get if key data are empty.
 
virtual bool fromString (const std::string &str)
 Set the key from a string representation of it.
 
void setKeyStorage (std::shared_ptr< KeyStorage > key_storage)
 Set the key storage used for this key.
 
std::shared_ptr< KeyStoragegetKeyStorage () const
 Get the key storage used for this key.
 
void serialize (boost::property_tree::ptree &node) override
 Serialize the current object to XML.
 
void unSerialize (boost::property_tree::ptree &node) override
 UnSerialize a XML node to the current object.
 
virtual bool operator== (const Key &key) const
 Equality operator.
 
virtual bool operator!= (const Key &key) const
 Inequality operator.
 
void setCipherKey (const std::string &key)
 Set the cipher key.
 
void setStoreCipheredData (bool cipher)
 Set if the data is stored ciphered.
 
bool getStoreCipheredData () const
 Get if the data is stored ciphered.
 
void setKeyDiversification (std::shared_ptr< KeyDiversification > div)
 
std::shared_ptr< KeyDiversificationgetKeyDiversification () const
 
ByteVector getBytes () const
 
- Public Member Functions inherited from logicalaccess::XmlSerializable
virtual ~XmlSerializable ()=default
 
virtual std::string serialize ()
 Serialize object to Xml Node string.
 
virtual std::string serializeWithHeaders ()
 Serialize object to Xml Node string, with xml headers.
 
virtual void serialize (boost::property_tree::ptree &parentNode)=0
 Serialize object to Xml Node.
 
virtual void serializeToFile (const std::string &filename)
 Serialize object to a Xml file.
 
virtual void unSerialize (boost::property_tree::ptree &node)=0
 UnSerialize object from a Xml Node.
 
virtual void unSerialize (const std::string &xmlstring, const std::string &rootNode)
 UnSerialize object from a Xml Node string.
 
virtual void unSerialize (std::istream &is, const std::string &rootNode)
 UnSerialize object from a Xml node.
 
virtual void unSerialize (boost::property_tree::ptree &node, const std::string &rootNode)
 UnSerialize object from a Xml node.
 
virtual void unSerializeFromFile (const std::string &filename)
 UnSerialize object from a Xml file.
 
virtual std::string getDefaultXmlNodeName () const =0
 Get the default Xml Node name for this object.
 

Protected Attributes

bool d_isEmpty
 Checked if key data are empty.
 
std::shared_ptr< KeyStoraged_key_storage
 The key storage used for this key.
 
std::shared_ptr< KeyDiversificationd_key_diversification
 The key storage used for this key.
 
std::string d_cipherKey
 The cipher key.
 
bool d_storeCipheredData
 The data is stored ciphered or not.
 

Private Member Functions

void cipherKeyData (boost::property_tree::ptree &node)
 Cipher a key if store ciphered data is true.
 
void uncipherKeyData (boost::property_tree::ptree &node)
 Uncipher a key if store ciphered data is true.
 

Static Private Attributes

static const std::string secureAiKey = "Obscurity is not security Julien would say. But..."
 The default 'secure' key for ciphering.
 

Additional Inherited Members

- Static Public Member Functions inherited from logicalaccess::XmlSerializable
static std::string removeXmlDeclaration (const std::string &xmlstring)
 Remove Xml declaration from a xml string.
 
static ByteVector formatHexString (std::string hexstr)
 Format hex string to hex string with space.
 
- Static Protected Member Functions inherited from logicalaccess::XmlSerializable
static unsigned long long atoull (const std::string &str)
 

Detailed Description

A Key base class. The key object is used to describe key chip information used for authentication on secured memory area or for restricted operation.

Constructor & Destructor Documentation

◆ Key()

logicalaccess::Key::Key ( )

Constructor.

◆ ~Key()

virtual logicalaccess::Key::~Key ( )
virtualdefault

Member Function Documentation

◆ cipherKeyData()

void logicalaccess::Key::cipherKeyData ( boost::property_tree::ptree &  node)
private

Cipher a key if store ciphered data is true.

Parameters
xmlwriterThe xml node.

◆ clear()

void logicalaccess::Key::clear ( )
virtual

Set the key to its default (only 0's).

Reimplemented in logicalaccess::MifareKey.

◆ fromString()

bool logicalaccess::Key::fromString ( const std::string &  str)
virtual

Set the key from a string representation of it.

Parameters
strThe string representation.
Returns
true on success, false otherwise.
Warning
On failure, the content of the key is undefined.

◆ getBytes()

ByteVector logicalaccess::Key::getBytes ( ) const

Retrieve the bytes of the key.

◆ getData() [1/2]

virtual const unsigned char * logicalaccess::Key::getData ( ) const
pure virtual

◆ getData() [2/2]

virtual unsigned char * logicalaccess::Key::getData ( )
pure virtual

◆ getKeyDiversification()

std::shared_ptr< KeyDiversification > logicalaccess::Key::getKeyDiversification ( ) const

◆ getKeyStorage()

std::shared_ptr< KeyStorage > logicalaccess::Key::getKeyStorage ( ) const

Get the key storage used for this key.

Returns
The key storage.

◆ getLength()

virtual size_t logicalaccess::Key::getLength ( ) const
pure virtual

◆ getStoreCipheredData()

bool logicalaccess::Key::getStoreCipheredData ( ) const

Get if the data is stored ciphered.

Returns
True if data is stored ciphered, false otherwise.

◆ getString()

std::string logicalaccess::Key::getString ( bool  withSpace = true) const

Get the string representation of the key.

Returns
The string representation of the key.

◆ isEmpty()

bool logicalaccess::Key::isEmpty ( ) const
inline

Get if key data are empty.

Returns
True if empty, false otherwise.

◆ operator!=()

bool logicalaccess::Key::operator!= ( const Key key) const
virtual

Inequality operator.

Parameters
keyKey to compare.
Returns
True if inequals, false otherwise.

◆ operator==()

bool logicalaccess::Key::operator== ( const Key key) const
virtual

Equality operator.

Parameters
keyKey to compare.
Returns
True if equals, false otherwise.

◆ serialize()

void logicalaccess::Key::serialize ( boost::property_tree::ptree &  node)
overridevirtual

◆ setCipherKey()

void logicalaccess::Key::setCipherKey ( const std::string &  key)

Set the cipher key.

Parameters
keyThe key.

◆ setData() [1/2]

void logicalaccess::Key::setData ( const ByteVector data,
size_t  offset = 0 
)
virtual

Set the key data.

Parameters
dataThe key data.

◆ setData() [2/2]

void logicalaccess::Key::setData ( const unsigned char *  data)
virtual

Set the key data.

Parameters
dataThe key data.

◆ setKeyDiversification()

void logicalaccess::Key::setKeyDiversification ( std::shared_ptr< KeyDiversification div)

◆ setKeyStorage()

void logicalaccess::Key::setKeyStorage ( std::shared_ptr< KeyStorage key_storage)

Set the key storage used for this key.

Parameters
key_storageThe key storage.

◆ setStoreCipheredData()

void logicalaccess::Key::setStoreCipheredData ( bool  cipher)

Set if the data is stored ciphered.

Parameters
cipherThe data is stored ciphered or not.

◆ uncipherKeyData()

void logicalaccess::Key::uncipherKeyData ( boost::property_tree::ptree &  node)
private

Uncipher a key if store ciphered data is true.

Parameters
nodeThe node containing key data.

◆ unSerialize()

void logicalaccess::Key::unSerialize ( boost::property_tree::ptree &  node)
overridevirtual

Member Data Documentation

◆ d_cipherKey

std::string logicalaccess::Key::d_cipherKey
protected

The cipher key.

◆ d_isEmpty

bool logicalaccess::Key::d_isEmpty
protected

Checked if key data are empty.

◆ d_key_diversification

std::shared_ptr<KeyDiversification> logicalaccess::Key::d_key_diversification
protected

The key storage used for this key.

◆ d_key_storage

std::shared_ptr<KeyStorage> logicalaccess::Key::d_key_storage
protected

The key storage used for this key.

◆ d_storeCipheredData

bool logicalaccess::Key::d_storeCipheredData
protected

The data is stored ciphered or not.

◆ secureAiKey

const std::string logicalaccess::Key::secureAiKey = "Obscurity is not security Julien would say. But..."
staticprivate

The default 'secure' key for ciphering.


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