timmerk / nfc-tools

Automatically exported from code.google.com/p/nfc-tools
0 stars 0 forks source link

tlv.c length marking error #94

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. using examples/mifare-classic-write-ndef to write a 257 byte ndef file. 
Actually anything larger than 126 will result in incorrect length

What is the expected output? What do you see instead?
The resulting card application starts with:
actual: x03xFFx01x01.....
expected: x03x82x01x01.....

What version of the product are you using? On what operating system?
0.3.4

Please provide any additional information below.

tlv.c puts all lengths less than 254 in a single byte, although only 7 bits can 
be used for single byte lengths. Anything more that 127 should result in at 
least two byte length.

in addition, when going over 254, the first byte is marked as 0xFF, while it 
should be 0x80 + n bytes where n notes the count of bytes that come after this 
byte where length is stored.

For example:
127 should be 0x7F
128 should be 0x81 0x80
257 should be 0x82 0x01 0x01

see: http://en.wikipedia.org/wiki/Basic_Encoding_Rules#Length

Original issue reported on code.google.com by ma...@unitedtickets.ee on 7 Jun 2012 at 7:20

GoogleCodeExporter commented 9 years ago
Hello,

tlv.c is conform to NFC-Forum Type 1 Tag Operation Specification and to NXP 
Type MF1K-4K Tag Operation which is the requierement to store NDEF in MIFARE 
Classic tags.

Original comment by romu...@libnfc.org on 8 Jun 2012 at 12:19

GoogleCodeExporter commented 9 years ago

Original comment by romu...@libnfc.org on 8 Jun 2012 at 12:19

GoogleCodeExporter commented 9 years ago
Indeed, I stand corrected :)

Original comment by ma...@unitedtickets.ee on 8 Jun 2012 at 7:00