安装 java card 应用,在JavaCard中安装小程序

I made a .cap file of the popular "Hello World" javacard code via Eclipse

And now I want to load it in a real javacard via GPShell and ACR38 smart card reader.

question: Am I need any key to load the .cap file in the card? I mean, should I authenticate before uploading my applet in the card or it's not necessory?

I think it is mndatory to authenticate. it is irrational to upload .cap without authentication. but I don't know , how to authenticate.

question: What's wrong in this?

C:\Users\ghasemi>java -jar e:\gpj\gpj.jar -load e:\helloWorld.cap -install

Found terminals: [PC/SC terminal ACS CCID USB Reader 0]

javax.smartcardio.CardException: connect() failed

at sun.security.smartcardio.TerminalImpl.connect(Unknown Source)

at net.sourceforge.gpj.cardservices.GlobalPlatformService.main(Unknown S

ource)

Caused by: sun.security.smartcardio.PCSCException: SCARD_E_SHARING_VIOLATION

at sun.security.smartcardio.PCSC.SCardConnect(Native Method)

at sun.security.smartcardio.CardImpl.(Unknown Source)

... 2 more

Found card in terminal: ACS CCID USB Reader 0

java.lang.NullPointerException

at net.sourceforge.gpj.cardservices.GlobalPlatformService.main(Unknown S

ource)

C:\Users\ghasemi>java -jar e:\gpj\gpj.jar -load e:\helloWorld.cap -install

Found terminals: [PC/SC terminal ACS CCID USB Reader 0]

Found card in terminal: ACS CCID USB Reader 0

ATR: 3B 7F 94 00 00 80 31 80 65 B0 85 02 02 ED 12 0F FF 82 90 00

DEBUG: Command APDU: 00 A4 04 00 07 A0 00 00 01 51 00 00

DEBUG: Response APDU: 6A 82

Failed to select Security Domain GP211 A0 00 00 01 51 00 00 , SW: 6A 82

DEBUG: Command APDU: 00 A4 04 00 08 A0 00 00 00 18 43 4D 00

DEBUG: Response APDU: 6F 65 84 08 A0 00 00 00 18 43 4D 00 A5 59 73 4A 06 07 2A 8

6 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B 02 02 01 01 63 09 06 07 2A 86 48

86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B 04 01 05 65 0B 06 09 2B 85 10 86 48 64

02 01 03 66 0C 06 0A 2B 06 01 04 01 2A 02 6E 01 02 9F 6E 06 12 91 20 11 02 02 9

F 65 01 FF 90 00

Successfully selected Security Domain GemaltoXpressPro A0 00 00 00 18 43 4D 00

DEBUG: Command APDU: 80 50 00 00 08 17 2A 53 4F AC DF 8D 16

DEBUG: Response APDU: 69 82

javax.smartcardio.CardException: Wrong initialize update, SW: 69 82

at net.sourceforge.gpj.cardservices.GlobalPlatformService.openSecureChan

nel(Unknown Source)

at net.sourceforge.gpj.cardservices.GlobalPlatformService.main(Unknown S

ource)

tnx

解决方案

You should require about the Global Platform state of the card. 6982 is a general status word that means "Security status not satisfied", so your card may be in the wrong state (e.g. the Global Platform LOCKED or TERMINATED state).

It could also be that you are using an invalid Global Platform key set, or that the keys are not available.

Please contact the supplier of the smart card about the card state and which keys you should use.

javacard applet 开发实例 正常运行 带jar包 package mifare; import com.ibm.jz.JZSystem; import javacard.framework.APDU; import javacard.framework.Applet; import javacard.framework.ISO7816; import javacard.framework.ISOException; import javacard.framework.Util; public class AmbiqApplet extends Applet { byte[] mifarePassDefault={(byte)0x0b,(byte)0x54,(byte)0x57,(byte)0x07,(byte)0x45,(byte)0xfe,(byte)0x3a,(byte)0xe7}; byte[] mifarePass8={(byte)0x0b,(byte)0x54,(byte)0x57,(byte)0x07,(byte)0x45,(byte)0xfe,(byte)0x3a,(byte)0xe7}; byte[] mifarePass9={(byte)0x0b,(byte)0x54,(byte)0x57,(byte)0x07,(byte)0x45,(byte)0xfe,(byte)0x3a,(byte)0xe7}; byte[] adminPass={(byte)0x40,(byte)0x41,(byte)0x42,(byte)0x43,(byte)0x44,(byte)0x45,(byte)0x46,(byte)0x47,(byte)0x48,(byte)0x49,(byte)0x4a,(byte)0x4b,(byte)0x4c,(byte)0x4d,(byte)0x4e,(byte)0x4f}; public static void install(byte[] bArray, short bOffset, byte bLength) { // GP-compliant JavaCard applet registration new AmbiqApplet().register(bArray, (short) (bOffset + 1), bArray[bOffset]); } public void process(APDU apdu) { short i; byte[] send=new byte[52]; byte[] send2=new byte[24]; // Good practice: Return 9000 on SELECT if (selectingApplet()) { return; } byte[] buf = apdu.getBuffer(); if(buf[ISO7816.OFFSET_CLA]==AmbiqConstant.CLS_AMBIQ) { switch (buf[ISO7816.OFFSET_INS]) { case AmbiqConstant.INS_GET_MIFARE: if(buf[ISO7816.OFFSET_P1]!=0 || buf[ISO7816.OFFSET_P2]!=0) { ISOException.throwIt(ISO7816.SW_INCORRECT_P1P2); return; } /*Get Entire Mifare Ticket data * Returns back the content of the entire sector 8 (3 block 8.0, 8.1, 8.2) and the first 4 bytes of block 9.0; total 52bytes. Filed Length (in bytes) Data Comments CLA 1 0x80 Fixed class for the applet INS 1 0x20 Read entire data P1 1 0x00 Sector number P2 1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值