Skip to content
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

Wiping RSA key doesn't wipe key type #26

Open
svareille opened this issue Jan 6, 2023 · 1 comment
Open

Wiping RSA key doesn't wipe key type #26

svareille opened this issue Jan 6, 2023 · 1 comment

Comments

@svareille
Copy link

Hi!

I noticed that wiping a RSA key only wipe the private part but not the type field. As a result, any subsequent use of the wiped key doesn't fail with Error no RSA Private Key set in this slot as expected. For example, wiping a RSA key and then sending a OKSIGN results in Error invalid key, key check failed.

When wiping an ECC key the type field is correctly set to 0, and every subsequent use of the key results in Error no ECC Private Key set in this slot.

Code involved

The code to patch, if the described behavior is indeed a bug, is located in okcore.cpp, in the rsa_priv_flash function:

libraries/onlykey/okcore.cpp

Lines 5097 to 5108 in c8804e3

if (wipe)
{
//Copy current flash contents to buffer
okcore_flashget_common(tptr, (unsigned long *)adr, 2048);
//Wipe content from buffer
flash_modify(buffer[5], temp, buffer, MAX_RSA_KEY_SIZE, 1);
//Write buffer to flash
okcore_flashset_common(tptr, (unsigned long *)adr, 2048);
hidprint("Successfully wiped RSA Private Key");
blink(2);
return;
}

I think there should be okeeprom_eeset_rsakey(0, (int)buffer[5]); inserted somewhere in this bloc.

@onlykey
Copy link
Collaborator

onlykey commented Jan 6, 2023

@svareille thanks, I will see if I can reproduce this issue and address this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants