X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/0014cb46da1bb7e0dfaa1d2cc8a291c6ab4ac1b3..ab4da50d99bb4334b86ff9bc8c5795723df37966:/armsrc/mifareutil.c diff --git a/armsrc/mifareutil.c b/armsrc/mifareutil.c index c5843fd7..085531f4 100644 --- a/armsrc/mifareutil.c +++ b/armsrc/mifareutil.c @@ -1,5 +1,5 @@ //----------------------------------------------------------------------------- -// Merlok, May 2011 +// Merlok, May 2011, 2012 // Many authors, whom made it possible // // This code is licensed to you under the terms of the GNU GPL, version 2 or, @@ -311,7 +311,7 @@ int mifare_classic_halt(struct Crypto1State *pcs, uint32_t uid) // Mifare HALT uint8_t* receivedAnswer = mifare_get_bigbufptr(); - len = mifare_sendcmd_short(pcs, 1, 0x50, 0x00, receivedAnswer); + len = mifare_sendcmd_short(pcs, pcs == NULL ? 0:1, 0x50, 0x00, receivedAnswer); if (len != 0) { if (MF_DBGLEVEL >= 1) Dbprintf("halt error. response len: %x", len); return 1; @@ -394,18 +394,18 @@ uint64_t emlGetKey(int sectorNum, int keyType) { } void emlClearMem(void) { - int i; + int b; const uint8_t trailer[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x80, 0x69, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - const uint8_t empty[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; const uint8_t uid[] = {0xe6, 0x84, 0x87, 0xf3, 0x16, 0x88, 0x04, 0x00, 0x46, 0x8e, 0x45, 0x55, 0x4d, 0x70, 0x41, 0x04}; - // fill sectors data - for(i = 0; i < 16; i++) { - emlSetMem((uint8_t *)empty, i * 4 + 0, 1); - emlSetMem((uint8_t *)empty, i * 4 + 1, 1); - emlSetMem((uint8_t *)empty, i * 4 + 2, 1); - emlSetMem((uint8_t *)trailer, i * 4 + 3, 1); - } + uint8_t* emCARD = eml_get_bigbufptr_cardmem(); + + memset(emCARD, 0, CARD_MEMORY_LEN); + + // fill sectors trailer data + for(b = 3; b < 256; b<127?(b+=4):(b+=16)) { + emlSetMem((uint8_t *)trailer, b , 1); + } // uid emlSetMem((uint8_t *)uid, 0, 1);