Skip to content

Commit db1ce08

Browse files
committed
lf hitag hts: correct byteorder for authentication
1 parent 5848b31 commit db1ce08

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

armsrc/hitagS.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,15 +1157,16 @@ static int hts_select_tag(const lf_hitag_data_t *packet, uint8_t *tx, size_t siz
11571157

11581158
key_le = *(uint64_t *)packet->key;
11591159

1160-
uint64_t state = ht2_hitag2_init(reflect48(key_le), reflect32(tag.data.s.uid_le), reflect32(*(uint32_t *)rnd));
1160+
uint64_t state = ht2_hitag2_init(BSWAP_64(reflect64(key_le)), BSWAP_32(reflect32(tag.data.s.uid_le)), reflect32(*(uint32_t *)rnd));
11611161

11621162
uint8_t auth_ks[4];
11631163
for (int i = 0; i < 4; i++) {
11641164
auth_ks[i] = ht2_hitag2_byte(&state) ^ 0xff;
11651165
}
11661166

11671167
txlen = 0;
1168-
txlen = concatbits(tx, txlen, rnd, 0, 32);
1168+
uint8_t revrnd[4] = {rnd[3], rnd[2], rnd[1], rnd[0]};
1169+
txlen = concatbits(tx, txlen, revrnd, 0, 32);
11691170
txlen = concatbits(tx, txlen, auth_ks, 0, 32);
11701171

11711172
DBG Dbprintf("%02X %02X %02X %02X %02X %02X %02X %02X", tx[0], tx[1], tx[2], tx[3], tx[4], tx[5], tx[6], tx[7]);

0 commit comments

Comments
 (0)