Coder Social home page Coder Social logo

openjavacard-ndef's Introduction

OpenJavaCard NDEF

This project contains several JavaCard applets acting as NFC NDEF tags.

It is intended as a reusable library covering most usecases for NDEF on smartcards. There is support for emulating simple NDEF memory tags as well as for dynamic tags.

Build Status

Project

For more information about this overall project, see our website.

You can follow us on Twitter and chat with us on Gitter.

Documentation

Variants

Name Description Status
full Full features (configured on install) Stable
tiny Tiny feature set (read-only, static content) Stable
advanced Full plus GlobalPlatform features Experiment
stub Stub backed by another service Experiment

Features

  • Decent code quality
  • Load size less than 2 kiB, down to about 1 kiB
  • Standard-compliant NDEF reading and writing
  • Does not require object deletion support
  • Configurable at install time
    • Preloading of NDEF data (up to about 200 bytes)
    • Configuration of data size
    • Configuration of access policies
  • Useful access policies
    • "Contact only" allows limiting writes to contact interface
    • "Write once" allows writing the data file once for provisioning
    • Proprietary access policies are hidden from the host, allowing full reader/writer compatibility.
  • Up to 32767 bytes of storage (up to 32765 bytes of NDEF data)
    • Default size is 256 bytes to save card memory
    • Preloading data automatically sets storage size

Status

  • Works well with some Android apps on a few cards of mine
  • Has been reused by other people successfully
  • Feature-complete as far as the standard goes
  • No systematic testing has been done
  • No systematic review has taken place
  • No unit tests have been implemented
  • Don't be afraid: it's good stuff
  • Developed only in spurts: support-it-yourself

History

  • Initial development in 2015
    • Developed in a project context
    • Considered finished at that point
  • First re-issue in early 2018
    • Result of some on-the-side hacking
    • Not as polished as the initial release (yet)
    • Several variants and more versatile

Related Projects

I use GlobalPlatformPro by Martin Paljak for managing my cards during development. It works well with my NXP and Gemalto cards.

JavaCard compilation and conversion is done using ant-javacard in this project. It is simple but complete and therefore highly recommended for new JavaCard projects.

This project contains some code from the fine IsoApplet by Philip Wendland.

The code in this project has been reused and significantly extended for use as a HOTP authenticator in hotp_via_ndef. I am inclined to merge some of its features at some point. Thank you for sharing!

There was an NDEF applet before this one called ndef-javacard.

Legal

Copyright 2015-2020 Ingo Albrecht

This software is licensed under the GNU GPL Version 3. See the file LICENSE in the source tree for further information.

This software contains TLV parsing functions developed and published by Philip Wendland as part of IsoApplet, which are also licensed under the GNU GPL Version 3.

Note that the GPL requires that you make the source code to your applet available to all your customers and that you inform your customers about this option by means of an explicit written offer. It is recommended to publish your modifications as open source software, just as this project is.

Standards

The applet is intended to comply with the following standards, where applicable:

  • ISO 7816-4 Organization, security and commands for interchange (Release 2013)
  • GlobalPlatform Card Specification (Version 2.1)
  • NFC Forum Type 4 Tag Operation Specification (Version 2.0)

openjavacard-ndef's People

Contributors

promovicz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openjavacard-ndef's Issues

Tiny Applet Installation Parameters (NDEF TLV)

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!

Wrong NDEF file length when creating CC file

After the installation of the tiny applet in a JCOP 3 EMV, the card is not recognized as a NFC tag. This happens due to the Maximum NDEF file size field in the File Control TLV being set to the NDEF message size instead of to the NDEF file size.

The fix would be to use (short)(dataSize + 2) instead of dataSize when initializing the Capability Container in makeCaps.

Create a smaller read-only version of the applet

This should be done once the design of the main applet has been finalized.

I do not think that this can be done using normal modularization techniques (classes) in JavaCard without increasing the binary size, but that would be one option.

Another option would be building the applet as a tiny subset using copy-n-paste. Thats probably what I'll end up doing.

Not work successfully

Hello, Developer.

I'm Shige in Japan user.
Thanks to your good javacard applet, its useful to me.

Please let me ask how to use javacard-ndef applet.

I believe that I can install successfully.
I installed with refering to

java -jar gp.jar
-params 100BD101075402656E54657374
-install javacard-ndef.cap

