LibLogicalAccess
2.5.0
An Open Source RFID Library
|
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>
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< KeyStorage > | getKeyStorage () 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< KeyDiversification > | getKeyDiversification () const |
ByteVector | getBytes () const |
![]() | |
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< KeyStorage > | d_key_storage |
The key storage used for this key. | |
std::shared_ptr< KeyDiversification > | d_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 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 unsigned long long | atoull (const std::string &str) |
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.
logicalaccess::Key::Key | ( | ) |
Constructor.
|
virtualdefault |
|
private |
Cipher a key if store ciphered data is true.
xmlwriter | The xml node. |
|
virtual |
Set the key to its default (only 0's).
Reimplemented in logicalaccess::MifareKey.
|
virtual |
Set the key from a string representation of it.
str | The string representation. |
ByteVector logicalaccess::Key::getBytes | ( | ) | const |
Retrieve the bytes of the key.
|
pure virtual |
Get the key data.
Implemented in logicalaccess::AES128Key, logicalaccess::HMAC1Key, logicalaccess::TripleDESKey, logicalaccess::BinaryFieldValue, logicalaccess::DESFireKey, logicalaccess::MifareKey, and logicalaccess::SeosKey.
|
pure virtual |
Get the key data.
Implemented in logicalaccess::AES128Key, logicalaccess::HMAC1Key, logicalaccess::TripleDESKey, logicalaccess::BinaryFieldValue, logicalaccess::DESFireKey, logicalaccess::MifareKey, and logicalaccess::SeosKey.
std::shared_ptr< KeyDiversification > logicalaccess::Key::getKeyDiversification | ( | ) | const |
std::shared_ptr< KeyStorage > logicalaccess::Key::getKeyStorage | ( | ) | const |
Get the key storage used for this key.
|
pure virtual |
Get the key length.
Implemented in logicalaccess::AES128Key, logicalaccess::HMAC1Key, logicalaccess::TripleDESKey, logicalaccess::BinaryFieldValue, logicalaccess::DESFireKey, logicalaccess::MifareKey, and logicalaccess::SeosKey.
bool logicalaccess::Key::getStoreCipheredData | ( | ) | const |
Get if the data is stored ciphered.
std::string logicalaccess::Key::getString | ( | bool | withSpace = true | ) | const |
Get the string representation of the key.
|
inline |
Get if key data are empty.
|
virtual |
|
virtual |
|
overridevirtual |
Serialize the current object to XML.
npde | The XML node. |
Implements logicalaccess::XmlSerializable.
Reimplemented in logicalaccess::BinaryFieldValue, logicalaccess::DESFireKey, logicalaccess::MifareKey, logicalaccess::SeosKey, logicalaccess::AES128Key, logicalaccess::TripleDESKey, logicalaccess::DESFireKey, logicalaccess::MifareKey, and logicalaccess::SeosKey.
void logicalaccess::Key::setCipherKey | ( | const std::string & | key | ) |
Set the cipher key.
key | The key. |
|
virtual |
Set the key data.
data | The key data. |
|
virtual |
Set the key data.
data | The key data. |
void logicalaccess::Key::setKeyDiversification | ( | std::shared_ptr< KeyDiversification > | div | ) |
void logicalaccess::Key::setKeyStorage | ( | std::shared_ptr< KeyStorage > | key_storage | ) |
Set the key storage used for this key.
key_storage | The key storage. |
void logicalaccess::Key::setStoreCipheredData | ( | bool | cipher | ) |
Set if the data is stored ciphered.
cipher | The data is stored ciphered or not. |
|
private |
Uncipher a key if store ciphered data is true.
node | The node containing key data. |
|
overridevirtual |
UnSerialize a XML node to the current object.
node | The XML node. |
Implements logicalaccess::XmlSerializable.
Reimplemented in logicalaccess::BinaryFieldValue, logicalaccess::DESFireKey, logicalaccess::MifareKey, logicalaccess::SeosKey, logicalaccess::AES128Key, logicalaccess::TripleDESKey, logicalaccess::DESFireKey, logicalaccess::MifareKey, and logicalaccess::SeosKey.
|
protected |
The cipher key.
|
protected |
Checked if key data are empty.
|
protected |
The key storage used for this key.
|
protected |
The key storage used for this key.
|
protected |
The data is stored ciphered or not.
|
staticprivate |
The default 'secure' key for ciphering.