]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/loclass/ikeys.c
ADD: Holimans new changes in master.
[proxmark3-svn] / client / loclass / ikeys.c
index 2bedad8dcfb6a8d75e49c652bed05334445e0ad4..fccd71d864f485d062ca4dfc3d736f8a829862f9 100644 (file)
@@ -1,5 +1,17 @@
 /*****************************************************************************
- * This file is part of iClassCipher. It is a reconstructon of the cipher engine
+ * WARNING
+ *
+ * THIS CODE IS CREATED FOR EXPERIMENTATION AND EDUCATIONAL USE ONLY. 
+ * 
+ * USAGE OF THIS CODE IN OTHER WAYS MAY INFRINGE UPON THE INTELLECTUAL 
+ * PROPERTY OF OTHER PARTIES, SUCH AS INSIDE SECURE AND HID GLOBAL, 
+ * AND MAY EXPOSE YOU TO AN INFRINGEMENT ACTION FROM THOSE PARTIES. 
+ * 
+ * THIS CODE SHOULD NEVER BE USED TO INFRINGE PATENTS OR INTELLECTUAL PROPERTY RIGHTS. 
+ *
+ *****************************************************************************
+ *
+ * This file is part of loclass. It is a reconstructon of the cipher engine
  * used in iClass, and RFID techology.
  *
  * The implementation is based on the work performed by
@@ -390,8 +402,8 @@ void diversifyKey(uint8_t csn[8], uint8_t key[8], uint8_t div_key[8])
        des_crypt_ecb(&ctx_enc,csn, crypted_csn);
 
        //Calculate HASH0(DES))
-        uint64_t crypt_csn = x_bytes_to_num(crypted_csn, 8);
-       uint64_t crypted_csn_swapped = swapZvalues(crypt_csn);
+    uint64_t crypt_csn = x_bytes_to_num(crypted_csn, 8);
+    //uint64_t crypted_csn_swapped = swapZvalues(crypt_csn);
 
        hash0(crypt_csn,div_key);
 }
@@ -725,16 +737,18 @@ int doTestsWithKnownInputs()
 
 int readKeyFile(uint8_t key[8])
 {
-
        FILE *f;
-
+       int retval = 1;
        f = fopen("iclass_key.bin", "rb");
        if (f)
        {
-               if(fread(key, sizeof(key), 1, f) == 1) return 0;
+               if(fread(key, sizeof(uint8_t), 8, f) == 1) 
+               {
+                       retval = 0;     
+               }
+               fclose(f);
        }
-       return 1;
-
+       return retval;
 }
 
 
Impressum, Datenschutz