1 /** 2 * --------- 3 * |.##> <##.| Open Smart Card Development Platform (www.openscdp.org) 4 * |# #| 5 * |# #| Copyright (c) 1999-2009 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 * @fileoverview Example script performing an emv transaction. 25 */ 26 27 28 load("emv.js"); 29 load("emvView.js"); 30 load("dataAuthentication.js"); 31 //load("transaction.js"); 32 33 // Example code 34 var card = new Card(_scsh3.reader); 35 card.reset(Card.RESET_COLD); 36 37 var crypto = new Crypto(); 38 39 var e = new EMV(card, crypto); 40 var v = new EMVView(e); 41 42 var d = new DataAuthentication(e); 43 d.addSchemePublicKey(new ByteString("A000000003", HEX), 1, new Key("schemepublickeys/kp_visa_1024_01.xml")); 44 d.addSchemePublicKey(new ByteString("A000000003", HEX), 7, new Key("schemepublickeys/kp_visa_1152_07.xml")); 45 d.addSchemePublicKey(new ByteString("A000000003", HEX), 8, new Key("schemepublickeys/kp_visa_1408_08.xml")); 46 d.addSchemePublicKey(new ByteString("A000000003", HEX), 9, new Key("schemepublickeys/kp_visa_1984_09.xml")); 47 48 49 e.selectPSE(false); 50 51 var aid = e.getAID(); 52 53 if (aid != null) { 54 e.selectADF(aid); 55 } else { 56 e.tryAID(); 57 } 58 59 60 e.initApplProc(); 61 e.readApplData(); 62 63 64 v.displayDataElements(); 65 66 var issuerPublicKeyModulus = d.retrieveIssuerPublicKey(); 67 68 d.verifySSAD(issuerPublicKeyModulus); 69 70 var iccPublicKeyModulus = d.retrieveICCPublicKey(issuerPublicKeyModulus); 71 d.dynamicDataAuthentication(iccPublicKeyModulus); 72 73 e.generateAC(); 74 75 //var getData = card.sendApdu(0x80, 0xCA, 0x9F, 0x36, 0x00); 76 //print(getData); 77 78 79 card.close(); 80