1 /*
  2  *  ---------
  3  * |.##> <##.|  Open Smart Card Development Platform (www.openscdp.org)
  4  * |#       #|  
  5  * |#       #|  Copyright (c) 1999-2006 CardContact Software & System Consulting
  6  * |'##> <##'|  Andreas Schwier, 32429 Minden, Germany (www.cardcontact.de)
  7  *  --------- 
  8  *
  9  *  This file is part of OpenSCDP.
 10  *
 11  *  OpenSCDP is free software; you can redistribute it and/or modify
 12  *  it under the terms of the GNU General Public License version 2 as
 13  *  published by the Free Software Foundation.
 14  *
 15  *  OpenSCDP is distributed in the hope that it will be useful,
 16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 18  *  GNU General Public License for more details.
 19  *
 20  *  You should have received a copy of the GNU General Public License
 21  *  along with OpenSCDP; if not, write to the Free Software
 22  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 23  *
 24  *  Load Musclecard Applet into JCOP card
 25  */
 26 
 27 load("const.js");
 28 load("gp/tools.js");
 29 
 30 
 31 var sdAid = new ByteString("A000000003000000", HEX);
 32 
 33 // Generate default keys
 34 var masterSENC = new Key("gp/kp_jcop_default_s-enc.xml");
 35 var masterSMAC = new Key("gp/kp_jcop_default_s-mac.xml");
 36 
 37 
 38 // Card object
 39 var card = new Card(_scsh3.reader);
 40 
 41 // Crypto object
 42 var crypto = new Crypto();
 43 
 44 
 45 // Define a security domain (profiles does not matter so far)
 46 var sd = new GPSecurityDomain("profiles/ap_sample.xml");
 47 sd.aid = sdAid;
 48 sd.card = card;
 49 
 50 //Reset the card 
 51 card.reset(Card.RESET_COLD);
 52 
 53 
 54 print("Selecting card manager application...");
 55 
 56 print(sd.select());
 57 
 58 GPAuthenticate(card, crypto, masterSENC, masterSMAC);
 59 
 60 print("Delete old applet instance...");
 61 sd.deleteAID(applAid, [0x9000, 0x6A88, 0x6A80] );
 62 
 63 print("Delete old load file...");
 64 sd.deleteAID(loadFileAid, [0x9000, 0x6A88, 0x6A80] );
 65 
 66 print("InstallForLoad...");
 67 sd.installForLoad(loadFileAid, sdAid, null, null, null);
 68 
 69 print("Loading applet...");
 70 sd.loadByName("musclecard/CardEdge.cap");
 71 
 72 print("Instantiating applet...");
 73 
 74 var applPrivileges = new ByteString("00", HEX);
 75 var installParam = new ByteString("C900", HEX);
 76 
 77 sd.installForInstallAndSelectable(loadFileAid, moduleAid, applAid, applPrivileges, installParam, null);
 78