2011-09-05 16:40:56 +02:00
|
|
|
/*-
|
|
|
|
* Public platform independent Near Field Communication (NFC) library examples
|
2012-05-29 02:33:22 +02:00
|
|
|
*
|
2012-10-21 16:09:16 +02:00
|
|
|
* Copyright (C) 2009 Roel Verdult
|
|
|
|
* Copyright (C) 2011 Adam Laurie
|
2012-05-29 02:33:22 +02:00
|
|
|
*
|
2011-09-05 16:40:56 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
* 1) Redistributions of source code must retain the above copyright notice,
|
2012-05-29 02:33:22 +02:00
|
|
|
* this list of conditions and the following disclaimer.
|
2011-09-05 16:40:56 +02:00
|
|
|
* 2 )Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
2012-05-29 02:33:22 +02:00
|
|
|
*
|
2011-09-05 16:40:56 +02:00
|
|
|
* Note that this license only applies on the examples, NFC library itself is under LGPL
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-05-29 02:33:22 +02:00
|
|
|
/**
|
2011-09-05 16:40:56 +02:00
|
|
|
* @file nfc-mfsetuid.c
|
|
|
|
* @brief Set UID of special Mifare cards
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* based on nfc-anticol.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <nfc/nfc.h>
|
|
|
|
|
2012-05-17 21:22:25 +02:00
|
|
|
#include "utils/nfc-utils.h"
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
#define SAK_FLAG_ATS_SUPPORTED 0x20
|
|
|
|
|
|
|
|
#define MAX_FRAME_LEN 264
|
|
|
|
|
2011-11-24 11:54:42 +01:00
|
|
|
static uint8_t abtRx[MAX_FRAME_LEN];
|
2012-01-04 16:30:42 +01:00
|
|
|
static int szRxBits;
|
2011-11-24 11:54:42 +01:00
|
|
|
static uint8_t abtRawUid[12];
|
|
|
|
static uint8_t abtAtqa[2];
|
|
|
|
static uint8_t abtSak;
|
|
|
|
static uint8_t abtAts[MAX_FRAME_LEN];
|
|
|
|
static uint8_t szAts = 0;
|
2011-09-05 16:40:56 +02:00
|
|
|
static size_t szCL = 1;//Always start with Cascade Level 1 (CL1)
|
2011-11-23 16:55:40 +01:00
|
|
|
static nfc_device *pnd;
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
bool quiet_output = false;
|
|
|
|
bool iso_ats_supported = false;
|
|
|
|
|
|
|
|
// ISO14443A Anti-Collision Commands
|
2011-11-24 11:54:42 +01:00
|
|
|
uint8_t abtReqa[1] = { 0x26 };
|
|
|
|
uint8_t abtSelectAll[2] = { 0x93, 0x20 };
|
|
|
|
uint8_t abtSelectTag[9] = { 0x93, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
uint8_t abtRats[4] = { 0xe0, 0x50, 0x00, 0x00 };
|
|
|
|
uint8_t abtHalt[4] = { 0x50, 0x00, 0x00, 0x00 };
|
2011-09-05 16:40:56 +02:00
|
|
|
#define CASCADE_BIT 0x04
|
|
|
|
|
|
|
|
// special unlock command
|
2011-11-24 11:54:42 +01:00
|
|
|
uint8_t abtUnlock1[1] = { 0x40 };
|
|
|
|
uint8_t abtUnlock2[1] = { 0x43 };
|
|
|
|
uint8_t abtWipe[1] = { 0x41 };
|
|
|
|
uint8_t abtWrite[4] = { 0xa0, 0x00, 0x5f, 0xb1 };
|
|
|
|
uint8_t abtData[18] = { 0x01, 0x23, 0x45, 0x67, 0x00, 0x08, 0x04, 0x00, 0x46, 0x59, 0x25, 0x58, 0x49, 0x10, 0x23, 0x02, 0x23, 0xeb };
|
|
|
|
uint8_t abtBlank[18] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x80, 0x69, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x36, 0xCC };
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
static bool
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bits(const uint8_t *pbtTx, const size_t szTxBits)
|
2011-09-05 16:40:56 +02:00
|
|
|
{
|
|
|
|
// Show transmitted command
|
|
|
|
if (!quiet_output) {
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Sent bits: ");
|
|
|
|
print_hex_bits(pbtTx, szTxBits);
|
2011-09-05 16:40:56 +02:00
|
|
|
}
|
|
|
|
// Transmit the bit frame command, we don't use the arbitrary parity feature
|
2012-05-29 17:54:36 +02:00
|
|
|
if ((szRxBits = nfc_initiator_transceive_bits(pnd, pbtTx, szTxBits, NULL, abtRx, NULL)) < 0)
|
2011-09-05 16:40:56 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// Show received answer
|
|
|
|
if (!quiet_output) {
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Received bits: ");
|
|
|
|
print_hex_bits(abtRx, szRxBits);
|
2011-09-05 16:40:56 +02:00
|
|
|
}
|
|
|
|
// Succesful transfer
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bytes(const uint8_t *pbtTx, const size_t szTx)
|
2011-09-05 16:40:56 +02:00
|
|
|
{
|
|
|
|
// Show transmitted command
|
|
|
|
if (!quiet_output) {
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Sent bits: ");
|
|
|
|
print_hex(pbtTx, szTx);
|
2011-09-05 16:40:56 +02:00
|
|
|
}
|
2012-05-27 23:06:22 +02:00
|
|
|
int res;
|
2011-09-05 16:40:56 +02:00
|
|
|
// Transmit the command bytes
|
2012-05-29 17:54:36 +02:00
|
|
|
if ((res = nfc_initiator_transceive_bytes(pnd, pbtTx, szTx, abtRx, sizeof(abtRx), 0)) < 0)
|
2011-09-05 16:40:56 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// Show received answer
|
|
|
|
if (!quiet_output) {
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Received bits: ");
|
|
|
|
print_hex(abtRx, res);
|
2011-09-05 16:40:56 +02:00
|
|
|
}
|
|
|
|
// Succesful transfer
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-29 17:54:36 +02:00
|
|
|
print_usage(char *argv[])
|
2011-09-05 16:40:56 +02:00
|
|
|
{
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Usage: %s [OPTIONS] [UID]\n", argv[0]);
|
|
|
|
printf("Options:\n");
|
|
|
|
printf("\t-h\tHelp. Print this message.\n");
|
|
|
|
printf("\t-f\tFormat. Delete all data (set to 0xFF) and reset ACLs to default.\n");
|
|
|
|
printf("\t-q\tQuiet mode. Suppress output of READER and CARD data (improves timing).\n");
|
|
|
|
printf("\n\tSpecify UID (4 HEX bytes) to set UID, or leave blank for default '01234567'.\n");
|
|
|
|
printf("\tThis utility can be used to recover cards that have been damaged by writing bad\n");
|
|
|
|
printf("\tdata (e.g. wrong BCC), thus making them non-selectable by most tools/readers.\n");
|
|
|
|
printf("\n\t*** Note: this utility only works with special Mifare 1K cards (Chinese clones).\n\n");
|
2011-09-05 16:40:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-05-29 17:54:36 +02:00
|
|
|
main(int argc, char *argv[])
|
2011-09-05 16:40:56 +02:00
|
|
|
{
|
2011-09-06 23:17:38 +02:00
|
|
|
int arg, i;
|
2012-05-29 17:54:00 +02:00
|
|
|
bool format = false;
|
2011-09-05 16:40:56 +02:00
|
|
|
unsigned int c;
|
2012-05-29 17:54:00 +02:00
|
|
|
char tmp[3] = { 0x00, 0x00, 0x00 };
|
2011-09-06 23:17:38 +02:00
|
|
|
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
// Get commandline options
|
|
|
|
for (arg = 1; arg < argc; arg++) {
|
2012-05-29 17:54:36 +02:00
|
|
|
if (0 == strcmp(argv[arg], "-h")) {
|
|
|
|
print_usage(argv);
|
2011-09-05 16:40:56 +02:00
|
|
|
exit(EXIT_SUCCESS);
|
2012-05-29 17:54:36 +02:00
|
|
|
} else if (0 == strcmp(argv[arg], "-f")) {
|
2012-05-29 17:54:00 +02:00
|
|
|
format = true;
|
2012-05-29 17:54:36 +02:00
|
|
|
} else if (0 == strcmp(argv[arg], "-q")) {
|
2011-09-05 16:40:56 +02:00
|
|
|
quiet_output = true;
|
|
|
|
} else if (strlen(argv[arg]) == 8) {
|
2012-05-29 17:54:36 +02:00
|
|
|
for (i = 0 ; i < 4 ; ++i) {
|
2012-05-29 17:54:00 +02:00
|
|
|
memcpy(tmp, argv[arg] + i * 2, 2);
|
2012-05-29 17:52:51 +02:00
|
|
|
sscanf(tmp, "%02x", &c);
|
2012-05-29 17:54:00 +02:00
|
|
|
abtData[i] = (char) c;
|
2012-05-29 17:52:51 +02:00
|
|
|
}
|
2012-05-29 17:54:00 +02:00
|
|
|
abtData[4] = abtData[0] ^ abtData[1] ^ abtData[2] ^ abtData[3];
|
2012-05-29 17:54:36 +02:00
|
|
|
iso14443a_crc_append(abtData, 16);
|
2011-09-05 16:40:56 +02:00
|
|
|
} else {
|
2012-05-29 17:54:36 +02:00
|
|
|
ERR("%s is not supported option.", argv[arg]);
|
|
|
|
print_usage(argv);
|
2011-09-05 16:40:56 +02:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-29 17:54:36 +02:00
|
|
|
nfc_init(NULL);
|
2012-05-29 02:33:22 +02:00
|
|
|
|
2011-09-05 16:40:56 +02:00
|
|
|
// Try to open the NFC reader
|
2012-05-29 17:54:36 +02:00
|
|
|
pnd = nfc_open(NULL, NULL);
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
if (!pnd) {
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("Error opening NFC reader\n");
|
2011-09-05 16:40:56 +02:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialise NFC device as "initiator"
|
2012-05-29 17:54:36 +02:00
|
|
|
if (nfc_initiator_init(pnd) < 0) {
|
|
|
|
nfc_perror(pnd, "nfc_initiator_init");
|
|
|
|
exit(EXIT_FAILURE);
|
2012-01-05 11:33:50 +01:00
|
|
|
}
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
// Configure the CRC
|
2012-05-29 17:54:36 +02:00
|
|
|
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
|
|
|
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
|
|
|
exit(EXIT_FAILURE);
|
2011-09-05 16:40:56 +02:00
|
|
|
}
|
|
|
|
// Use raw send/receive methods
|
2012-05-29 17:54:36 +02:00
|
|
|
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false) < 0) {
|
|
|
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
|
|
|
exit(EXIT_FAILURE);
|
2011-09-05 16:40:56 +02:00
|
|
|
}
|
|
|
|
// Disable 14443-4 autoswitching
|
2012-05-29 17:54:36 +02:00
|
|
|
if (nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false) < 0) {
|
|
|
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
|
|
|
exit(EXIT_FAILURE);
|
2011-09-05 16:40:56 +02:00
|
|
|
}
|
|
|
|
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
// Send the 7 bits request command specified in ISO 14443A (0x26)
|
2012-05-29 17:54:36 +02:00
|
|
|
if (!transmit_bits(abtReqa, 7)) {
|
|
|
|
printf("Error: No tag available\n");
|
|
|
|
nfc_close(pnd);
|
|
|
|
nfc_exit(NULL);
|
2011-09-05 16:40:56 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtAtqa, abtRx, 2);
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
// Anti-collision
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bytes(abtSelectAll, 2);
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
// Check answer
|
|
|
|
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
|
|
|
|
printf("WARNING: BCC check failed!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save the UID CL1
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtRawUid, abtRx, 4);
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
//Prepare and send CL1 Select-Command
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtSelectTag + 2, abtRx, 5);
|
|
|
|
iso14443a_crc_append(abtSelectTag, 7);
|
|
|
|
transmit_bytes(abtSelectTag, 9);
|
2011-09-05 16:40:56 +02:00
|
|
|
abtSak = abtRx[0];
|
|
|
|
|
|
|
|
// Test if we are dealing with a CL2
|
|
|
|
if (abtSak & CASCADE_BIT) {
|
|
|
|
szCL = 2;//or more
|
|
|
|
// Check answer
|
|
|
|
if (abtRawUid[0] != 0x88) {
|
|
|
|
printf("WARNING: Cascade bit set but CT != 0x88!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-29 17:54:36 +02:00
|
|
|
if (szCL == 2) {
|
2011-09-05 16:40:56 +02:00
|
|
|
// We have to do the anti-collision for cascade level 2
|
|
|
|
|
|
|
|
// Prepare CL2 commands
|
|
|
|
abtSelectAll[0] = 0x95;
|
|
|
|
|
|
|
|
// Anti-collision
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bytes(abtSelectAll, 2);
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
// Check answer
|
|
|
|
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
|
|
|
|
printf("WARNING: BCC check failed!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save UID CL2
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtRawUid + 4, abtRx, 4);
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
// Selection
|
|
|
|
abtSelectTag[0] = 0x95;
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtSelectTag + 2, abtRx, 5);
|
|
|
|
iso14443a_crc_append(abtSelectTag, 7);
|
|
|
|
transmit_bytes(abtSelectTag, 9);
|
2011-09-05 16:40:56 +02:00
|
|
|
abtSak = abtRx[0];
|
|
|
|
|
|
|
|
// Test if we are dealing with a CL3
|
|
|
|
if (abtSak & CASCADE_BIT) {
|
|
|
|
szCL = 3;
|
|
|
|
// Check answer
|
|
|
|
if (abtRawUid[0] != 0x88) {
|
|
|
|
printf("WARNING: Cascade bit set but CT != 0x88!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-29 17:54:36 +02:00
|
|
|
if (szCL == 3) {
|
2011-09-05 16:40:56 +02:00
|
|
|
// We have to do the anti-collision for cascade level 3
|
|
|
|
|
|
|
|
// Prepare and send CL3 AC-Command
|
|
|
|
abtSelectAll[0] = 0x97;
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bytes(abtSelectAll, 2);
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
// Check answer
|
|
|
|
if ((abtRx[0] ^ abtRx[1] ^ abtRx[2] ^ abtRx[3] ^ abtRx[4]) != 0) {
|
|
|
|
printf("WARNING: BCC check failed!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save UID CL3
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtRawUid + 8, abtRx, 4);
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
// Prepare and send final Select-Command
|
|
|
|
abtSelectTag[0] = 0x97;
|
2012-05-29 17:54:36 +02:00
|
|
|
memcpy(abtSelectTag + 2, abtRx, 5);
|
|
|
|
iso14443a_crc_append(abtSelectTag, 7);
|
|
|
|
transmit_bytes(abtSelectTag, 9);
|
2011-09-05 16:40:56 +02:00
|
|
|
abtSak = abtRx[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Request ATS, this only applies to tags that support ISO 14443A-4
|
|
|
|
if (abtRx[0] & SAK_FLAG_ATS_SUPPORTED) {
|
2012-05-29 17:52:51 +02:00
|
|
|
iso_ats_supported = true;
|
2011-09-05 16:40:56 +02:00
|
|
|
}
|
|
|
|
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("\nFound tag with\n UID: ");
|
2011-09-05 16:40:56 +02:00
|
|
|
switch (szCL) {
|
|
|
|
case 1:
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("%02x%02x%02x%02x", abtRawUid[0], abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
2012-05-29 17:52:51 +02:00
|
|
|
break;
|
2011-09-05 16:40:56 +02:00
|
|
|
case 2:
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
|
|
|
printf("%02x%02x%02x%02x", abtRawUid[4], abtRawUid[5], abtRawUid[6], abtRawUid[7]);
|
2012-05-29 17:52:51 +02:00
|
|
|
break;
|
2011-09-05 16:40:56 +02:00
|
|
|
case 3:
|
2012-05-29 17:54:36 +02:00
|
|
|
printf("%02x%02x%02x", abtRawUid[1], abtRawUid[2], abtRawUid[3]);
|
|
|
|
printf("%02x%02x%02x", abtRawUid[5], abtRawUid[6], abtRawUid[7]);
|
|
|
|
printf("%02x%02x%02x%02x", abtRawUid[8], abtRawUid[9], abtRawUid[10], abtRawUid[11]);
|
2012-05-29 17:52:51 +02:00
|
|
|
break;
|
2011-09-05 16:40:56 +02:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
printf("ATQA: %02x%02x\n SAK: %02x\n", abtAtqa[1], abtAtqa[0], abtSak);
|
|
|
|
if (szAts > 1) { // if = 1, it's not actual ATS but error code
|
2012-05-29 17:52:51 +02:00
|
|
|
printf(" ATS: ");
|
2012-05-29 17:54:36 +02:00
|
|
|
print_hex(abtAts, szAts);
|
2011-09-05 16:40:56 +02:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
// now reset UID
|
|
|
|
iso14443a_crc_append(abtHalt, 2);
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bytes(abtHalt, 4);
|
|
|
|
transmit_bits(abtUnlock1, 7);
|
|
|
|
if (format) {
|
|
|
|
transmit_bytes(abtWipe, 1);
|
|
|
|
transmit_bytes(abtHalt, 4);
|
|
|
|
transmit_bits(abtUnlock1, 7);
|
2011-09-06 23:17:38 +02:00
|
|
|
}
|
2012-05-29 17:54:36 +02:00
|
|
|
transmit_bytes(abtUnlock2, 1);
|
|
|
|
transmit_bytes(abtWrite, 4);
|
|
|
|
transmit_bytes(abtData, 18);
|
|
|
|
if (format) {
|
|
|
|
for (i = 3 ; i < 64 ; i += 4) {
|
2012-05-29 17:54:00 +02:00
|
|
|
abtWrite[1] = (char) i;
|
2012-05-29 17:54:36 +02:00
|
|
|
iso14443a_crc_append(abtWrite, 2);
|
|
|
|
transmit_bytes(abtWrite, 4);
|
|
|
|
transmit_bytes(abtBlank, 18);
|
2011-09-06 23:17:38 +02:00
|
|
|
}
|
|
|
|
}
|
2011-09-05 16:40:56 +02:00
|
|
|
|
|
|
|
|
2012-05-29 17:54:36 +02:00
|
|
|
nfc_close(pnd);
|
|
|
|
nfc_exit(NULL);
|
2011-09-05 16:40:56 +02:00
|
|
|
return 0;
|
|
|
|
}
|