nfc,smartcard,mifare,ndef,pcsc , How to read binary blocks of mifare card?


How to read binary blocks of mifare card?

Question:

Tag: nfc,smartcard,mifare,ndef,pcsc

I develop application which read NFC card from the reader. I know the code for read binary block like this:

FF B0 00 04 10

04 for the block 4 and 10 for 16 bytes data. My card has the data "TEST009996". I run 5 code for read binary blocks from 4-8 like this:

FF B0 00 04 10
FF B0 00 05 10
FF B0 00 06 10
FF B0 00 07 10
FF B0 00 08 10

I got following result:

T☻enTEÉ ☺
T☻enTEST00É
T☻enTEST009996É
enTEST009996■  6É
ST009996■  6    É

or in hexadecimal:

01 03 A0 10 44 03 11 D1 01 0D 54 02 65 6E 48 43 90 00
44 03 11 D1 01 0D 54 02 65 6E 48 43 49 44 30 30 90 00
01 0D 54 02 65 6E 48 43 49 44 30 30 39 39 39 36 90 00
65 6E 48 43 49 44 30 30 39 39 39 36 FE 00 00 36 90 00
49 44 30 30 39 39 39 36 FE 00 00 36 00 00 00 00 90 00

Should i create algorithm to cut the result to get the data? is there any better ways?


Source:

http://downloads.acs.com.hk/drivers/en/API-ACR122U-2.02.pdf


Answer:

So it seems that your tag is an NFC Forum Type 2 tag (find the NFC Forum Type 2 Tag Operation specification on the NFC Forum website). As you mentiion MIFARE this could, for instance, be a MIFARE Ultralight, MIFARE Ultralight C or NTAG tag.

A block on a Type 2 tag consists of 4 bytes. The read command reads 4 blocks at a time. So the read command gives you 4 blocks (4 bytes each) starting at a given block offset plus a status word for the read command (0x9000 for success). In your case you get

Read(4, 16): 0103A010 440311D1 010D5402 656E4843 9000
Read(5, 16):          440311D1 010D5402 656E4843 49443030 9000
Read(6, 16):                   010D5402 656E4843 49443030 39393936 9000
Read(7, 16):                            656E4843 49443030 39393936 FE000036 9000
Read(8, 16):                                     49443030 39393936 FE000036 00000000 9000

Consequently, the memory of your tag looks like this:

0103A010 
440311D1
010D5402
656E4843
49443030
39393936
FE000036
00000000

A Type 2 Tag (btw. in order to make sure that this tag actually conforms to the Type 2 Tag Operation Specification you would also need to read the capability container which is located in block 3) contains a series of tag-length-value (TLV) structures:

01 (Tag: Lock Control TLV)
  03 (Length: 3 bytes)
  A0 10 44 (Value: Information on position and function of lock bytes)
03 (Tag: NDEF Message TLV)
  11 (Length: 17 bytes)
  D1010D5402656E48434944303039393936 (Value: NDEF message)
FE (Tag: Terminator TLV; has no length field)

So your tag contains the NDEF message

D1010D5402656E48434944303039393936

This translates to

D1 (Header byte of record 1)
    - Message begin is set (= first record of an NDEF message)
    - Message end is set (= last record of an NDEF message)
    - Short record flag is set (= Payload length field consists of 1 byte only)
    - Type Name Format = 0x1 (= Type field contains an NFC Forum well-known type)
  01 (Type length: 1 byte)
  0D (Payload length: 13 bytes)
  54 (Type: "T")
  02656E48434944303039393936 (Payload field)

The payload field of a NFC Forum Text record decodes like this:

02 (Status byte: Text is UTF-8 encoded, Language code has a length of 2 bytes)
656E (Language code: "en")
48434944303039393936 (Text: "TEST009996")

Related:


How to remove a `tag listener` in Phonegap NFC plugin


