OpenJavaCard / openjavacard-ndef

NDEF tag implementation for JavaCard
GNU General Public License v3.0
70 stars 25 forks source link

Tiny Applet Installation Parameters (NDEF TLV) #15

Open jaredvacanti opened 3 years ago

jaredvacanti commented 3 years ago

The documentation has an example here of how to install the tiny app variant using param data:

 user@host:~$ java -jar gp.jar \
        -applet D2760000850101 \
        -params 100BD101075402656E54657374 \
        -install build/javacard/javacard-ndef-tiny.cap
 (Install tiny variant with static text "Test")

What is the leading byte of the param data here? Is the param itself a TLV?

Type Length Value ... ... ... ... ... ...
TNF: Type Name Format Type Length Payload Length Type
0x10 0x0B 0xD1 0x01 0x07 0x54 0x02 0x65 0x6E 0x54657374
11 bytes 0b11010001 1 byte 7 bytes T en Test

When I use this python code to generate an NDEF, I only get the payload:

import ndef

record1 = ndef.TextRecord("Test")

encoder = ndef.message_encoder()

encoder.send(None)
encoder.send(record1)
encoder.send(None)

message = [record1]

print(b''.join((ndef.message_encoder(message))).hex())
>>> d101075402656e54657374

It also mentions in the docs for the tiny applet:

You should not prepend the dataset with a length prefix as in the stored form.

So maybe I've missed some other detail. What's the initial byte 0x10 in the tiny applet param? Thanks for any help in advance!

promovicz commented 3 years ago

The param that you must provide is a bare NDEF message and will be written to the tag memory as-is.

NDEF messages are TLV, but they do not conform to ASN.1 or any related standards.

I'm not sure about the example though. It might need fixing.