Skip to content

Loading an Applet on your ring

chrisleach edited this page Oct 30, 2019 · 1 revision

Applet loading utility

To load an applet on a ring we will use a GlobalPlatformPro (written by Martian Paljak) utility. This is open source software and freely available on GitHub. GPPro can be used to load and delete applets, change keys, change CPLC, lock cards and many more. More details about GlobalPlatformPro can be found at https://github.com/martinpaljak/GlobalPlatformPro/

To download the utility, go to https://github.com/martinpaljak/GlobalPlatformPro/releases/latest. Based on your operating system download one of the files:

  • Ubuntu - gp.jar
  • Windows - gp.exe

Move downloaded file to your project root directory.

On Ubuntu OS, the utility can be executed the following way (in Terminal):

$ java -jar gp.jar --list

On Windows (PowerShell):

> ./gp.exe --list

**Note: For consistency throughout the tutorial, all GlobalPlatformPro commands will be written in Linux style. For running the commands on Windows please replace 'java -jar gp.jar' with './gp.exe'. **

Loading applet on a ring

Deleting factory loaded applet

Our rings come preloaded with a simple NDEF applet containing a website link to this tutorial. Before we can load our custom applet on, we need to remove it.

To remove the applet, run the following command:

$ java -jar gp.jar --uninstall D276000085

To verify that the applet has been deleted and/or there are no other applets on, use the following command:

$ java -jar gp.jar --list

The list output for a ring with applet(s) will look like this:

List output for factory loaded ring:

Warning: no keys given, using default test key 404142434445464748494A4B4C4D4E4F
ISD: A000000151000000 (OP_READY)
     Privs:   SecurityDomain, CardLock, CardTerminate, CardReset, CVMManagement, TrustedPath, AuthorizedManagement, TokenVerification, GlobalDelete, GlobalLock, GlobalRegistry, FinalApplication, ReceiptGeneration

APP: D2760000850101 (SELECTABLE)
     Privs:

PKG: D276000085 (LOADED)
     Applet:  D2760000850101

List output after deleting factory applet:

Warning: no keys given, using default test key 404142434445464748494A4B4C4D4E4F
ISD: A000000151000000 (OP_READY)
     Privs:   SecurityDomain, CardLock, CardTerminate, CardReset, CVMManagement, TrustedPath, AuthorizedManagement, TokenVerification, GlobalDelete, GlobalLock, GlobalRegistry, FinalApplication, ReceiptGeneration

Loading new applet on a ring

To load recently built applet on a ring, use following command:

$ java -jar gp.jar --install MyApplet.cap --default

Congratulations! You have just built a simple applet and loaded it on a ring.

To validate, we can send an APDU to the ring using GlobalPlatformPro.

$ java -jar gp.jar --apdu 0000000000 -d

This produces output:

$ java -jar gp.jar --apdu 0000000000 -d
GlobalPlatformPro 19.01.22-0-gf94d7f5
# Detected readers from JNA2PCSC
[*] ACS ACR122U PICC Interface 0
SCardConnect("ACS ACR122U PICC Interface 0", T=*) -> T=1, 3B8C80015040CE595E00000011778183B0
SCardBeginTransaction("ACS ACR122U PICC Interface 0")
A>> T=1 (4+0000) 00000000 00
A<< (0012+2) (15ms) 48656C6C6F20576F726C6421 9000
A>> T=1 (4+0000) 00A40400 00
A<< (0097+2) (85ms) 6F5F8408A000000151000000A553734906072A864886FC6B01600B06092A864886FC6B020202630906072A864886FC6B03640B06092A864886FC6B040215650B06092A864886FC6B020101660C060A2B060104012A026E01039F6E01019F6501FE 9000
[TRACE] GlobalPlatform -  [6F]
[TRACE] GlobalPlatform -      [84] A000000151000000
[TRACE] GlobalPlatform -      [A5]
[TRACE] GlobalPlatform -          [73]
[TRACE] GlobalPlatform -              [06] 2A864886FC6B01
[TRACE] GlobalPlatform -              [60]
[TRACE] GlobalPlatform -                  [06] 2A864886FC6B020202
[TRACE] GlobalPlatform -              [63]
[TRACE] GlobalPlatform -                  [06] 2A864886FC6B03
[TRACE] GlobalPlatform -              [64]
[TRACE] GlobalPlatform -                  [06] 2A864886FC6B040215
[TRACE] GlobalPlatform -              [65]
[TRACE] GlobalPlatform -                  [06] 2A864886FC6B020101
[TRACE] GlobalPlatform -              [66]
[TRACE] GlobalPlatform -                  [06] 2B060104012A026E0103
[TRACE] GlobalPlatform -          [9F6E] 01
[TRACE] GlobalPlatform -          [9F65] FE
[DEBUG] GlobalPlatform - Auto-detected ISD: A000000151000000
SCardEndTransaction(ACS ACR122U PICC Interface 0)
SCardDisconnect("ACS ACR122U PICC Interface 0", true)

Lines 8-9 are the ones we are interested in.

  • Line 8 - A>> T=1 (4+0000) 00000000 00 - we can see the 0000000000 APDU is being transmitted
  • Line 9 - A<< (0012+2) (15ms) 48656C6C6F20576F726C6421 9000- response from the ring. Putting “48656C6C6F20576F726C6421” through hex-to-ascii converter, we get: “Hello World!”

Note: If you are getting 6D 00 or 6E 00 error response then try removing a ring for few seconds and put it back on the reader.


Done

This concludes the quick start tutorial on how to set up basic toolchain, build an applet from source and how to load it on a ring.