cordova,callback,phonegap-plugins,nfc
I am using chariotsolution's nfc plugin for phonegap (https://github.com/chariotsolutions/phonegap-nfc) and it's all working perfect until the time came that I needed to remove a listener. I can't do it and it seems like it's not working. My question is, is this a common bug? Has anyone ever tried to remove...

Can't Read data (payload) from non-NDEF tag


android,cordova,phonegap-plugins,nfc
I'm using Phonegap-nfc plugin I'm trying to read data (payload) from my non-NDEF NFC card. the only ACTION that is triggered is ACTION_TAG_DISCOVERED and i only can read the tag_info. the tag's techs are NfcB and IsoDep nfc_tech_filter.xml <tech-list> <tech>android.nfc.tech.NfcB</tech> <tech>android.nfc.tech.IsoDep</tech> </tech-list> NfcReader/AndroidManifest.xml <intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED" /> <action...

NFC reader writer


nfc,rfid
NFC reader - Yesterday i got NFC reader programmer with label U F R Classic reader and have a problem. I cant find documentation about this reader. Can someone help me?

How do I progammatically play the Android NFC notification sound?


android,audio,nfc
I have an app (NFC Sniffer) which allows users to read NFC tags. When a user attempts to read a tag, 1 of 3 things happens: Nothing, the tag was not brought close enough Detected NFC, but fails to read card, in which case a notification tone is played. Reads...

NFC SWP applet selection returns 6999


android,nfc,smartcard,javacard,sim-card
I have a simple JavaCard applet installed on my SIM card. I try to communicate with my applet using Omnikey 5121 CL reader and NFC-enabled Sony Xperia L through NFC/SWP (single wire protocol). The problem is I cannot select the applet - as a status word I get 6999. The...

How can I extract an X509 certificate from a smart card using Java?


java,smartcard
I use the OmniKey 3121 reader and can use the javax.smartcardio API to send APDU commands to the card reader. I'm not sure if there is a standard way to access the certificate stored on the card. Pointers to example code to read the certificate data would greatly help. Also,...

Start an Android App when an “unknown tag type” is scanned


android,embedded,nfc,spi
I am working on an Android NFC reader project in which I use the AS3953 NFC chip. according to the datasheet: This NFC chip could be used Where log data is stored periodically by the microcontroller and can then be read by the PCD even when the microcontroller is not...

I got 0x9E parameter error while Credit value file on DESFire card


android,nfc,mifare,apdu,contactless-smartcard
I now work with value files on DESFire cards. I created a value file in my DESFire card with the following command: byte[] cmdCreateValueFile = new byte[]{ //cmd (byte)0xCC, //file no (byte)0x01, //com.sett. (byte)0x00 , //access rights (byte)0x44 , (byte)0x44, //lower limit (byte)0x00 ,(byte)0x00 ,(byte)0x00 ,(byte)0x00 , //upper limit (byte)0x00...

ADPU Service in iOS


ios,nfc,smartcard,apdu,contactless-smartcard
I'm looking for an NFC solution for iOS similar to HostApduService for Android. Can someone tell me how can I exchange APDU commands in iOS. Thank you....

ISO7816 - Odd INS codes?


smartcard,javacard,apdu
I found these mysterious lines in ISO 7816, (http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx#chap5_4): 5.4.2 Instruction byte The instruction byte INS of a command shall be coded to allow transmission with any of the protocols defined in part 3 of ISO/IEC 7816. Table 10 shows the INS codes that are consequently invalid. Table 10 -...

I'm getting a tag lost exception when I try writing to an NFC tag


android,tags,nfc,mifare
I hope someone can tell me what I'm missing here. Maybe it's my approach to connecting. My Tag, is in fact a Mifare Ultralight so I'm not getting things wrong there. I debugged, connecting to the tag was successful - everything seemed fine. But the log keeps on saying: android.nfc.TagLostException:...

Android NFC passing single parameter when starting application


android,tags,nfc,ndef,android-applicationrecord
I would like to start an application using an NFC tag. I got that part working using an android application record (AAR) as described in Start Android application from NFC-tag with extra data or by using NDEF_DISCOVERED / TECH_DISCOVERED intent filters. But how do I pass data from the NFC...

Smartcard PKCS11 AES Key Gen Failure


python,aes,smartcard,pkcs11
I am attempting to create an AES 256 key on an ACOS5-64 smartcard and OMNIKEY 3121 card reader, using PKCS11 in python (using the PyKCS11 library). So far, all the "standard" operations seem to work with regards to asymmetric crypto. I have run plenty of code samples and pkcs11-tool commands,...

Tag returns null when trying to write NDEF message to NFC tag - Tag is not detected


android,android-intent,tags,nfc,ndef
I am trying to write an NDEF message to a tag. Below is the code that I have. I run the code using the debugger in my IDE, but after executing the line Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); tag is null (I assume this means that no tag was found) and...

onNewIntent() being called in onResume() multiple times


android,nfc,nfc-p2p
My problem is that in onNewIntent() function I start a new intent to open contacts app and allow the user the complete the process of creating a new contact, but when I try to exit the contacts app and go back to my app it seems that onNewIntent() is called...

How do I permanently lock specific data pages in a MIFARE Ultralight C tag?


android,nfc,mifare,lockbits
I have successfully written some data on data pages 30 to 38. After that I want to lock those pages in order to prevent further writing. The write lock should be permanent, so even if someone knows the authentication key, they should not be able to write to those pages....

Sending signature data in response APDU - Java Card


digital-signature,smartcard,javacard,apdu,ecdsa
I would like to sign some data (the MESSAGE byte array) on my Java Card and then return the signature in a response APDU. My code works fine (or at least I think it does and it returns 9000) without the line apdu.sendBytes(BAS, sSignLen), but when I uncomment it I...

Determine Facility Code and Card Number from ATR in C#


c#,.net,bytearray,smartcard,winscard
I have the following card reader HID Omnikey 5325. I have a contact-less card named HIS Proximity. The number written on this card is 133593 42101044091-3. By reading the card, I get the following ATR hex: 3B050002F10673 Using the folowing applications I have managed to see the following information. I...

Intent filter for NFC Smart Poster


android,android-intent,nfc
I would like to create an application that catch all NFC Smart Poster record. How can I catch Smart Poster records? I tried this way: <intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="application/*" /> <data android:mimeType="audio/*" /> <data android:mimeType="example/*" /> <data android:mimeType="image/*" /> <data android:mimeType="message/*" /> <data android:mimeType="model/*"...

C on smartcards [closed]


c,smartcard
I have the task to write some crypto stuff in C and make it lightweight. The idea behind making it lightweight is, that it could run on a smartcard which doesn't offer much computational power and memory. It won't come to actually running it on a smartcard and it won't...

How to use method onNewIntent(Intent intent) inside a Fragment?


android,android-activity,fragment,nfc
I'm trying to use NFC Hardware from my device. But, the problem is that when I register the Activity to receive the Intent: PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); I receive the result in an Activity instead of a Fragment. Is there a way to handle this...

NFC read tag to launch Google Maps with coordinates


android,google-maps,geolocation,nfc,ndef
I am trying to write an NFC tag with coordinates (latitude and longitude), in the following manner: This is inside onCreate(): btnWriteMap.setOnClickListener(new OnClickListener() { public void onClick(View v) { String latitude = lat.getText().toString(); String longitude = lon.getText().toString(); urlAddress = "geo:"+latitude+","+longitude; TextView messageText = (TextView)findViewById(R.id.txtMessage); messageText.setText("Touch NFC Tag to share GEO...

Is a network shield required to do POSTGET requests with arduino?


post,networking,get,arduino,nfc
By means of being thorough i was wondering if someone could tell me if I need an ethernet/wifi shield to be able to use POSTGET requests using my arduino. I've got an NFC shield and I need to send the data stored on the tag to my web server....

How to get RFID tag from ACS122U NFC


android,nfc,acr122
I am working on ACS122U NFC which reads tag's RFID. From ACS http://www.acs.com.hk/en/products/3/acr122u-usb-nfc-reader/ I got the development kit which will only connect to the reader and gives the state when a tag is placed on the NFC reader. But I need to get the ID (UID, serial number) of a...

Secure Box in JCOP card


smartcard,javacard,globalplatform,jcop,nxp-microcontroller
JCOP V2.4.2 Revision 3 Security Target: Page 11-12 A Secure Box concept is implemented within JCOP 2.4.2 R3. The Secure Box is a construct which allows to run non certified third party native code and ensures that this code cannot harm, influence or manipulate the JCOP 2.4.2 R3 operating system...

Weird Android device behaviour in reading NFC tech-list


android,tags,nfc,mifare,ndef
I am trying to read an NFC tag from 2 devices (Nexus 5 and Samsung S5). I am reading the tag through the foreground dispatch and using ACTION_TECH_DISCOVERED intent. On the Samsung S5, the tech-list lists NfcA, MifareClassic, and Ndef, but on the Nexus 5, it lists only NfcA. I...

UID of a NFC/SWP-accessed SIM card


android,nfc,smartcard,sim-card
SIM card is used as a secure element in my project. It is accessed through NFC-SWP contactless interface from a terminal device. I need to identify the SIM card somehow with a unique and permanent identifier and I need to be able to read the identifier through NFC. ICCID seems...

How to change master key of DESfire cards?What is deciphered key?


smartcard,mifare
I want to change the master key of a DESfire card. I read mifare DESFire datasheet already, but as I am new in this field, I couldn't understand it. It is explained how to Change the Key at page 37 of above document. Can anybody give me an example or...

Starting a specific activity through NFC tag


android,nfc,mime-types,intentfilter,ndef
Is it possible to launch a specific activity in an app using NFC tag? I want to start an activity called MainMap which is not the main activity. I've tried using a tag writer for writing mime record and still failing. Here's the manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.km.parkit"...

Send APDU commands to USIM/SIM card in android


android,smartcard,at-command,javacard,sim-card
I was already worked with smart cards and I am familiar with APDU commands (that are defined in ISO/IEC 7816 and Global Platform specifications). Now I want to know if is there any way to send an APDU command to my USIM/SIM card that is inserted to my mobile phone?...

how changing master key or other keys can provide security ?how used session key to keep the further communication between DESFire and reader?


security,session,authentication,nfc,smartcard
I am working on the ticket electronik that tickets are DESFire cards. I want communications be safe . i now trying change PICC key . Before changing DESFire master key Authenticate with master key is necessary. In desfire sheet about Authenticate at page 31 was described: "This procedure not only...

How can I reconnect to IsoDep tag?


android,nfc
I'm trying to send some apdu commands from android phone to the nfc tag and get answers. The type of used technology is IsoDep. Everything works fine, but sometimes, when the time between sending commands is too large, the tag switches to the disabled state and after that every reconnection...

Can I get access to NFC without manifest permission in android?


android,nfc,android-permissions
I need to create app with optional NFC functionality. Can I get access to NFC without manifest permission (Android)? Or should I create two apps: an NFC version and one without it.

Cardholder name not included when reading EMV card


nfc,apdu,contactless-smartcard,emv,tlv
I've successfully been able to retrieve the card number and expiry date from a contactless debit/credit card. However, the cardholder name is not being returned in the READ RECORD command response. Am I missing a something? - Select Application # IN_DATA_EXCHANGE >> D4 40 01 00 A4 04 00 07...

Change PIN of a Gemalto Smartcard through a script


smartcard,gemalto
We have to use the Gemalto IDPrime .Net card Smartcard. We get these USB Dongles and have to change the PIN. Gemalto says via windows: From the Start menu, choose Run and type PINTool. Insert a IDPrime .Net card in the reader as prompted, and click OK. The change PIN...

node-hid not showing all USB devices


node.js,osx,nfc,hid,acr122
I'm using node-hid with this call: HID.devices() and I should get a list of all connected USB devices as listed here in the guide. As result I'm getting this devices list: [ { vendorId: 1452, productId: 33346, path: 'USB_05ac_8242_6500000', serialNumber: '', manufacturer: 'Apple Computer, Inc.', product: 'Apple IR', release: 22,...

Is it possible to program a “Java Card” - enabled smart card in any other language than Java?


c,embedded,smartcard,javacard
I have a Java Card enabled smart card and a card reader that was given by my Lab-instructor. I am supposed to do a project using Java Card 2.1.1 API. I don't like the Java Card API. Is it possible to program my given smart card using any other language...

Performance measures : Java vs JavaCard [closed]


java,performance,time,smartcard,javacard
I implemented two algorithms in Java. To compare their effectiveness, I call each function 1000 times and compare the execution time (using System.currentTimeMillis()). It needs 2500 ms to execute the first one and 1300 ms for the second one. With these results, I thought have a significative difference (in term...

When app receives NFC data it opens “New Tag collected”


android,nfc,intentfilter,ndef,nfc-p2p
I am creating an app where two devices communicate over NFC and then one transmits to the server. I am trying to develop this for both pre- and post-lollipop. The problem is that I create my NDEF message in one app and then receive it in another app. However when...

Two OwnerPIN object in Java Card


security,smartcard,javacard,apdu,pin-code
I am working on a Java Card application where our requirement is to keep some static data and balance in the card. For security I was thinking to make 2 object of OwnerPIN. One object is for terminal authentication (i.e. the terminal needs to send 8 bytes of data to...

number value to byte[6] array card reader


c#,smartcard,smartcard-reader,cardreader
What's the best way to convert a number to a byte[6] in C#? I'm using MagTek Card reader and trying to display desired amount on device screen, it should be 6-byte array. The amount needs to be used and authorized, EMV Tag 9F02, format n12. Function: int requestSmartCard(int cardType, int...

NDEF vs APDU NFC Android


android,nfc,apdu,ndef,contactless-smartcard
Can you tell me please what is the difference between NDEF (NFC Data Exchange Format) and APDU (Application Protocol Data Unit). I have developed an Android application that reads NDEF messages, and I want to know if it can work for APDU data too....

NFC Read Tag SMS Service


android,sms,uri,nfc,ndef
I have written a program in which I am trying to write and read NFC tag, which may help user in sending message. I have successfully written to the tag but whenever I am trying to read, the Tags app shows vnd.android.nfc://ext/nfclab.com:smsService but does not allow me to send the...

How to mock a Android NFC Tag object for unit testing


android,unit-testing,android-intent,mocking,nfc
I'm currently working on an Android project which needs NFC integration. Now I want to write some (j)unit tests to see if the application can receive NFC intents (specifically ACTION_TECH_DISCOVERED) and put the given tag (in NfcAdapter.EXTRA_TAG) on a bus system. However to my surprise I cannot create a Tag...

How to launch an app without launcher icon by scanning an NFC tag?


android,nfc,intentfilter,ndef,android-applicationrecord
I want to launch my application by scanning an NFC tag containing an Android Application Record. However, this app shouldn't have a launcher icon, so I can't use CATEGORY_LAUNCHER. My problem is that if I comment out the CATEGORY_LAUNCHER line in the manifest, the app is not launched anymore (a...

Smart Card Reader T0 T1 communication on APDU level


smartcard,apdu,smartcard-reader
I am struggle to understand what protocol I have to use to communicate with the card T0 or T1? So, correct me if I am wrong, but the reader actually decides by itself what protocol to use to communicate with the card if the card supports both. So my logic...