Skip to content

Commit 9498d2e

Browse files
author
Scott Powell
committed
* ID hash 0x00 and 0xFF now reserved for future.
1 parent 86a3f59 commit 9498d2e

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

examples/companion_radio/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ class MyMesh : public BaseChatMesh {
228228
void loadMainIdentity() {
229229
if (!_identity_store->load("_main", self_id)) {
230230
self_id = radio_new_identity(); // create new random identity
231+
int count = 0;
232+
while (count < 10 && (self_id.pub_key[0] == 0x00 || self_id.pub_key[0] == 0xFF)) { // reserved id hashes
233+
self_id = radio_new_identity(); count++;
234+
}
231235
saveMainIdentity(self_id);
232236
}
233237
}

examples/simple_repeater/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,10 @@ void setup() {
643643
if (!store.load("_main", the_mesh.self_id)) {
644644
MESH_DEBUG_PRINTLN("Generating new keypair");
645645
the_mesh.self_id = radio_new_identity(); // create new random identity
646+
int count = 0;
647+
while (count < 10 && (the_mesh.self_id.pub_key[0] == 0x00 || the_mesh.self_id.pub_key[0] == 0xFF)) { // reserved id hashes
648+
the_mesh.self_id = radio_new_identity(); count++;
649+
}
646650
store.save("_main", the_mesh.self_id);
647651
}
648652

examples/simple_room_server/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,10 @@ void setup() {
872872
#endif
873873
if (!store.load("_main", the_mesh.self_id)) {
874874
the_mesh.self_id = radio_new_identity(); // create new random identity
875+
int count = 0;
876+
while (count < 10 && (the_mesh.self_id.pub_key[0] == 0x00 || the_mesh.self_id.pub_key[0] == 0xFF)) { // reserved id hashes
877+
the_mesh.self_id = radio_new_identity(); count++;
878+
}
875879
store.save("_main", the_mesh.self_id);
876880
}
877881

examples/simple_secure_chat/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ class MyMesh : public BaseChatMesh, ContactVisitor {
300300
((StdRNG *)getRNG())->begin(millis());
301301

302302
self_id = mesh::LocalIdentity(getRNG()); // create new random identity
303+
int count = 0;
304+
while (count < 10 && (self_id.pub_key[0] == 0x00 || self_id.pub_key[0] == 0xFF)) { // reserved id hashes
305+
self_id = mesh::LocalIdentity(getRNG()); count++;
306+
}
303307
store.save("_main", self_id);
304308
}
305309

0 commit comments

Comments
 (0)