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 * Generate a 2048 bit RSA key pair 25 */ 26 27 load("tools.js"); 28 29 var card = new Card(_scsh3.reader); 30 card.reset(Card.RESET_COLD); 31 32 33 // Select Applet 34 card.sendApdu(0x00, 0xA4, 0x04, 0x00, mcaid, [0x9000]); 35 36 // MSCGenerateKeyPair 37 38 var param = new ByteString("01" // Algorithm ( "01" - RSA, "02" - RSA_CRT, "03" - DSA, "04" - EC_F2M, "05" - EC_FP 39 + "0800" // Key size in bits 40 + "FFFF" // Private Key Read Access ("FFFF" - NEV) 41 + "FFFF" // Private Key Write Access 42 + "0001" // Private Key Use Access 43 + "0000" // Public Key Read Access ("0000" - ALW) 44 + "FFFF" // Public Key Write Access 45 + "FFFF" // Public Key Use Access 46 + "00" // Options 47 , HEX); 48 49 print("Generating key..."); 50 card.sendApdu(0xB0, 0x30, 0x02, 0x03, param); 51 52 // MSCExportKey 53 card.sendApdu(0xB0, 0x34, 0x03, 0x00, new ByteString("00", HEX), [0x9000]); 54 55 var kb = readKeyBlob(card); 56 57 print(kb.header); 58 print("Modulus : " + kb[0]); 59 print("Exponent: " + kb[1]); 60