Challenge Response Block

From Lazer Swarm Wiki
Jump to navigation Jump to search
Smart Device Protocol Block
Name CHALLENGE-RESPONSE
BType 0xEF
BData Count 2
Sent By Device

This block is sent by the device in response to the Challenge Code block to authenticate itself to the tagger.

  • BData0—Response code (most significant byte)
  • BData1—Response code (least significant byte)

The following code will generate the correct response for a given challenge code:

shifted = challenge << 1;
shifted |= (challenge & 0x8) >> 3 ^
           (challenge & 0x1000) >> 12 ^
           (challenge & 0x4000) >> 14 ^
           (challenge & 0x8000) >> 15;
response = (shifted & 0xf) << 12 |
           (shifted & 0xf0) << 4 |
           (shifted & 0xf00) >> 4 |
           (shifted & 0xf000) >> 12;