11 #ifndef _REMOTE_AUTHENTICATION_H_
12 #define _REMOTE_AUTHENTICATION_H_
14 #include <EepromAbstraction.h>
17 #ifndef MAX_PIN_LENGTH
18 #define MAX_PIN_LENGTH 16
21 #ifndef CLIENT_DESC_SIZE
22 #define CLIENT_DESC_SIZE 16
25 #define UUID_KEY_SIZE 40
26 #define TOTAL_KEY_SIZE (UUID_KEY_SIZE + CLIENT_DESC_SIZE)
28 enum AuthenticationManagerType: uint8_t {
29 AUTHENTICATION_NONE, AUTHENTICATION_IN_EEPROM, AUTHENTICATION_IN_FLASH
40 AuthenticationManagerType authenticationManagerType;
42 explicit AuthenticationManager(AuthenticationManagerType authType) : authenticationManagerType(authType) {}
67 virtual bool isAuthenticated(
const char* connectionName,
const char* authResponse)=0;
85 EepromAbstraction *eeprom;
86 EepromPosition romStart;
88 uint8_t numberOfEntries;
94 this->numberOfEntries = numOfEntries;
105 void initialise(EepromAbstraction* eeprom, EepromPosition start, uint16_t magicKey = 0x9B32);
147 bool isAuthenticated(
const char* connectionName,
const char* authResponse)
override;
155 return numberOfEntries;
159 int findSlotFor(
const char* name);
162 EepromPosition eepromOffset(
int i)
const {
163 return romStart + 2 + (i * TOTAL_KEY_SIZE);
190 char name[CLIENT_DESC_SIZE];
191 char uuid[UUID_KEY_SIZE];
202 const char* pgmActualPin;
211 this->authBlocksPgm = authBlocksPgm;
212 this->numberOfEntries = numberOfEntries;
213 this->pgmActualPin = pgmActualPin;
217 this->authBlocksPgm =
nullptr;
218 this->numberOfEntries = 0;
219 this->pgmActualPin = pgmActualPin;
230 bool isAuthenticated(
const char* connectionName,
const char* authResponse)
override;
233 return strcmp_P(pgmActualPin, pinAttempt) == 0;
Definition: RemoteAuthentication.h:189
Definition: RemoteAuthentication.h:38
virtual bool isAuthenticated(const char *connectionName, const char *authResponse)=0
virtual bool doesPinMatch(const char *pinAttempt)=0
AuthenticationManagerType getAuthenticationManagerType()
Definition: RemoteAuthentication.h:48
virtual bool addAdditionalUUIDKey(const char *connectionName, const char *uuid)=0
Definition: RemoteAuthentication.h:83
bool addAdditionalUUIDKey(const char *connectionName, const char *uuid) override
Definition: RemoteAuthentication.cpp:19
void copyKeyNameToBuffer(int idx, char *buffer, int bufSize)
Definition: RemoteAuthentication.cpp:72
void initialise(EepromAbstraction *eeprom, EepromPosition start, uint16_t magicKey=0x9B32)
Definition: RemoteAuthentication.cpp:9
void copyPinToBuffer(char *buffer, int size)
Definition: RemoteAuthentication.cpp:124
bool isAuthenticated(const char *connectionName, const char *authResponse) override
Definition: RemoteAuthentication.cpp:49
bool doesPinMatch(const char *pinAttempt) override
Definition: RemoteAuthentication.cpp:117
void resetAllKeys()
Definition: RemoteAuthentication.cpp:83
int getNumberOfEntries() const
Definition: RemoteAuthentication.h:154
void changePin(const char *newPin)
Definition: RemoteAuthentication.cpp:129
Definition: RemoteAuthentication.h:171
bool addAdditionalUUIDKey(const char *, const char *) override
Definition: RemoteAuthentication.h:176
bool doesPinMatch(const char *) override
Definition: RemoteAuthentication.h:182
bool isAuthenticated(const char *, const char *) override
Definition: RemoteAuthentication.h:179
Definition: RemoteAuthentication.h:198
bool addAdditionalUUIDKey(const char *, const char *) override
Definition: RemoteAuthentication.h:223
bool isAuthenticated(const char *connectionName, const char *authResponse) override
Definition: RemoteAuthentication.cpp:133
ReadOnlyAuthenticationManager(const AuthBlock *authBlocksPgm, int numberOfEntries, const char *pgmActualPin)
Definition: RemoteAuthentication.h:209
bool doesPinMatch(const char *pinAttempt) override
Definition: RemoteAuthentication.h:232
A series of utilities that used throughout tcMenu.