Add device id to support multiple remotes
This commit is contained in:
@ -12,6 +12,9 @@ constexpr uint32_t serialBaudRate = 115200;
|
||||
|
||||
/* Keys */
|
||||
|
||||
// The number of remote devices
|
||||
constexpr int remoteDeviceCount = 1;
|
||||
|
||||
// The size of the symmetric keys used for signing and verifying messages
|
||||
constexpr size_t keySize = 32;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* @brief The size of the message counter in bytes (uint32_t)
|
||||
@ -72,13 +73,15 @@ void prepareMessageCounterUsage();
|
||||
*
|
||||
* @return The next counter to use by the remote
|
||||
*/
|
||||
uint32_t getNextMessageCounter();
|
||||
uint32_t getNextMessageCounter(uint8_t deviceId);
|
||||
|
||||
/**
|
||||
* @brief Print info about the current message counter to the serial output
|
||||
*
|
||||
*/
|
||||
void printMessageCounter();
|
||||
void printMessageCounters();
|
||||
|
||||
bool isDeviceIdValid(uint8_t deviceId);
|
||||
|
||||
/**
|
||||
* @brief Check if a received counter is valid
|
||||
@ -90,7 +93,7 @@ void printMessageCounter();
|
||||
* @return true The counter is valid
|
||||
* @return false The counter belongs to an old message
|
||||
*/
|
||||
bool isMessageCounterValid(uint32_t counter);
|
||||
bool isMessageCounterValid(uint32_t counter, uint8_t deviceId);
|
||||
|
||||
/**
|
||||
* @brief Mark a counter of a message as used.
|
||||
@ -101,7 +104,7 @@ bool isMessageCounterValid(uint32_t counter);
|
||||
*
|
||||
* @param counter The counter used in the last message.
|
||||
*/
|
||||
void didUseMessageCounter(uint32_t counter);
|
||||
void didUseMessageCounter(uint32_t counter, uint8_t deviceId);
|
||||
|
||||
/**
|
||||
* @brief Reset the message counter.
|
||||
@ -111,4 +114,4 @@ void didUseMessageCounter(uint32_t counter);
|
||||
* used for replay attacks.
|
||||
*
|
||||
*/
|
||||
void resetMessageCounter();
|
||||
void resetMessageCounters();
|
||||
|
@ -45,6 +45,11 @@ typedef struct {
|
||||
*/
|
||||
uint32_t id;
|
||||
|
||||
/**
|
||||
* @brief The id of the device sending the message
|
||||
*/
|
||||
uint8_t device;
|
||||
|
||||
} Message;
|
||||
|
||||
/**
|
||||
@ -97,6 +102,7 @@ enum class SesameEvent {
|
||||
MessageTimeMismatch = 5,
|
||||
MessageCounterInvalid = 6,
|
||||
MessageAccepted = 7,
|
||||
MessageDeviceInvalid = 8,
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user