1 #ifndef __HITAG2_CRYPTO_H
2 #define __HITAG2_CRYPTO_H
9 TAG_STATE_RESET
= 0x01, // Just powered up, awaiting GetSnr
10 TAG_STATE_ACTIVATING
= 0x02, // In activation phase (password mode), sent UID, awaiting reader password
11 TAG_STATE_ACTIVATED
= 0x03, // Activation complete, awaiting read/write commands
12 TAG_STATE_WRITING
= 0x04, // In write command, awaiting sector contents to be written
14 uint16_t active_sector
;
15 uint8_t crypto_active
;
17 uint8_t sectors
[12][4];
20 uint32_t _f20(const uint64_t x
);
21 uint64_t _hitag2_init(const uint64_t key
, const uint32_t serial
, const uint32_t IV
);
22 uint64_t _hitag2_round(uint64_t *state
);
23 uint32_t _hitag2_byte(uint64_t *x
);
24 void hitag2_cipher_reset(struct hitag2_tag
*tag
, const uint8_t *iv
);
25 int hitag2_cipher_authenticate(uint64_t *cs
, const uint8_t *authenticator_is
);
26 int hitag2_cipher_transcrypt(uint64_t *cs
, uint8_t *data
, uint16_t bytes
, uint16_t bits
) ;