aboutsummaryrefslogtreecommitdiffstats
path: root/dev-util/mfcuk
diff options
context:
space:
mode:
Diffstat (limited to 'dev-util/mfcuk')
-rw-r--r--dev-util/mfcuk/Manifest2
-rw-r--r--dev-util/mfcuk/files/mfcuk-new-libnfc-version.patch1099
-rw-r--r--dev-util/mfcuk/mfcuk-9999.ebuild29
3 files changed, 1130 insertions, 0 deletions
diff --git a/dev-util/mfcuk/Manifest b/dev-util/mfcuk/Manifest
new file mode 100644
index 0000000..9f11b9b
--- /dev/null
+++ b/dev-util/mfcuk/Manifest
@@ -0,0 +1,2 @@
+AUX mfcuk-new-libnfc-version.patch 39765 RMD160 0540e930a10c5ccfee906a31ad1fd1d72ed5138c SHA1 6bf67f260cf6a82092e834370406c89c3346d665 SHA256 8ca8c70cfde48e352434b7ada479233111b3fdea35d00c68b3dc25f11a83a53f
+EBUILD mfcuk-9999.ebuild 673 RMD160 caa2bb386142f38a38db4999c7fd3db5c7966571 SHA1 d21cb4cc4ac8653f682810001ab28bbf31ae8842 SHA256 4a175240f4ff0c0b2d859d1156e788bf4ae7785ea752309e197dd6a68c38da46
diff --git a/dev-util/mfcuk/files/mfcuk-new-libnfc-version.patch b/dev-util/mfcuk/files/mfcuk-new-libnfc-version.patch
new file mode 100644
index 0000000..e27f105
--- /dev/null
+++ b/dev-util/mfcuk/files/mfcuk-new-libnfc-version.patch
@@ -0,0 +1,1099 @@
+Index: src/nfc-utils.c
+===================================================================
+--- src/nfc-utils.c (revision 62)
++++ src/nfc-utils.c (working copy)
+@@ -33,7 +33,7 @@
+
+ #include "nfc-utils.h"
+
+-static const byte_t OddParity[256] = {
++static const uint8_t OddParity[256] = {
+ 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
+ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
+ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
+@@ -52,14 +52,14 @@
+ 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
+ };
+
+-byte_t
+-oddparity (const byte_t bt)
++uint8_t
++oddparity (const uint8_t bt)
+ {
+ return OddParity[bt];
+ }
+
+ void
+-oddparity_bytes_ts (const byte_t * pbtData, const size_t szLen, byte_t * pbtPar)
++oddparity_bytes_ts (const uint8_t * pbtData, const size_t szLen, uint8_t * pbtPar)
+ {
+ size_t szByteNr;
+ // Calculate the parity bits for the command
+@@ -69,7 +69,7 @@
+ }
+
+ void
+-print_hex (const byte_t * pbtData, const size_t szBytes)
++print_hex (const uint8_t * pbtData, const size_t szBytes)
+ {
+ size_t szPos;
+
+@@ -80,7 +80,7 @@
+ }
+
+ void
+-print_hex_bits (const byte_t * pbtData, const size_t szBits)
++print_hex_bits (const uint8_t * pbtData, const size_t szBits)
+ {
+ uint8_t uRemainder;
+ size_t szPos;
+@@ -102,7 +102,7 @@
+ }
+
+ void
+-print_hex_par (const byte_t * pbtData, const size_t szBits, const byte_t * pbtDataPar)
++print_hex_par (const uint8_t * pbtData, const size_t szBits, const uint8_t * pbtDataPar)
+ {
+ uint8_t uRemainder;
+ size_t szPos;
+@@ -133,7 +133,7 @@
+ #define SAK_ISO18092_COMPLIANT 0x40
+
+ void
+-print_nfc_iso14443a_info (const nfc_iso14443a_info_t nai, bool verbose)
++print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose)
+ {
+ printf (" ATQA (SENS_RES): ");
+ print_hex (nai.abtAtqa, 2);
+@@ -202,7 +202,7 @@
+
+ size_t offset = 1;
+ if (nai.abtAts[0] & 0x10) { // TA(1) present
+- byte_t TA = nai.abtAts[offset];
++ uint8_t TA = nai.abtAts[offset];
+ offset++;
+ printf ("* Bit Rate Capability:\n");
+ if (TA == 0) {
+@@ -234,7 +234,7 @@
+ }
+ }
+ if (nai.abtAts[0] & 0x20) { // TB(1) present
+- byte_t TB= nai.abtAts[offset];
++ uint8_t TB= nai.abtAts[offset];
+ offset++;
+ printf ("* Frame Waiting Time: %.4g ms\n",256.0*16.0*(1<<((TB & 0xf0) >> 4))/13560.0);
+ if ((TB & 0x0f) == 0) {
+@@ -244,7 +244,7 @@
+ }
+ }
+ if (nai.abtAts[0] & 0x40) { // TC(1) present
+- byte_t TC = nai.abtAts[offset];
++ uint8_t TC = nai.abtAts[offset];
+ offset++;
+ if (TC & 0x1) {
+ printf("* Node ADdress supported\n");
+@@ -260,20 +260,20 @@
+ if (nai.szAtsLen > offset) {
+ printf ("* Historical bytes Tk: " );
+ print_hex (nai.abtAts + offset, (nai.szAtsLen - offset));
+- byte_t CIB = nai.abtAts[offset];
++ uint8_t CIB = nai.abtAts[offset];
+ offset++;
+ if (CIB != 0x00 && CIB != 0x10 && (CIB & 0xf0) != 0x80) {
+ printf(" * Proprietary format\n");
+ if (CIB == 0xc1) {
+ printf(" * Tag byte: Mifare or virtual cards of various types\n");
+- byte_t L = nai.abtAts[offset];
++ uint8_t L = nai.abtAts[offset];
+ offset++;
+ if (L != (nai.szAtsLen - offset)) {
+ printf(" * Warning: Type Identification Coding length (%i)", L);
+ printf(" not matching Tk length (%zi)\n", (nai.szAtsLen - offset));
+ }
+ if ((nai.szAtsLen - offset - 2) > 0) { // Omit 2 CRC bytes
+- byte_t CTC = nai.abtAts[offset];
++ uint8_t CTC = nai.abtAts[offset];
+ offset++;
+ printf(" * Chip Type: ");
+ switch (CTC & 0xf0) {
+@@ -316,7 +316,7 @@
+ }
+ }
+ if ((nai.szAtsLen - offset) > 0) { // Omit 2 CRC bytes
+- byte_t CVC = nai.abtAts[offset];
++ uint8_t CVC = nai.abtAts[offset];
+ offset++;
+ printf(" * Chip Status: ");
+ switch (CVC & 0xf0) {
+@@ -350,7 +350,7 @@
+ }
+ }
+ if ((nai.szAtsLen - offset) > 0) { // Omit 2 CRC bytes
+- byte_t VCS = nai.abtAts[offset];
++ uint8_t VCS = nai.abtAts[offset];
+ offset++;
+ printf(" * Specifics (Virtual Card Selection):\n");
+ if ((VCS & 0x09) == 0x00) {
+@@ -530,7 +530,7 @@
+ }
+
+ void
+-print_nfc_felica_info (const nfc_felica_info_t nfi, bool verbose)
++print_nfc_felica_info (const nfc_felica_info nfi, bool verbose)
+ {
+ (void) verbose;
+ printf (" ID (NFCID2): ");
+@@ -542,7 +542,7 @@
+ }
+
+ void
+-print_nfc_jewel_info (const nfc_jewel_info_t nji, bool verbose)
++print_nfc_jewel_info (const nfc_jewel_info nji, bool verbose)
+ {
+ (void) verbose;
+ printf (" ATQA (SENS_RES): ");
+@@ -555,7 +555,7 @@
+ #define PI_NAD_SUPPORTED 0x01
+ #define PI_CID_SUPPORTED 0x02
+ void
+-print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi, bool verbose)
++print_nfc_iso14443b_info (const nfc_iso14443b_info nbi, bool verbose)
+ {
+ const int iMaxFrameSizes[] = { 16, 24, 32, 40, 48, 64, 96, 128, 256 };
+ printf (" PUPI: ");
+@@ -610,7 +610,7 @@
+ }
+
+ void
+-print_nfc_iso14443bi_info (const nfc_iso14443bi_info_t nii, bool verbose)
++print_nfc_iso14443bi_info (const nfc_iso14443bi_info nii, bool verbose)
+ {
+ printf (" DIV: ");
+ print_hex (nii.abtDIV, 4);
+@@ -634,7 +634,7 @@
+ }
+
+ void
+-print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info_t nsi, bool verbose)
++print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info nsi, bool verbose)
+ {
+ (void) verbose;
+ printf (" UID: ");
+@@ -642,7 +642,7 @@
+ }
+
+ void
+-print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info_t nci, bool verbose)
++print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info nci, bool verbose)
+ {
+ (void) verbose;
+ uint32_t uid;
+@@ -655,7 +655,7 @@
+ }
+
+ void
+-print_nfc_dep_info (const nfc_dep_info_t ndi, bool verbose)
++print_nfc_dep_info (const nfc_dep_info ndi, bool verbose)
+ {
+ (void) verbose;
+ printf (" NFCID3: ");
+@@ -671,7 +671,7 @@
+ }
+
+ const char *
+-str_nfc_baud_rate (const nfc_baud_rate_t nbr)
++str_nfc_baud_rate (const nfc_baud_rate nbr)
+ {
+ switch(nbr) {
+ case NBR_UNDEFINED:
+@@ -694,7 +694,7 @@
+ }
+
+ void
+-print_nfc_target (const nfc_target_t nt, bool verbose)
++print_nfc_target (const nfc_target nt, bool verbose)
+ {
+ switch(nt.nm.nmt) {
+ case NMT_ISO14443A:
+Index: src/mfcuk.c
+===================================================================
+--- src/mfcuk.c (revision 62)
++++ src/mfcuk.c (working copy)
+@@ -222,9 +222,9 @@
+ uint32_t numSpoofEntries = 0; // Actual number of entries in the arrSpoofEntries
+ uint32_t numAuthAttempts = 0; // Number of authentication attempts for Recovery of keys - used to statistics. TODO: implement proper statistics with timings, number of tries, etc.
+ bool bfOpts[256] = {false}; // Command line options, indicates their presence, initialize with false
+-byte_t verboseLevel = 0; // No verbose level by default
++uint8_t verboseLevel = 0; // No verbose level by default
+
+-static const nfc_modulation_t nmMifare = {
++static const nfc_modulation nmMifare = {
+ .nmt = NMT_ISO14443A,
+ .nbr = NBR_106,
+ };
+@@ -240,7 +240,7 @@
+ }
+
+ // TODO: combine mfcuk_verify_key_block() with mfcuk_recover_key_block(), since a lot of code is duplicate
+-uint32_t mfcuk_verify_key_block(nfc_device_t* pnd, uint32_t uiUID, uint64_t ui64Key, mifare_key_type bKeyType, byte_t bTagType, uint32_t uiBlock)
++uint32_t mfcuk_verify_key_block(nfc_device* pnd, uint32_t uiUID, uint64_t ui64Key, mifare_key_type bKeyType, uint8_t bTagType, uint32_t uiBlock)
+ {
+ uint32_t pos;
+
+@@ -254,11 +254,11 @@
+ uint64_t lfsr;
+
+ // Communication related variables
+- byte_t abtAuth[4] = { 0x00,0x00,0x00,0x00 };
+- byte_t abtArEnc[8] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
+- byte_t abtArEncPar[8] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
+- byte_t abtRx[MAX_FRAME_LEN];
+- byte_t abtRxPar[MAX_FRAME_LEN];
++ uint8_t abtAuth[4] = { 0x00,0x00,0x00,0x00 };
++ uint8_t abtArEnc[8] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
++ uint8_t abtArEncPar[8] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
++ uint8_t abtRx[MAX_FRAME_LEN];
++ uint8_t abtRxPar[MAX_FRAME_LEN];
+ size_t szRx;
+ uint32_t nt, nt_orig; // Supplied tag nonce
+
+@@ -283,20 +283,20 @@
+ iso14443a_crc_append(abtAuth,2);
+
+ // Now we take over, first we need full control over the CRC
+- if ( !nfc_configure(pnd,NDO_HANDLE_CRC,false) )
++ if ( !nfc_device_set_property_bool(pnd,NP_HANDLE_CRC,false) )
+ {
+ return MFCUK_FAIL_COMM;
+ }
+
+ // We need to disable EASY_FRAMING feature to talk in "raw" mode
+- nfc_configure (pnd, NDO_EASY_FRAMING, false);
++ nfc_device_set_property_bool (pnd, NP_EASY_FRAMING, false);
+
+ // Request plain tag-nonce
+- if (!nfc_initiator_transceive_bytes(pnd,abtAuth,4,abtRx,&szRx, NULL))
++ if (!nfc_initiator_transceive_bytes(pnd,abtAuth,4,abtRx,&szRx, 0))
+ {
+ return MFCUK_FAIL_COMM;
+ }
+- nfc_configure (pnd, NDO_EASY_FRAMING, true);
++ nfc_device_set_property_bool (pnd, NP_EASY_FRAMING, true);
+
+ // Save the tag nonce (nt)
+ nt = bswap_32(*((uint32_t *) abtRx));
+@@ -347,12 +347,13 @@
+ }
+
+ // Finally we want to send arbitrary parity bits
+- if ( !nfc_configure(pnd,NDO_HANDLE_PARITY,false) )
++ if ( !nfc_device_set_property_bool(pnd,NP_HANDLE_PARITY,false) )
+ {
+ return MFCUK_FAIL_COMM;
+ }
+
+- if ( !nfc_initiator_transceive_bits(pnd,abtArEnc,64,abtArEncPar,abtRx,&szRx,abtRxPar) )
++ szRx = nfc_initiator_transceive_bits(pnd,abtArEnc,64,abtArEncPar,abtRx,abtRxPar);
++ if (szRx <= 0)
+ {
+ return MFCUK_FAIL_AUTH;
+ }
+@@ -392,16 +393,16 @@
+ return MFCUK_SUCCESS;
+ }
+
+-uint32_t mfcuk_key_recovery_block(nfc_device_t* pnd, uint32_t uiUID, uint64_t ui64Key, mifare_key_type bKeyType, byte_t bTagType, uint32_t uiBlock, uint64_t *ui64KeyRecovered)
++uint32_t mfcuk_key_recovery_block(nfc_device* pnd, uint32_t uiUID, uint64_t ui64Key, mifare_key_type bKeyType, uint8_t bTagType, uint32_t uiBlock, uint64_t *ui64KeyRecovered)
+ {
+ // Communication variables
+ uint32_t pos, pos2, nt;
+ struct Crypto1State* pcs;
+- byte_t abtAuth[4] = { 0x60,0x00,0x00,0x00 };
+- byte_t abtArEnc[8] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
+- byte_t abtArEncPar[8] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
+- byte_t abtRx[MAX_FRAME_LEN];
+- byte_t abtRxPar[MAX_FRAME_LEN];
++ uint8_t abtAuth[4] = { 0x60,0x00,0x00,0x00 };
++ uint8_t abtArEnc[8] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
++ uint8_t abtArEncPar[8] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
++ uint8_t abtRx[MAX_FRAME_LEN];
++ uint8_t abtRxPar[MAX_FRAME_LEN];
+ size_t szRx;
+
+ // zveriu
+@@ -414,7 +415,7 @@
+ struct Crypto1State *current_state;
+ uint32_t i;
+ uint64_t key_recovered;
+- byte_t flag_key_recovered = 0; // FIXME: fix the {Nr} iteration properly. This a quick fix for cases when 0xDEADBEEF {Nr} is not working
++ uint8_t flag_key_recovered = 0; // FIXME: fix the {Nr} iteration properly. This a quick fix for cases when 0xDEADBEEF {Nr} is not working
+
+ if ( (bKeyType != keyA) && (bKeyType != keyB) )
+ {
+@@ -437,19 +438,19 @@
+ iso14443a_crc_append(abtAuth,2);
+
+ // Now we take over, first we need full control over the CRC
+- nfc_configure(pnd,NDO_HANDLE_CRC,false);
++ nfc_device_set_property_bool(pnd,NP_HANDLE_CRC,false);
+
+ // We need to disable EASY_FRAMING feature to talk in "raw" mode
+- nfc_configure (pnd, NDO_EASY_FRAMING, false);
++ nfc_device_set_property_bool (pnd, NP_EASY_FRAMING, false);
+
+ // Request plain tag-nonce
+ //printf("Nt: ");
+- if (!nfc_initiator_transceive_bytes(pnd,abtAuth,4,abtRx,&szRx, NULL))
++ if ( !nfc_initiator_transceive_bytes(pnd,abtAuth,4,abtRx,&szRx, 0))
+ {
+ //printf("\n\nFAILURE - Failed to get TAG NONCE!!!\n\n");
+ return MFCUK_FAIL_COMM;
+ }
+- nfc_configure (pnd, NDO_EASY_FRAMING, true);
++ nfc_device_set_property_bool (pnd, NP_EASY_FRAMING, true);
+
+ //print_hex(abtRx,4);
+
+@@ -631,13 +632,14 @@
+ }
+
+ // Finally we want to send arbitrary parity bits
+- nfc_configure(pnd,NDO_HANDLE_PARITY,false);
++ nfc_device_set_property_bool(pnd,NP_HANDLE_PARITY,false);
+
+ // Transmit reader-answer
+ //printf(" Ar: ");
+ //print_hex_par(abtArEnc,64,abtArEncPar);
+
+- if (!nfc_initiator_transceive_bits(pnd,abtArEnc,64,abtArEncPar,abtRx,&szRx,abtRxPar))
++ szRx = nfc_initiator_transceive_bits(pnd,abtArEnc,64,abtArEncPar,abtRx,abtRxPar);
++ if (szRx <= 0)
+ {
+ if (sendSpoofAr)
+ {
+@@ -792,7 +794,7 @@
+ void print_mifare_classic_tag_actions(const char *title, mifare_classic_tag *tag)
+ {
+ uint32_t i, max_blocks, trailer_block;
+- byte_t bTagType;
++ uint8_t bTagType;
+ mifare_classic_block_trailer *ptr_trailer = NULL;
+
+ if (!tag)
+@@ -860,26 +862,26 @@
+ return;
+ }
+
+-bool mfcuk_darkside_reset_advanced(nfc_device_t* pnd)
++bool mfcuk_darkside_reset_advanced(nfc_device* pnd)
+ {
+- if ( !nfc_configure(pnd,NDO_HANDLE_CRC,true) )
++ if ( !nfc_device_set_property_bool(pnd,NP_HANDLE_CRC,true) )
+ {
+- //ERR("configuring NDO_HANDLE_CRC");
++ //ERR("configuring NP_HANDLE_CRC");
+ //return false;
+ }
+
+- if ( !nfc_configure(pnd,NDO_HANDLE_PARITY,true) )
++ if ( !nfc_device_set_property_bool(pnd,NP_HANDLE_PARITY,true) )
+ {
+- //ERR("configuring NDO_HANDLE_PARITY");
++ //ERR("configuring NP_HANDLE_PARITY");
+ //return false;
+ }
+
+ return true;
+ }
+
+-bool mfcuk_darkside_select_tag(nfc_device_t* pnd, int iSleepAtFieldOFF, int iSleepAfterFieldON, nfc_target_info_t* ti)
++bool mfcuk_darkside_select_tag(nfc_device* pnd, int iSleepAtFieldOFF, int iSleepAfterFieldON, nfc_target_info* ti)
+ {
+- nfc_target_t ti_tmp;
++ nfc_target ti_tmp;
+
+ if ( !pnd || !ti )
+ {
+@@ -888,9 +890,9 @@
+ }
+
+ // Drop the field for a while, so the card can reset
+- if ( !nfc_configure(pnd,NDO_ACTIVATE_FIELD,false) )
++ if ( !nfc_device_set_property_bool(pnd,NP_ACTIVATE_FIELD,false) )
+ {
+- ERR("configuring NDO_ACTIVATE_FIELD");
++ ERR("configuring NP_ACTIVATE_FIELD");
+ return false;
+ }
+
+@@ -898,29 +900,29 @@
+ sleep(iSleepAtFieldOFF);
+
+ // Let the reader only try once to find a tag
+- if ( !nfc_configure(pnd,NDO_INFINITE_SELECT,false) )
++ if ( !nfc_device_set_property_bool(pnd,NP_INFINITE_SELECT,false) )
+ {
+- ERR("configuring NDO_INFINITE_SELECT");
++ ERR("configuring NP_INFINITE_SELECT");
+ return false;
+ }
+
+ // Configure the CRC and Parity settings
+- if ( !nfc_configure(pnd,NDO_HANDLE_CRC,true) )
++ if ( !nfc_device_set_property_bool(pnd,NP_HANDLE_CRC,true) )
+ {
+- ERR("configuring NDO_HANDLE_CRC");
++ ERR("configuring NP_HANDLE_CRC");
+ return false;
+ }
+
+- if ( !nfc_configure(pnd,NDO_HANDLE_PARITY,true) )
++ if ( !nfc_device_set_property_bool(pnd,NP_HANDLE_PARITY,true) )
+ {
+- ERR("configuring NDO_HANDLE_PARITY");
++ ERR("configuring NP_HANDLE_PARITY");
+ return false;
+ }
+
+ // Enable field so more power consuming cards can power themselves up
+- if ( !nfc_configure(pnd,NDO_ACTIVATE_FIELD,true) )
++ if ( !nfc_device_set_property_bool(pnd,NP_ACTIVATE_FIELD,true) )
+ {
+- ERR("configuring NDO_ACTIVATE_FIELD");
++ ERR("configuring NP_ACTIVATE_FIELD");
+ return false;
+ }
+
+@@ -931,7 +933,7 @@
+ if (!nfc_initiator_select_passive_target(pnd, nmMifare,NULL,0,&ti_tmp))
+ {
+ ERR("connecting to MIFARE Classic tag");
+- //nfc_disconnect(pnd);
++ //nfc_close(pnd);
+ return false;
+ }
+
+@@ -946,15 +948,15 @@
+ int ch = 0;
+ char strOutputFilename[256] = {0}; // Initialize with '\0' character
+ //char extendedDescription[MFCUK_EXTENDED_DESCRIPTION_LENGTH] = {0}; // Initialize with '\0' character
+- byte_t keyOpt[MIFARE_CLASSIC_KEY_BYTELENGTH] = {0};
+- byte_t uidOpt[MIFARE_CLASSIC_UID_BYTELENGTH] = {0};
++ uint8_t keyOpt[MIFARE_CLASSIC_KEY_BYTELENGTH] = {0};
++ uint8_t uidOpt[MIFARE_CLASSIC_UID_BYTELENGTH] = {0};
+ mifare_classic_block_trailer *ptr_trailer = NULL;
+ mifare_classic_block_trailer *ptr_trailer_dump = NULL;
+ int sector = 0;
+ uint32_t block = 0;
+- byte_t action = 0;
+- byte_t specific_key_type = 0;
+- byte_t max_sectors = MIFARE_CLASSIC_4K_MAX_SECTORS;
++ uint8_t action = 0;
++ uint8_t specific_key_type = 0;
++ uint8_t max_sectors = MIFARE_CLASSIC_4K_MAX_SECTORS;
+ // Defaults, can be overriden by -S and -s command line arguments
+ int iSleepAtFieldOFF = SLEEP_AT_FIELD_OFF; // modified with argument -S
+ int iSleepAfterFieldON = SLEEP_AFTER_FIELD_ON; // modified with argument -s
+@@ -965,8 +967,8 @@
+ int iter = 0;
+
+ // libnfc related
+- nfc_device_t* pnd;
+- nfc_target_t ti;
++ nfc_device* pnd;
++ nfc_target ti;
+
+ // mifare and crapto related
+ uint32_t uiErrCode = MFCUK_SUCCESS;
+@@ -1004,7 +1006,7 @@
+ int i, j, k;
+ size_t st;
+ int numDefKeys = mfcuk_default_keys_num;
+- byte_t (*current_default_keys)[MIFARE_CLASSIC_KEY_BYTELENGTH];
++ uint8_t (*current_default_keys)[MIFARE_CLASSIC_KEY_BYTELENGTH];
+
+ // At runtime, duplicate the mfcuk_default_keys[], and then add at it's bottom the default keys specified via -d command line options
+ if ( !(current_default_keys = malloc(numDefKeys * MIFARE_CLASSIC_KEY_BYTELENGTH)) )
+@@ -1588,7 +1590,8 @@
+
+ // READER INITIALIZATION BLOCK
+ // Try to open the NFC reader
+- pnd = nfc_connect(NULL);
++ nfc_init(NULL);
++ pnd = nfc_open(NULL, NULL);
+
+ if (pnd == NULL)
+ {
+@@ -1598,18 +1601,20 @@
+
+ if ( !nfc_initiator_init(pnd) )
+ {
+- ERR("initializing NFC reader: %s", pnd->acName);
+- nfc_disconnect(pnd);
++ ERR("initializing NFC reader: %s", nfc_device_get_name(pnd));
++ nfc_close(pnd);
++ nfc_exit(NULL);
+ return 1;
+ }
+
+- printf("\nINFO: Connected to NFC reader: %s\n\n", pnd->acName);
++ printf("\nINFO: Connected to NFC reader: %s\n\n", nfc_device_get_name(pnd));
+
+ // Select tag and get tag info
+ if ( !mfcuk_darkside_select_tag(pnd, iSleepAtFieldOFF, iSleepAfterFieldON, &ti.nti) )
+ {
+- ERR("selecting tag on the reader %s", pnd->acName);
+- nfc_disconnect(pnd);
++ ERR("selecting tag on the reader %s", nfc_device_get_name(pnd));
++ nfc_close(pnd);
++ nfc_exit(NULL);
+ return 1;
+ }
+
+@@ -1654,13 +1659,13 @@
+ for (i=0; i<max_sectors; i++)
+ {
+ uint64_t crntVerifKey = 0;
+- byte_t crntVerifTagType = tag_recover_verify.type;
++ uint8_t crntVerifTagType = tag_recover_verify.type;
+ int crntNumVerifKeys = (bfOpts['D'])?(numDefKeys):(1);
+ mifare_param mp;
+
+ // Depending on which of keyA or keyB the j value is, the checks and actions below will address exactly that keyA or keyB of current sector
+- byte_t action_byte = ACTIONS_KEY_A + 2*(1 - (keyB-k));
+- byte_t result_byte = RESULTS_KEY_A + 2*(1 - (keyB-k));
++ uint8_t action_byte = ACTIONS_KEY_A + 2*(1 - (keyB-k));
++ uint8_t result_byte = RESULTS_KEY_A + 2*(1 - (keyB-k));
+
+ printf(" %x", i);
+ fflush(stdout);
+@@ -1691,7 +1696,8 @@
+ /*
+ // TODO: make this kind of key verification as part of option -a - advanced verification of keys with crapto1 rollback for double verification
+ // TEST
+- nfc_disconnect(pnd);
++ nfc_close(pnd);
++ nfc_exit(NULL);
+
+ // Try to open the NFC reader
+ pnd = nfc_connect(NULL);
+@@ -1705,7 +1711,8 @@
+ if ( !nfc_initiator_init(pnd) )
+ {
+ ERR("initializing NFC reader: %s", pnd->acName);
+- nfc_disconnect(pnd);
++ nfc_close(pnd);
++ nfc_exit(NULL);
+ return 1;
+ }
+ // TEST
+@@ -1775,8 +1782,8 @@
+ for (j=keyA; j<=keyB; j++)
+ {
+ // Depending on which of keyA or keyB the j value is, the checks and actions below will address exactly that keyA or keyB of current sector
+- byte_t action_byte = ACTIONS_KEY_A + 2*(1 - (keyB-j));
+- byte_t result_byte = RESULTS_KEY_A + 2*(1 - (keyB-j));
++ uint8_t action_byte = ACTIONS_KEY_A + 2*(1 - (keyB-j));
++ uint8_t result_byte = RESULTS_KEY_A + 2*(1 - (keyB-j));
+
+ // We have a sector and a key-type of that sector marked for recovery and still the key was not either verified nor recovered
+ if ( (ptr_trailer->abtAccessBits[action_byte] & ACTIONS_RECOVER) &&
+@@ -1789,10 +1796,10 @@
+
+ // TEST
+ // Before starting a new recovery session, disconnect and reconnect to reader and then tag
+- nfc_disconnect(pnd);
++ nfc_close(pnd);
+
+ // Try to open the NFC reader
+- pnd = nfc_connect(NULL);
++ pnd = nfc_open(NULL, NULL);
+
+ if (pnd == NULL)
+ {
+@@ -1802,8 +1809,9 @@
+
+ if ( !nfc_initiator_init(pnd) )
+ {
+- ERR("initializing NFC reader: %s", pnd->acName);
+- nfc_disconnect(pnd);
++ ERR("initializing NFC reader: %s", nfc_device_get_name(pnd));
++ nfc_close(pnd);
++ nfc_exit(NULL);
+ return 1;
+ }
+ // TEST
+@@ -1874,7 +1882,8 @@
+ */
+
+ // Clean up and release device
+- nfc_disconnect(pnd);
++ nfc_close(pnd);
++ nfc_exit(NULL);
+
+ // TODO: think which tag to output and make sure it contains all the retreived data
+ // TODO: make this as a function and call it after each key is verified or recovered (because of reader-locking bug)
+Index: src/nfc-utils.h
+===================================================================
+--- src/nfc-utils.h (revision 62)
++++ src/nfc-utils.h (working copy)
+@@ -79,22 +79,22 @@
+ # define ERR(...) warnx ("ERROR: " __VA_ARGS__ )
+ #endif
+
+-byte_t oddparity (const byte_t bt);
+-void oddparity_byte_ts (const byte_t * pbtData, const size_t szLen, byte_t * pbtPar);
++uint8_t oddparity (const uint8_t bt);
++void oddparity_uint8_ts (const uint8_t * pbtData, const size_t szLen, uint8_t * pbtPar);
+
+-void print_hex (const byte_t * pbtData, const size_t szLen);
+-void print_hex_bits (const byte_t * pbtData, const size_t szBits);
+-void print_hex_par (const byte_t * pbtData, const size_t szBits, const byte_t * pbtDataPar);
++void print_hex (const uint8_t * pbtData, const size_t szLen);
++void print_hex_bits (const uint8_t * pbtData, const size_t szBits);
++void print_hex_par (const uint8_t * pbtData, const size_t szBits, const uint8_t * pbtDataPar);
+
+-void print_nfc_iso14443a_info (const nfc_iso14443a_info_t nai, bool verbose);
+-void print_nfc_iso14443b_info (const nfc_iso14443b_info_t nbi, bool verbose);
+-void print_nfc_iso14443bi_info (const nfc_iso14443bi_info_t nii, bool verbose);
+-void print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info_t nsi, bool verbose);
+-void print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info_t nci, bool verbose);
+-void print_nfc_felica_info (const nfc_felica_info_t nfi, bool verbose);
+-void print_nfc_jewel_info (const nfc_jewel_info_t nji, bool verbose);
+-void print_nfc_dep_info (const nfc_dep_info_t ndi, bool verbose);
++void print_nfc_iso14443a_info (const nfc_iso14443a_info nai, bool verbose);
++void print_nfc_iso14443b_info (const nfc_iso14443b_info nbi, bool verbose);
++void print_nfc_iso14443bi_info (const nfc_iso14443bi_info nii, bool verbose);
++void print_nfc_iso14443b2sr_info (const nfc_iso14443b2sr_info nsi, bool verbose);
++void print_nfc_iso14443b2ct_info (const nfc_iso14443b2ct_info nci, bool verbose);
++void print_nfc_felica_info (const nfc_felica_info nfi, bool verbose);
++void print_nfc_jewel_info (const nfc_jewel_info nji, bool verbose);
++void print_nfc_dep_info (const nfc_dep_info ndi, bool verbose);
+
+-void print_nfc_target (const nfc_target_t nt, bool verbose);
++void print_nfc_target (const nfc_target nt, bool verbose);
+
+ #endif
+Index: src/mfcuk.h
+===================================================================
+--- src/mfcuk.h (revision 62)
++++ src/mfcuk.h (working copy)
+@@ -95,7 +95,7 @@
+ typedef struct tag_nonce_entry
+ {
+ uint32_t tagNonce; // Tag nonce we target for fixation
+- byte_t spoofFlag; // No spoofing until we have a successful auth with this tagNonce. Once we have, we want to spoof to get the encrypted 0x5 value
++ uint8_t spoofFlag; // No spoofing until we have a successful auth with this tagNonce. Once we have, we want to spoof to get the encrypted 0x5 value
+ uint32_t num_of_appearances; // For statistics, how many times this tag nonce appeared for the given SLEEP_ values
+
+ // STAGE1 data for "dark side" and lsfr_common_prefix()
+Index: src/mifare.c
+===================================================================
+--- src/mifare.c (revision 62)
++++ src/mifare.c (working copy)
+@@ -48,12 +48,12 @@
+ * The MIFARE Classic Specification (http://www.nxp.com/acrobat/other/identification/M001053_MF1ICS50_rev5_3.pdf) explains more about this process.
+ */
+ bool
+-nfc_initiator_mifare_cmd (nfc_device_t * pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param * pmp)
++nfc_initiator_mifare_cmd (nfc_device * pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param * pmp)
+ {
+- byte_t abtRx[265];
++ uint8_t abtRx[265];
+ size_t szRx = sizeof(abtRx);
+ size_t szParamLen;
+- byte_t abtCmd[265];
++ uint8_t abtCmd[265];
+ bool bEasyFraming;
+
+ abtCmd[0] = mc; // The MIFARE Classic command
+@@ -92,16 +92,16 @@
+
+ // When available, copy the parameter bytes
+ if (szParamLen)
+- memcpy (abtCmd + 2, (byte_t *) pmp, szParamLen);
++ memcpy (abtCmd + 2, (uint8_t *) pmp, szParamLen);
+
+- bEasyFraming = pnd->bEasyFraming;
+- if (!nfc_configure (pnd, NDO_EASY_FRAMING, true)) {
++ bEasyFraming = nfc_device_get_easy_framing(pnd);
++ if (!nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, true)) {
+ nfc_perror (pnd, "nfc_configure");
+ return false;
+ }
+ // Fire the mifare command
+- if (!nfc_initiator_transceive_bytes (pnd, abtCmd, 2 + szParamLen, abtRx, &szRx, NULL)) {
+- if (pnd->iLastError == EINVRXFRAM) {
++ if (!nfc_initiator_transceive_bytes (pnd, abtCmd, 2 + szParamLen, abtRx, &szRx, 0)) {
++ if (nfc_device_get_last_error(pnd) == NFC_EINVARG) {
+ // "Invalid received frame" AKA EINVRXFRAM, usual means we are
+ // authenticated on a sector but the requested MIFARE cmd (read, write)
+ // is not permitted by current acces bytes;
+@@ -109,10 +109,10 @@
+ } else {
+ nfc_perror (pnd, "nfc_initiator_transceive_bytes");
+ }
+- nfc_configure (pnd, NDO_EASY_FRAMING, bEasyFraming);
++ nfc_device_set_property_bool (pnd, NP_EASY_FRAMING, bEasyFraming);
+ return false;
+ }
+- if (!nfc_configure (pnd, NDO_EASY_FRAMING, bEasyFraming)) {
++ if (!nfc_device_set_property_bool (pnd, NP_EASY_FRAMING, bEasyFraming)) {
+ nfc_perror (pnd, "nfc_configure");
+ return false;
+ }
+Index: src/mifare.h
+===================================================================
+--- src/mifare.h (revision 62)
++++ src/mifare.h (working copy)
+@@ -38,7 +38,7 @@
+
+ # include <nfc/nfc-types.h>
+
+-// Compiler directive, set struct alignment to 1 byte_t for compatibility
++// Compiler directive, set struct alignment to 1 uint8_t for compatibility
+ # pragma pack(1)
+
+ typedef enum {
+@@ -54,16 +54,16 @@
+
+ // MIFARE command params
+ typedef struct {
+- byte_t abtKey[6];
+- byte_t abtUid[4];
++ uint8_t abtKey[6];
++ uint8_t abtUid[4];
+ } mifare_param_auth;
+
+ typedef struct {
+- byte_t abtData[16];
++ uint8_t abtData[16];
+ } mifare_param_data;
+
+ typedef struct {
+- byte_t abtValue[4];
++ uint8_t abtValue[4];
+ } mifare_param_value;
+
+ typedef union {
+@@ -75,28 +75,28 @@
+ // Reset struct alignment to default
+ # pragma pack()
+
+-bool nfc_initiator_mifare_cmd (nfc_device_t * pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param * pmp);
++bool nfc_initiator_mifare_cmd (nfc_device * pnd, const mifare_cmd mc, const uint8_t ui8Block, mifare_param * pmp);
+
+-// Compiler directive, set struct alignment to 1 byte_t for compatibility
++// Compiler directive, set struct alignment to 1 uint8_t for compatibility
+ # pragma pack(1)
+
+ // MIFARE Classic
+ typedef struct {
+- byte_t abtUID[4];
+- byte_t btBCC;
+- byte_t btUnknown;
+- byte_t abtATQA[2];
+- byte_t abtUnknown[8];
++ uint8_t abtUID[4];
++ uint8_t btBCC;
++ uint8_t btUnknown;
++ uint8_t abtATQA[2];
++ uint8_t abtUnknown[8];
+ } mifare_classic_block_manufacturer;
+
+ typedef struct {
+- byte_t abtData[16];
++ uint8_t abtData[16];
+ } mifare_classic_block_data;
+
+ typedef struct {
+- byte_t abtKeyA[6];
+- byte_t abtAccessBits[4];
+- byte_t abtKeyB[6];
++ uint8_t abtKeyA[6];
++ uint8_t abtAccessBits[4];
++ uint8_t abtKeyB[6];
+ } mifare_classic_block_trailer;
+
+ typedef union {
+@@ -111,17 +111,17 @@
+
+ // MIFARE Ultralight
+ typedef struct {
+- byte_t sn0[3];
+- byte_t btBCC0;
+- byte_t sn1[4];
+- byte_t btBCC1;
+- byte_t internal;
+- byte_t lock[2];
+- byte_t otp[4];
++ uint8_t sn0[3];
++ uint8_t btBCC0;
++ uint8_t sn1[4];
++ uint8_t btBCC1;
++ uint8_t internal;
++ uint8_t lock[2];
++ uint8_t otp[4];
+ } mifareul_block_manufacturer;
+
+ typedef struct {
+- byte_t abtData[16];
++ uint8_t abtData[16];
+ } mifareul_block_data;
+
+ typedef union {
+Index: src/mfcuk_mifare.c
+===================================================================
+--- src/mfcuk_mifare.c (revision 62)
++++ src/mfcuk_mifare.c (working copy)
+@@ -53,7 +53,7 @@
+ #include "mfcuk_mifare.h"
+
+ // Default keys used as a *BIG* mistake in many applications - especially System Integrators should pay attention!
+-byte_t mfcuk_default_keys[][MIFARE_CLASSIC_KEY_BYTELENGTH] =
++uint8_t mfcuk_default_keys[][MIFARE_CLASSIC_KEY_BYTELENGTH] =
+ {
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // Place-holder for current key to verify
+ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+@@ -68,7 +68,7 @@
+
+ int mfcuk_default_keys_num = sizeof(mfcuk_default_keys)/sizeof(mfcuk_default_keys[0]);
+
+-bool is_valid_block(byte_t bTagType, uint32_t uiBlock)
++bool is_valid_block(uint8_t bTagType, uint32_t uiBlock)
+ {
+ if ( IS_MIFARE_CLASSIC_1K(bTagType) && (uiBlock < MIFARE_CLASSIC_1K_MAX_BLOCKS) )
+ {
+@@ -83,7 +83,7 @@
+ return false;
+ }
+
+-bool is_valid_sector(byte_t bTagType, uint32_t uiSector)
++bool is_valid_sector(uint8_t bTagType, uint32_t uiSector)
+ {
+ if ( IS_MIFARE_CLASSIC_1K(bTagType) && (uiSector < MIFARE_CLASSIC_1K_MAX_SECTORS) )
+ {
+@@ -98,7 +98,7 @@
+ return false;
+ }
+
+-bool is_first_block(byte_t bTagType, uint32_t uiBlock)
++bool is_first_block(uint8_t bTagType, uint32_t uiBlock)
+ {
+ if ( !is_valid_block(bTagType, uiBlock) )
+ {
+@@ -121,7 +121,7 @@
+ return false;
+ }
+
+-bool is_trailer_block(byte_t bTagType, uint32_t uiBlock)
++bool is_trailer_block(uint8_t bTagType, uint32_t uiBlock)
+ {
+ if ( !is_valid_block(bTagType, uiBlock) )
+ {
+@@ -144,7 +144,7 @@
+ return false;
+ }
+
+-uint32_t get_first_block(byte_t bTagType, uint32_t uiBlock)
++uint32_t get_first_block(uint8_t bTagType, uint32_t uiBlock)
+ {
+ if ( !is_valid_block(bTagType, uiBlock) )
+ {
+@@ -167,7 +167,7 @@
+ return MIFARE_CLASSIC_INVALID_BLOCK;
+ }
+
+-uint32_t get_trailer_block(byte_t bTagType, uint32_t uiBlock)
++uint32_t get_trailer_block(uint8_t bTagType, uint32_t uiBlock)
+ {
+ if ( !is_valid_block(bTagType, uiBlock) )
+ {
+@@ -190,7 +190,7 @@
+ return MIFARE_CLASSIC_INVALID_BLOCK;
+ }
+
+-bool is_big_sector(byte_t bTagType, uint32_t uiSector)
++bool is_big_sector(uint8_t bTagType, uint32_t uiSector)
+ {
+ if ( !is_valid_sector(bTagType, uiSector) )
+ {
+@@ -205,7 +205,7 @@
+ return false;
+ }
+
+-uint32_t get_first_block_for_sector(byte_t bTagType, uint32_t uiSector)
++uint32_t get_first_block_for_sector(uint8_t bTagType, uint32_t uiSector)
+ {
+ if ( !is_valid_sector(bTagType, uiSector) )
+ {
+@@ -228,7 +228,7 @@
+ return MIFARE_CLASSIC_INVALID_BLOCK;
+ }
+
+-uint32_t get_trailer_block_for_sector(byte_t bTagType, uint32_t uiSector)
++uint32_t get_trailer_block_for_sector(uint8_t bTagType, uint32_t uiSector)
+ {
+ if ( !is_valid_sector(bTagType, uiSector) )
+ {
+@@ -251,7 +251,7 @@
+ return MIFARE_CLASSIC_INVALID_BLOCK;
+ }
+
+-uint32_t get_sector_for_block(byte_t bTagType, uint32_t uiBlock)
++uint32_t get_sector_for_block(uint8_t bTagType, uint32_t uiBlock)
+ {
+ if ( !is_valid_block(bTagType, uiBlock) )
+ {
+@@ -274,44 +274,44 @@
+ return MIFARE_CLASSIC_INVALID_BLOCK;
+ }
+
+-bool is_first_sector(byte_t bTagType, uint32_t uiSector)
++bool is_first_sector(uint8_t bTagType, uint32_t uiSector)
+ {
+ // TODO: write code
+ return false;
+ }
+
+-bool is_first_big_sector(byte_t bTagType, uint32_t uiSector)
++bool is_first_big_sector(uint8_t bTagType, uint32_t uiSector)
+ {
+ // TODO: write code
+ return false;
+ }
+
+-bool is_first_small_sector(byte_t bTagType, uint32_t uiSector)
++bool is_first_small_sector(uint8_t bTagType, uint32_t uiSector)
+ {
+ // TODO: write code
+ return false;
+ }
+
+-bool is_last_sector(byte_t bTagType, uint32_t uiSector)
++bool is_last_sector(uint8_t bTagType, uint32_t uiSector)
+ {
+ // TODO: write code
+ return false;
+ }
+
+-bool is_last_big_sector(byte_t bTagType, uint32_t uiSector)
++bool is_last_big_sector(uint8_t bTagType, uint32_t uiSector)
+ {
+ // TODO: write code
+ return false;
+ }
+
+-bool is_last_small_sector(byte_t bTagType, uint32_t uiSector)
++bool is_last_small_sector(uint8_t bTagType, uint32_t uiSector)
+ {
+ // TODO: write code
+ return false;
+ }
+
+ // Test case function for checking correct functionality of the block/sector is_ ang get_ functions
+-void test_mifare_classic_blocks_sectors_functions(byte_t bTagType)
++void test_mifare_classic_blocks_sectors_functions(uint8_t bTagType)
+ {
+ uint32_t i;
+ uint32_t max_blocks, max_sectors;
+@@ -460,7 +460,7 @@
+ void print_mifare_classic_tag_keys(const char *title, mifare_classic_tag *tag)
+ {
+ uint32_t i, max_blocks, trailer_block;
+- byte_t bTagType;
++ uint8_t bTagType;
+ mifare_classic_block_trailer *ptr_trailer = NULL;
+
+ if (!tag)
+@@ -521,7 +521,7 @@
+ return;
+ }
+
+-bool mfcuk_key_uint64_to_arr(const uint64_t *ui64Key, byte_t *arr6Key)
++bool mfcuk_key_uint64_to_arr(const uint64_t *ui64Key, uint8_t *arr6Key)
+ {
+ int i;
+
+@@ -532,13 +532,13 @@
+
+ for (i = 0; i<MIFARE_CLASSIC_KEY_BYTELENGTH; i++)
+ {
+- arr6Key[i] = (byte_t) (((*ui64Key) >> 8*(MIFARE_CLASSIC_KEY_BYTELENGTH - i - 1)) & 0xFF);
++ arr6Key[i] = (uint8_t) (((*ui64Key) >> 8*(MIFARE_CLASSIC_KEY_BYTELENGTH - i - 1)) & 0xFF);
+ }
+
+ return true;
+ }
+
+-bool mfcuk_key_arr_to_uint64(const byte_t *arr6Key, uint64_t *ui64Key)
++bool mfcuk_key_arr_to_uint64(const uint8_t *arr6Key, uint64_t *ui64Key)
+ {
+ uint64_t key = 0;
+ int i;
+Index: src/mfcuk_mifare.h
+===================================================================
+--- src/mfcuk_mifare.h (revision 62)
++++ src/mfcuk_mifare.h (working copy)
+@@ -101,7 +101,7 @@
+ // Define an extended type of dump, basically a wrapper dump around basic tag dump
+ typedef struct {
+ uint32_t uid; // looks redundant, but it is easier to use dmp.uid instead of dmp.amb.mbm.abtUID[0]...[3]
+- byte_t type; // ATS/SAK from ti.tia.btSak, example 0x08h for Mifare 1K, 0x18h for Mifare 4K
++ uint8_t type; // ATS/SAK from ti.tia.btSak, example 0x08h for Mifare 1K, 0x18h for Mifare 4K
+ char datetime[14]; // non-zero-terminated date-time of dump in format YYYYMMDDH24MISS, example 20091114231541 - 14 Nov 2009, 11:15:41 PM
+ char description[MFCUK_EXTENDED_DESCRIPTION_LENGTH]; // a description of the tag dump, example "RATB_DUMP_BEFORE_PAY"
+ mifare_classic_tag tag_basic;
+@@ -114,32 +114,32 @@
+ } mifare_key_type;
+
+ // Default keys used as a *BIG* mistake in many applications - especially System Integrators should pay attention!
+-extern byte_t mfcuk_default_keys[][MIFARE_CLASSIC_KEY_BYTELENGTH];
++extern uint8_t mfcuk_default_keys[][MIFARE_CLASSIC_KEY_BYTELENGTH];
+ extern int mfcuk_default_keys_num;
+
+-bool is_valid_block(byte_t bTagType, uint32_t uiBlock);
+-bool is_valid_sector(byte_t bTagType, uint32_t uiSector);
+-bool is_first_block(byte_t bTagType, uint32_t uiBlock);
+-bool is_trailer_block(byte_t bTagType, uint32_t uiBlock);
+-uint32_t get_first_block(byte_t bTagType, uint32_t uiBlock);
+-uint32_t get_trailer_block(byte_t bTagType, uint32_t uiBlock);
+-bool is_big_sector(byte_t bTagType, uint32_t uiSector);
+-uint32_t get_first_block_for_sector(byte_t bTagType, uint32_t uiSector);
+-uint32_t get_trailer_block_for_sector(byte_t bTagType, uint32_t uiSector);
+-uint32_t get_sector_for_block(byte_t bTagType, uint32_t uiBlock);
+-bool is_first_sector(byte_t bTagType, uint32_t uiSector);
+-bool is_first_big_sector(byte_t bTagType, uint32_t uiSector);
+-bool is_first_small_sector(byte_t bTagType, uint32_t uiSector);
+-bool is_last_sector(byte_t bTagType, uint32_t uiSector);
+-bool is_last_big_sector(byte_t bTagType, uint32_t uiSector);
+-bool is_last_small_sector(byte_t bTagType, uint32_t uiSector);
+-void test_mifare_classic_blocks_sectors_functions(byte_t bTagType);
++bool is_valid_block(uint8_t bTagType, uint32_t uiBlock);
++bool is_valid_sector(uint8_t bTagType, uint32_t uiSector);
++bool is_first_block(uint8_t bTagType, uint32_t uiBlock);
++bool is_trailer_block(uint8_t bTagType, uint32_t uiBlock);
++uint32_t get_first_block(uint8_t bTagType, uint32_t uiBlock);
++uint32_t get_trailer_block(uint8_t bTagType, uint32_t uiBlock);
++bool is_big_sector(uint8_t bTagType, uint32_t uiSector);
++uint32_t get_first_block_for_sector(uint8_t bTagType, uint32_t uiSector);
++uint32_t get_trailer_block_for_sector(uint8_t bTagType, uint32_t uiSector);
++uint32_t get_sector_for_block(uint8_t bTagType, uint32_t uiBlock);
++bool is_first_sector(uint8_t bTagType, uint32_t uiSector);
++bool is_first_big_sector(uint8_t bTagType, uint32_t uiSector);
++bool is_first_small_sector(uint8_t bTagType, uint32_t uiSector);
++bool is_last_sector(uint8_t bTagType, uint32_t uiSector);
++bool is_last_big_sector(uint8_t bTagType, uint32_t uiSector);
++bool is_last_small_sector(uint8_t bTagType, uint32_t uiSector);
++void test_mifare_classic_blocks_sectors_functions(uint8_t bTagType);
+ bool mfcuk_save_tag_dump(char *filename, mifare_classic_tag *tag);
+ bool mfcuk_save_tag_dump_ext(char *filename, mifare_classic_tag_ext *tag_ext);
+ bool mfcuk_load_tag_dump(char *filename, mifare_classic_tag *tag);
+ bool mfcuk_load_tag_dump_ext(char *filename, mifare_classic_tag_ext *tag_ext);
+ void print_mifare_classic_tag_keys(const char *title, mifare_classic_tag *tag);
+-bool mfcuk_key_uint64_to_arr(const uint64_t *ui64Key, byte_t *arr6Key);
+-bool mfcuk_key_arr_to_uint64(const byte_t *arr6Key, uint64_t *ui64Key);
++bool mfcuk_key_uint64_to_arr(const uint64_t *ui64Key, uint8_t *arr6Key);
++bool mfcuk_key_arr_to_uint64(const uint8_t *arr6Key, uint64_t *ui64Key);
+
+ #endif // _MFCUK_MIFARE_H_
diff --git a/dev-util/mfcuk/mfcuk-9999.ebuild b/dev-util/mfcuk/mfcuk-9999.ebuild
new file mode 100644
index 0000000..fe45531
--- /dev/null
+++ b/dev-util/mfcuk/mfcuk-9999.ebuild
@@ -0,0 +1,29 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+EAPI="2"
+
+inherit eutils subversion autotools
+
+DESCRIPTION="MiFare Classic Universal toolKit"
+HOMEPAGE="http://code.google.com/p/mfcuk/"
+ESVN_REPO_URI="http://mfcuk.googlecode.com/svn/trunk/"
+ESVN_PROJECT="mfuck"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~x86 ~amd64"
+
+CDEPEND=">=dev-libs/libnfc-1.5.1"
+RDEPEND="${CDEPEND}"
+
+src_prepare() {
+ epatch "${FILESDIR}/mfcuk-new-libnfc-version.patch"
+ eautoreconf || die "autoreconf failed"
+}
+
+src_install() {
+ emake DESTDIR="${D}" install || die "Install failed"
+ dodoc README ChangeLog AUTHORS NEWS TODO || die
+}