sparkfun / SparkFun_ATECCX08a_Arduino_Library

An Arduino library to use with the Microchip ATECCX08a Cryptographic Co-processors.
https://www.sparkfun.com
Other
36 stars 18 forks source link

writeConfigSparkFun() Issue #23

Closed patrickmcm closed 1 year ago

patrickmcm commented 1 year ago

Hi, I have been reading through the datasheet and got confused by the config used by writeConfigSparkFun()

bool ATECCX08A::writeConfigSparkFun()
{
  // keep track of our write command results.
  bool result1;
  bool result2;

  // set keytype on slot 0 and 1 to 0x3300
  // Lockable, ECC, PuInfo set (public key always allowed to be generated), contains a private Key
  uint8_t data1[] = {0x33, 0x00, 0x33, 0x00}; // 0x3300 sets the keyconfig.keyType, see datasheet pg 20
  result1 = write(ZONE_CONFIG, (96 / 4), data1, 4);
  // set slot config on slot 0 and 1 to 0x8320
  // EXT signatures, INT signatures, IsSecret, Write config never
  uint8_t data2[] = {0x83, 0x20, 0x83, 0x20}; // for slot config bit definitions see datasheet pg 20
  result2 = write(ZONE_CONFIG, (20 / 4), data2, 4);

  return (result1 && result2);
}

Mainly I see that 0x8320 are used for both slot 0 and slot 1 configs however 0x8320 gives this in binary:

1000 0011 0010 0000

In the comment it said 'isSecret'. I assume this means enabled? However if we go to bit 7, we find a 0 where a 1 should be present if we want IsSecret. I cannot understand why this would be 0 espeically when we see that later a private key gets generated inside of slot 0, as seen in createNewKeyPair() in Example1_Configuration.ino. I believe I'm missing something here as GenKey shouldn't even work if bit 7 is set to 0.

image