Giter VIP home page Giter VIP logo

globalplatformpro's Introduction

Build status LGPL-3.0 licensed

Latest release Maven version Maven Central

GlobalPlatformPro

ย ย ย ย  from JavaCardPro

Load and manage applets on compatible JavaCards from command line or from your Java project with a Do What I Mean approach (testimonials).

Provides an easy to use and high level interface that most of the time JustWorks(TM), is flexible and 100% open source!

Building JavaCard applets is equally pleasing with ant-javacard

Like it? Become a sponsor!

Jump to ...

Get it now!

  • Download latest pre-built .JAR or .EXE from release area
  • Requires JDK-11

Homebrew

brew install martinapaljak/brew/gppro --HEAD # installs the master branch

Source

Build it yourself, it is really easy:

git clone https://github.com/martinpaljak/GlobalPlatformPro
cd GlobalPlatformPro
./mvnw package

NEWS

Usage

Beware: both command line and Java API are subject to change without notice. Check back often.

Warning about correct keying

Command line samples assume default test keys of 40..4F. If you need a custom key, specify it with -key (you can give separate keyset components with -key-mac, -key-enc and -key-kek. You need to know the details or ask your card provider. Some cards require key diversification with -emv or -visa2 (ask your vendor if unsure). A Key Check Value can be given with -kcv option.

Generic information

  • Show some basic information about a card (failsafe):

    java -jar gp.jar -info
    
    • On Windows just replace java -jar gp.jar with gp.exe like this:

      gp.exe -info
      
    • On Linux it is easier to add an alias to the shell like this:

      alias gp="java -jar $PWD/gp.jar"
      # Now you can avoid typing `java -jar` and `gp` works from any folder
      gp -h
      

List / install / delete applets

Please consult the help output for options that are not described here

  • List applets (this and following commands open the secure channel and thus can brick your card with wrong keys!):

    gp -list # or gp -l
    

    How to interpret the output:

    • All AID-s of on-card objects are listed, starting with Issuer Security Domain (ISD)
    • Object's type, lifecycle state and privileges are listed below the AID line
    • Applications have type App and a state (like SELECTABLE) and privileges (like Default selected)
    • Executable Modules (type ExM, representing Java packages) are listed together with applets in them (which can be initiated with --create)
    • Security Domains have type SeD
  • Delete current default applet's package and all instances:

    gp -delete -default
    
  • Delete package D27600012401 and all applets from it:

    gp -delete D27600012401
    
  • Install applet.cap as default applet (with AID information from the CAP):

    gp -install applet.cap -default
    
  • Install applet.cap (with AID information from the CAP):

    gp -install applet.cap
    
  • Unistall applet.cap (with AID information from the CAP):

    gp -uninstall applet.cap
    
  • Force installation of applet.cap, deleting anything that's necessary, with AID information from the CAP:

    gp -f -install applet.cap
    
  • Create new instance of applet D2760001240102000000000000000000 from package D27600012401 with AID D2760001240102000000000272950000:

    gp -package D27600012401 -applet D2760001240102000000000000000000 -create D2760001240102000000000272950000
    
  • Same as previous, but takes the package/applet AID-s from CAP file and makes the new instance default selected:

    gp -cap OpenPGPApplet.cap -create D2760001240102000000000272950000 -default
    
Installation options
  • -default - makes the applet default selected
  • -terminate - gives card lock and card terminate privileges to the applet
  • -params <hex> - installation parameters for applet

Lock / unlock usage

  • Set 010B0371D78377B801F2D62AFC671D95 key to a card with default 40..4F keys:

    gp -lock 010B0371D78377B801F2D62AFC671D95
    
  • Set default 40..4F keys to card that was previously locked with key 010B0371D78377B801F2D62AFC671D95:

    gp -key 010B0371D78377B801F2D62AFC671D95 -unlock
    
  • Set the default 40..4F keys to a card that uses EMV diversification (like G&D):

    gp -emv -unlock
    

    * note that you will have to use --relax option after this operation to get rid of the warning about probably needed diversification, which is not true any more.

  • Set the default 40..4F keys to a card that uses VISA2 diversification with the well-known mother key on a Gemalto card:

    gp -visa2 -key 47454D5850524553534F53414D504C45 -unlock -mode clr
    

Debugging options

  • Show APDU-s sent to the card:

    add -debug or -d to your command

  • Be more verbose about decisions and conditions:

    add -verbose or -v to your command

  • Don't use MAC on commands (plain GlobalPlatform syntax):

    add -mode clr to your command (not supported on all cards)

  • Show all options recognized by gp utility:

    add -help or -h or --help to your gp command

Usage from Java ย  Maven Central

Include the dependency:

<!-- https://mvnrepository.com/artifact/com.github.martinpaljak/globalplatformpro -->
<dependency>
    <groupId>com.github.martinpaljak</groupId>
    <artifactId>globalplatformpro</artifactId>
    <version>0.3.10-rc6</version>
</dependency>
  • For now consult the command line utility source code
  • Rudimentary Javadoc
  • General rules:
    • Expect RuntimeException-s when things go unexpectedly wrong
    • CardException-s when link layer fails
    • GPException-s when protocol layer fails

Supported cards

History

The ancestor of this code is GPJ (Global Platform for SmartCardIO) which is (still) available from http://gpj.sourceforge.net. I started the project because I felt that messing with cryptic script files was not nice and I wanted to have a simple, open source, usable and native-to-the-rest-of-development-environment (Java) toolchain.

Credits (from GPJ):

Similar projects

Design principles

  • focus on real life and practical daily use cases
  • KISS, YAGNI, DWIM, no-NIH
  • APDU-chat over anything that extends CardChannel to (most probably real) tokens
  • thin and self-contained, re-usable, easy to integrate
  • easily readable, auditable and secure codebase (less is more)

About

The promise of GlobalPlatformPro is similar to OpenSSL:

Why buy a smart card software kit as a black box when you can get an open one for free?

In regard to GlobalPlatform, the goal is to make simple operations like installing and removing applets and locking the card with new keys as easy as next-next-done - you don't have to know the whole Global Platform specification by heart for that or buy a piece of proprietary software for a few hundred euros! For all those features that are not described in the GlobalPlatform specification that actually make your card work... you still have to use those proprietary commands, but OpenKMS GlobalPlatformPro toolkit's flexibility (and its license) should allow you to do that as well.

License

  • LGPL-3.0 for derived code and MIT/LGPL3 for original code.

Included/used open source projects

  • BouncyCastle for OID parsing and NIST SP 800-108/NIST SP 800-38B (MIT)
  • JOpt Simple for parsing command line (MIT)
  • Launch4j for generating the .exe (BSD/MIT)
  • apdu4j for APDU level PC/SC access/logging/replaying (MIT)
  • ber-tlv for tag parsing (Apache)

Contact

  • For technical support:
    • Re-run your failing command with -d -v -i switches and send the output, information about your card and applet/CAP
    • Only plaintext logs. NO screenshots, pictures, word documents. NO generic questions about java/linux/windows/globalplatform. Questions about jcshell/gpshell/gpj/something else shall be ignored.
    • If unsure, first read about asking questions
    • For "How do I ... ?" questions start a thread in discussions
  • Generic enquiries
  • For reporting bugs and issues (ask for help and questions in discussions)
  • Please donate!

Legal disclaimer

The casual: trademarks to their owners, copyrights to authors, software patents to hell, legal letters to /dev/null PGP key 0x1d86f74c7b9dd593. Everything is provided AS-IS AND THERE IS A CONSTANT RISK OF DEATH FROM SUDDEN LIGHTNING. Writing in all caps made it look like serious, didn't it?


JavaCardPro

globalplatformpro's People

Contributors

alarkvell avatar bertrandmartel avatar edwardcher avatar ekleog avatar elipsion avatar erikhandersson avatar gregorjohannson avatar gwachob avatar johnmclear avatar klali avatar koluch avatar leonardonewave avatar martinpaljak avatar maxxyme avatar megabug avatar mhardeman avatar minkyn avatar robertbachmann avatar sergkh avatar slorquet avatar snyk-bot avatar tsenger avatar xavo95 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  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  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

globalplatformpro's Issues

Command line option "production"

Ensures that no sensitive information - e.g., OP keys are displayed or in logs. OP keys could be replaced with KCV values allowing audit.

can't use param other than 'C9'

the definition of installAndMakeSelectable is

 public void installAndMakeSelectable(AID packageAID, AID appletAID, AID instanceAID, byte privileges, byte[] installParams,
            byte[] installToken)

installParams just use 'C9' tag, but accroding to the GP specification 'C9' tag is only one of the install params, there is 'EF' ,'EA', 'B6' params tags, so perhaps '-params' should just pass throught all data not suppose the data is kind of 'C9' tag. just like gpj did, so I can use param like this:

gp -v -d -install test.cap -params C900EA1B80
0DFF0012010100000003C0000100810400010000820400010000

gp.jar contains duplicate file entries under /META-INF

Have found that the pre-built gp.jar file has duplicate file entries under /META-INF/maven/net.sf.jopt-simple/jopt-simple/ which is causing some Maven builds to fail.

We currently use GlobalPlatformPro embedded in a larger application, and use Maven to handle the build process for the application. We sign all jars with our code signing keys via the maven-jarsigner-plugin, and during the phase in which it removes existing signatures on application dependencies, it fails on the gp.jar file as it contains multiple file entries under the above specified path.

Recommended fix would be to remove /META-INF/maven folder/directory from the gp.jar as it's not needed for gp.jar to work and would solve the jar signing issues as well.

Lock fails for Fetian Java Token

Trying to lock the card appears to fail at getKeyInfoTemplate(), which returns an empty array. Please see trace below:

$ java -jar gp.jar -d -v -lock B4F75CE0A95EA3F86BBD051CB77C0FAE

Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:B4F75CE0A95EA3F86BBD051CB77C0FAE
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:B4F75CE0A95EA3F86BBD051CB77C0FAE
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:B4F75CE0A95EA3F86BBD051CB77C0FAE
Detected readers from JNA2PCSC
[] Fetian Java Token
SCardConnect("Fetian Java Token", T=
) -> T=1, 3BFC180000813180459067464A01642F70C172FEE0FD
SCardBeginTransaction("Fetian Java Token")
Reader: Fetian Java Token
ATR: 3BFC180000813180459067464A01642F70C172FEE0FD
More information about your card:
http://smartcard-atr.appspot.com/parse?ATR=3BFC180000813180459067464A01642F70C172FEE0FD

A>> T=1 (4+0000) 00A40400 00
A<< (0018+2) (15ms) 6F108408A000000003000000A5049F6501FF 9000
Auto-detected ISD AID: A000000003000000
A>> T=1 (4+0008) 80500000 08 11EA1AE10497AFA4 00
A<< (0028+2) (7ms) 00000000000000000000FF020014C343BDBA954492BDA0038AD4C5EC 9000
Host challenge: 11EA1AE10497AFA4
Card challenge: 0014C343BDBA9544
Card reports SCP02 with version 255 keys
Master keys:
Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
Sequnce counter: 0014
Derived session keys:
Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:8BE20F81214CBDEF0930B4CA867AEEE8
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:C41B70EFC062D8C4AD086FEDB2B9763D
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:FB820F201C9C5654E05EE1AD5F5CB2B4
Verified card cryptogram: 92BDA0038AD4C5EC
Calculated host cryptogram: 4BF7B4F5083454FD
A>> T=1 (4+0016) 84820100 10 4BF7B4F5083454FD7583517BD2D9CCA7
A<< (0000+2) (38ms) 9000

Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:B4F75CE0A95EA3F86BBD051CB77C0FAE
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:B4F75CE0A95EA3F86BBD051CB77C0FAE
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:B4F75CE0A95EA3F86BBD051CB77C0FAE
Replace: true
PUT KEY:Ver:1 ID:1 Type:DES3 Len:16 Value:B4F75CE0A95EA3F86BBD051CB77C0FAE
PUT KEY:Ver:1 ID:2 Type:DES3 Len:16 Value:B4F75CE0A95EA3F86BBD051CB77C0FAE
PUT KEY:Ver:1 ID:3 Type:DES3 Len:16 Value:B4F75CE0A95EA3F86BBD051CB77C0FAE
A>> T=1 (4+0008) 84CA00E0 08 8390C915386EDC4C 00
A<< (0002+2) (6ms) 9000
SCardEndTransaction()
SCardDisconnect("Fetian Java Token", true)
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at pro.javacard.gp.GlobalPlatform.putKeys(GlobalPlatform.java:945)
at pro.javacard.gp.GPTool.main(GPTool.java:592)

SCP03: One Byte Counter "i"

Hi,
I'm a little bit confused about implementation of scp03_kdf. From my point of view, this function lacks implementation of byte counter i.

Section 4.1.5 of SCP03 Protocol
A 1 byte counter โ€œiโ€ as specified in the KDF (which may take the values '01' or '02'; value '02' is used
when โ€œLโ€ takes the values '00C0' and '0100', i.e. when the PRF of the KDF is to be called twice to
generate enough derived data).

I.e.
bo.write((lengthBits > 128) ? 0x02 : 0x01);

Best regards,
klinz2050

Add SD related interface (domain installation)

  • interface for domain creation from command line
  • expose all privileges to command line
  • key loading to security domains, in addition to -lock/-unlock
    • asymmetric key loading from a file
  • Extending GPKey to support RSA and ECC

Add better key management interface

  • commands for listing/deleting SD keys
  • option to use a custom session key provider, much like "-terminals"
  • generic 3DES PKCS#11 session key provider based on SunPKCS11

Error on applet instantiation with parameters

I'm trying to install an applet that has parameters. The command used is:

gp -d -visa2 -key MY_KEY --package MY_PACKAGE --applet MY_APPLET --create MY_INSTANCE -params MY_PARAMS

The problem is that MY_PARAMS is 23 bytes long. I have set it with C917MY_PARAMS and only MY_PARAMS. Both returns the same error:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at pro.javacard.gp.GPTool.getInstParams(GPTool.java:661)
       at pro.javacard.gp.GPTool.main(GPTool.java:507)

Besides, is there any way to set the privileges? Do I have to include them on the params as well?

Can not unlock Card Mannager even with Correct key and correct card using GP

Can not unlock Card Mannager even with Correct key and correct card using GP, but same key unlocks same card using different software. I am using OpenScp01 to unlock the card.
I have added the APDU log file where I unlock the card be low the stars in the message below

Can someone please give me advice how to "configure" the GP exe correctly?


Command File : C:\PCom32_6.0\IDONE\IDONE_Select.cmd
Logging File : C:\PCom32_6.0\Logs\IDONE_Select.L55
Date : 30 October 2015 at 13h25 45s
Version : PCOM32 Version 6.4.3.3
Reader Name : BROADCOM CORP CONTACTED SMARTCARD 0
HubReader : C:\Windows\system32\HubReader.dll Version 1.9.0.0
IFDEF values :

0001 : .LIST_ON
0002 : .LOAD CALCUL.DLL
Dll Calcul chargรฉe Version: 4,13,0,0

     using C:\PCom32_6.0\Crypto.DLL version: 4.13.0.0
    using C:\PCom32_6.0\calcul.dll version: 4, 13, 0, 0

0003 :
0004 : .DEFINE %KMC 203F19CDD7D219787CBC4A8E1234D62E

   %KMC        : 20 3F 19 CD  D7 D2 19 78  7C BC 4A 8E  12 34 D6 2E  

0005 : .DEFINE %KMC_VERSION 01

   %KMC_VERSION : 01 

0006 :
0007 :
0008 :
0009 :
0010 : .INSERT
0011 :
0012 :
0013 : .POWER_ON

Command : POWER_ON
Output Data : 00 31 C0 64 3F 68 01 04 07
Status : 90 00

0014 : *00A4040008A000000003000000 (9000,61XX)
0015 :
0016 :
0017 : *
.CALL OpenScp01.pcom /LIST_OFF
0018 :
0019 : 00A4040008A000000003000000 (61xx,9000)

Command : 00 A4 04 00 08
Input Data : A0 00 00 00 03 00 00 00
Output Data : none
Status : 61 3F

0020 :
0021 : ;.LIST_OFF
0022 :
0023 : .CALL OpenScp01.pcom /LIST_ON
Called File : C:\PCom32_6.0\IDONE\OpenScp01.pcom
0001 :
0002 : .LIST_ON
0003 :
0004 : .UNDEFINE %DIV
0005 : .UNDEFINE %KS_SEK
0006 : .UNDEFINE %KS_SMK
0007 : .UNDEFINE %KS_KEK
0008 : .UNDEFINE %ENC_KEY
0009 :
0010 :
0011 : 80 50 00 00 08 1122334455667788 (61 1C)

Command : 80 50 00 00 08
Input Data : 11 22 33 44 55 66 77 88
Output Data : none
Status : 61 1C

0012 : 00 C0 00 00 1C (90 00)

Command : 00 C0 00 00 1C
Output Data : FF 40 43 06 00 00 30 07 00 90 01 01 32 06 52 E4
: D4 52 8C 7B CF 52 DA 0B CA 19 7D D9
Status : 90 00

0013 :
0014 : .SET_BUFFER K R

   Buffer K    : FF 40 43 06  00 00 30 07  00 90 01 01  32 06 52 E4  
               : D4 52 8C 7B  CF 52 DA 0B  CA 19 7D D9  

0015 : .SET_BUFFER H 1122334455667788

   Buffer H    : 11 22 33 44  55 66 77 88  

0016 :
0017 : .DEFINE %DIV K(5;6)

   %DIV        : 00 00 30 07  00 90 

0018 : .SET_BUFFER O K(13;8) * card challenge

   Buffer O    : 32 06 52 E4  D4 52 8C 7B  

0019 : ;.DEFINE %DIV 0000 R(5;4)
0020 : ;.DEFINE %DIV R(5;6)
0021 : ;.SET_BUFFER O R(13;8) * card challenge
0022 :
0023 : * compute KDCenc
0024 : .SET_DATA %DIV F001 %DIV 0F01
*** DATA UPDATED ***

0025 : .SET_KEY %KMC
*** KEY UPDATED ***
Key = 203F19CDD7D219787CBC4A8E1234D62E

0026 : .DES3 I 00
*** DES3 PROCESSED ***

0027 : .DEFINE %KS_SEK I

   %KS_SEK     : 9F A4 16 DC  8C DE 1E 2E  76 8D AC 07  7B A8 9D 77  

0028 : * compute KDCmac
0029 : .SET_DATA %DIV F002 %DIV 0F02
*** DATA UPDATED ***

0030 : .SET_KEY %KMC
*** KEY UPDATED ***
Key = 203F19CDD7D219787CBC4A8E1234D62E

0031 : .DES3 J 00
*** DES3 PROCESSED ***

0032 : .DEFINE %KS_SMK J

   %KS_SMK     : A8 87 7C 70  07 FB 00 6F  12 7B F3 4A  C1 94 2B 02  

0033 : * compute KDCkek
0034 : .SET_DATA %DIV F003 %DIV 0F03
*** DATA UPDATED ***

0035 : .SET_KEY %KMC
*** KEY UPDATED ***
Key = 203F19CDD7D219787CBC4A8E1234D62E

0036 : .DES3 K 00
*** DES3 PROCESSED ***

0037 : .DEFINE %KS_KEK K

   %KS_KEK     : 93 75 A0 97  C4 C2 AE D4  FF 8A 40 29  25 D6 11 FA  

0038 :
0039 :
0040 :
0041 : * compute authentication/encryption session key
0042 : .SET_DATA O(5:8) H(1:4) O(1:4) H(5:8)
*** DATA UPDATED ***

0043 : .SET_VECT_INI 0000000000000000
*** INIT VECTOR UPDATED ***

0044 : .SET_KEY I
*** KEY UPDATED ***
Key = 9FA416DC8CDE1E2E768DAC077BA89D77

0045 : .DES3 I 80
*** DES3 PROCESSED ***

0046 :
0047 : .DEFINE %ENC_KEY I

   %ENC_KEY    : 62 C9 70 7E  8F A1 41 18  4F EC 9E 6A  D2 B5 3C C8  

0048 :
0049 : * compute mac session key
0050 : .SET_DATA O(5:8) H(1:4) O(1:4) H(5:8)
*** DATA UPDATED ***

0051 : .SET_VECT_INI 0000000000000000
*** INIT VECTOR UPDATED ***

0052 : .SET_KEY J
*** KEY UPDATED ***
Key = A8877C7007FB006F127BF34AC1942B02

0053 : .DES3 J 80
*** DES3 PROCESSED ***

0054 : * compute host cryptogram
0055 : .SET_DATA O H
*** DATA UPDATED ***

0056 : .SET_VECT_INI 0000000000000000
*** INIT VECTOR UPDATED ***

0057 : .SET_KEY I
*** KEY UPDATED ***
Key = 62C9707E8FA141184FEC9E6AD2B53CC8

0058 : .MAC33 O 80 /P
*** MAC33 PROCESSED ***

0059 : * compute command MAC
0060 : .SET_DATA 84 82 00 00 10 O
*** DATA UPDATED ***

0061 : .SET_VECT_INI 0000000000000000
*** INIT VECTOR UPDATED ***

0062 : .SET_KEY J
*** KEY UPDATED ***
Key = 629C33A1B61C01DC9CFE621BEDFA94C5

0063 : .MAC33 M 80 /P
*** MAC33 PROCESSED ***

0064 :
0065 :
0066 : .LIST_ON
0067 :
0068 : ;* External Authenticate
0069 : 84 82 00 00 10 O M (90 00)

Command : 84 82 00 00 10
Input Data : C7 26 01 65 76 13 95 D3 05 C8 0C CD 57 5A 47 39
Output Data : none
Status : 90 00

0070 : ;;.LIST_OFF

    ***************************************************************
    * CALL RESULT                                                  
    * Filename: OpenScp01.pcom 
    ***************************************************************
    *        NORMAL EXECUTION
    ***************************************************************
                    In 639 ms
    ***************************************************************

0024 :
0025 : .LIST_ON
0026 : ;80 E2 80 00 0B 9F66081145313403000000 (61xx,9000)
0027 : ;DEBUG: Command APDU:
0028 : ;80 E6 0C 00 29 0A 01020304050607080900 0B 0102030405060708090000 0B 0102030405060708090000 010002 C9 00 00
0029 :
0030 : ;80 E6 0C 00 10 A0000000770100000A10100000000001 10 A0000000770100000A10100100000001 0B A0000000770100000A1010 C9 12 FF0101010201030204020502060207020B0A 0000(61xx,9000) 0031 : ;84 E6 0C 00 64 10 A0000000185000000000000052414450 10 A0000000185000000000000052414441 10 A0000000185000000000000052414441 010025EF21C7020000C8020000CA170100FF0014070101020203030404050506060707000000 C9 00002440FDBAF2A0127F00 9000 0032 : ;80 E6 0C 00 10 A0000000770100000A10100000000001 10 A0000000770100000A10100100000001 09 A00000007741010101 C9 12 FF0101010201030204020502060207020B0A 0000 (61xx,9000)
0033 : ;00 A4 04 0C <?> A00000007741010101 (61xx,9000)
0034 :
0035 :
0036 : .POWER_OFF
0037 :
0038 :
0039 : ;80E60200 1D 10 A0000000770100000210000000000018 08 A00000000300000000000000(9000)
0040 : ;80E80000 21 C481CE01001ADECAFFED0102020101 10 A0000000770100000210000000000018 0200 (9000)
0041 : ;80E60C0046 10 A0000000770106000120000000000008 10 A0000000770106000120000100000008 0B A0000000041010D71003010 C9 12 FF0101010201030204020502060207020B0A 0000 (61xx,9000)
0042 : ;84 E6 0C 00 64 10 A0 00 00 00 18 50 00 00 00 00 00 00 52 41 44 50 10 A0 00 00 00 18 50 00 00 00 00 00 00 52 41 44 41 10 A0 00 00 00 18 50 00 00 00 00 00 00 52 41 44 41 01 00 25 EF 21 C7 02 00 00 C8 02 00 00 CA 17 01 00 FF 00 14 07 01 01 02 02 03 03 04 04 05 05 06 06 07 07 00 00 00 C9 00 00 24 40 FD BA F2 A0 12 7F (00)
0043 : ;00, 90 00 y ymm,8.8888888888888888888888888888888888888888888888888888ii8u

                 *********************************
                 *   FILE PROCESSING RESULT :    *
                 *                               *
                 *       NORMAL EXECUTION        *
                 *                               *
                 *********************************

proprietary FCI item warning

OK, I was a bit too quick about that warning - just used different cards: This is the warning I'm getting:

WARN pro.javacard.gp.GlobalPlatform - Unknown/unhandled tag in FCI proprietary data: 9F6E06479120813B00

... and this site https://www.eftlab.co.uk/index.php/site-map/knowledge-base/145-emv-nfc-tags says:
Third Party Data - The Third Party Data contains various information, possibly including information from a third party. If present in the Card, the Third Party Data must be returned in a file read using the READ RECORD command or in the File Control Information Template. 'Device Type' is present when the most significant bit of byte 1 of 'Unique Identifier' is set to 0b. In this case, the maximum length of 'Proprietary Data' is 26 bytes. Otherwise it is 28 bytes.

many errors in the installation, the applet does not wish to be default

installation with all the privileges:
`c:\work>gp --install online.cap --default --terminate -sdomain
[main] WARN pro.javacard.gp.GlobalPlatform - Unknown/unhandled tag in FCI propri
etary data: 9F6E06479100783300
Exception in thread "main" java.lang.IllegalArgumentException: apdu must be at l
east 4 bytes long
at javax.smartcardio.CommandAPDU.parse(Unknown Source)
at javax.smartcardio.CommandAPDU.(Unknown Source)
at pro.javacard.gp.GPTool.main(GPTool.java:468)
c:\work>gp -l
[main] WARN pro.javacard.gp.GlobalPlatform - Unknown/unhandled tag in FCI propri
etary data: 9F6E06479100783300

Mode: GP211

ISD: A000000003000000 (OP_READY)
Privs: SecurityDomain, CardLock, CardTerminate, CVMManagement
PKG: A0000000035350 (LOADED)
Applet: A000000003535041Now let only defaultc:\work>gp --install online.cap --default
[main] WARN pro.javacard.gp.GlobalPlatform - Unknown/unhandled tag in FCI propri
etary data: 9F6E06479100783300
[main] WARN pro.javacard.gp.GlobalPlatform - GET STATUS failed for 80F24002024F0
000 with 6a88
CAP loaded
[main] WARN pro.javacard.gp.GlobalPlatform - GET STATUS failed for 80F24002024F0
000 with 6a88

c:\work>gp -l
[main] WARN pro.javacard.gp.GlobalPlatform - Unknown/unhandled tag in FCI propri
etary data: 9F6E06479100783300

Mode: GP211

ISD: A000000003000000 (OP_READY)
Privs: SecurityDomain, CardLock, CardTerminate, CVMManagement

APP: D1D2D3D4D50101 (SELECTABLE)
Privs: CardReset

PKG: A0000000035350 (LOADED)
Applet: A000000003535041

PKG: D1D2D3D4D501 (LOADED)
Applet: D1D2D3D4D50101
Now terminate c:\work>gp --install online.cap --default --terminate
[main] WARN pro.javacard.gp.GlobalPlatform - Unknown/unhandled tag in FCI propri
etary data: 9F6E06479100783300
[main] WARN pro.javacard.gp.GlobalPlatform - GET STATUS failed for 80F24002024F0
000 with 6a88
CAP loaded
[main] WARN pro.javacard.gp.GlobalPlatform - GET STATUS failed for 80F24002024F0
000 with 6a88

c:\work>gp -l
[main] WARN pro.javacard.gp.GlobalPlatform - Unknown/unhandled tag in FCI propri
etary data: 9F6E06479100783300

Mode: GP211

ISD: A000000003000000 (OP_READY)
Privs: SecurityDomain, CardLock, CardTerminate, CVMManagement

APP: D1D2D3D4D50101 (SELECTABLE)
Privs: CardLock, CardTerminate, CardReset

PKG: A0000000035350 (LOADED)
Applet: A000000003535041

PKG: D1D2D3D4D501 (LOADED)
Applet: D1D2D3D4D50101
`
how to avoid these mistakes and make the applet defaults?

DESFire EV1 lead to java.lang.ArrayIndexOutOfBoundsException

Hi,

I'm trying to use your tool with a Mifare DESFire EV1 and Prox'n'Roll PC/SC Reader from SpringCard but I get exceptions on all cases.

Version

P:\Users\zero\Downloads>java -jar gp.jar -V
GlobalPlatformPro v0.3.7
Running on Windows 10 10.0 amd64, Java 1.8.0_74 by Oracle Corporation

Try 1 (Without specified ISD)

P:\Users\zero\Downloads>java -jar gp.jar -lvdi
[DEBUG] PlaintextKeys - static keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
# Detected readers from JNA2PCSC
[*] SpringCard Prox'N'Roll 0
SCardConnect("SpringCard Prox'N'Roll 0", T=*) -> T=1, 3B8180018080
SCardBeginTransaction("SpringCard Prox'N'Roll 0")
Reader: SpringCard Prox'N'Roll 0
ATR: 3B8180018080
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B8180018080

A>> T=1 (4+0000) 00A40400 00
A<< (0000+2) (3ms) 6A87
***** Card info:
A>> T=1 (4+0000) 80CA9F7F 00
A<< (0000+2) (2ms) 6E00
A>> T=1 (4+0000) 00CA9F7F 00
A<< (0000+2) (2ms) 6D00
[DEBUG] GlobalPlatform - GET DATA(CPLC) returned SW: 6D00
NO CPLC
***** CARD DATA
A>> T=1 (4+0000) 80CA0066 00
A<< (0000+2) (2ms) 6E00
NO CARD DATA
***** KEY INFO
A>> T=1 (4+0000) 80CA00E0 00
A<< (0000+2) (1ms) 6E00
A>> T=1 (4+0000) 00CA00E0 00
A<< (0000+2) (2ms) 6D00
[DEBUG] GlobalPlatform - GET DATA(Key Information Template) not supported
SCardEndTransaction()
SCardDisconnect("SpringCard Prox'N'Roll 0", true)
Exception in thread "main" java.lang.IllegalStateException: No selected ISD!
        at pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:365)
        at pro.javacard.gp.GPTool.main(GPTool.java:410)

