@@ -51,9 +51,7 @@ typedef struct {
5151 uint8_t nonce [8 ];
5252 uint8_t privEncKey [16 ];
5353 uint8_t privMacKey [16 ];
54- uint8_t readKey [16 ];
55- uint8_t writeKey [16 ];
56- uint8_t adminKey [16 ];
54+ uint8_t authKey [16 ];
5755} keyset_t ;
5856
5957keyset_t keys [] = {
@@ -62,36 +60,28 @@ keyset_t keys[] = {
6260 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // Nonce
6361 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // privEncKey
6462 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // privMacKey
65- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // readKey
66- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // writeKey
67- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } // adminKey
63+ { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // authKey
6864 },
6965 {
7066 0x01 , // Keyslot
7167 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // Nonce
7268 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // privEncKey
7369 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // privMacKey
74- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // readKey
75- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // writeKey
76- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } // adminKey
70+ { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // authKey
7771 },
7872 {
7973 0x02 , // Keyslot
8074 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // Nonce
8175 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // privEncKey
8276 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // privMacKey
83- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // readKey
84- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // writeKey
85- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } // adminKey
77+ { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // authKey
8678 },
8779 {
8880 0x09 , // Keyslot
8981 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // Nonce
9082 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // privEncKey
9183 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // privMacKey
92- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // readKey
93- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // writeKey
94- { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } // adminKey
84+ { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 }, // authKey
9585 },
9686};
9787
@@ -894,7 +884,7 @@ static int seos_mutual_auth(uint8_t *adfOID, size_t adfoid_len, uint8_t *randomI
894884
895885 // ---------------- Diversify Keys ----------------
896886 uint8_t mk [16 ] = { 0x00 };
897- memcpy (mk , keys [key_index ].readKey , 16 );
887+ memcpy (mk , keys [key_index ].authKey , 16 );
898888 uint8_t AES_key [24 ] = {0x00 };
899889 uint8_t MAC_key [24 ] = {0x00 };
900890
@@ -1428,9 +1418,7 @@ static int seos_print_keys(bool verbose) {
14281418 PrintAndLogEx (INFO , "Nonce............................ " _YELLOW_ ("%s" ), sprint_hex (keys [i ].nonce , 8 ));
14291419 PrintAndLogEx (INFO , "Privacy Encryption Key........... " _YELLOW_ ("%s" ), sprint_hex (keys [i ].privEncKey , 16 ));
14301420 PrintAndLogEx (INFO , "Privacy MAC Key.................. " _YELLOW_ ("%s" ), sprint_hex (keys [i ].privMacKey , 16 ));
1431- PrintAndLogEx (INFO , "Read Key......................... " _YELLOW_ ("%s" ), sprint_hex (keys [i ].readKey , 16 ));
1432- PrintAndLogEx (INFO , "Write Key........................ " _YELLOW_ ("%s" ), sprint_hex (keys [i ].writeKey , 16 ));
1433- PrintAndLogEx (INFO , "Admin Key........................ " _YELLOW_ ("%s" ), sprint_hex (keys [i ].adminKey , 16 ));
1421+ PrintAndLogEx (INFO , "Auth Key......................... " _YELLOW_ ("%s" ), sprint_hex (keys [i ].authKey , 16 ));
14341422 PrintAndLogEx (INFO , "----------------------------" );
14351423 }
14361424 } else {
@@ -1473,9 +1461,7 @@ static int seos_load_keys(char *filename) {
14731461 memcpy (keys [i ].nonce , dump + ((i * kn ) + 1 ), 8 );
14741462 memcpy (keys [i ].privEncKey , dump + ((i * kn ) + 9 ), 16 );
14751463 memcpy (keys [i ].privMacKey , dump + ((i * kn ) + 25 ), 16 );
1476- memcpy (keys [i ].readKey , dump + ((i * kn ) + 41 ), 16 );
1477- memcpy (keys [i ].writeKey , dump + ((i * kn ) + 57 ), 16 );
1478- memcpy (keys [i ].adminKey , dump + ((i * kn ) + 73 ), 16 );
1464+ memcpy (keys [i ].authKey , dump + ((i * kn ) + 41 ), 16 );
14791465 }
14801466
14811467 free (dump );
@@ -1793,7 +1779,7 @@ static int CmdHfSeosSim(const char *Cmd) {
17931779 // Copy all the provided values into the request object
17941780 memcpy (request .privenc , keys [key_index ].privEncKey , 16 );
17951781 memcpy (request .privmac , keys [key_index ].privMacKey , 16 );
1796- memcpy (request .authkey , keys [key_index ].readKey , 16 );
1782+ memcpy (request .authkey , keys [key_index ].authKey , 16 );
17971783
17981784 memcpy (request .uid , uid , uid_len );
17991785 memcpy (request .diversifier , diversifier , diversifier_len );
@@ -1837,9 +1823,7 @@ static int CmdHfSeosManageKeys(const char *Cmd) {
18371823 arg_str0 (NULL , "nonce" , "<hex>" , "Nonce value as 8 hex bytes" ),
18381824 arg_str0 (NULL , "privenc" , "<hex>" , "Privacy Encryption key as 16 hex bytes" ),
18391825 arg_str0 (NULL , "privmac" , "<hex>" , "Privacy MAC key as 16 hex bytes" ),
1840- arg_str0 (NULL , "read" , "<hex>" , "Undiversified Read key as 16 hex bytes" ),
1841- arg_str0 (NULL , "write" , "<hex>" , "Undiversified Write key as 16 hex bytes" ),
1842- arg_str0 (NULL , "admin" , "<hex>" , "Undiversified Admin key as 16 hex bytes" ),
1826+ arg_str0 (NULL , "auth" , "<hex>" , "Undiversified Auth key as 16 hex bytes" ),
18431827
18441828 arg_str0 ("f" , "file" , "<fn>" , "Specify a filename for load / save operations" ),
18451829 arg_lit0 (NULL , "save" , "Save keys in memory to file specified by filename" ),
@@ -1859,28 +1843,22 @@ static int CmdHfSeosManageKeys(const char *Cmd) {
18591843 uint8_t nonce [8 ] = {0 };
18601844 uint8_t privenc [16 ] = {0 };
18611845 uint8_t privmac [16 ] = {0 };
1862- uint8_t read [16 ] = {0 };
1863- uint8_t write [16 ] = {0 };
1864- uint8_t admin [16 ] = {0 };
1846+ uint8_t auth [16 ] = {0 };
18651847 int keyslot_len = 0 ;
18661848 int nonce_len = 0 ;
18671849 int privenc_len = 0 ;
18681850 int privmac_len = 0 ;
1869- int read_len = 0 ;
1870- int write_len = 0 ;
1871- int admin_len = 0 ;
1851+ int auth_len = 0 ;
18721852
18731853 int key_index = arg_get_int_def (ctx , 1 , -1 );
18741854
18751855 CLIGetHexWithReturn (ctx , 2 , keyslot , & keyslot_len );
18761856 CLIGetHexWithReturn (ctx , 3 , nonce , & nonce_len );
18771857 CLIGetHexWithReturn (ctx , 4 , privenc , & privenc_len );
18781858 CLIGetHexWithReturn (ctx , 5 , privmac , & privmac_len );
1879- CLIGetHexWithReturn (ctx , 6 , read , & read_len );
1880- CLIGetHexWithReturn (ctx , 7 , write , & write_len );
1881- CLIGetHexWithReturn (ctx , 8 , admin , & admin_len );
1859+ CLIGetHexWithReturn (ctx , 6 , auth , & auth_len );
18821860
1883- CLIParamStrToBuf (arg_get_str (ctx , 9 ), (uint8_t * )filename , FILE_PATH_SIZE , & fnlen );
1861+ CLIParamStrToBuf (arg_get_str (ctx , 7 ), (uint8_t * )filename , FILE_PATH_SIZE , & fnlen );
18841862
18851863 if (key_index >= 0 ) {
18861864 operation += 3 ;
@@ -1897,14 +1875,8 @@ static int CmdHfSeosManageKeys(const char *Cmd) {
18971875 if (privmac_len != 0 ) {
18981876 PrintAndLogEx (SUCCESS , "Current value for Priv Mac[%d] " _GREEN_ ("%s" ), key_index , sprint_hex_inrow (keys [key_index ].privMacKey , 16 ));
18991877 }
1900- if (read_len != 0 ) {
1901- PrintAndLogEx (SUCCESS , "Current value for Read Key[%d] " _GREEN_ ("%s" ), key_index , sprint_hex_inrow (keys [key_index ].readKey , 16 ));
1902- }
1903- if (write_len != 0 ) {
1904- PrintAndLogEx (SUCCESS , "Current value for Write Key[%d] " _GREEN_ ("%s" ), key_index , sprint_hex_inrow (keys [key_index ].writeKey , 16 ));
1905- }
1906- if (admin_len != 0 ) {
1907- PrintAndLogEx (SUCCESS , "Current value for Admin Key[%d] " _GREEN_ ("%s" ), key_index , sprint_hex_inrow (keys [key_index ].adminKey , 16 ));
1878+ if (auth_len != 0 ) {
1879+ PrintAndLogEx (SUCCESS , "Current value for Auth Key[%d] " _GREEN_ ("%s" ), key_index , sprint_hex_inrow (keys [key_index ].authKey , 16 ));
19081880 }
19091881 } else {
19101882 PrintAndLogEx (ERR , "Key index is out-of-range" );
@@ -1913,17 +1885,17 @@ static int CmdHfSeosManageKeys(const char *Cmd) {
19131885 }
19141886 }
19151887
1916- if (arg_get_lit (ctx , 10 )) { //save
1888+ if (arg_get_lit (ctx , 8 )) { //save
19171889 operation += 6 ;
19181890 }
1919- if (arg_get_lit (ctx , 11 )) { //load
1891+ if (arg_get_lit (ctx , 9 )) { //load
19201892 operation += 5 ;
19211893 }
1922- if (arg_get_lit (ctx , 12 )) { //print
1894+ if (arg_get_lit (ctx , 10 )) { //print
19231895 operation += 4 ;
19241896 }
19251897
1926- bool verbose = arg_get_lit (ctx , 13 );
1898+ bool verbose = arg_get_lit (ctx , 11 );
19271899
19281900 CLIParserFree (ctx );
19291901
@@ -1939,7 +1911,7 @@ static int CmdHfSeosManageKeys(const char *Cmd) {
19391911 PrintAndLogEx (ERR , "You must enter a filename when loading or saving\n" );
19401912 return PM3_EINVARG ;
19411913 }
1942- if (((keyslot_len > 0 ) || (nonce_len > 0 ) || (privenc_len > 0 ) || (privmac_len > 0 ) || (read_len > 0 ) || ( write_len > 0 ) || ( admin_len > 0 )) && key_index == -1 ) {
1914+ if (((keyslot_len > 0 ) || (nonce_len > 0 ) || (privenc_len > 0 ) || (privmac_len > 0 ) || (auth_len > 0 )) && key_index == -1 ) {
19431915 PrintAndLogEx (ERR , "Please specify key index when specifying key" );
19441916 return PM3_EINVARG ;
19451917 }
@@ -1962,17 +1934,9 @@ static int CmdHfSeosManageKeys(const char *Cmd) {
19621934 memcpy (keys [key_index ].privMacKey , privmac , 16 );
19631935 PrintAndLogEx (SUCCESS , "New value for Priv Mac[%d] " _GREEN_ ("%s" ), key_index , sprint_hex_inrow (keys [key_index ].privMacKey , 16 ));
19641936 }
1965- if (read_len != 0 ) {
1966- memcpy (keys [key_index ].readKey , read , 16 );
1967- PrintAndLogEx (SUCCESS , "New value for Read Key[%d] " _GREEN_ ("%s" ), key_index , sprint_hex_inrow (keys [key_index ].readKey , 16 ));
1968- }
1969- if (write_len != 0 ) {
1970- memcpy (keys [key_index ].writeKey , write , 16 );
1971- PrintAndLogEx (SUCCESS , "New value for Write Key[%d] " _GREEN_ ("%s" ), key_index , sprint_hex_inrow (keys [key_index ].writeKey , 16 ));
1972- }
1973- if (admin_len != 0 ) {
1974- memcpy (keys [key_index ].adminKey , admin , 16 );
1975- PrintAndLogEx (SUCCESS , "New value for Admin Key[%d] " _GREEN_ ("%s" ), key_index , sprint_hex_inrow (keys [key_index ].adminKey , 16 ));
1937+ if (auth_len != 0 ) {
1938+ memcpy (keys [key_index ].authKey , auth , 16 );
1939+ PrintAndLogEx (SUCCESS , "New value for Auth Key[%d] " _GREEN_ ("%s" ), key_index , sprint_hex_inrow (keys [key_index ].authKey , 16 ));
19761940 }
19771941 return PM3_SUCCESS ;
19781942 case 4 :
0 commit comments