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

FACTORY SETUP mode problem with secret key #8

Open
niagFT opened this issue Jun 23, 2022 · 2 comments
Open

FACTORY SETUP mode problem with secret key #8

niagFT opened this issue Jun 23, 2022 · 2 comments

Comments

@niagFT
Copy link

niagFT commented Jun 23, 2022

Hi,

we are experiencing some issues regarding sending the secret key over serial to the device during Factory Setup mode. More specifically, the device doesn't receive the secret key correctly and therefore the token decoding process always fails.

For example, when trying to send these numbers to the device (which is the example included in the code):

#1234;123456789;a29ab82edc5fbbc41ec9530f6dac86b1

the device understand the following:

SN:1234 SC:123456789 SK:22AA88EECCFFBB44EE9933FFDDCC6611

I believe the issue is to be found in the updateSecretKey() function and more specifically in how the received chars are converted to the sum variable through the strtol() function.

Something like this instead works great:

int updateSecretKey(unsigned char secretKey[16])
{
  int i;
  for (i = 0; i < 16; i++){
    char temp[3];
    char char1 = getByteSent();
    char char2 = getByteSent();
    sprintf(temp, "%c%c", char1, char2);
    int sum = strtoul(temp, NULL, 16);
    secretKey[i] = (unsigned char)sum;
    delay(100);
  }
  return 0;
}
@benmod
Copy link
Member

benmod commented Oct 20, 2022

Can you give a bit of context about the hardware you are using? Which MCU model / compiler?

@niagFT
Copy link
Author

niagFT commented Oct 25, 2022

Our MCU is the ESP32 and we are developing using the Espressif's arduino-esp32 core as a component in the esp-idf development framework.

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