LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
sambasickeyentry.hpp
Go to the documentation of this file.
1
7#ifndef LOGICALACCESS_SAMBASICKEYENTRY_HPP
8#define LOGICALACCESS_SAMBASICKEYENTRY_HPP
9
10#include <logicalaccess/key.hpp>
11#include <logicalaccess/plugins/cards/samav/lla_cards_samav_api.hpp>
12
16#define SAM_DES_KEY_SIZE 16
17
21#define SAM_AES_KEY_SIZE 16
22
26#define SAM_MAXKEY_SIZE 24
27
28namespace logicalaccess
29{
33typedef enum { SAM_KEY_DES = 0x00, SAM_KEY_3K3DES = 0x18, SAM_KEY_AES = 0x20 } SAMKeyType;
34
36{
37 unsigned char keyVa;
38 unsigned char keyVb;
39 unsigned char keyVc;
40 unsigned char df_aid_keyno;
41 unsigned char key_no_v_cek;
42 unsigned char refkeykuc;
43 unsigned char updateset;
46
47typedef struct s_changeKeyInfo
48{
49 unsigned char desfireNumber;
50 unsigned char isMasterKey;
51 unsigned char oldKeyInvolvement;
52 unsigned char currentKeySlotNo;
53 unsigned char currentKeySlotV;
54 unsigned char newKeySlotNo;
55 unsigned char newKeySlotV;
57
59
61{
63 unsigned char *divInput;
64 unsigned char divInputSize;
65 unsigned char diversifyCurrent;
66 unsigned char diversifyNew;
68
72class LLA_CARDS_SAMAV_API SAMBasicKeyEntry
73{
74 public:
78 virtual ~SAMBasicKeyEntry();
79
84 size_t getLength() const;
85
90 std::vector<ByteVector> getKeysData() const;
91
95 virtual void setKeysData(std::vector<ByteVector> keys, SAMKeyType type);
96
101 unsigned char *getData() const
102 {
103 return d_key;
104 }
105
110 void setDiversify(bool diversify)
111 {
112 d_diversify = diversify;
113 }
114
119 bool getDiversify() const
120 {
121 return d_diversify;
122 }
123
128 void setKeyType(SAMKeyType keyType)
129 {
130 d_keyType = keyType;
131 } // TODO DELETE IT
132
138 {
139 return d_keyType;
140 } // TODO DELETE IT
141
146 virtual void serialize(boost::property_tree::ptree &parentNode);
147
152 virtual void unSerialize(boost::property_tree::ptree &node);
153
158 virtual std::string getDefaultXmlNodeName() const;
159
165 virtual bool operator==(const SAMBasicKeyEntry &key) const;
166
172 bool operator!=(const SAMBasicKeyEntry &key) const
173 {
174 return !operator==(key);
175 }
176
181 static std::string SAMKeyEntryTypeStr(SAMKeyType t);
182
183 size_t getSingleLength() const;
184
185 unsigned char getUpdateMask() const
186 {
187 return d_updatemask;
188 }
189 void setUpdateMask(unsigned char c)
190 {
191 d_updatemask = c;
192 }
193
194 KeyEntryUpdateSettings getUpdateSettings();
195 void setUpdateSettings(const KeyEntryUpdateSettings &t);
196
197 protected:
199
201
202 SAMBasicKeyEntry(const std::string &str, const std::string &str1,
203 const std::string &str2);
204
205 SAMBasicKeyEntry(const void **buf, size_t buflen, char numberkey);
206
210 unsigned char *d_key;
211
216
220 SAMKeyType d_keyType; // TODO DELETE IT
221
222 unsigned char d_updatemask;
223};
224}
225
226#endif /* LOGICALACCESS_SAMBASICKEYENTRY_HPP */
A SAMBasicKeyEntry Key class.
Definition: sambasickeyentry.hpp:73
void setUpdateMask(unsigned char c)
Definition: sambasickeyentry.hpp:189
unsigned char * getData() const
Get the key data.
Definition: sambasickeyentry.hpp:101
SAMKeyType d_keyType
The SAM key type.
Definition: sambasickeyentry.hpp:220
unsigned char getUpdateMask() const
Definition: sambasickeyentry.hpp:185
SAMKeyType getKeyType() const
Get the key type.
Definition: sambasickeyentry.hpp:137
bool d_diversify
Diversify the key on the card.
Definition: sambasickeyentry.hpp:215
bool getDiversify() const
Get if the key is diversified on the card.
Definition: sambasickeyentry.hpp:119
unsigned char d_updatemask
Definition: sambasickeyentry.hpp:222
unsigned char * d_key
The key bytes;.
Definition: sambasickeyentry.hpp:210
void setDiversify(bool diversify)
Set if the key is diversified on the card.
Definition: sambasickeyentry.hpp:110
void setKeyType(SAMKeyType keyType)
Set the key type.
Definition: sambasickeyentry.hpp:128
bool operator!=(const SAMBasicKeyEntry &key) const
Inequality operator.
Definition: sambasickeyentry.hpp:172
Definition: asn1.hpp:9
SAMKeyType
The SAM key type.
Definition: sambasickeyentry.hpp:33
@ SAM_KEY_AES
Definition: sambasickeyentry.hpp:33
@ SAM_KEY_DES
Definition: sambasickeyentry.hpp:33
@ SAM_KEY_3K3DES
Definition: sambasickeyentry.hpp:33
struct logicalaccess::s_KeyEntryUpdateSettings KeyEntryUpdateSettings
struct logicalaccess::s_changeKeyDiversification ChangeKeyDiversification
struct logicalaccess::s_changeKeyInfo ChangeKeyInfo
NXPKeyDiversificationType
Definition: sambasickeyentry.hpp:58
@ SAMAV1
Definition: sambasickeyentry.hpp:58
@ NO_DIV
Definition: sambasickeyentry.hpp:58
@ SAMAV2
Definition: sambasickeyentry.hpp:58
Definition: sambasickeyentry.hpp:36
unsigned char refkeykuc
Definition: sambasickeyentry.hpp:42
unsigned char key_no_v_cek
Definition: sambasickeyentry.hpp:41
unsigned char keyVb
Definition: sambasickeyentry.hpp:38
unsigned char updateset
Definition: sambasickeyentry.hpp:43
unsigned char keyversionsentseparatly
Definition: sambasickeyentry.hpp:44
unsigned char keyVc
Definition: sambasickeyentry.hpp:39
unsigned char keyVa
Definition: sambasickeyentry.hpp:37
unsigned char df_aid_keyno
Definition: sambasickeyentry.hpp:40
Definition: sambasickeyentry.hpp:61
unsigned char * divInput
Definition: sambasickeyentry.hpp:63
NXPKeyDiversificationType divType
Definition: sambasickeyentry.hpp:62
unsigned char diversifyNew
Definition: sambasickeyentry.hpp:66
unsigned char diversifyCurrent
Definition: sambasickeyentry.hpp:65
unsigned char divInputSize
Definition: sambasickeyentry.hpp:64
Definition: sambasickeyentry.hpp:48
unsigned char newKeySlotV
Definition: sambasickeyentry.hpp:55
unsigned char oldKeyInvolvement
Definition: sambasickeyentry.hpp:51
unsigned char newKeySlotNo
Definition: sambasickeyentry.hpp:54
unsigned char desfireNumber
Definition: sambasickeyentry.hpp:49
unsigned char currentKeySlotV
Definition: sambasickeyentry.hpp:53
unsigned char currentKeySlotNo
Definition: sambasickeyentry.hpp:52
unsigned char isMasterKey
Definition: sambasickeyentry.hpp:50