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 * eGK explorer with card to card authentication 25 */ 26 27 requires("3.6.525"); 28 29 var reader_hic = ""; 30 var reader_hpc = ""; 31 32 // Uncomment the following, if you have two PC/SC reader rather than a terminal 33 // with multiple slots. Fill in the card reader names as they are shown in the 34 // Options/Reader Configuration dialog 35 36 // reader_hic = "ORGA CardMouse USB 0"; 37 // reader_hpc = "SCM Microsystems Inc. SCR33x USB Smart Card Reader 0"; 38 39 print("eGK Explorer with Card-To-Card Authentication."); 40 print("=============================================="); 41 42 if (!_scsh3.reader) { 43 if (!reader_hic || !reader_hpc) { 44 print("This script will only work, if you configured a card reader with dual-slots"); 45 print("from the Options/Reader Configuration menu or set the variables reader_hic"); 46 print("and reader_hpc in this script"); 47 throw new GPError("explorec2c.js", 0, 0, "Reader not configured"); 48 } 49 slot_hic = reader_hic; 50 slot_hpc = reader_hpc; 51 } else { 52 if (reader_hic || reader_hpc) { 53 slot_hic = reader_hic; 54 slot_hpc = reader_hpc; 55 } else { 56 slot_hic = _scsh3.reader + "#1"; 57 slot_hpc = _scsh3.reader + "#2"; 58 } 59 } 60 61 print("Make sure you have a HIC in " + slot_hic); 62 print(" and a HPC in " + slot_hpc); 63 64 // Load CardOutlineFactory to display card tree 65 load("tools/CardOutlineFactory.js"); 66 67 // Load special classes to display XML encoded fields 68 load("tools.js"); 69 70 // Load Card2CardAuthentication() function 71 load("c2caut.js"); 72 73 74 // Create crypto object 75 var crypto = new Crypto(); 76 77 // Create application factory that holds all application profiles 78 var af = new ApplicationFactory(crypto); 79 80 // Add ec-card application profiles 81 af.addApplicationProfile("ap_mf.xml"); 82 af.addApplicationProfile("ap_hca.xml"); 83 af.addApplicationProfile("ap_nfd.xml"); 84 af.addApplicationProfile("ap_perserkl.xml"); 85 af.addApplicationProfile("ap_zuzahlung.xml"); 86 af.addApplicationProfile("ap_esign.xml"); 87 af.addApplicationProfile("ap_ciaesign.xml"); 88 af.addApplicationProfile("ap_qes.xml"); 89 90 91 // Create card outline factory 92 var of = new eGKCardOutlineFactory(); 93 94 // Create list of AIDs, just in case the EF.DIR is empty 95 // This is just temporary to make sure the explorer works 96 // even for card with a defect in EF.DIR 97 98 var aidlist = new Array(); 99 100 /* Enable, if EF.DIR is invalid 101 aidlist.push(new ByteString("D27600000102", HEX)); 102 aidlist.push(new ByteString("A000000167455349474E", HEX)); 103 aidlist.push(new ByteString("E828BD080FA000000167455349474E", HEX)); 104 aidlist.push(new ByteString("D27600006601", HEX)); 105 */ 106 107 var card_HIC = new Card(slot_hic, "cp_egk.xml"); // Reader with eGK in slot#1 108 var card_HPC = new Card(slot_hpc); // Reader with HPC in slot#2 109 110 card_HPC.reset(Card.RESET_COLD); 111 112 // Select application on HPC 113 var mf_hpc = new CardFile(card_HPC, ":3F00"); 114 115 print("Please enter PIN for HPC"); 116 // Verify PIN for HPC 117 ok = mf_hpc.performCHV(true, 1); 118 119 if (!ok) { 120 print("PIN Verification failed"); 121 exit; 122 } 123 124 125 // Activate explorer 126 try { 127 var egk = new OutlineCard(of, card_HIC, af, aidlist); 128 egk.view.setContextMenu(["Verify PIN.CH", "Verify PIN.home"]); 129 egk.actionListener = OutlineCardActionListener; 130 131 var rootPuk = [ new Key("kp_cvc_root_test.xml"), 132 new Key("kp_cvc_root_testlabor.xml"), 133 new Key("kp_cvc_root_test_2.xml")]; 134 135 Card2CardAuthentication(card_HIC, card_HPC, rootPuk); 136 137 print(""); 138 print("Right click on the eGK node to select PIN verification"); 139 print("before you select any DF or EF."); 140 141 egk.view.show(); 142 } 143 144 catch(e) { 145 print("Problem accessing the card : " + e); 146 } 147