Compare commits

..

3 Commits

Author SHA1 Message Date
Christoph Hagen
6256b6ef33 Improve crypto primitives 2024-02-10 11:32:16 +01:00
Christoph Hagen
bd5a8d52cc Public inheritance for esp sources 2024-02-10 11:31:10 +01:00
Christoph Hagen
be274132d6 Extract configurations to separate files 2024-02-10 11:30:52 +01:00
6 changed files with 66 additions and 42 deletions

View File

@ -0,0 +1,31 @@
#pragma once
#include <stdint.h>
struct EthernetConfiguration {
// The MAC address of the ethernet connection
uint8_t macAddress[6];
// The master-in slave-out pin of the SPI connection for the Ethernet module
int8_t spiPinMiso;
// The master-out slave-in pin of the SPI connection for the Ethernet module
int8_t spiPinMosi;
// The slave clock pin of the SPI connection for the Ethernet module
int8_t spiPinSclk;
// The slave-select pin of the SPI connection for the Ethernet module
int8_t spiPinSS;
unsigned long dhcpLeaseTimeoutMs;
unsigned long dhcpLeaseResponseTimeoutMs;
// The static IP address to assign if DHCP fails
uint8_t manualIp[4];
// The IP address of the DNS server, if DHCP fails
uint8_t manualDnsAddress[4];
};

View File

@ -0,0 +1,12 @@
#pragma once
#include <stdint.h>
struct KeyConfiguration {
const uint8_t* remoteKey;
const uint8_t* localKey;
uint32_t challengeExpiryMs;
};

View File

@ -4,43 +4,8 @@
#include "servo.h"
#include "message.h"
#include <ESPAsyncWebServer.h>
struct EthernetConfiguration {
// The MAC address of the ethernet connection
uint8_t macAddress[6];
// The master-in slave-out pin of the SPI connection for the Ethernet module
int8_t spiPinMiso;
// The master-out slave-in pin of the SPI connection for the Ethernet module
int8_t spiPinMosi;
// The slave clock pin of the SPI connection for the Ethernet module
int8_t spiPinSclk;
// The slave-select pin of the SPI connection for the Ethernet module
int8_t spiPinSS;
unsigned long dhcpLeaseTimeoutMs;
unsigned long dhcpLeaseResponseTimeoutMs;
// The static IP address to assign if DHCP fails
uint8_t manualIp[4];
// The IP address of the DNS server, if DHCP fails
uint8_t manualDnsAddress[4];
};
struct KeyConfiguration {
const uint8_t* remoteKey;
const uint8_t* localKey;
uint32_t challengeExpiryMs;
};
#include "configurations/EthernetConfiguration.h"
#include "configurations/KeyConfiguration.h"
class SesameController: public ServerConnectionCallbacks {

View File

@ -3,7 +3,7 @@
#include "relay/interface/CryptoSource.h"
#include "ESP32NoiseSource.h"
class ESP32CryptoSource: CryptoSource {
class ESP32CryptoSource: public CryptoSource {
public:

View File

@ -1,7 +1,7 @@
#include "relay/interface/StorageSource.h"
class ESP32StorageSource: StorageSource {
class ESP32StorageSource: public StorageSource {
bool writeByteAtIndex(uint8_t byte, uint16_t index) override;

View File

@ -10,10 +10,18 @@
struct PrivateKey {
/// @brief The size of a private key
static const int size = 32;
static constexpr int size = 32;
uint8_t bytes[size];
bool isUnset() {
for (uint8_t i = 0; i < size; i += 1) {
if (bytes[i] != 0) {
return false;
}
}
return true;
}
};
/**
@ -22,10 +30,18 @@ struct PrivateKey {
struct PublicKey {
/// @brief The size of a public key
static const int size = 32;
static constexpr int size = 32;
uint8_t bytes[size];
bool isUnset() {
for (uint8_t i = 0; i < size; i += 1) {
if (bytes[i] != 0) {
return false;
}
}
return true;
}
};
/**
@ -34,7 +50,7 @@ struct PublicKey {
struct Signature {
/// @brief The size of a message signature
static const int size = 64;
static constexpr int size = 64;
uint8_t bytes[size];