]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/mifareutil.c
improved version of "hf 14a mifare" command
[proxmark3-svn] / armsrc / mifareutil.c
index 59dafedc57e5661c693d72f13b8799e7620642cf..1f8a4d17564faa202c2d64cab246177cee09061d 100644 (file)
@@ -24,6 +24,11 @@ uint8_t* mifare_get_bigbufptr(void) {
 }\r
 \r
 int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer)\r
+{\r
+       return mifare_sendcmd_shortex(pcs, crypted, cmd, data, answer, NULL);\r
+}\r
+\r
+int mifare_sendcmd_shortex(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint32_t * parptr)\r
 {\r
        uint8_t dcmd[4], ecmd[4];\r
        uint32_t pos, par, res;\r
@@ -48,7 +53,9 @@ int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd,
                ReaderTransmit(dcmd, sizeof(dcmd));\r
        }\r
 \r
-       int len = ReaderReceive(answer);\r
+       int len = ReaderReceivePar(answer, &par);\r
+       \r
+       if (parptr) *parptr = par;\r
 \r
        if (crypted == CRYPT_ALL) {\r
                if (len == 1) {\r
@@ -70,6 +77,11 @@ int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd,
 }\r
 \r
 int mifare_classic_auth(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint64_t isNested) \r
+{\r
+       return mifare_classic_authex(pcs, uid, blockNo, keyType, ui64Key, isNested, NULL);\r
+}\r
+\r
+int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint64_t isNested, uint32_t * ntptr) \r
 {\r
        // variables\r
        int len;        \r
@@ -111,7 +123,12 @@ int mifare_classic_auth(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo,
        }\r
 \r
        // some statistic\r
-       Dbprintf("auth uid: %08x nt: %08x", uid, nt);  \r
+       if (!ntptr)\r
+               Dbprintf("auth uid: %08x nt: %08x", uid, nt);  \r
+       \r
+       // save Nt\r
+       if (ntptr)\r
+               *ntptr = nt;\r
 \r
        par = 0;\r
        // Generate (encrypted) nr+parity by loading it into the cipher (Nr)\r
Impressum, Datenschutz