JCWDE:从安装异常()方法 [英] JCWDE : Exception from install() method

查看:363
本文介绍了JCWDE:从安装异常()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作JavaCard的,我开发了JCDE一个applet Eclipse的:

I am working on JavaCard and I developed an applet with JCDE on Eclipse:

import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.Util;
import javacardx.framework.math.BigNumber;
import javacard.security.CryptoException;
import javacard.security.MessageDigest;

public class SignatureGPS extends Applet {
    public static final byte CLA = (byte) 0xB0;
    public static final byte INS = (byte) 0x00;

    private BigNumber s;
    private BigNumber x;
    private MessageDigest h;

    private SignatureGPS() {
        s = new BigNumber((short) 100);
        x = new BigNumber((short) 100);
        try {
            h = MessageDigest.getInstance(MessageDigest.ALG_SHA_256, false);
        } catch (CryptoException e) {
            if (e.getReason() == CryptoException.NO_SUCH_ALGORITHM){
            }
        }
    }


    public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException {
        new SignatureGPS().register();
    }


    public void process(APDU apdu) throws ISOException {
        byte[] buffer = apdu.getBuffer();

        if (this.selectingApplet()) return;

        if (buffer[ISO7816.OFFSET_CLA] != CLA)
            ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);

        ...
 }

}

但是当我启动JCWDE和工具(apdutool),我有以下错误:

But When I launch JCWDE and APDUTOOL, I have the following errors :

Java Card 2.2.2 APDU Tool, Version 1.3
Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
Opening connection to localhost on port 9025.
Connected.
powerup;
// Select the installer applet
0x00 0xA4 0x04 0x00 0x09 0xa0 0x00 0x00 0x00 0x62 0x03 0x01 0x08 0x01 0x7F;
// create SignatureGPS applet
0x80 0xB8 0x00 0x00 0xd 0xb 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x01 0x00 0x7F;Received ATR = 0x3b 0xf0 0x11 0x00 0xff 0x00 
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 09, a0, 00, 00, 00, 62, 03, 01, 08, 01, Le: 00, SW1: 90, SW2: 00
// select SignatureGPS applet
0x00 0xA4 0x04 0x00 0xb 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x01 0x7F;CLA: 80, INS: b8, P1: 00, P2: 00, Lc: 0d, 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 01, 00, Le: 00, SW1: 64, SW2: 44

和在Eclipse中,JCWDE说:

And in Eclipse, JCWDE says

 Exception from the invoked install() method:public static void metispackage.SignatureGPS.install(byte[],short,byte) throws javacard.framework.ISOException

有谁知道是怎么回事错我的安装的方法是什么?我搜索的谷歌,但我没有发现任何解决我的问题:( SW1 = 64 SW2 = 44表示该小程序创建失败,但我不知道为什么...

Does anybody know what is going wrong with my install method ? I searched on google but I found nothing to solve my problem :( SW1 = 64 SW2 = 44 indicates that the applet creation failed but I have no idea why...

推荐答案

正如你已经发现你自己新BigNumber((短)100); 引发 ArithmeticException 。您可以捕获该异常与try-catch块:

As you already found out on your own, new BigNumber((short)100); raises an ArithmeticException. You can catch that exception with a try-catch block:

try {
    s = new BigNumber((short)100);
} catch (ArithmeticException e) {
    // TODO: handle exception
}

但是,这既不会解决问题的根源,也让您使用 BigNumber 对象作为他们将永远不会被创建。

But that will neither solve the source of the problem nor allow you to use the BigNumber objects as they will never be created.

BigNumber 的构造提出了一个 ArithmeticException ,因为100个字节的容量超过JCWDE实施支持的最大容量。在<一个href=\"http://www.win.tue.nl/pinpasjc/docs/apis/jc222/javacardx/framework/math/BigNumber.html#BigNumber%28short%29\"相对=nofollow> API文档指出 BigNumber 只需要支持至少8个字节。因此,您可能希望以测试容量较小的值,以找出JCWDE实现的最大容量是什么。

The constructor of BigNumber raises an ArithmeticException because 100 bytes capacity exceeds the supported maximum capacity of the JCWDE implementation. The API documentation states that implementations of BigNumber only need to support at least 8 bytes. Therefore, you may want to test smaller capacity values in order to find out what the maximum capacity of the JCWDE implementation is.

这篇关于JCWDE:从安装异常()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