mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-27 10:21:40 +00:00
wire in OEM.proto keystore
This commit is contained in:
parent
1b6395b4e4
commit
7c8c479b96
@ -84,10 +84,6 @@ static char ourId[5];
|
|||||||
// GeoCoord object for the screen
|
// GeoCoord object for the screen
|
||||||
GeoCoord geoCoord;
|
GeoCoord geoCoord;
|
||||||
|
|
||||||
// OEM Config File
|
|
||||||
static const char *oemConfigFile = "/oem/oem.proto";
|
|
||||||
OEMStore oemStore;
|
|
||||||
|
|
||||||
#ifdef SHOW_REDRAWS
|
#ifdef SHOW_REDRAWS
|
||||||
static bool heartbeat = false;
|
static bool heartbeat = false;
|
||||||
#endif
|
#endif
|
||||||
@ -928,9 +924,6 @@ void Screen::setup()
|
|||||||
dispdev.setDetected(screen_model);
|
dispdev.setDetected(screen_model);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Load OEM config from Proto file if existent
|
|
||||||
loadProto(oemConfigFile, OEMStore_size, sizeof(oemConfigFile), OEMStore_fields, &oemStore);
|
|
||||||
|
|
||||||
// Initialising the UI will init the display too.
|
// Initialising the UI will init the display too.
|
||||||
ui.init();
|
ui.init();
|
||||||
|
|
||||||
|
@ -62,13 +62,6 @@ Channel &Channels::fixupChannel(ChannelIndex chIndex)
|
|||||||
// Convert the old string "Default" to our new short representation
|
// Convert the old string "Default" to our new short representation
|
||||||
if (strcmp(channelSettings.name, "Default") == 0)
|
if (strcmp(channelSettings.name, "Default") == 0)
|
||||||
*channelSettings.name = '\0';
|
*channelSettings.name = '\0';
|
||||||
|
|
||||||
/* Convert any old usage of the defaultpsk into our new short representation.
|
|
||||||
if (channelSettings.psk.size == sizeof(defaultpsk) &&
|
|
||||||
memcmp(channelSettings.psk.bytes, defaultpsk, sizeof(defaultpsk)) == 0) {
|
|
||||||
*channelSettings.psk.bytes = 1;
|
|
||||||
channelSettings.psk.size = 1;
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hashes[chIndex] = generateHash(chIndex);
|
hashes[chIndex] = generateHash(chIndex);
|
||||||
@ -124,7 +117,22 @@ CryptoKey Channels::getKey(ChannelIndex chIndex)
|
|||||||
DEBUG_MSG("Expanding short PSK #%d\n", pskIndex);
|
DEBUG_MSG("Expanding short PSK #%d\n", pskIndex);
|
||||||
if (pskIndex == 0)
|
if (pskIndex == 0)
|
||||||
k.length = 0; // Turn off encryption
|
k.length = 0; // Turn off encryption
|
||||||
else {
|
else if (oemStore.oem_aes_key.size > 1) {
|
||||||
|
// Use the OEM key
|
||||||
|
DEBUG_MSG("Using OEM Key with %d bytes\n", oemStore.oem_aes_key.size);
|
||||||
|
memcpy(k.bytes, oemStore.oem_aes_key.bytes , oemStore.oem_aes_key.size);
|
||||||
|
k.length = oemStore.oem_aes_key.size;
|
||||||
|
// Bump up the last byte of PSK as needed
|
||||||
|
uint8_t *last = k.bytes + oemStore.oem_aes_key.size - 1;
|
||||||
|
*last = *last + pskIndex - 1; // index of 1 means no change vs defaultPSK
|
||||||
|
if (k.length < 16) {
|
||||||
|
DEBUG_MSG("Warning: OEM provided a too short AES128 key - padding\n");
|
||||||
|
k.length = 16;
|
||||||
|
} else if (k.length < 32 && k.length != 16) {
|
||||||
|
DEBUG_MSG("Warning: OEM provided a too short AES256 key - padding\n");
|
||||||
|
k.length = 32;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
memcpy(k.bytes, defaultpsk, sizeof(defaultpsk));
|
memcpy(k.bytes, defaultpsk, sizeof(defaultpsk));
|
||||||
k.length = sizeof(defaultpsk);
|
k.length = sizeof(defaultpsk);
|
||||||
// Bump up the last byte of PSK as needed
|
// Bump up the last byte of PSK as needed
|
||||||
|
@ -38,6 +38,7 @@ MyNodeInfo &myNodeInfo = devicestate.my_node;
|
|||||||
LocalConfig config;
|
LocalConfig config;
|
||||||
LocalModuleConfig moduleConfig;
|
LocalModuleConfig moduleConfig;
|
||||||
ChannelFile channelFile;
|
ChannelFile channelFile;
|
||||||
|
OEMStore oemStore;
|
||||||
|
|
||||||
/** The current change # for radio settings. Starts at 0 on boot and any time the radio settings
|
/** The current change # for radio settings. Starts at 0 on boot and any time the radio settings
|
||||||
* might have changed is incremented. Allows others to detect they might now be on a new channel.
|
* might have changed is incremented. Allows others to detect they might now be on a new channel.
|
||||||
@ -354,6 +355,8 @@ static const char *prefFileName = "/prefs/db.proto";
|
|||||||
static const char *configFileName = "/prefs/config.proto";
|
static const char *configFileName = "/prefs/config.proto";
|
||||||
static const char *moduleConfigFileName = "/prefs/module.proto";
|
static const char *moduleConfigFileName = "/prefs/module.proto";
|
||||||
static const char *channelFileName = "/prefs/channels.proto";
|
static const char *channelFileName = "/prefs/channels.proto";
|
||||||
|
static const char *oemConfigFile = "/oem/oem.proto";
|
||||||
|
|
||||||
|
|
||||||
/** Load a protobuf from a file, return true for success */
|
/** Load a protobuf from a file, return true for success */
|
||||||
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
||||||
@ -433,6 +436,9 @@ void NodeDB::loadFromDisk()
|
|||||||
DEBUG_MSG("Loaded saved channelFile version %d\n", channelFile.version);
|
DEBUG_MSG("Loaded saved channelFile version %d\n", channelFile.version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loadProto(oemConfigFile, OEMStore_size, sizeof(OEMStore), OEMStore_fields, &oemStore))
|
||||||
|
DEBUG_MSG("Loaded OEMStore\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Save a protobuf from a file, return true for success */
|
/** Save a protobuf from a file, return true for success */
|
||||||
|
@ -26,6 +26,7 @@ extern ChannelFile channelFile;
|
|||||||
extern MyNodeInfo &myNodeInfo;
|
extern MyNodeInfo &myNodeInfo;
|
||||||
extern LocalConfig config;
|
extern LocalConfig config;
|
||||||
extern LocalModuleConfig moduleConfig;
|
extern LocalModuleConfig moduleConfig;
|
||||||
|
extern OEMStore oemStore;
|
||||||
extern User &owner;
|
extern User &owner;
|
||||||
|
|
||||||
/// Given a node, return how many seconds in the past (vs now) that we last heard from it
|
/// Given a node, return how many seconds in the past (vs now) that we last heard from it
|
||||||
|
Loading…
Reference in New Issue
Block a user