LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
samcommands.hpp
Go to the documentation of this file.
1
7#ifndef LOGICALACCESS_SAMCOMMANDS_HPP
8#define LOGICALACCESS_SAMCOMMANDS_HPP
9
14
15namespace logicalaccess
16{
17#define CMD_SAM "SAM"
18
20{
21 unsigned char uniqueserialnumber[7];
22 unsigned char productionbatchnumber[5];
23 unsigned char dayofproduction;
24 unsigned char monthofproduction;
25 unsigned char yearofproduction;
26 unsigned char globalcryptosettings;
27 unsigned char modecompatibility;
29
31{
32 unsigned char vendorid;
33 unsigned char type;
34 unsigned char subtype;
35 unsigned char majorversion;
36 unsigned char minorversion;
37 unsigned char storagesize;
38 unsigned char protocoltype;
40
41typedef struct s_SAMVersion
42{
47
49{
50 Unlock = 0x00,
53 SwitchAV2Mode = 0x03
54};
55
56class DESFireKey;
57
58// todo: We removed export macro to fix link issue. need to investigate more.
59template <typename T, typename S>
60class SAMCommands : public Commands
61{
62 public:
65 {
66 }
67 explicit SAMCommands(std::string ct)
68 : Commands(ct)
69 {
70 }
71 virtual SAMVersion getVersion() = 0;
72 virtual std::shared_ptr<SAMKeyEntry<T, S>> getKeyEntry(unsigned char keyno) = 0;
73 virtual std::shared_ptr<SAMKucEntry> getKUCEntry(unsigned char keyno) = 0;
74 virtual void changeKeyEntry(unsigned char keyno,
75 std::shared_ptr<SAMKeyEntry<T, S>> keyentry,
76 std::shared_ptr<DESFireKey> key) = 0;
77 virtual void changeKUCEntry(unsigned char keyno,
78 std::shared_ptr<SAMKucEntry> keyentry,
79 std::shared_ptr<DESFireKey> key) = 0;
80 virtual void authenticateHost(std::shared_ptr<DESFireKey> key,
81 unsigned char keyno) = 0;
82 virtual std::string getSAMTypeFromSAM() = 0;
83 virtual void disableKeyEntry(unsigned char keyno) = 0;
84 virtual void selectApplication(ByteVector aid) = 0;
86 virtual void loadInitVector(ByteVector iv) = 0;
87 virtual ByteVector decipherData(ByteVector data, bool islastdata) = 0;
88 virtual ByteVector encipherData(ByteVector data, bool islastdata) = 0;
90 const ChangeKeyDiversification &diversifycation) = 0;
91 virtual void lockUnlock(std::shared_ptr<DESFireKey> masterKey, SAMLockUnlock state,
92 unsigned char keyno, unsigned char unlockkeyno,
93 unsigned char unlockkeyversion) = 0;
94 virtual ByteVector transmit(ByteVector cmd, bool first = true, bool last = true) = 0;
95};
96}
97
98#endif /* LOGICALACCESS_SAMCOMMANDS_HPP */
The base commands class for all card commands.
Definition: commands.hpp:21
Definition: samcommands.hpp:61
virtual void selectApplication(ByteVector aid)=0
virtual ByteVector encipherData(ByteVector data, bool islastdata)=0
virtual void loadInitVector(ByteVector iv)=0
virtual void changeKeyEntry(unsigned char keyno, std::shared_ptr< SAMKeyEntry< T, S > > keyentry, std::shared_ptr< DESFireKey > key)=0
virtual std::string getSAMTypeFromSAM()=0
virtual ByteVector dumpSessionKey()=0
virtual void disableKeyEntry(unsigned char keyno)=0
virtual void changeKUCEntry(unsigned char keyno, std::shared_ptr< SAMKucEntry > keyentry, std::shared_ptr< DESFireKey > key)=0
virtual std::shared_ptr< SAMKeyEntry< T, S > > getKeyEntry(unsigned char keyno)=0
SAMCommands()
Definition: samcommands.hpp:63
SAMCommands(std::string ct)
Definition: samcommands.hpp:67
virtual ByteVector transmit(ByteVector cmd, bool first=true, bool last=true)=0
virtual ByteVector decipherData(ByteVector data, bool islastdata)=0
virtual SAMVersion getVersion()=0
virtual void authenticateHost(std::shared_ptr< DESFireKey > key, unsigned char keyno)=0
virtual std::shared_ptr< SAMKucEntry > getKUCEntry(unsigned char keyno)=0
virtual void lockUnlock(std::shared_ptr< DESFireKey > masterKey, SAMLockUnlock state, unsigned char keyno, unsigned char unlockkeyno, unsigned char unlockkeyversion)=0
virtual ByteVector changeKeyPICC(const ChangeKeyInfo &info, const ChangeKeyDiversification &diversifycation)=0
A SAMKeyEntry class.
Definition: samkeyentry.hpp:90
Commands.
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Location.
Definition: asn1.hpp:9
struct logicalaccess::s_SAMVersionInformation SAMVersionInformation
struct logicalaccess::s_SAMManufactureInformation SAMManufactureInformation
SAMLockUnlock
Definition: samcommands.hpp:49
@ Unlock
Definition: samcommands.hpp:50
@ LockWithoutSpecifyingKey
Definition: samcommands.hpp:51
@ SwitchAV2Mode
Definition: samcommands.hpp:53
@ LockWithSpecifyingKey
Definition: samcommands.hpp:52
struct logicalaccess::s_SAMVersion SAMVersion
#define CMD_SAM
Definition: samcommands.hpp:17
SAMKeyEntry source.
SAM KUC Entry.
Definition: samcommands.hpp:20
unsigned char dayofproduction
Definition: samcommands.hpp:23
unsigned char monthofproduction
Definition: samcommands.hpp:24
unsigned char uniqueserialnumber[7]
Definition: samcommands.hpp:21
unsigned char modecompatibility
Definition: samcommands.hpp:27
unsigned char globalcryptosettings
Definition: samcommands.hpp:26
unsigned char yearofproduction
Definition: samcommands.hpp:25
unsigned char productionbatchnumber[5]
Definition: samcommands.hpp:22
Definition: samcommands.hpp:31
unsigned char protocoltype
Definition: samcommands.hpp:38
unsigned char storagesize
Definition: samcommands.hpp:37
unsigned char type
Definition: samcommands.hpp:33
unsigned char subtype
Definition: samcommands.hpp:34
unsigned char majorversion
Definition: samcommands.hpp:35
unsigned char minorversion
Definition: samcommands.hpp:36
unsigned char vendorid
Definition: samcommands.hpp:32
Definition: samcommands.hpp:42
SAMVersionInformation software
Definition: samcommands.hpp:44
SAMManufactureInformation manufacture
Definition: samcommands.hpp:45
SAMVersionInformation hardware
Definition: samcommands.hpp:43
Definition: sambasickeyentry.hpp:61
Definition: sambasickeyentry.hpp:48