5 #include "hitagcrypto.h"
6 #include "ht2crackutils.h"
8 int main(int argc
, char *argv
[]) {
22 printf("%s nRaRfile KEY UID\n", argv
[0]);
26 fp
= fopen(argv
[1], "r");
28 printf("cannot open file\n");
32 if (!strncmp(argv
[2], "0x", 2)) {
38 if (!strncmp(argv
[3], "0x", 2)) {
44 while ((len
= getline(&line
, &linelen
, fp
)) > 0) {
46 ar
= strchr(line
, ' ');
49 ar
[strlen(ar
) - 1] = 0x00;
50 if (!strncmp(line
, "0x", 2)) {
55 hitag2_init(&hstate
, rev64(hexreversetoulonglong(key
)), rev32(hexreversetoulong(uid
)), rev32(hexreversetoulong(nr
)));
57 arval
= strtol(ar
, NULL
, 16);
58 ks
= hitag2_nstep(&hstate
, 32);
61 if ((arval
^ ks
) != 0xffffffff) {
62 printf("FAIL! nR = %s, aR = %s\n", line
, ar
);
64 printf("SUCCESS! nR = %s, aR = %s\n", line
, ar
);