Try 2 (with ISD)

P:\Users\zero\Downloads>java -jar gp.jar --sdaid D2760000850100 -lvdi
[DEBUG] PlaintextKeys - static keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
# Detected readers from JNA2PCSC
[*] SpringCard Prox'N'Roll 0
SCardConnect("SpringCard Prox'N'Roll 0", T=*) -> T=1, 3B8180018080
SCardBeginTransaction("SpringCard Prox'N'Roll 0")
Reader: SpringCard Prox'N'Roll 0
ATR: 3B8180018080
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B8180018080

A>> T=1 (4+0007) 00A40400 07 D2760000850100 00
A<< (0000+2) (4ms) 9000
SCardEndTransaction()
SCardDisconnect("SpringCard Prox'N'Roll 0", true)
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at pro.javacard.gp.TLVUtils.expectTag(TLVUtils.java:35)
        at pro.javacard.gp.TLVUtils.skipTagAndLength(TLVUtils.java:41)
        at pro.javacard.gp.GlobalPlatform.select(GlobalPlatform.java:225)
        at pro.javacard.gp.GPTool.main(GPTool.java:385)

Recommended card is JC 2.1.1 and applet installation fails

I purchased a couple of SmartCafe Expert 3.2 cards per the Wiki's recommendation, but this model uses JavaCard 2.2.1. Consequently, I was not able to install any applets on them. All the ones I tried - MuscleApplet, IsoApplet, and ykneo-openpgp - failed with an error similar to this one. (Unlocking was successful, though.)

โžœ  GlobalPlatformPro git:(master) โœ— gp -install AppletPlayground/MuscleApplet.cap -default
Applet loading failed. Are you sure the CAP file (JC version, packages) is compatible with your card?
pro.javacard.gp.GPException: LOAD failed SW: 6A80
    at pro.javacard.gp.GlobalPlatform.check(GlobalPlatform.java:1092)
    at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:728)
    at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:686)
    at pro.javacard.gp.GPTool.main(GPTool.java:471)
โžœ  GlobalPlatformPro git:(master) โœ—

I assume this error is referring to the fact that the card is JC 2.2.1. Is it possible to compile any OpenSC-compatible applet for 2.2.1? If not, I would recommend removing any 2.2.1 cards/purchase links from the hardware recommendations.

"kcv"

With "dual control" option but also available for "single component" use. "kcv" would provide means for key entry control - protection from typos when entering OP keys.

--bs option re-written by SELECT FCI

I think this needs a bit of a re-think. There are 2 aspects of the command length:

  1. what smartcard supports - FCI
  2. format of T=1 and efficient communication - the max Length of T=1 TPDU is 254B - this includes CLA INS P1 P2 Le. If it's longer, the reader will start chaining and there are additional message exchanges between reader and smartcard to transfer a few remaining bytes.

Card cryptogram invalid

Ran into this error with Gemalto Cyberflex Access 64K v2c (TOP IM FIPS CY2) cards. What might be causing it?

Log:

C:\Users\user\Downloads\gp>gp -sdaid A000000003000000 -l -d -v
[DEBUG] PlaintextKeys - static keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47

Detected readers from JNA2PCSC

[] Broadcom Corp Contacted SmartCard 0
SCardConnect("Broadcom Corp Contacted SmartCard 0", T=
) -> T=0, 3B959540FFAE01030000
SCardBeginTransaction("Broadcom Corp Contacted SmartCard 0")
Reader: Broadcom Corp Contacted SmartCard 0
ATR: 3B959540FFAE01030000
More information about your card:
http://smartcard-atr.appspot.com/parse?ATR=3B959540FFAE01030000

A>> T=0 (4+0008) 00A40400 08 A000000003000000 00
A<< (0027+2) (38ms) 6F198408A000000003000000A50D9F6E062091010342759F6501FF 9000
[DEBUG] GlobalPlatform - Auto-detected ISD AID: A000000003000000
[WARN] GlobalPlatform - Unknown/unhandled tag in FCI proprietary data: 9F6E06209101034275
[DEBUG] GlobalPlatform - Auto-detected block size: 255
A>> T=0 (4+0008) 80500000 08 EC7ADDC16616B17C 00
A<< (0028+2) (78ms) 0000600026101842A56B0101C3D8E4783663B864DC2C7B8F366375B4 9000
[DEBUG] GlobalPlatform - Host challenge: EC7ADDC16616B17C
[DEBUG] GlobalPlatform - Card challenge: C3D8E4783663B864
[DEBUG] GlobalPlatform - Card reports SCP01 with version 1 keys
[DEBUG] PlaintextKeys - session keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:DABBF6794A04F4316D5BF0579F1EF37D KCV: A77644
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:DABBF6794A04F4316D5BF0579F1EF37D KCV: A77644
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
pro.javacard.gp.GPException: STRICT WARNING: Card cryptogram invalid!
Card: DC2C7B8F366375B4
Host: 9555CB3EFB52130A
!!! DO NOT RE-TRY THE SAME COMMAND/KEYS OR YOU MAY BRICK YOUR CARD !!!
at pro.javacard.gp.GlobalPlatform.giveStrictWarning(GlobalPlatform.java:207)
at pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:583)
at pro.javacard.gp.GPTool.main(GPTool.java:463)

--force to solve installation failures automatically?

Some --force flag would be useful which could handle failures automatically.

For example: java -jar gp.jar --force -install applet.cap -default
could remove previous applet if it is already on the card and if there is some other applet with -default privilege then it would also be removed.

External authenticate failed

I'm trying to list my fidesmo card with GlobalPlatformPro v0.3.4, however:

$ java -jar ~/Downloads/gp.jar --relax -v -list 
Reader: SCL011 Contactless Reader [SCL01x Contactless Reader] (21161045208718) 00 00
ATR: 3B8980014A434F5032343252324A
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B8980014A434F5032343252324A

Auto-detected ISD AID: A000000151000000
Host challenge: 4849A29D9FCFC9E3
Card challenge: 001D47D2B3096958
Card reports SCP02 with version 1 keys
Master keys: 
Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
Sequnce counter: 001D
Derived session keys: 
Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:1526478F541984920D6C39016463B195
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:B3DC47CE007033D288B4EA273EE5C0F5
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:262AC040EA69227BD7FD5CDE2353454A
STRICT WARNING: Card cryptogram invalid!
Card: 2E4165CBA9B207F6
Host: 573B9A89EBF78EA3
!!! DO NOT RE-TRY THE SAME COMMAND/KEYS OR YOU MAY BRICK YOUR CARD !!!
Calculated host cryptogram: 8234791221A1FEBE
pro.javacard.gp.GPException: External authenticate failed SW: 6982
        at pro.javacard.gp.GlobalPlatform.check(GlobalPlatform.java:1092)
        at pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:534)
        at pro.javacard.gp.GPTool.main(GPTool.java:371)

Am I doing something silly? Is it because I don't give the User PIN?

Kind regards,

aanno

Bug with host cryptogram calculation in SCP02

I have my custom keyset of ENC, MAC, KEK running under SCP02:

gp -d -v --scp 2 --key-enc XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --key-mac YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY --key-kek ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ --list

I got the command output:

GlobalPlatformPro v0.3.9-24-g7e62155
Running on Mac OS X 10.12.1 x86_64, Java 1.8.0_60 by Oracle Corporation
Unlimited crypto policy is NOT installed!
ATTENTION: Overriding default keys ...
[DEBUG] PlaintextKeys - static keys: 
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX KCV: D3A661
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY KCV: AEE3F5
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ KCV: FC6828
# Detected readers from JNA2PCSC
[*] ACS ACR 38U-CCID
SCardConnect("ACS ACR 38U-CCID", T=*) -> T=0, 3B9F95801FC78031E073FE2113671192004001000118
SCardBeginTransaction("ACS ACR 38U-CCID")
Reader: ACS ACR 38U-CCID
ATR: 3B9F95801FC78031E073FE2113671192004001000118
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B9F95801FC78031E073FE2113671192004001000118

A>> T=0 (4+0000) 00A40400 00 
A<< (0017+2) (17ms) 6F0F8407A0000001510000A5049F6501FF 9000
[DEBUG] GlobalPlatform - Auto-detected ISD AID: A0000001510000
[DEBUG] GlobalPlatform - Auto-detected block size: 255
A>> T=0 (4+0008) 80500000 08 2E07ADE6502DC607 00
A<< (0028+2) (15ms) 0000C6D86A1CB20214132002000DFBC91D4F0C9E68060E82EA5C814B 9000
[DEBUG] GlobalPlatform - Host challenge: 2E07ADE6502DC607
[DEBUG] GlobalPlatform - Card challenge: 000DFBC91D4F0C9E
[DEBUG] GlobalPlatform - Card reports SCP02 with version 32 keys
[DEBUG] PlaintextKeys - session keys: 
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:AD24EAD378F1365E333FCBE909F3E6D2 KCV: 99BDEA
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:DCB288C75E7B4970E840FCB56A139507 KCV: 24138C
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:9E0E9B5D4B76B102ED0FCB6A1E3F0166 KCV: 4B590A
[DEBUG] GlobalPlatform - Verified card cryptogram: 68060E82EA5C814B
[DEBUG] GlobalPlatform - Calculated host cryptogram: 9C650864521157D8
A>> T=0 (4+0016) 84820100 10 9C650864521157D8126595F7B75ABC18
A<< (0000+2) (8ms) 6982
pro.javacard.gp.GPException: External authenticate failed SW: 6982
	at pro.javacard.gp.GPException.check(GPException.java:66)
	at pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:602)
	at pro.javacard.gp.GPTool.main(GPTool.java:465)
External authenticate failed SW: 6982

I ran with other tools (e.g. GPShell) and there is nothing wrong with the external authentication. I'm 100% sure of the correctness of my keyset, because when I manually changed that, I would get:

!!! DO NOT RE-TRY THE SAME COMMAND/KEYS OR YOU MAY BRICK YOUR CARD !!!
	at pro.javacard.gp.GlobalPlatform.giveStrictWarning(GlobalPlatform.java:207)
	at pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:583)
	at pro.javacard.gp.GPTool.main(GPTool.java:465)
STRICT WARNING: Card cryptogram invalid!

Can you double check the host cryptogram logic please?

Weird response in listing applets with long AID-s

Dear Martin,

I create a package that contains 22 equal applets.(The applets are equal in program but different in AID.)
When I set the package AID and applet's AIDs as below, everything is OK. (I can install it and I can see them in the response of gp -list command)

Package AID = 0102030405

App1 AID = 010203040501
App2 AID = 010203040502
App3 AID = 010203040503
App4 AID = 010203040504
App5 AID = 010203040505
App6 AID = 010203040506
App7 AID = 010203040507
App8 AID = 010203040508
App9 AID = 010203040509
App10 AID = 01020304050a
App11 AID = 01020304050b
App12 AID = 01020304050c
App13 AID = 01020304050d
App14 AID = 01020304050e
App15 AID = 01020304050f
App16 AID = 010203040510
App17 AID = 010203040511
App18 AID = 010203040512
App19 AID = 010203040513
App20 AID = 010203040514
App21 AID = 010203040515
App22 AID = 010203040516

Look :

gp: gp -list
AID: A000000151000000 (|....Q...|)
     ISD OP_READY: Security Domain, Card lock, Card terminate, Default selected,
 CVM (PIN) management

AID: A0000001515350 (|....QSP|)
     ExM LOADED: (none)
     A000000151535041 (|....QSPA|)


gp: gp -install e:\PackageWithShortAIDs.cap

gp: gp -list
AID: A000000151000000 (|....Q...|)
     ISD OP_READY: Security Domain, Card lock, Card terminate, Default selected,
 CVM (PIN) management

AID: 010203040507 (|......|)
     App SELECTABLE: (none)

AID: A0000001515350 (|....QSP|)
     ExM LOADED: (none)
     A000000151535041 (|....QSPA|)

AID: 0102030405 (|.....|)
     ExM LOADED: (none)
     010203040507 (|......|)
     010203040506 (|......|)
     010203040505 (|......|)
     010203040504 (|......|)
     010203040503 (|......|)
     010203040502 (|......|)
     010203040501 (|......|)
     010203040513 (|......|)
     010203040512 (|......|)
     010203040511 (|......|)
     010203040510 (|......|)
     01020304050F (|......|)
     01020304050E (|......|)
     01020304050D (|......|)
     01020304050C (|......|)
     01020304050B (|......|)
     01020304050A (|......|)
     010203040516 (|......|)
     010203040515 (|......|)
     010203040514 (|......|)
     010203040509 (|......|)
     010203040508 (|......|)  
gp:

Now,I change I change the AID of Applets as below (everything else is the same as for before) :

Package AID = 0102030405

App1 AID = 0102030405060708090001
App2 AID = 0102030405060708090002
App3 AID = 0102030405060708090003
App4 AID = 0102030405060708090004
App5 AID = 0102030405060708090005
App6 AID = 0102030405060708090006
App7 AID = 0102030405060708090007
App8 AID = 0102030405060708090008
App9 AID = 0102030405060708090009
App10 AID = 010203040506070809000a
App11 AID = 010203040506070809000b
App12 AID = 010203040506070809000c
App13 AID = 010203040506070809000d
App14 AID = 010203040506070809000e
App15 AID = 010203040506070809000f
App16 AID = 0102030405060708090010
App17 AID = 0102030405060708090011
App18 AID = 0102030405060708090012
App19 AID = 0102030405060708090013
App20 AID = 0102030405060708090014
App21 AID = 0102030405060708090015
App22 AID = 0102030405060708090016

In this case, I can load and install it. But I can't list my installed applets anymore!

gp: gp -list
AID: A000000151000000 (|....Q...|)
     ISD OP_READY: Security Domain, Card lock, Card terminate, Default selected,
 CVM (PIN) management

AID: A0000001515350 (|....QSP|)
     ExM LOADED: (none)
     A000000151535041 (|....QSPA|)


gp: gp -install e:\PackageWithLongAIDs.cap

gp: gp -list
javax.smartcardio.CardException: Get Status failed, SW: 6A88
        at pro.javacard.gp.GlobalPlatform.getConcatenatedStatus(GlobalPlatform.j
ava:1020)
        at pro.javacard.gp.GlobalPlatform.getStatus(GlobalPlatform.java:1070)
        at pro.javacard.gp.GlobalPlatform.getRegistry(GlobalPlatform.java:673)
        at pro.javacard.gp.GPTool.main(GPTool.java:499)
Exception in thread "main" javax.smartcardio.CardException: Get Status failed, S
W: 6A88
        at pro.javacard.gp.GlobalPlatform.getConcatenatedStatus(GlobalPlatform.j
ava:1020)
        at pro.javacard.gp.GlobalPlatform.getStatus(GlobalPlatform.java:1070)
        at pro.javacard.gp.GlobalPlatform.getRegistry(GlobalPlatform.java:673)
        at pro.javacard.gp.GPTool.main(GPTool.java:499)

gp:

Debug mode output :

.
. 
.
A>> T=1 (4+0008) 80500000 08 E81EAC2B833E5DCF
A<< (0028+2) (70ms) 00004198001714974248FF0200B93785186688F163331EF41FA02CB8 900
0
Host challenge: E81EAC2B833E5DCF
Card challenge: 00B93785186688F1
Card reports SCP02 with version 255 keys
Master keys:
Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
Sequnce counter: 00B9
Derived session keys:
Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:1EC5FBCA9A5F21F727C14461A7D7E2C6
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:2688CFFD58CCF9EB52B5D5E786364C89
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:C181FE8094950965495E0D5023AFD65D
Verified card cryptogram: 63331EF41FA02CB8
Calculated host cryptogram: A269860A0E584230
A>> T=1 (4+0016) 84820100 10 A269860A0E5842301E0CBE71E485EA79
A<< (0000+2) (66ms) 9000
A>> T=1 (4+0010) 84F28000 0A 4F00DF01359AC330E966
A<< (0011+2) (46ms) 08A000000151000000019E 9000
A>> T=1 (4+0010) 84F24000 0A 4F003E447E78BC4DE5CC
A<< (0014+2) (45ms) 0B01020304050607080900070700 9000
A>> T=1 (4+0010) 84F22000 0A 4F00D20EAEA9E44363C1
A<< (0018+2) (48ms) 07A000000151535001000501020304050100 9000
A>> T=1 (4+0010) 84F21000 0A 4F003EA1383F26463052
A<< (0020+2) (54ms) 07A000000151535001000108A000000151535041 6310
A>> T=1 (4+0010) 84F21001 0A 4F002196E82C3A537F62
A<< (0000+2) (50ms) 6A88
javax.smartcardio.CardException: Get Status failed, SW: 6A88
        at pro.javacard.gp.GlobalPlatform.getConcatenatedStatus(GlobalPlatform.j
ava:1020)
        at pro.javacard.gp.GlobalPlatform.getStatus(GlobalPlatform.java:1070)
        at pro.javacard.gp.GlobalPlatform.getRegistry(GlobalPlatform.java:673)
        at pro.javacard.gp.GPTool.main(GPTool.java:499)
SCardEndTransaction()
SCardDisconnect("ACS CCID USB Reader 0", false)
Exception in thread "main" javax.smartcardio.CardException: Get Status failed, S
W: 6A88
        at pro.javacard.gp.GlobalPlatform.getConcatenatedStatus(GlobalPlatform.j
ava:1020)
        at pro.javacard.gp.GlobalPlatform.getStatus(GlobalPlatform.java:1070)
        at pro.javacard.gp.GlobalPlatform.getRegistry(GlobalPlatform.java:673)
        at pro.javacard.gp.GPTool.main(GPTool.java:499)

gp:

Is this a issue related to my card or it is related to the GlobalPlatformPro?

problem when cap file too large

I got " java.lang.ArrayIndexOutOfBoundsException" when my cap file is 83KB

It worked fine when I decrease cap file size to *73KB. *

Here it is trace log when I install my 83KB cap file.

gp -d -v  -install sjy71.cap
# Detected readers from SunPCSC
[*] OMNIKEY CardMan 1021 0
SCardConnect("OMNIKEY CardMan 1021 0", T=*) -> T=0, 3B9F95803FC7A08031E073FE2113
6701434F5357A101F2
SCardBeginTransaction("OMNIKEY CardMan 1021 0")
Reader: OMNIKEY CardMan 1021 0
ATR: 3B9F95803FC7A08031E073FE21136701434F5357A101F2
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B9F95803FC7A08031E073FE211367014
34F5357A101F2

A>> T=0 (4+0000) 00A40400 00
A<< (0081+2) (31ms) 6F4F8410D1560001010001600000000100000000A53B7331732F06072A81
1C86FC6B01600C060A2A811C86FC6B02020101630906072A811C86FC6B03640B06092A811C86FC6B
0402159F6E010F9F6501FF 9000
Auto-detected ISD AID: D1560001010001600000000100000000
A>> T=0 (4+0008) 80500000 08 7946FBBBE2F9F3DF
A<< (0028+2) (18ms) 0182000000000000000020020236A74EFBEC430CC65C9DBE2055C8CB 900
0
Host challenge: 7946FBBBE2F9F3DF
Card challenge: 0236A74EFBEC430C
Card reports SCP02 with version 32 keys
Master keys:
Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F
Sequnce counter: 0236
Derived session keys:
Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:7CDFBDCFDEB3E13DDD26075E22CEE6FB
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:28AEB6F000838BB06BCFB1E3812A43F3
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:4367EBD1840B5353AB28F742EE0125FD
Verified card cryptogram: C65C9DBE2055C8CB
Calculated host cryptogram: 92F94A2E3ED1E091
A>> T=0 (4+0016) 84820100 10 92F94A2E3ED1E091CB6767E45D44E820
A<< (0000+2) (16ms) 9000
A>> T=0 (4+0010) 84F28000 0A 4F007919D70A56172156
A<< (0019+2) (10ms) 10D15600010100016000000001000000000F9A 9000
A>> T=0 (4+0010) 84F24000 0A 4F00AFDEFCEF9D98C98F
A<< (0061+2) (15ms) 09A0000001514352530007000CA000000063504B43532D313507000E3250
41592E5359532E444446303107000E315041592E5359532E44444630310700 9000
A>> T=0 (4+0010) 84F22000 0A 4F00C778C891C35B8907
A<< (0240+2) (33ms) 10D1560001010001610000000000000000010008A0000001514352530100
07A0000000620301010007A0000000620002010007A0000000620001010007A00000006200030100
07A0000000620101010008A000000062010101010007A0000000620102010007A000000062020101
0009A00000006202080101010007A000000062020301000FA0636F73770067707365727669636501
0006A00000015100010006A00000015102010010A0000000090003FFFFFFFF8910710001010010A0
000000090003FFFFFFFF891071000201000BA0636F7377000E00000E00010010A0000000090005FF
FFFFFF89110000000100 6310
A>> T=0 (4+0010) 84F22001 0A 4F00510F323D96C32586
A<< (0248+2) (35ms) 10A0000000090005FFFFFFFF8911010000010010A0000000090005FFFFFF
FF8913000000010010A0000000090005FFFFFFFF8912000000010010A0000000090005FFFFFFFF89
15000000010010A0000000871005FFFFFFFF8913100000010010A0000000871005FFFFFFFF891320
0000010008A0636F737700FE00010010A0000000090005FFFFFFFF8916010000010010A000000009
0005FFFFFFFF8916020100010010A0000000090005FFFFFFFF8916020200010010A0000000090005
FFFFFFFF89160203000100060A0300000002010010D15600010100016000FFFFFF02000000010010
D15600010100016000FFFFFF010000000100 6310
A>> T=0 (4+0010) 84F22001 0A 4F00C57E6F94BF22B001
A<< (0155+2) (25ms) 10A0636F7377696E7465726E616C41504901000BA0636F7377535A544150
4901000BA0636F7377535A5441504A01000BA0636F7377000C00000C00010009A000000062030101
0101000AD1560001010A030002080100060A03000000010100060A030000000301000A0A03000000
1CCE561F00010010D1560001018001600000050100000000010010D1560001018001600000050100
0000010100 9000
A>> T=0 (4+0010) 84F21000 0A 4F005C2D6BACA45EF706
A<< (0251+2) (35ms) 10D156000101000161000000000000000001000110D15600010100016110
0000000000000008A00000015143525301000109A0000001514352530007A0000000620301010000
07A000000062000201000007A000000062000101000007A000000062000301000007A00000006201
0101000008A00000006201010101000007A000000062010201000007A000000062020101000009A0
000000620208010101000007A00000006202030100000FA0636F7377006770736572766963650100
0006A0000001510001000006A0000001510201000010A0000000090003FFFFFFFF89107100010100
0010A0000000090003FFFFFFFF8910710002010000 6310
A>> T=0 (4+0010) 84F21001 0A 4F001BCB50BC1033E948
A<< (0247+2) (35ms) 0BA0636F7377000E00000E0001000010A0000000090005FFFFFFFF891100
000001000010A0000000090005FFFFFFFF891101000001000010A0000000090005FFFFFFFF891300
000001000010A0000000090005FFFFFFFF891200000001000010A0000000090005FFFFFFFF891500
000001000010A0000000871005FFFFFFFF891310000001000010A0000000871005FFFFFFFF891320
000001000008A0636F737700FE0001000010A0000000090005FFFFFFFF891601000001000010A000
0000090005FFFFFFFF891602010001000010A0000000090005FFFFFFFF891602020001000010A000
0000090005FFFFFFFF8916020300010000 6310
A>> T=0 (4+0010) 84F21001 0A 4F0034E84298047A9D58
A<< (0228+2) (33ms) 060A030000000201000010D15600010100016000FFFFFF02000000010000
10D15600010100016000FFFFFF0100000001000010A0636F7377696E7465726E616C415049010000
0BA0636F7377535A544150490100000BA0636F7377535A5441504A0100000BA0636F7377000C0000
0C0001000009A000000062030101010100000AD1560001010A030002080100010ED1560001015468
6DB50A03000208060A0300000001010000060A03000000030100000A0A030000001CCE561F000100
0010D156000101800160000005010000000001000110D1560001018001600000050200000000 631
0
A>> T=0 (4+0010) 84F21001 0A 4F003332EE6ACBAE52DB
A<< (0037+2) (12ms) 10D156000101800160000005010000000101000110D15600010180016000
00050200000001 9000
No manifest in CAP. Information from Header and Applet components:
Package: sjy71 v0.1 with AID D1560000403000635900505100000000
Applet: AID D1560000405000635900505100000000
Installing applet from package sjy71
A>> T=0 (4+0045) 84E60200 2D 10D156000040300063590050510000000010D15600010100016
00000000100000000000000D9D61F4C596EF23A
A<< (0001+2) (20ms) 9000
SCardEndTransaction()
SCardDisconnect("OMNIKEY CardMan 1021 0", false)
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at pro.javacard.gp.CapFile.getRawCode(CapFile.java:262)
        at pro.javacard.gp.CapFile.getLoadBlocks(CapFile.java:220)
        at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:722)
        at pro.javacard.gp.GlobalPlatform.loadCapFile(GlobalPlatform.java:684)
        at pro.javacard.gp.GPTool.main(GPTool.java:448)

No Selected ISD error

Hi, I am seeing a No selected ISD! error when running commands via Feitian smartcards and also using Feitian's card reader.

1.) Attempting to use list.

C:\>java -jar gp.jar -v -d -l
# Detected readers from SunPCSC
[ ] 0FTJC8 Virtual Card Reader 0
[ ] 0FTJC8 Virtual Ctless Reader 1
[ ] Unknown
[*] Feitian SCR301 0
SCardConnect("Feitian SCR301 0", T=*) -> T=0, 3B959640F001130A001D
SCardBeginTransaction("Feitian SCR301 0")
Reader: Feitian SCR301 0
ATR: 3B959640F001130A001D
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B959640F001130A001D

A>> T=0 (4+0000) 00A40400 00
A<< (0000+2) (2ms) 6A81
SCardEndTransaction()
SCardDisconnect("Feitian SCR301 0", false)
Exception in thread "main" java.lang.IllegalStateException: No selected ISD!
        at pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:
366)
        at pro.javacard.gp.GPTool.main(GPTool.java:371)

2.) Attempting to set ISD AID

C:\>java -jar gp.jar -v -d -l --sdaid A000000003000000 --all
# Detected readers from SunPCSC
[ ] 0FTJC8 Virtual Card Reader 0
[ ] 0FTJC8 Virtual Ctless Reader 1
[ ] Unknown
[*] Feitian SCR301 0
SCardConnect("Feitian SCR301 0", T=*) -> T=0, 3B959640F001130A001D
SCardBeginTransaction("Feitian SCR301 0")
Reader: Feitian SCR301 0
ATR: 3B959640F001130A001D
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B959640F001130A001D

A>> T=0 (4+0008) 00A40400 08 A000000003000000 00
A<< (0000+2) (2ms) 6A81
SCardEndTransaction()
SCardDisconnect("Feitian SCR301 0", false)
Exception in thread "main" java.lang.IllegalStateException: No selected ISD!
        at pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:
366)
        at pro.javacard.gp.GPTool.main(GPTool.java:371)

3.) Attempting to select ISD's AID instead of using --sdaid flag hoping to get something up

C:\>java -jar gp.jar -v -d -l --applet A000000003000000 --all
# Detected readers from SunPCSC
[ ] 0FTJC8 Virtual Card Reader 0
[ ] 0FTJC8 Virtual Ctless Reader 1
[ ] Unknown
[*] Feitian SCR301 0
SCardConnect("Feitian SCR301 0", T=*) -> T=0, 3B959640F001130A001D
SCardBeginTransaction("Feitian SCR301 0")
Reader: Feitian SCR301 0
ATR: 3B959640F001130A001D
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B959640F001130A001D

A>> T=0 (4+0000) 00A40400 00
A<< (0000+2) (2ms) 6A81
SCardEndTransaction()
SCardDisconnect("Feitian SCR301 0", false)
Exception in thread "main" java.lang.IllegalStateException: No selected ISD!
        at pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:
366)
        at pro.javacard.gp.GPTool.main(GPTool.java:371)

Do not fail silently

Currently if card or reader is not plugged in the tool will silently quit without giving any error message.
Would be nice to have something being output on the screen.

Unable to initiate a scp03 session?

Hi,

I'm trying to run this basic command against a blank Oberthur ID-One v8 card, and it seems not able to establish SCP03 session? I am also new into the whole smartcard thing, so if I'm running the commands wrong, please let me know.

gp -l -d -v
[DEBUG] PlaintextKeys - static keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
# Detected readers from JNA2PCSC
[*] ACS ACR39U ICC Reader 0
SCardConnect("ACS ACR39U ICC Reader 0", T=*) -> T=1, 3BD6970081B1FE451F078031C1521118F9
SCardBeginTransaction("ACS ACR39U ICC Reader 0")
Reader: ACS ACR39U ICC Reader 0
ATR: 3BD6970081B1FE451F078031C1521118F9
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3BD6970081B1FE451F078031C1521118F9

A>> T=1 (4+0000) 00A40400 00
A<< (0066+2) (58ms) 6F408407A0000001510000A535732F06072A864886FC6B01600C060A2A864886FC6B02020201630906072A864886FC6B03640B06092A864886FC6B0403709F6501FF 9000
[DEBUG] GlobalPlatform - Auto-detected ISD AID: A0000001510000
[DEBUG] GlobalPlatform - Auto-detected GP version: GP22
[DEBUG] GlobalPlatform - Auto-detected block size: 255
A>> T=1 (4+0008) 80500000 08 6F0CD0DB2C6462C5 00
A<< (0032+2) (304s266ms) 1424613300001AA00100010370C2247885FB5321D4EC35A1EC595494E7000011 9000
[DEBUG] GlobalPlatform - Host challenge: 6F0CD0DB2C6462C5
[DEBUG] GlobalPlatform - Card challenge: C2247885FB5321D4
[DEBUG] GlobalPlatform - Card reports SCP03 with version 1 keys
[DEBUG] GlobalPlatform - SCP03 i=112
[DEBUG] PlaintextKeys - session keys:
ENC: Ver:0 ID:0 Type:AES Len:16 Value:B5945860AE54730EF6D1869040E0547C KCV: 85D2A0
MAC: Ver:0 ID:0 Type:AES Len:16 Value:7B71175F90F8729A03B2D06566A54D5D KCV: 03AFF7
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
pro.javacard.gp.GPException: STRICT WARNING: Card cryptogram invalid!
Card: EC35A1EC595494E7
Host: 2AA4AF9689B10560
!!! DO NOT RE-TRY THE SAME COMMAND/KEYS OR YOU MAY BRICK YOUR CARD !!!
        at pro.javacard.gp.GlobalPlatform.giveStrictWarning(GlobalPlatform.java:207)
        at pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:583)
        at pro.javacard.gp.GPTool.main(GPTool.java:463)

-scp option not working properly with gp.exe

I have two commands that expected to behave the same:
gp -key-enc 404142434445464748494a4b4c4d4e4f -key-kek 404142434445464748494a4b4c4d4e4f -key-mac 404142434445464748494a4b4c4d4e4f -mode mac keyid 0 keyver 0 -sdaid A000000151000000 -debug -list

gp -key-enc 404142434445464748494a4b4c4d4e4f -key-kek 404142434445464748494a4b4c4d4e4f -key-mac 404142434445464748494a4b4c4d4e4f -mode mac -scp 2 keyid 0 keyver 0 -sdaid A000000151000000 -debug -list

The only difference is the addition of "-scp 2" in the second command. The card clearly supports scp 02. The options are explicitly stated.

The first command is okay in external authentication. The second command is not okay in external authentication (0x6982).

I need to understand what could be the issue I am encountering right now. I tried some proprietary tools and it works perfectly but I need to make it work here in GlobalPlatformPro.
Thanks

Exception when installing CAP without applet AID

Hi,
I get an exception when installing a CAP file, that has a package without applet and therefore no applet AID.

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at pro.javacard.gp.GPTool.main(GPTool.java:567)

Commit is 276edf5

Cheers,
Thomas

Dual control

"dualcontrol" - that will allow entering and reconstructing OP keys from components (2 or 3).

Not clear how to create new instances of apps

It isn't entirely clear to me how to create a new instance of an installed applet using the --create argument. The relation of this argument with the --package and/or --applet/--cap arguments is also frustratingly vague.

I'm trying to create an instance of an OpenPGP app on a card with a specific serial number, but I can't seem to figure out the right arguments.

Doing something like gp --package D27600012401 --applet D27600012401 --create 02000000000272950000 doesn't seem to work. (Error Install for Install and make selectable failed SW: 6A88)

Could you add some examples of how to do this?

Exception when installing CAP file

Hi.

I am getting this exception when trying to install my applets:

Exception in thread "main" java.lang.NullPointerException
at java.io.FileInputStream.(Unknown Source)
at pro.javacard.gp.GPTool.main(GPTool.java:548)

That line doesn't look like it should be doing something very complicated. Does anybody have any idea why this exception is thrown?

Here's the DEBUG output of GP.exe:

[DEBUG] PlaintextKeys - static keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:404142434445464748494A4B4C4D4E4F KCV: 8BAF47
# Detected readers from JNA2PCSC
[*] ACS ACR1281 1S Dual Reader PICC 0
SCardConnect("ACS ACR1281 1S Dual Reader PICC 0", T=*) -> T=1, 3B8B80010031C0641F27010000900036
SCardBeginTransaction("ACS ACR1281 1S Dual Reader PICC 0")
Reader: ACS ACR1281 1S Dual Reader PICC 0
ATR: 3B8B80010031C0641F27010000900036
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B8B80010031C0641F27010000900036

A>> T=1 (4+0000) 00A40400 00
A<< (0063+2) (53ms) 6F3D8408A000000003000000A5319F6E2A4790516882310258006B223468000FA2000111422234426353624264536201FFFF0100000000000000009F6501FF 9000
[DEBUG] GlobalPlatform - Auto-detected ISD AID: A000000003000000
[WARN] GlobalPlatform - Unknown/unhandled tag in FCI proprietary data: 9F6E2A4790516882310258006B223468000FA2000111422234426353624264536201FFFF010000000000000000
[DEBUG] GlobalPlatform - Auto-detected block size: 255
***** Card info:
A>> T=1 (4+0000) 80CA9F7F 00
A<< (0045+2) (10ms) 9F7F2A4790516882310258006B223468000FA2000111422234426353624264536201FFFF010000000000000000 9000
Card CPLC:
ICFabricator: 4790
ICType: 5168
OperatingSystemID: 8231
OperatingSystemReleaseDate: 0258
OperatingSystemReleaseLevel: 006B
ICFabricationDate: 2234
ICSerialNumber: 68000FA2
ICBatchIdentifier: 0001
ICModuleFabricator: 1142
ICModulePackagingDate: 2234
ICCManufacturer: 4263
ICEmbeddingDate: 5362
ICPrePersonalizer: 4264
ICPrePersonalizationEquipmentDate: 5362
ICPrePersonalizationEquipmentID: 01FFFF01
ICPersonalizer: 0000
ICPersonalizationDate: 0000
ICPersonalizationEquipmentID: 00000000
***** CARD DATA
A>> T=1 (4+0000) 80CA0066 00
A<< (0051+2) (12ms) 6631732F06072A864886FC6B01600C060A2A864886FC6B02020101630906072A864886FC6B03640B06092A864886FC6B040215 9000
Unknown tag: 31
***** KEY INFO
A>> T=1 (4+0000) 80CA00E0 00
A<< (0020+2) (10ms) E012C00401018010C00402018010C00403018010 9000
VER:1 ID:1 TYPE:DES3 LEN:16
VER:1 ID:2 TYPE:DES3 LEN:16
VER:1 ID:3 TYPE:DES3 LEN:16
A>> T=1 (4+0008) 80500000 08 39692502711DFD1D 00
A<< (0028+2) (26ms) 03600000000168000FA2010200AD1089A9516A889330C7326E1DC7A6 9000
[DEBUG] GlobalPlatform - Host challenge: 39692502711DFD1D
[DEBUG] GlobalPlatform - Card challenge: 00AD1089A9516A88
[DEBUG] GlobalPlatform - Card reports SCP02 with version 1 keys
[DEBUG] PlaintextKeys - card keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:6E715EDC24B47F23AAC4BCECCF24AD7B KCV: C8D607
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:C0D8C14C5E715E3FACFAC7FB0F38DCD4 KCV: 7F1182
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:C71CF7BAB2958FE622F47AC493357425 KCV: F36DE0
[DEBUG] PlaintextKeys - session keys:
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:5F27B52DF5E37F3FEC82C28630EF2C8E KCV: 9EF063
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:AF4A0D6043C7BD56D062222DF0D3BBB8 KCV: A29567
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:BB13E4C1DA859B10C410DCD7E8BD3667 KCV: 31673F
[DEBUG] GlobalPlatform - Verified card cryptogram: 9330C7326E1DC7A6
[DEBUG] GlobalPlatform - Calculated host cryptogram: CB3634416BC59C1F
A>> T=1 (4+0016) 84820100 10 CB3634416BC59C1F0DBF76ABE552AF10
A<< (0000+2) (28ms) 9000
CAP file (v2.1) generated on Sat Apr 16 11:31:09 EST 2016
By Sun Microsystems Inc. converter 1.3 with JDK 1.4.2_19 (Sun Microsystems Inc.)
Package: issuer v1.0 with AID 4B4650495353554552
Applet: Issuer with AID 4B465049535355455200
Import: 4B465042617365 v1.0
Import: A0000000620101 v1.2
Import: A0000000620001 v1.0
Total code size: 2042 bytes (2516 with debug)
SHA256 (code): 5CA3DAA3BAB25106C3166E187CA987BF720FF69F2E3B38FD585B6FC9B80C1C96
SHA1   (code): 8A9BD64F4A4030B4FA6BE3AB807D1BD7DF0CFE98
A>> T=1 (4+0010) 84F28002 0A 4F0075002CC6284E0B0D 00
A<< (0019+2) (16ms) E3114F08A0000000030000009F700107C5019E 9000
A>> T=1 (4+0010) 84F24002 0A 4F00F0BACCB5A4321908 00
A<< (0000+2) (14ms) 6A88
[WARN] GlobalPlatform - GET STATUS failed for 80F24002024F0000 with 6a88
A>> T=1 (4+0010) 84F22002 0A 4F00772E97E22624D343 00
A<< (0044+2) (24ms) E3144F07A00000000353509F700101C50100CE020203E3144F074B4650426173659F700101C50100CE020100 9000
A>> T=1 (4+0010) 84F21002 0A 4F0045C634FE9B2E1F67 00
A<< (0072+2) (28ms) E3304F07A00000000353509F700101C50100CE0202038407A00000000300008407A00000015100008408A000000003535041E3144F074B4650426173659F700101C50100CE020100 9000
A>> T=1 (4+0030) 84E60200 1E 094B465049535355455208A0000000030000000000005CE2BBE4E9CC8DA4
A<< (0001+2) (70ms) 00 9000
A>> T=1 (4+0255) 84E80000 FF C48207FA010013DECAFFED0102040001094B465049535355455202001F0013001F000E001F00C600500550002700F3000001D700020001001A03010004001F030001074B465042617365020107A0000000620101000107A000000062000103000E010A4B4650495353554552000009060050428004040004051300000359FFFFFFFFFFFFFFFFFFFFFFFF036F035D00740362037503B903D402B202C202D302E4034E810200800104141516170082000100010100000000800203000301010000041907055001035080050356002D02308F00123D8C001F3B7A0511188C001E181010900B8700181010910025870103301D10106D12AD019FD45F60A8FE5290
A<< (0001+2) (156ms) 00 9000
A>> T=1 (4+0255) 84E80001 FF 1D8F00253D8C00143759010170ED188F001C3D8C001D8702AD0303AD0392038D00203B188F00233D06058C00248704AD048B0026AD04AD0303058B0029188B002E7A80100201AE057502340004FFCA006DFFDC0155001100150020004D03311E10106D13AD001E2560081169868D001359020170ECAE0610106A081167008D00138D00151908AD000310108D00163B8D0017A801EC18078B0018AD041908058B00199901DC1063AD048B001A8D001B8D0013A801CCAE076166AE08750037000300010011000200200017002F18038809190304381804890AA801A618038809190305381804890AA8019718048B0018A8018F18048B001817E45583FC416B3B
A<< (0001+2) (67ms) 00 9000
A>> T=1 (4+0255) 84E80002 FF 18AD02830B7B0021AE0804432519037B0021AE08257B0021AE08044325438D0022890AA80164AE0704A3007418048B0018AE08AD01926C08116A868D001318AD01AE0824830C0319AD01AE0824830D830B0319AD01AE0824830E830B0319AD01AE0824830F031903AD01AE0824830F928D0022AD01AE0824830E830B928D0022AD01AE0824830D830B928D0022AD01AE0824830C928D0022890AA800ED116A868D0013A800E4AE079900D7AE08066D08116A868D0013AE0810176B1C18058B0018188B00276106188B0028AD041908058B0029A800B4AE0810186A08AE0810196B0A1810088B001870081810808B00188D0015AD02830B448A3881B2837EE9
A<< (0001+2) (57ms) 00 9000
A>> T=1 (4+0255) 84E80003 FF 7B0021AE08044325AD01AD10042524830E830B7B0021AE080443257B0021AE08257B0021AE08044325438D00163B1908AD01AD10042524830D830B7B0021AE080443257B0021AE08257B0021AE08044325438D00163BAD01AD10042524AE088B002A1908AD02830B7B0021AE080443257B0021AE08257B0021AE08044325438D00163B8D0017700A116A868D0013037804780110AD048B002B61081169828D00137A0210AD02830B103A25046B0504700303780320AD02830B7B002108251D418D002C78052105900B3D0303383D041D382D8D0015AD02830B7B0021101725AD01AD10042524830E830B7B0021101725058D00163B1A03D50C9478C6BFF14D
A<< (0001+2) (57ms) 00 9000
A>> T=1 (4+0255) 84E80004 FF AD01AD10042524830D830B7B0021101725058D00163BAD01AD1004252410188B002A1A03AD02830B7B0021101725058D00163B8D00177A0111188B002804782C03780130187701101007780530AD0003191E10108D0022780110111612780310AD110525730037000000040011001900200027002FAD1104108B387026AD11040438701FAD110408387018AD11041007387010AD1104100D3870081199008D00137A0310188B00276114AE076010119800AD02830B103A25418D00137A0510AD0303AD01AD10042524830F0310168D00163B7A0210188C002F18103D900B870B7A0310188C0030188F001C3D8C001D870E188F001C3D8CCDC54DAF2747F00E
A<< (0001+2) (57ms) 00 9000
A>> T=1 (4+0255) 84E80005 FF 001D870D1806900B870C7A04201D7301330003001900350041004D005900650071007C00870092009E00AA00B600C100CC00D600E000EA00F50100010B01160121012BAD0C033E2510805538A800F5AD0C033E2510405538A800E9AD0C033E2510205538A800DDAD0C033E2510105538A800D1AD0C033E2510085538A800C5AD0C033E25075538A800BAAD0C033E25055538A800AFAD0C033E25045538A800A4AD0C043E2510805538A80098AD0C043E2510405538A8008CAD0C043E2510205538A80080AD0C043E25101055387074AD0C043E25100855387069AD0C043E25075538705FAD0C043E250555387055AD0C043E2504553870BDBD8F6AA0C7A879
A<< (0001+2) (56ms) 00 9000
A>> T=1 (4+0255) 84E80006 FF 4BAD0C053E25108055387040AD0C053E25104055387035AD0C053E2510205538702AAD0C053E2510105538701FAD0C053E25100855387014AD0C053E25075538700AAD0C053E250555387A08002700020001000103001AFFFF00021618202223242526282A2B2C2D2E2F303135393A3B3C000000000500C600310200000002000001020000020280040E0200000302800402028004050280040302800404028004000280040602003A0002004402020044010200440002800200028004090280040D0100000006810701060003F80681080106811001068108020380040B03810901038109020681100501003A00060003EA0680040006410F1C0FD7B6B2E8
A<< (0001+2) (107ms) 00 9000
A>> T=1 (4+0255) 84E80007 FF 00001406811003050000000681100201810900068109000100440003810906030000140300001303810908030044010381090406811004018107000381030106820000068002000900F3009720080918020312020502101E1111140D0E04150807081302050A0609050B020C020304020302040203020402030502030602030206020302060203060E050B150B06170205050205020508060C0205020508060A020507020508061B10020F021E02080205020F0205020D020C02271315080707081707020C03020515110A063B0C0C0C0C0C0B0B0B0C0C0C0B0B0A0A0A0B0B0B0B0B0A0058070504080D0F040A040C05060709042F1103C854F17B2A601F63
A<< (0001+2) (547ms) 00 9000
A>> T=1 (4+0078) 84E88008 4E 0A0408080A03033D08080A0609100D350D0D0B0B130B0406081508030713080609110806090D0908060904080B081B071207110711070D090704071A4A071415080E040406042B53755EED3D9020
A<< (0001+2) (266ms) 00 9000
SCardEndTransaction()
SCardDisconnect("ACS ACR1281 1S Dual Reader PICC 0", true)
Exception in thread "main" java.lang.NullPointerException
        at java.io.FileInputStream.<init>(Unknown Source)
        at pro.javacard.gp.GPTool.main(GPTool.java:548)

handling of many smart cards

We are currently using Python scripts to do that but it means that we are spawning that many JVMs and have been having some issues with memory ... :o

I have no idea at the moment how to do it but would it be possible to run one instance of gp.jar and send to it commands identified with terminal names?

Get rid of ArgMatchers

Too much boilerplate for too little fun. Use static Class fromStringArgument() instead.

GPTool - allow stdout/stderr redirection to PrintStreams

I remember you saying that you don't want to turn the project into one-size-fits-all-needs but I want to try my luck.

The request is to enable re-direction of logs into files or strings. The change would require:

  1. adding two new class variables
    protected PrintStream out = System.out;
    protected PrintStream err = System.err;

  2. adding a new method
    public static OptionSet parseArguments(String[] argv, PrintStream out, PrintStream err)
    which would set out/err to provided values, or keep them as System.out, System.err

  3. changing all outputs from standard ones to out/err.

6D00 on Initialize Update on Contact Reader

Hi Martin,

I got error when I wanted to list the applications using gp.exe version 0.3.2.

Here is the command prompt log:

C:\Users\Lenovo\Downloads\GlobalPlatformPro>gp -r "ACS ACR128U ICC Interface 0"
-list -d
# Detected readers from SunPCSC
[*] ACS ACR128U ICC Interface 0
[ ] ACS ACR128U PICC Interface 0
[ ] ACS ACR128U SAM Interface 0
SCardConnect("ACS ACR128U ICC Interface 0", T=*) -> T=0, 3B6800000073C8400000900
0
SCardBeginTransaction("ACS ACR128U ICC Interface 0")
A>> T=0 (4+0000) 00A40400 00
A<< (0018+2) (52ms) 6F108408A000000003000000A5049F6501FF 9000
A>> T=0 (4+0008) 80500000 08 363E6BE34D9A400A
A<< (0000+2) (44ms) 6D00
pro.javacard.gp.GPException: INITIALIZE UPDATE failed SW: 6D00
        at pro.javacard.gp.GlobalPlatform.check(GlobalPlatform.java:1096)
        at pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:
396)
        at pro.javacard.gp.GPTool.main(GPTool.java:373)

Here's what I have tried:

  1. Use gp.exe with Contactless Interface --> no issue.
  2. Use cards from other vendors --> still got 6D00.
  3. Use the contact cards in other tools --> no issue.
  4. Use older version 0.3.0 --> still got 6D00

Best regards,
David

gp.jar not working without libpcsclite.so symlink?

I'm new to the whole smartcard business, so I might have missed something, but in Ubuntu 15.04 gp.jar is not working unless I explicitely create a symlink to libpcsclite.so.1.0.0 in /usr/lib64, like so:

$ java -jar gp.jar -list                                                                                  
$ sudo mkdir /usr/lib64 ; sudo ln -s /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0 /usr/lib64/libpcsclite.so 
$ java -jar gp.jar -list                                                                                  
AID: A000000003000000 (|........|)                                                                        
     ISD OP_READY: Security Domain, Card lock, Card terminate, Default selected, CVM (PIN) management     

AID: D156000132000401 (|.V..2...|)                                                                        
     App SELECTABLE: (none)                                                                               

Using a compiled gp.jar from the current HEAD.

I guess there should be some sort of error message to explain what's going on, it took me a while to find this workaround...

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.