Skip to main content

Module crc

Module crc 

Source
Expand description

CRC-16 as used by the ATECC608B protocol.

Parameters of the algorithm (Microchip uses the name “CRC-16/DNP” loosely. The chip’s variant matches none of the standard catalog entries exactly, the parameters below are the source of truth):

  • Polynomial : 0x8005
  • Initial value : 0x0000
  • Reflect input : false (MSB first)
  • Reflect output: false
  • XOR output : 0x0000
  • Byte order : low byte first when serialized on the wire

The implementation is a faithful translation of the bit-by-bit routine in lib/calib/calib_command.c of Microchip’s CryptoAuthLib. We deliberately avoid a table-driven approach. The driver only computes a CRC over short packets at human time scales (microseconds), so the gain would be negligible while flash usage would grow.

Functions§

crc16
Compute the CRC-16 over data.
crc16_to_bytes
Serialize a CRC into the two-byte little-endian form expected on the wire.
verify_trailing_crc 🔒
Verify the trailing two bytes of frame against a freshly computed CRC of everything before them.