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

ensure device goes into idle even on error #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions src/ECCX08.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,48 +173,47 @@ int ECCX08Class::random(byte data[], size_t length)

int ECCX08Class::generatePrivateKey(int slot, byte publicKey[])
{
int result = 0;

if (!wakeup()) {
return 0;
}

if (!sendCommand(0x40, 0x04, slot)) {
return 0;
}

delay(115);
if (sendCommand(0x40, 0x04, slot)) {
delay(115);

if (!receiveResponse(publicKey, 64)) {
return 0;
if (receiveResponse(publicKey, 64)) {
delay(1);
result = 1;
}
}

delay(1);

idle();

return 1;
return result;
}

int ECCX08Class::generatePublicKey(int slot, byte publicKey[])
{
if (!wakeup()) {
return 0;
}

if (!sendCommand(0x40, 0x00, slot)) {
int result = 0;

if (!wakeup())
{
return 0;
}

delay(115);
if (sendCommand(0x40, 0x00, slot))
{
delay(115);

if (!receiveResponse(publicKey, 64)) {
return 0;
if (receiveResponse(publicKey, 64))
{
delay(1);
result = 1;
}
}

delay(1);

idle();

return 1;
return result;
}

int ECCX08Class::ecdsaVerify(const byte message[], const byte signature[], const byte pubkey[])
Expand Down
Loading