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

ECDH support #20

Open
monsieur7 opened this issue Mar 13, 2020 · 1 comment · May be fixed by #35
Open

ECDH support #20

monsieur7 opened this issue Mar 13, 2020 · 1 comment · May be fixed by #35
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@monsieur7
Copy link

The ATECC508A ( ATECC608A ) chip support ECDH but I can't find support for this in the library. Can you add it, please?

@per1234 per1234 added the type: enhancement Proposed improvement label Mar 14, 2020
@KRolander
Copy link

Hi @monsieur7,
In the ECCX08.h you can add to the public functions:

int ecdh(const byte publicKey[], int slot, byte share[]);

And to ECCX08.cpp you can add this:

int ECCX08Class::ecdh(const byte publicKey[], int slot, byte share[])
{

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

  if (!sendCommand(0x43, 0x0C, slot, publicKey, 64)) {
    return 0;
  }

  delay(115);

  if (!receiveResponse(share, 32)) {
    return 0;
  }

  delay(1);

  idle();

  return 1;
}

In the main you can call like this:

uint8_t share[32];
  ECCX08.ecdh(pubkeyCipher, 2, share);
  if (res == 0)
  {

    Serial.println("[ecdh] Not Valid");
    Serial.println();
  }
  else
  {
    Serial.println("[ecdh] Valid");
    print_array(share, 32);
    Serial.println();
  }
void print_array(uint8_t *array, int arraySize)
{
  char buffer[3];
  for (int i = 0; i < arraySize; i++)
  {
    sprintf(buffer, "%02x", array[i]);
    Serial.print(buffer);
  }
  Serial.println("");
}

@per1234 per1234 linked a pull request Sep 6, 2022 that will close this issue
@per1234 per1234 added the topic: code Related to content of the project itself label Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants