This repository has been archived on 2024-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
zamek-hswro/Key.h

49 lines
858 B
C
Raw Normal View History

2017-12-17 11:31:13 +00:00
#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