]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdanalyse.c
FIX: T5555/Q5 datarate when used in "Q" parameter, consequential fix in lf commands...
[proxmark3-svn] / client / cmdanalyse.c
index 0d6072cbddcf8ad8d74b5b6cbd9a9e2e12fb2b8a..32309c1c229135e89479874c28a860ff4c99fa4e 100644 (file)
@@ -101,6 +101,22 @@ static uint8_t calcSumNibbleAdd( uint8_t* bytes, uint8_t len, uint32_t mask) {
 static uint8_t calcSumNibbleAddOnes( uint8_t* bytes, uint8_t len, uint32_t mask){
        return ~calcSumNibbleAdd(bytes, len, mask);
 }
+static uint8_t calcSumNibbleXor( uint8_t* bytes, uint8_t len, uint32_t mask) {
+    uint8_t sum = 0;
+    for (uint8_t i = 0; i < len; i++) {
+        sum ^= NIBBLE_LOW(bytes[i]);
+               sum ^= NIBBLE_HIGH(bytes[i]);
+       }
+       sum &= mask;    
+    return sum;
+}
+static uint8_t calcSumByteXor( uint8_t* bytes, uint8_t len, uint32_t mask) {
+    uint8_t sum = 0;
+    for (uint8_t i = 0; i < len; i++)
+        sum ^= bytes[i];
+       sum &= mask;    
+    return sum;
+}
 
 static uint8_t calcSumByteAdd( uint8_t* bytes, uint8_t len, uint32_t mask) {
     uint8_t sum = 0;
@@ -114,6 +130,8 @@ static uint8_t calcSumByteAddOnes( uint8_t* bytes, uint8_t len, uint32_t mask) {
        return ~calcSumByteAdd(bytes, len, mask);
 }
 
+
+
 static uint8_t calcSumByteSub( uint8_t* bytes, uint8_t len, uint32_t mask) {
     uint8_t sum = 0;
     for (uint8_t i = 0; i < len; i++)
@@ -277,6 +295,10 @@ int CmdAnalyseCHKSUM(const char *Cmd){
        PrintAndLog("Byte Subtract   | 0x%X", calcSumByteSubOnes(data, len, mask));
        PrintAndLog("Nibble Subtract | 0x%X", calcSumNibbleSubOnes(data, len, mask));
        
+       PrintAndLog("\nXOR");
+       PrintAndLog("Byte Xor   | 0x%X", calcSumByteXor(data, len, mask));
+       PrintAndLog("Nibble Xor   | 0x%X", calcSumNibbleXor(data, len, mask));
+       
        return 0;
 }
 
@@ -423,6 +445,9 @@ static void generate(uint8_t *data, uint8_t len) {
 }
 int CmdAnalyseHid(const char *Cmd){
 
+       uint8_t key[8] = {0};   
+       uint8_t key_std_format[8] = {0};
+       uint8_t key_iclass_format[8] = {0};
        uint8_t data[16] = {0};
        bool isReverse = FALSE;
        int len = 0;
@@ -435,12 +460,20 @@ int CmdAnalyseHid(const char *Cmd){
        param_gethex_ex(Cmd, 1, data, &len);
        if ( len%2 ) return usage_analyse_hid();
        
-       len >>= 1;
-       
-       if ( isReverse )
+       len >>= 1;      
+
+       memcpy(key, data, 8);
+
+       if ( isReverse ) {
                generate_rev(data, len);
-       else 
+               permutekey_rev(key, key_std_format);
+               printf(" holiman iclass key | %s \n", sprint_hex(key_std_format, 8));
+       }
+       else {
                generate(data, len);
+               permutekey(key, key_iclass_format);             
+               printf(" holiman std key | %s \n", sprint_hex(key_iclass_format, 8));
+       }
        return 0;
 }
 
Impressum, Datenschutz