1 //-----------------------------------------------------------------------------
2 // Kevin Sheldrake <kev@headhacking.com>, Aug 2018
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
8 // Definitions hitag2 attack functions
9 //-----------------------------------------------------------------------------
11 bool hitag2_crack(uint8_t *response
, uint8_t *nrarhex
);
12 bool hitag2crack_find_valid_e_cmd(uint8_t e_cmd
[], uint8_t nrar
[]);
13 bool hitag2crack_find_e_page0_cmd(uint8_t keybits
[], uint8_t e_firstcmd
[], uint8_t nrar
[], uint8_t uid
[]);
14 bool hitag2crack_test_e_p0cmd(uint8_t *keybits
, uint8_t *nrar
, uint8_t *e_cmd
, uint8_t *uid
, uint8_t *e_uid
);
15 void hitag2crack_xor(uint8_t *target
, uint8_t *source
, uint8_t *pad
, unsigned int len
);
16 bool hitag2crack_read_page(uint8_t *responsestr
, uint8_t pagenum
, uint8_t *nrar
, uint8_t *keybits
);
17 bool hitag2crack_send_e_cmd(uint8_t *responsestr
, uint8_t *nrar
, uint8_t *cmd
, int len
);
18 bool hitag2crack_tx_rx(uint8_t *responsestr
, uint8_t *msg
, int len
, int state
, bool reset
);
20 bool hitag2crack_rng_init(uint8_t *response
, uint8_t *input
);
21 bool hitag2crack_decrypt_hex(uint8_t *response
, uint8_t *hex
);
22 bool hitag2crack_decrypt_bin(uint8_t *response
, uint8_t *e_binstr
);
23 bool hitag2crack_encrypt_hex(uint8_t *response
, uint8_t *hex
);
24 bool hitag2crack_encrypt_bin(uint8_t *response
, uint8_t *e_binstr
);
26 bool hitag2_keystream(uint8_t *response
, uint8_t *nrarhex
);
27 bool hitag2crack_send_auth(uint8_t *nrar
);
28 bool hitag2crack_consume_keystream(uint8_t *keybits
, int kslen
, int *ksoffset
, uint8_t *nrar
);
29 bool hitag2crack_extend_keystream(uint8_t *keybits
, int *kslen
, int ksoffset
, uint8_t *nrar
, uint8_t *uid
);
31 bool hitag2_reader(uint8_t *response
, uint8_t *key
, bool interactive
);