-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[hf seos] Make keyslot configurable #3044
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: master
Are you sure you want to change the base?
Conversation
Replaces unused `nonce` value
|
You are welcome to add an entry to the CHANGELOG.md as well |
| PrintAndLogEx(INFO, "idx| key"); | ||
| PrintAndLogEx(INFO, "---+------------------------"); | ||
| PrintAndLogEx(INFO, "idx|slot| key"); | ||
| PrintAndLogEx(INFO, "---+----+------------------------"); | ||
| for (uint8_t i = 0; i < ARRAYLEN(keys); i++) { | ||
| if (memcmp(keys[i].privEncKey, zeros, sizeof(zeros)) == 0) | ||
| PrintAndLogEx(INFO, " %u |", i); | ||
| PrintAndLogEx(INFO, " %u | |", i); | ||
| else | ||
| PrintAndLogEx(INFO, " %u | " _YELLOW_("%s"), i, sprint_hex(keys[i].nonce, 8)); | ||
| PrintAndLogEx(INFO, " %u | " _YELLOW_("% 2u") " | " _YELLOW_("%s"), i, keys[i].keyslot, sprint_hex(keys[i].readKey, 8)); | ||
| } | ||
| PrintAndLogEx(INFO, "---+------------------------"); | ||
| PrintAndLogEx(INFO, "---+----+------------------------"); |
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.
I figured also showing an actual key would be useful, rather than just the slot number. Should there be logic here to show a different key based on the selected keyslot, or maybe show one of the privacy keys instead?
|
|
||
| size_t i = 0; | ||
| for (; i < bytes_read / kn; i++) { | ||
| memcpy(keys[i].nonce, dump + (i * kn), 8); |
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.
Could also be done like:
keys[i].nonce = *(dump + (i * kn));
I did it this way to keep it more similar to the rest of the block, but let me know if you'd rather change it.
| memcpy(&keys[i].keyslot, dump + (i * kn), 1); | ||
| memcpy(keys[i].privEncKey, dump + ((i * kn) + 1), 16); | ||
| memcpy(keys[i].privMacKey, dump + ((i * kn) + 17), 16); | ||
| memcpy(keys[i].readKey, dump + ((i * kn) + 33), 16); | ||
| memcpy(keys[i].writeKey, dump + ((i * kn) + 49), 16); | ||
| memcpy(keys[i].adminKey, dump + ((i * kn) + 65), 16); |
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.
Not as relevant to this PR, but maybe it would make sense to have the offsets instead stored as a variable and incremented by each memcpy since these odd numbers look weird?
Alternatively, does it make more sense to move the keyslot to the end of the struct so all the rest of the values are nice even multiples of 8?
| "hf seos managekeys --ki 0 --keyslot 1 -> Set keyslot value at key index 0\n" | ||
| "hf seos managekeys --ki 1 --read 0102030405060708 -> Set read key value at key index 1\n" |
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.
I figured I'd switch the line over to the read key, since it's more similar to the original message (showing how you can input a hex string) and it applies to more values. I added an additional line for the keyslot, but I'm not sure if this is actually necessary.
| if (nonce_len != 0) { | ||
| PrintAndLogEx(SUCCESS, "Current value for nonce[%d] " _GREEN_("%s"), key_index, sprint_hex_inrow(keys[key_index].nonce, 8)); | ||
| if (keyslot != -1) { | ||
| PrintAndLogEx(SUCCESS, "Current value for keyslot[%d] " _GREEN_("%u"), key_index, keys[key_index].keyslot); |
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.
Everywhere the keyslot is used internally, it's fetched with a %02X format string, but I think it's better displayed to the user in decimal. Is this actually true or should I swap it back to hex everywhere?
(AKA #3031 attempt 2)
Replaces unused
noncevalue with a newkeyslotvalue. By default, key indexes 0 and 1 use keyslot 1, key index 2 uses keyslot 3, and key index 3 uses keyslot 9 respectively. This means thathf seos adfandhf seos pacswork the same as before, andhf seos gdfwas updated to default to key index 3 to also maintain compatibility. Key index 2 is set to keyslot 3 to prepare for future write support.