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

A DESFire Key class. More...

#include <desfirekey.hpp>

Inheritance diagram for logicalaccess::DESFireKey:
logicalaccess::Key logicalaccess::XmlSerializable

Public Member Functions

 DESFireKey ()
 Build an empty DESFire key.
 
 DESFireKey (const std::string &str)
 Build a DESFire key given a string representation of it.
 
 DESFireKey (const void *buf, size_t buflen)
 Build a DESFire key given a buffer.
 
size_t getLength () const override
 Get the key length.
 
const unsigned char * getData () const override
 Get the key data.
 
unsigned char * getData () override
 Get the key data.
 
void setKeyVersion (unsigned char key_version)
 Set the key version.
 
unsigned char getKeyVersion () const
 Get the key version.
 
void setKeyType (DESFireKeyType keyType)
 Set the key type.
 
DESFireKeyType getKeyType () const
 Get the key type.
 
void serialize (boost::property_tree::ptree &parentNode) override
 Serialize the current object to XML.
 
void unSerialize (boost::property_tree::ptree &node) override
 UnSerialize a XML node to the current object.
 
std::string getDefaultXmlNodeName () const override
 Get the default Xml Node name for this object.
 
virtual bool operator== (const DESFireKey &key) const
 Equality operator.
 
bool operator!= (const DESFireKey &key) const
 Inequality operator.
 
virtual std::string serialize ()
 Serialize object to Xml Node string.
 
virtual void serialize (boost::property_tree::ptree &parentNode)=0
 Serialize object to Xml Node.
 
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.
 
- Public Member Functions inherited from logicalaccess::Key
 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.
 

Static Public Member Functions

static std::string DESFireKeyTypeStr (DESFireKeyType t)
 Get the DESFire Key Type in string format.
 
- 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.
 

Private Attributes

ByteVector d_key
 The key bytes;.
 
unsigned char d_key_version
 The key version.
 
DESFireKeyType d_keyType
 The DESFire key type.
 

Additional Inherited Members

- Static Protected Member Functions inherited from logicalaccess::XmlSerializable
static unsigned long long atoull (const std::string &str)
 
- Protected Attributes inherited from logicalaccess::Key
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.
 

Detailed Description

A DESFire Key class.

Constructor & Destructor Documentation

◆ DESFireKey() [1/3]

logicalaccess::DESFireKey::DESFireKey ( )

Build an empty DESFire key.

◆ DESFireKey() [2/3]

logicalaccess::DESFireKey::DESFireKey ( const std::string &  str)
explicit

Build a DESFire key given a string representation of it.

Parameters
strThe string representation.

◆ DESFireKey() [3/3]

logicalaccess::DESFireKey::DESFireKey ( const void *  buf,
size_t  buflen 
)

Build a DESFire key given a buffer.

Parameters
bufThe buffer.
buflenThe buffer length.

Member Function Documentation

◆ DESFireKeyTypeStr()

std::string logicalaccess::DESFireKey::DESFireKeyTypeStr ( DESFireKeyType  t)
static

Get the DESFire Key Type in string format.

Returns
The key type in string.

◆ getData() [1/2]

const unsigned char * logicalaccess::DESFireKey::getData ( ) const
inlineoverridevirtual

Get the key data.

Returns
The key data.

Implements logicalaccess::Key.

◆ getData() [2/2]

unsigned char * logicalaccess::DESFireKey::getData ( )
inlineoverridevirtual

Get the key data.

Returns
The key data.

Implements logicalaccess::Key.

◆ getDefaultXmlNodeName()

std::string logicalaccess::DESFireKey::getDefaultXmlNodeName ( ) const
overridevirtual

Get the default Xml Node name for this object.

Returns
The Xml node name.

Implements logicalaccess::XmlSerializable.

◆ getKeyType()

DESFireKeyType logicalaccess::DESFireKey::getKeyType ( ) const
inline

Get the key type.

Returns
The key type.

◆ getKeyVersion()

unsigned char logicalaccess::DESFireKey::getKeyVersion ( ) const
inline

Get the key version.

Returns
The key version.

◆ getLength()

size_t logicalaccess::DESFireKey::getLength ( ) const
overridevirtual

Get the key length.

Returns
The key length.

Implements logicalaccess::Key.

◆ operator!=()

bool logicalaccess::DESFireKey::operator!= ( const DESFireKey key) const
inline

Inequality operator.

Parameters
aiDESFire key to compare.
Returns
True if inequals, false otherwise.

◆ operator==()

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

Equality operator.

Parameters
aiDESFire key to compare.
Returns
True if equals, false otherwise.

◆ serialize() [1/3]

std::string logicalaccess::XmlSerializable::serialize ( )
virtual

Serialize object to Xml Node string.

Returns
The serialized object.

Reimplemented from logicalaccess::XmlSerializable.

◆ serialize() [2/3]

void logicalaccess::DESFireKey::serialize ( boost::property_tree::ptree &  parentNode)
overridevirtual

Serialize the current object to XML.

Parameters
parentNodeThe parent node.

Reimplemented from logicalaccess::Key.

◆ serialize() [3/3]

virtual void logicalaccess::XmlSerializable::serialize ( boost::property_tree::ptree &  parentNode)
virtual

Serialize object to Xml Node.

Parameters
osThe XML stream.

Reimplemented from logicalaccess::Key.

◆ setKeyType()

void logicalaccess::DESFireKey::setKeyType ( DESFireKeyType  keyType)

Set the key type.

Parameters
keyTypeThe key type.

◆ setKeyVersion()

void logicalaccess::DESFireKey::setKeyVersion ( unsigned char  key_version)
inline

Set the key version.

Parameters
key_versionThe key version.

◆ unSerialize() [1/5]

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

UnSerialize a XML node to the current object.

Parameters
nodeThe XML node.

Reimplemented from logicalaccess::Key.

◆ unSerialize() [2/5]

virtual void logicalaccess::XmlSerializable::unSerialize ( boost::property_tree::ptree &  node)
virtual

UnSerialize object from a Xml Node.

Parameters
nodeThe Xml node.

Reimplemented from logicalaccess::Key.

◆ unSerialize() [3/5]

void logicalaccess::XmlSerializable::unSerialize ( boost::property_tree::ptree &  node,
const std::string &  rootNode 
)
virtual

UnSerialize object from a Xml node.

Parameters
nodeThe Xml node.
rootNodeThe root node.
Returns
True on success, false otherwise.

Reimplemented from logicalaccess::XmlSerializable.

◆ unSerialize() [4/5]

void logicalaccess::XmlSerializable::unSerialize ( const std::string &  xmlstring,
const std::string &  rootNode 
)
virtual

UnSerialize object from a Xml Node string.

Parameters
xmlstringThe Xml Node string.
rootNodeThe root node.
Returns
True on success, false otherwise.

Reimplemented from logicalaccess::XmlSerializable.

◆ unSerialize() [5/5]

void logicalaccess::XmlSerializable::unSerialize ( std::istream &  is,
const std::string &  rootNode 
)
virtual

UnSerialize object from a Xml node.

Parameters
isThe Xml stream.
rootNodeThe root node.
Returns
True on success, false otherwise.

Reimplemented from logicalaccess::XmlSerializable.

Member Data Documentation

◆ d_key

ByteVector logicalaccess::DESFireKey::d_key
private

The key bytes;.

◆ d_key_version

unsigned char logicalaccess::DESFireKey::d_key_version
private

The key version.

◆ d_keyType

DESFireKeyType logicalaccess::DESFireKey::d_keyType
private

The DESFire key type.


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