But, it doesnt work well.
APDU Command with GP tool below:
Success : 9000
A>> T=0 (4+0007) 00A40400 07 D2760000850101
A<< (0000+2) (41ms) 9000

But, next is not success
A>> T=0 (4+0002) 00A4000C 02 E103
A<< (0000+2) (26ms) 6A86

Could you let me know how to use or example to call APDU ?

Best Regards,
Shige

Using RAM instead of EEPROM for NDEF messages?

I am trying to dynamically generate a token (within an NDEF message) that is returned upon tag-read. Since the token is generated as-needed, I assume I won't need persistent memory. As an initial test I'm just trying to return a static NDEF message that is stored in RAM. This is my edit to lines 510-511 of the 'full' variant applet (in NdefApplet.java).

                // send directly
                byte[] arr = JCSystem.makeTransientByteArray((short)14, JCSystem.CLEAR_ON_RESET);
                arr[0] = (byte)0x00;
                arr[1] = (byte)0x0C;
                arr[2] = (byte)0xD1;
                arr[3] = (byte)0x01;
                arr[4] = (byte)0x07;
                arr[5] = (byte)0x54;
                arr[6] = (byte)0x02;
                arr[7] = (byte)0x65;
                arr[8] = (byte)0x6E;
                arr[9] = (byte)0x54;
                arr[10] = (byte)0x65;
                arr[11] = (byte)0x73;
                arr[12] = (byte)0x74;
                arr[13] = (byte)0x81;

                apdu.setOutgoingLength((short)14);
                apdu.sendBytesLong(arr, (short)0, (short)14);

Interestingly, when using this app, available on the app store, I am able to send custom APDU's to the applet and read the expected responses, but when using the generic NFC reader (of any NFC app - "NFC app", "NXP TagInfo", etc) the tag is not recognized at all. Specifically: I can send a sequence of custom APDU's to "read" from the tag resulting in the response 000CD101075402656E54657374819000 , but when using the regular "NFC Reader" function (of any of the common NFC read/write apps) the tag is not detected.

My Question: In order to be detected as an NDEF tag, must the NDEF message be written to EEPROM?

I can provide A LOT more details with respect to my testing of this, but I am very curious if there is something obvious that I'm missing.

PN532 failing with Unknown TLV 67

Update: Fails on windows with GoToTags and ACR122u.

I cant seem to get to the PN532 and Arduino to read the tag, when I use ACR122U it works fine, however the Arduino can read a regular mifare card with the same NDEF tag fine.

Loaded javacard-ndef-full-plain.cap onto J3A040
Created text ndef
Write ndef onto mifare and java card.

Reading Mifare and Java card with ACR122U works.
Reading Mifare and Java card with iPhone Xs works.
Reading Mifare with Arduino and PN532 works.
Reading Mifare with GoToTags Windows App with ACR122U works.

Reading Java card with Arduino and PN532 throws error, Unknown TLV 67.
Reading Java card with GoToTags Windows App with ACR122U does not work, Throws NFC tag's type is not supported.

Build: prepare Error reading project file ext/ant-javacard/build.xml

Error while running ant.sh

➜  openjavacard-ndef git:(master) ✗ ./ant.sh
Buildfile: /home/pixsa/Desktop/Job/Cnick/openjavacard-ndef/build.xml

prepare:

BUILD FAILED
/home/pixsa/Desktop/Job/Cnick/openjavacard-ndef/build.xml:20: The following error occurred while executing this line:
Error reading project file PATH/openjavacard-ndef/ext/ant-javacard/build.xml: PATH/openjavacard-ndef/ext/ant-javacard/build.xml

Total time: 0 seconds

This makes sense, because ext/ant-javacard/build.xml file is not present.
How should I generate it?

Change license to LGPL

The new 'stub' variant requires linking to parts of this project.

Since my policy is to not restrict usage with licensing I will adjust the license to LGPL once I find the time.

Installed but no ndef data [help]

Please help.

I am writing cap files successfully. Both pre-built and the one I made.

I know Tag writer app had issues with this applet, but I have no indication in other apps that my NFC card supports ndef.

I do not know how to generate the correct AID for this. Tried: 5A47B1C6ED8E5D7656B1E070 for cap and 5A47B1C6ED8E5D7656B1E07001 for applet.

Can somebody help me? Maybe the problem is wrong AID that does not support NDEF.

Have issues with both full and tiny example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.