test eewayinfo.cap

cm>  send 00a404000f4150504c45544545574159494e464f
 => 00 A4 04 00 0F 41 50 50 4C 45 54 45 45 57 41 59    .....APPLETEEWAY
    49 4E 46 4F                                        INFO
 (262883 nsec)
 <= 90 00                                              ..
Status: No Error
cm>  send 00200000024142
 => 00 20 00 00 02 41 42                               . ...AB
 (245004 nsec)
 <= 90 00                                              ..
Status: No Error
cm>  send 0030000002
 => 00 30 00 00 02                                     .0...
 (273778 nsec)
 <= 63 00                                              c.
Status: Authentication failed


cm>  send 00a404000f4150504c45544545574159494e464f
 => 00 A4 04 00 0F 41 50 50 4C 45 54 45 45 57 41 59    .....APPLETEEWAY
    49 4E 46 4F                                        INFO
 (206730 nsec)
 <= 90 00                                              ..
Status: No Error
cm>  send 00200000024142
 => 00 20 00 00 02 41 42                               . ...AB
 (235505 nsec)
 <= 90 00                                              ..
Status: No Error
cm>  send 0030000002
 => 00 30 00 00 02                                     .0...
 (462070 nsec)
 <= 00 12                                              ..
Status: 0x0012


cm>  send 00300000C9
 => 00 30 00 00 C9                                     .0...
 (259530 nsec)
 <= 6F 00                                              o.
Status: No precise diagnosis
cm>  send 00300000ff
 => 00 30 00 00 FF                                     .0...
 (226565 nsec)
 <= 6F 00                                              o.
Status: No precise diagnosis
cm>  send 0030000000
 => 00 30 00 00 00                                     .0...
 (279365 nsec)
 <= 6F 00                                              o.
Status: No precise diagnosis


附:AppletMain.java

/**
 * File:AppletMain.java Package:com.pervcom.eeway Project:EEWayInfo
 * Date:2010-12-1 Author:Peter.Feng
 * Copyright (c) 2010 Pervcom, Inc. All Rights Reserved.
 */
package com.pervcom.eeway.eewayinfo;

import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.Util;

/**
 * <pre>
 * Author: Peter.Feng
 * Date&Time: 2010-12-1 下午02:16:07
 * AppletMain
 * 在易惠通手机客户端推荐优惠券给指定的好友之前,必须先确定自己的身份,也就是推荐人的在软件使用时对外的信息。
 * </pre>
 */
public class AppletMain extends Applet {
 
 private byte[] data = new byte[200];
 
 final static short INS_WRITE = (byte)0x20;
 final static short INS_READ = (byte)0x30;
 
 final static short SW_WRONG_LC_LENGTH = 0x0011;
 final static short SW_WRONG_LE_LENGTH = 0x0012;
 
 private AppletMain(byte[] data, short offset, byte length)
 {  
  super.register();
 }

 public static void install(byte[] data, short offset, byte length) {
  new AppletMain(data, offset, length);
 }

 public void process(APDU apdu) {
  byte[] buffer = apdu.getBuffer();
  switch(buffer[ISO7816.OFFSET_INS])
  {
  case INS_WRITE:
   writeData(apdu);
   return;
  case INS_READ:
   readData(apdu);
   return;
  }
 }
 
 private void readData(APDU apdu)
 {
  byte[] buffer = apdu.getBuffer();
  short le = apdu.setOutgoing();
  if(le<data.length)
   ISOException.throwIt(SW_WRONG_LE_LENGTH);
  Util.arrayCopy(data,(short)0,buffer,(short)0,le);
  apdu.sendBytes((short)0, le);
 }
 
 private void writeData(APDU apdu)
 {
  byte[] buffer = apdu.getBuffer();
  byte lc = buffer[ISO7816.OFFSET_LC];
  byte lengthReceive = (byte)(apdu.setIncomingAndReceive());
  if(lc!=lengthReceive)
   ISOException.throwIt(SW_WRONG_LC_LENGTH);
  Util.arrayCopy(buffer,(short)(ISO7816.OFFSET_LC+1),data,(short)0,(short)lengthReceive);
 }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值