Skip to content

FACTORY SETUP mode problem with secret key #8

@niagFT

Description

@niagFT

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions