3
votes

When I first tried to send an APDU command and got the "Above supported length" error, I assumed that is just a limitation of the NFC chip itself - no way around it. However this site suggests that it might be a software problem in the Android OS instead:

many currently available smartphones are only able to transmit 261 Bytes[2] via NFC without major modifications of the operating system.

Does anyone know more about how to get get around this problem and how "major" exactly the modifications are?

Also, do you have a list, which phones support extended length APDU? If not, we should probably start one, as you really don't find much on google.

I know that the Samsung Galaxy Note II supports it, while Samsung Galaxy S3, Nexus 5 and Galaxy Nexus don't.

2

2 Answers

2
votes

See this site: https://code.google.com/p/android/issues/detail?id=76598

What you have to do:

  • Download the Android Sources
  • Change "261" to "2462" in the line in NativeNfcManager.java (as shown on the site linked above)
  • Build Android
  • Flash your modified Android version on the phone

A tutorial for building Android for Nexus 5 can be found here: http://nosemaj.org/howto-build-android-kitkat-nexus-5

This works for the reader mode of your smartphone, I do not know yet how to get it to work for the card emulation mode.

1
votes

A better/easier/more portable solution is to only send 261 Bytes (or less) and returning the ISO7816-4 status codes SW1-SW2 = 0x61xx with xx telling the number of data bytes still available. The reader will send the ISO7816-4 command 'GET RESPONSE' to request the remaining bytes.

For instance, if you want to send 300 bytes from Android HCE, then you will start to reply:

  1. HCE: sendResponseApdu({ 250 first bytes of data + 0x6132 }) (0x32 means 50 remaining bytes)
  2. NFC Card reader should send: GET RESPONSE
  3. HCE: sendResponseApdu({ last 50 bytes of data + 0x9000 })