]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/loclass/elite_crack.h
3 void permutekey(uint8_t key
[8], uint8_t dest
[8]);
5 * Permutes a key from iclass specific format to NIST format
6 * @brief permutekey_rev
10 void permutekey_rev(uint8_t key
[8], uint8_t dest
[8]);
11 //Crack status, see below
12 #define CRACKED 0x0100
13 #define BEING_CRACKED 0x0200
14 #define CRACK_FAILED 0x0400
17 * Perform a bruteforce against a file which has been saved by pm3
19 * @brief bruteforceFile
21 * @param keytable an arrah (128 x 16 bit ints). This is where the keydata is stored.
22 * OBS! the upper part of the 16 bits store crack-status,
25 int bruteforceFile(const char *filename
, uint16_t keytable
[]);
28 * @brief Same as above, if you don't care about the returned keytable (results only printed on screen)
32 int bruteforceFileNoKeys(const char *filename
);
34 * @brief Same as bruteforcefile, but uses a an array of dumpdata instead
40 int bruteforceDump(uint8_t dump
[], size_t dumpsize
, uint16_t keytable
[]);
43 This is how we expect each 'entry' in a dumpfile to look
53 * @brief Performs brute force attack against a dump-data item, containing csn, cc_nr and mac.
54 *This method calculates the hash1 for the CSN, and determines what bytes need to be bruteforced
55 *on the fly. If it finds that more than three bytes need to be bruteforced, it aborts.
56 *It updates the keytable with the findings, also using the upper half of the 16-bit ints
57 *to signal if the particular byte has been cracked or not.
59 * @param dump The dumpdata from iclass reader attack.
60 * @param keytable where to write found values.
63 int bruteforceItem(dumpdata item
, uint16_t keytable
[]);
65 * Hash1 takes CSN as input, and determines what bytes in the keytable will be used
66 * when constructing the K_sel.
67 * @param csn the CSN used
70 void hash1(uint8_t csn
[] , uint8_t k
[]);
71 void hash2(uint8_t *key64
, uint8_t *outp_keytable
);
73 * From dismantling iclass-paper:
74 * Assume that an adversary somehow learns the first 16 bytes of hash2(K_cus ), i.e., y [0] and z [0] .
75 * Then he can simply recover the master custom key K_cus by computing
76 * K_cus = ~DES(z[0] , y[0] ) .
78 * Furthermore, the adversary is able to verify that he has the correct K cus by
79 * checking whether z [0] = DES enc (K_cus , ~K_cus ).
80 * @param keytable an array (128 bytes) of hash2(kcus)
81 * @param master_key where to put the master key
82 * @return 0 for ok, 1 for failz
84 int calculateMasterKey(uint8_t first16bytes
[], uint64_t master_key
[] );
87 * @brief Test function
93 Here are some pretty optimal values that can be used to recover necessary data in only
95 // CSN HASH1 Bytes recovered //
96 { {0x00,0x0B,0x0F,0xFF,0xF7,0xFF,0x12,0xE0} , {0x01,0x01,0x00,0x00,0x45,0x01,0x45,0x45 } ,{0,1 }},
97 { {0x00,0x13,0x94,0x7e,0x76,0xff,0x12,0xe0} , {0x02,0x0c,0x01,0x00,0x45,0x01,0x45,0x45} , {2,12}},
98 { {0x2a,0x99,0xac,0x79,0xec,0xff,0x12,0xe0} , {0x07,0x45,0x0b,0x00,0x45,0x01,0x45,0x45} , {7,11}},
99 { {0x17,0x12,0x01,0xfd,0xf7,0xff,0x12,0xe0} , {0x03,0x0f,0x00,0x00,0x45,0x01,0x45,0x45} , {3,15}},
100 { {0xcd,0x56,0x01,0x7c,0x6f,0xff,0x12,0xe0} , {0x04,0x00,0x08,0x00,0x45,0x01,0x45,0x45} , {4,8}},
101 { {0x4b,0x5e,0x0b,0x72,0xef,0xff,0x12,0xe0} , {0x0e,0x06,0x08,0x00,0x45,0x01,0x45,0x45} , {6,14}},
102 { {0x00,0x73,0xd8,0x75,0x58,0xff,0x12,0xe0} , {0x0b,0x09,0x0f,0x00,0x45,0x01,0x05,0x45} , {9,5}},
103 { {0x0c,0x90,0x32,0xf3,0x5d,0xff,0x12,0xe0} , {0x0d,0x0f,0x0a,0x00,0x45,0x01,0x05,0x45} , {10,13}},