Skip to main content

checkmac_response

Function checkmac_response 

Source
pub(crate) fn checkmac_response(
    slot_value: &[u8; 32],
    challenge: &[u8; 32],
    other_data: &[u8; 13],
    chip_serial: &[u8; 9],
) -> [u8; 32]
Expand description

Compute the host-side CheckMac response for slot 5 or 6.

The MAC layout matches CryptoAuthLib’s atcah_check_mac exactly (lib/host/atca_host.c):

msg[0..32]   = slot_value         (32)
msg[32..64]  = challenge          (32)
msg[64..68]  = other_data[0..4]   ( 4)
msg[68..76]  = OTP[0..8] (zero)   ( 8)
msg[76..79]  = other_data[4..7]   ( 3)
msg[79]      = serial[8]          ( 1)
msg[80..84]  = other_data[7..11]  ( 4)
msg[84..86]  = serial[0..2]       ( 2)
msg[86..88]  = other_data[11..13] ( 2)

All 13 bytes of other_data are consumed, in three discontinuous chunks. Only serial bytes 0, 1, and 8 contribute to the hash; the remaining serial bytes (2..8) are absent from the formula by design.

chip_serial must therefore have valid values at indices 0, 1, 8; the others are ignored.