-
-
Notifications
You must be signed in to change notification settings - Fork 823
Support working with ed25519 seeds in addition to raw keypairs. #1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -535,6 +535,17 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep | |
| } else { | ||
| strcpy(reply, "Error, bad key"); | ||
| } | ||
| } else if (memcmp(config, "prv.seed ", 9) == 0) { | ||
| uint8_t seed[SEED_SIZE]; | ||
| bool success = mesh::Utils::fromHex(seed, SEED_SIZE, &config[9]); | ||
| if (success) { | ||
| mesh::LocalIdentity new_id; | ||
| new_id.readFrom(seed, SEED_SIZE); | ||
| _callbacks->saveIdentity(new_id); | ||
| strcpy(reply, "OK"); | ||
| } else { | ||
| strcpy(reply, "Error, invalid seed"); | ||
| } | ||
| } else if (memcmp(config, "name ", 5) == 0) { | ||
| if (isValidName(&config[5])) { | ||
| StrHelper::strncpy(_prefs->node_name, &config[5], sizeof(_prefs->node_name)); | ||
|
|
@@ -758,9 +769,14 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep | |
| sprintf(reply, "> %s", _prefs->guest_password); | ||
| } else if (sender_timestamp == 0 && memcmp(config, "prv.key", 7) == 0) { // from serial command line only | ||
| uint8_t prv_key[PRV_KEY_SIZE]; | ||
| int len = _callbacks->getSelfId().writeTo(prv_key, PRV_KEY_SIZE); | ||
| auto len = _callbacks->getSelfId().writePrvkeyTo(prv_key, PRV_KEY_SIZE); | ||
| mesh::Utils::toHex(tmp, prv_key, len); | ||
| sprintf(reply, "> %s", tmp); | ||
| } else if (sender_timestamp == 0 && memcmp(config, "prv.seed", 8) == 0) { // from serial command line only | ||
| uint8_t seed[SEED_SIZE]; | ||
| auto len = _callbacks->getSelfId().writeSeedTo(seed, SEED_SIZE); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for devices that update firmware, but keep their existing identity, I'd assume this will just provide an output of full zeros. Probably fine, as you could check for full zeros to know there's no seed available. But wondering if it should return an error message instead...
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming you mean here devices that were seeded before this code: yes, LocalIdentity::readFrom() zeroes the seed and then attempts to read over it if the seed is in the identity store, so if the identity were stored from an older revision it'll stay zeroed and this will output a zero string. I suppose returning an error would be more helpful but we should have something in the docs to say more than the firmware itself can. |
||
| mesh::Utils::toHex(tmp, seed, len); | ||
| sprintf(reply, "> %s", tmp); | ||
| } else if (memcmp(config, "name", 4) == 0) { | ||
| sprintf(reply, "> %s", _prefs->node_name); | ||
| } else if (memcmp(config, "repeat", 6) == 0) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's no length validation for the provided seed, is there any issue with providing a seed that's too short or too long? I guess the remainder would just be all zeros...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Utils::fromHex() does a check that
strlen(src_hex)==dest_size*2, so it should give an error with a seed that's too short or too long (I'd test but I'm across an ocean from my nearest spare repeater until the weekend.)