mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-05 20:41:34 -07:00
fix #2547 - compilation warning error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
This commit is contained in:
parent
145b3ac8d6
commit
4422101243
3 changed files with 18 additions and 18 deletions
|
@ -821,12 +821,17 @@ static bool hitag2_crypto(uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t *
|
|||
// stage 1, got UID
|
||||
if (bCrypto == false) {
|
||||
|
||||
uint64_t ui64key = key[0] |
|
||||
((uint64_t)key[1]) << 8 |
|
||||
((uint64_t)key[2]) << 16 |
|
||||
((uint64_t)key[3]) << 24 |
|
||||
((uint64_t)key[4]) << 32 |
|
||||
((uint64_t)key[5]) << 40;
|
||||
|
||||
uint32_t ui32uid = MemLeToUint4byte(rx);
|
||||
|
||||
DBG Dbprintf("hitag2_crypto: key array ");
|
||||
DBG Dbhexdump(6, key, false);
|
||||
|
||||
uint64_t ui64key = key[0] | ((uint64_t)key[1]) << 8 | ((uint64_t)key[2]) << 16 | ((uint64_t)key[3]) << 24 | ((uint64_t)key[4]) << 32 | ((uint64_t)key[5]) << 40;
|
||||
|
||||
uint32_t ui32uid = rx[0] | ((uint32_t)rx[1]) << 8 | ((uint32_t)rx[2]) << 16 | ((uint32_t)rx[3]) << 24;
|
||||
DBG Dbprintf("hitag2_crypto: key=0x%x%x uid=0x%x"
|
||||
, (uint32_t)((REV64(ui64key)) >> 32)
|
||||
, (uint32_t)((REV64(ui64key)) & 0xffffffff)
|
||||
|
|
|
@ -538,7 +538,8 @@ static void hts_handle_reader_command(uint8_t *rx, const size_t rxlen,
|
|||
rotate_uid++;
|
||||
*txlen = 32;
|
||||
// init crypt engine
|
||||
state = ht2_hitag2_init(REV64(tag.data.s.key), REV32(tag.data.s.uid_le), REV32(*(uint32_t *)rx));
|
||||
uint32_t le_rx = MemLeToUint4byte(rx);
|
||||
state = ht2_hitag2_init(REV64(tag.data.s.key), REV32(tag.data.s.uid_le), REV32(le_rx));
|
||||
DBG Dbhexdump(8, tx, false);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
@ -1129,10 +1130,7 @@ static int hts_select_tag(const lf_hitag_data_t *packet, uint8_t *tx, size_t siz
|
|||
// if the tag is in authentication mode try the key or challenge
|
||||
if (packet->cmd == HTSF_KEY) {
|
||||
|
||||
DBG DbpString("Authenticating using key:");
|
||||
DBG Dbhexdump(6, packet->key, false);
|
||||
|
||||
key_le = *(uint64_t *)packet->key;
|
||||
key_le = MemLeToUint6byte(packet->key);
|
||||
|
||||
uint32_t le_val = MemLeToUint4byte(rnd);
|
||||
uint64_t state = ht2_hitag2_init(REV64(key_le), REV32(tag.data.s.uid_le), REV32(le_val));
|
||||
|
@ -1146,6 +1144,8 @@ static int hts_select_tag(const lf_hitag_data_t *packet, uint8_t *tx, size_t siz
|
|||
txlen = concatbits(tx, txlen, rnd, 0, 32);
|
||||
txlen = concatbits(tx, txlen, auth_ks, 0, 32);
|
||||
|
||||
DBG DbpString("Authenticating using key:");
|
||||
DBG Dbhexdump(6, packet->key, false);
|
||||
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]);
|
||||
|
||||
} else if (packet->cmd == HTSF_CHALLENGE) {
|
||||
|
|
|
@ -404,15 +404,10 @@ void ht2_hitag2_cipher_reset(hitag2_t *tag, const uint8_t *iv) {
|
|||
((uint64_t)tag->sectors[1][1] << 24) |
|
||||
((uint64_t)tag->sectors[1][2] << 32) |
|
||||
((uint64_t)tag->sectors[1][3] << 40);
|
||||
uint32_t uid = ((uint32_t)tag->sectors[0][0]) |
|
||||
((uint32_t)tag->sectors[0][1] << 8) |
|
||||
((uint32_t)tag->sectors[0][2] << 16) |
|
||||
((uint32_t)tag->sectors[0][3] << 24);
|
||||
uint32_t iv_ = (((uint32_t)(iv[0]))) |
|
||||
(((uint32_t)(iv[1])) << 8) |
|
||||
(((uint32_t)(iv[2])) << 16) |
|
||||
(((uint32_t)(iv[3])) << 24);
|
||||
tag->cs = ht2_hitag2_init(REV64(key), REV32(uid), REV32(iv_));
|
||||
uint32_t uid = MemLeToUint4byte(tag->sectors[0]);
|
||||
uint32_t riv = MemLeToUint4byte(iv);
|
||||
|
||||
tag->cs = ht2_hitag2_init(REV64(key), REV32(uid), REV32(riv));
|
||||
}
|
||||
|
||||
int ht2_hitag2_cipher_authenticate(uint64_t *state, const uint8_t *authenticator_is) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue