Problem during loadgae of file
Hello,
I am trying to modify Loader.java sample to load simple HelloWorld applet to the
JCOP simulator.
During the execution the problem with call to the installForInstallAbdMakeSelectable aperas. The error code returned by he simulator is just 6a80 (Wrong data). I cant't find out what is the problem... Maybe anyone could help me?
So here is the code of my program, that shoul load and install applet, also make it selectable:
publicclass Loader
{
private Loader(){}
privatevoid load(String capFileName)throws Exception
{
CapFile capFile =new CapFile(capFileName,null);
System.out.println("Package name: " + capFile.pkg);
byte[][] applets = capFile.aids;
if ((applets ==null) || (applets.length == 0))
{
thrownew RuntimeException("no applets in cap file");
}
// Get connection to terminal, we look for the simulation.
// As you might want to use "pcsc", "4" or "tcl", "10" in case of
// Windows or "PCSC", null in case of Linux, you should pass the name
// of the terminal on the command line or in a properties file
System.out.println("Open terminal ...");
JCTerminal term = JCTerminal.getInstance("Remote",null);
term.open();
// Create a logging terminal spitting out the APDUs on standard out
TraceJCTerminal _term =new TraceJCTerminal();
_term.setLog(new PrintWriter(System.out));
_term.init(term);
term = _term;
// Get JavaCard representative, passing NULL resets card and returns ATR
System.out.println("Get card ...");
JCard card =new JCard(term, null, 2000);
// Get the off-card representative for the card manager and use it to
// select the on-card CardManager
System.out.println("Select card manager ...");
CardManager cardManager =new CardManager(card, CardManager.daid);
cardManager.select();
// For downloading something, we have to be authenticated to card manager.
// For this, the keys must be set. The keys to use should of course
// be configurable as well.
byte[] dfltKey = c2b("404142434445464748494a4b4c4d4e4f");
cardManager.setKey(new OPKey(255, 1, OPKey.DES_ECB, dfltKey));
cardManager.setKey(new OPKey(255, 2, OPKey.DES_ECB, dfltKey));
cardManager.setKey(new OPKey(255, 3, OPKey.DES_ECB, dfltKey));
//cardManager.setKey(new OPKey(1, 1, OPKey.DES_ECB, c2b("707172737475767778797a7b7c7d7e7f")));
//cardManager.setKey(new OPKey(1, 2, OPKey.DES_ECB, c2b("606162636465666768696a6b6c6d6e6f")));
cardManager.setKey(new OPKey(1, 3, OPKey.DES_ECB, c2b("505152535455565758595a5b5c5d5e5f")));
System.out.println("Authenticate to card manager ...");
cardManager.initializeUpdate(255, 0, OPApplet.SCP_UNDEFINED);
cardManager.externalAuthenticate(OPApplet.APDU_CLR);
System.out.println("deleting applets");
cardManager.deleteObject(capFile.pkgId, 0, capFile.pkgId.length,true);
System.out.println("applets deleted");
// And load the cap-file, do not forget to call installForLoad
System.out.println("Loading cap-file ..."+capFile.pkg);
cardManager.installForLoad(capFile.pkgId, 0, capFile.pkgId.length, null, 0, 0, null, 0, null, 0, 0, null, 0);
cardManager.load(capFile, null, SecurityDomain.LOAD_ALL,new PrintWriter(System.out), 250);
System.out.println("Finished loading !");
// Install applet, we try to install the first applet given in the
// cap file, and try to instantiate it under the same AID as given for its
// representation in the cap file. No installation data is passed.
System.out.println("Installing applet ...");
cardManager.installForInstallAndMakeSelectable//HERE EXCEPTION APPEARS
(
capFile.pkgId,
0,
capFile.pkgId.length,
applets[0],
0,
applets[0].length,/* applet */
applets[0],
0,
applets[0].length,/* instance aid */
OPApplet.NO_PRIVS,/* no special priviledges */
null,
0,
0,/* install data */
null,
0
);
System.out.println("Install succeeded!");
// synchronize state with on-card card manager
cardManager.update();
// Print information regarding card manager, applets and packages on-card
JCInfo info = JCInfo.INFO;
System.out.println("\nCardManager AID: " + info.dataToString(cardManager.getAID()));
System.out.println("CardManager state : " + info.toString("card.status", (byte) cardManager.getState()) +"\n");
There is the reaply of the smulator:
Open terminal ...
Get card ...
--Waitingfor card...
Select card manager ...
ATR=3B FA 13 00 00 81 31 FE 45 4A 43 4F 50 34 31 56;.....1.EJCOP41V
32 32 31 96221.
=> 00 A4 04 00 07 A0 00 00 00 03 00 00 00 .............
(0 msec)
<= 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65o..............e
01 FF 90 00....
Status: No Error
Authenticate to card manager ...
=> 80 50 00 00 08 A9 2D 23 0F 2E CD 55 7A 00 .P....-#...Uz.
(0 msec)
<= 00 00 57 F3 97 D9 7F 72 88 55 FF 02 00 20 BA 9A..W....r.U... ..
16 94 77 B9 81 CE 96 61 84 55 71 73 90 00 ..w....a.Uqs..
Status: No Error
=> 84 82 00 00 10 18 F1 1A 0C 97 BD D1 66 8B 43 41............f.CA
46 39 44 85 9C F9D..
(0 msec)
<= 90 00 ..
Status: No Error
deleting applets
=> 80 E4 00 80 0C 4F 0A 48 65 6C 6C 6F 57 6F 72 6C.....O.HelloWorl
64 00 d.
(0 msec)
<= 00 90 00...
Status: No Error
applets deleted
Loading cap-file ...com.sun.javacard.samples.HelloWorld
=> 80 E6 02 00 0F 0A 48 65 6C 6C 6F 57 6F 72 6C 64......HelloWorld
00 00 00 00 00 .....
(0 msec)
<= 00 90 00...
Status: No Error
=> 80 E8 00 00 FA C4 82 01 57 01 00 38 DE CA FF ED........W..8....
02 02 04 00 01 0A 48 65 6C 6C 6F 57 6F 72 6C 64......HelloWorld
23 63 6F 6D 2F 73 75 6E 2F 6A 61 76 61 63 61 72#com/sun/javacar
64 2F 73 61 6D 70 6C 65 73 2F 48 65 6C 6C 6F 57d/samples/HelloW
6F 72 6C 64 02 00 21 00 38 00 21 00 12 00 0B 00orld..!.8.!.....
36 00 0E 00 65 00 0A 00 13 00 00 00 6E 02 9A 006...e.......n...
00 00 00 00 00 01 01 00 04 00 0B 01 02 01 07 A0................
00 00 00 62 01 01 03 00 12 01 0E 48 65 6C 6C 6F...b.......Hello
57 6F 72 6C 64 41 70 70 6C 00 14 06 00 0E 00 00WorldAppl.......
00 80 03 01 00 01 07 01 00 00 00 1D 07 00 65 00..............e.
02 10 18 8C 00 07 18 11 01 00 90 0B 87 00 18 8B................
00 05 7A 01 30 8F 00 03 8C 00 0A 7A 05 23 19 8B..z.0......z.#..
00 08 2D 19 8B 00 02 32 03 29 04 70 19 1A 08 AD..-....2.).p....
00 16 04 1F 8D 00 01 3B 16 04 1F 41 29 04 19 08.......;...A)...
8B 00 09 32 1F 64 E8 19 8B 00 06 3B 19 16 04 08...2.d.....;....
41 8B 00 04 19 03 08 8B 00 0B 19 AD 00 03 16 00A...............
(0 msec)
<= 00 90 00...
Status: No Error
=> 80 E8 80 01 61 04 8B 00 0C 7A 08 00 0A 00 00 00....a....z......
00 00 00 00 00 00 00 05 00 36 00 0D 02 00 02 00.........6......
06 80 10 02 03 80 0A 06 01 00 02 00 03 80 0A 09................
03 80 03 01 03 80 0A 07 06 80 03 00 03 80 0A 01................
03 80 0A 03 06 00 00 01 03 80 0A 04 03 80 0A 05................
09 00 13 00 03 0E 23 2C 00 0C 05 0C 06 03 07 05......#,........
10 0C 08 09 06 09 00.......
(16 msec)
<= 00 90 00...
Status: No Error
Finished loading !
Installing applet ...
=> 80 E6 0C 00 2D 0A 48 65 6C 6C 6F 57 6F 72 6C 64....-.HelloWorld
0E 48 65 6C 6C 6F 57 6F 72 6C 64 41 70 70 6C 0E.HelloWorldAppl.
48 65 6C 6C 6F 57 6F 72 6C 64 41 70 70 6C 01 00HelloWorldAppl..
00 00 00...
(0 msec)
<= 6A 80 j.
Status: Wrong data
EX: msg null,classclass com.ibm.jc.JCException
com.ibm.jc.JCException:
Error: 6a80
APDU: 6A80
at com.ibm.jc.JCUtil.check9000(Unknown Source)
at com.ibm.jc.SecurityDomain.handleInstall(Unknown Source)
at com.ibm.jc.SecurityDomain.installForInstallAndMakeSelectable(Unknown
Source)
at loader.Loader.load(Loader.java:93)
at loader.Loader.main(Loader.java:187)
Please, help me, I don't get it, ehat could be wrong in this sample?

