LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
desfirekey.hpp
Go to the documentation of this file.
1
7#ifndef LOGICALACCESS_DESFIREKEY_HPP
8#define LOGICALACCESS_DESFIREKEY_HPP
9
10#include <logicalaccess/key.hpp>
11#include <logicalaccess/plugins/cards/desfire/lla_cards_desfire_api.hpp>
12
16#define DESFIRE_DES_KEY_SIZE 16
17
21#define DESFIRE_AES_KEY_SIZE 16
22
26#define DESFIRE_MAXKEY_SIZE 24
27
28namespace logicalaccess
29{
33typedef enum {
34 DF_KEY_DES = 0x00,
36 DF_KEY_AES = 0x80
38
42class LLA_CARDS_DESFIRE_API DESFireKey : public Key
43{
44 public:
45 using XmlSerializable::serialize;
46 using XmlSerializable::unSerialize;
47
51 DESFireKey();
52
57 explicit DESFireKey(const std::string &str);
58
64 DESFireKey(const void *buf, size_t buflen);
65
70 size_t getLength() const override;
71
76 const unsigned char *getData() const override
77 {
78 return &d_key[0];
79 }
80
85 unsigned char *getData() override
86 {
87 return &d_key[0];
88 }
89
94 void setKeyVersion(unsigned char key_version)
95 {
96 d_key_version = key_version;
97 }
98
103 unsigned char getKeyVersion() const
104 {
105 return d_key_version;
106 }
107
112 void setKeyType(DESFireKeyType keyType);
113
119 {
120 return d_keyType;
121 }
122
127 void serialize(boost::property_tree::ptree &parentNode) override;
128
133 void unSerialize(boost::property_tree::ptree &node) override;
134
139 std::string getDefaultXmlNodeName() const override;
140
146 virtual bool operator==(const DESFireKey &key) const;
147
153 bool operator!=(const DESFireKey &key) const
154 {
155 return !operator==(key);
156 }
157
162 static std::string DESFireKeyTypeStr(DESFireKeyType t);
163
164 private:
169
173 unsigned char d_key_version;
174
179};
180}
181
182#endif /* LOGICALACCESS_DESFIREKEY_HPP */
A DESFire Key class.
Definition: desfirekey.hpp:43
const unsigned char * getData() const override
Get the key data.
Definition: desfirekey.hpp:76
void setKeyVersion(unsigned char key_version)
Set the key version.
Definition: desfirekey.hpp:94
DESFireKeyType getKeyType() const
Get the key type.
Definition: desfirekey.hpp:118
unsigned char d_key_version
The key version.
Definition: desfirekey.hpp:173
unsigned char * getData() override
Get the key data.
Definition: desfirekey.hpp:85
ByteVector d_key
The key bytes;.
Definition: desfirekey.hpp:168
unsigned char getKeyVersion() const
Get the key version.
Definition: desfirekey.hpp:103
bool operator!=(const DESFireKey &key) const
Inequality operator.
Definition: desfirekey.hpp:153
DESFireKeyType d_keyType
The DESFire key type.
Definition: desfirekey.hpp:178
A Key base class. The key object is used to describe key chip information used for authentication on ...
Definition: key.hpp:22
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Definition: asn1.hpp:9
DESFireKeyType
The DESFire key type.
Definition: desfirekey.hpp:33
@ DF_KEY_AES
Definition: desfirekey.hpp:36
@ DF_KEY_DES
Definition: desfirekey.hpp:34
@ DF_KEY_3K3DES
Definition: desfirekey.hpp:35