-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKey.h
48 lines (37 loc) · 858 Bytes
/
Key.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef KEY_H
#define KEY_H
#include <stddef.h>
#include <stdint.h>
class Key {
public:
enum {
MAX_KEY_SIZE = 8
};
enum class KeyType
{
Invalid = 0,
MifareClassic = 1,
iButton = 2,
};
Key();
bool isValid() const;
bool operator==(const Key& rhs) const;
protected:
Key(KeyType type, size_t size, const void* data);
private:
bool isBufferEqual(const unsigned char *lhs, const unsigned char* rhs, size_t size) const;
KeyType type;
size_t size;
unsigned char value[MAX_KEY_SIZE];
};
class DallasIButtonKey: public Key {
public:
enum {UID_SIZE = 8};
explicit DallasIButtonKey(const uint8_t uid[UID_SIZE]);
};
class MifareClassicKey: public Key {
public:
enum {NUID_SIZE = 4};
explicit MifareClassicKey(const uint8_t nuid[NUID_SIZE]);
};
#endif // KEY_H