LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
mifarekey.hpp
Go to the documentation of this file.
1
7#ifndef LOGICALACCESS_MIFAREKEY_HPP
8#define LOGICALACCESS_MIFAREKEY_HPP
9
10#include <logicalaccess/key.hpp>
11#include <logicalaccess/plugins/cards/mifare/lla_cards_mifare_api.hpp>
12
16#define MIFARE_KEY_SIZE 6
17
18namespace logicalaccess
19{
23class LLA_CARDS_MIFARE_API MifareKey : public Key
24{
25 public:
26 using XmlSerializable::serialize;
27 using XmlSerializable::unSerialize;
28
32 MifareKey();
33
38 explicit MifareKey(const std::string &str);
39
45 MifareKey(const void *buf, size_t buflen);
46
50 void clear() override;
51
56 size_t getLength() const override
57 {
58 return MIFARE_KEY_SIZE;
59 }
60
65 const unsigned char *getData() const override
66 {
67 return d_key;
68 }
69
74 unsigned char *getData() override
75 {
76 return d_key;
77 }
78
83 void serialize(boost::property_tree::ptree &parentNode) override;
84
89 void unSerialize(boost::property_tree::ptree &node) override;
90
95 std::string getDefaultXmlNodeName() const override;
96
98 {
99 unsigned char *keyA = this->getData();
100 unsigned char *keyB = b.getData();
101
102 for (unsigned int i = 0; i != 6; i++)
103 {;
104 if (keyA[i] != keyB[i])
105 return false;
106 }
107 return true;
108 }
109
111 {
112 bool a = (*this) == b;
113 return !a;
114 }
115 private:
119 unsigned char d_key[MIFARE_KEY_SIZE];
120};
121}
122
123#endif /* LOGICALACCESS_MIFAREKEY_HPP */
A Key base class. The key object is used to describe key chip information used for authentication on ...
Definition: key.hpp:22
A Mifare Key class.
Definition: mifarekey.hpp:24
size_t getLength() const override
Get the key length.
Definition: mifarekey.hpp:56
bool operator==(MifareKey b)
Definition: mifarekey.hpp:97
const unsigned char * getData() const override
Get the key data.
Definition: mifarekey.hpp:65
bool operator!=(MifareKey b)
Definition: mifarekey.hpp:110
unsigned char * getData() override
Get the key data.
Definition: mifarekey.hpp:74
#define MIFARE_KEY_SIZE
The default Mifare key size.
Definition: mifarekey.hpp:16
Definition: asn1.hpp:9