JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html

My program returns 6F 00:No precise diagnosis, why?

JavaCard Applet Development Related Questions and Answers.
Erisaron
Posts: 15
Joined: Wed Dec 02, 2015 1:23 am
Points :64
Contact:

My program returns 6F 00:No precise diagnosis, why?

Post by Erisaron » Tue Dec 08, 2015 6:04 am

I downloaded a part of java card program from the web. But I have a question when debugging this program in JCIDE.

Here is the code.

Code: Select all

package fileSigner;

import javacard.framework.*;
import javacard.security.KeyPair;
import javacard.security.RSAPrivateKey;
import javacard.security.RSAPublicKey;
import javacard.security.Signature;

public class FileSigning extends Applet {

    //Proprietary Status Words
    private static final short SIGN_VERIFIED_SW = (short) 0x6701;
    private static final short SIGN_NOT_VERIFIED_SW = (short) 0x6702;

    //Proprietary Instructions
    private static final byte SIGN_INS = (byte) 0x00;
    private static final byte VERIFY_INS = (byte) 0x02;
    private static final byte RET_PUB_KEY_INS = (byte) 0x04;

    //Required Objects
    private static RSAPrivateKey privateKey;
    private static RSAPublicKey publicKey;
    private static KeyPair keyPair;
    private static Signature signature;

    public static void install(byte[] bArray, short bOffset, byte bLength) {
        new FileSigning();
    }

    protected FileSigning() {
        register();
        keyPair = new KeyPair(KeyPair.ALG_RSA, (short) 1024);
        keyPair.genKeyPair();
        publicKey = (RSAPublicKey) keyPair.getPublic();
        privateKey = (RSAPrivateKey) keyPair.getPrivate();
        signature = Signature.getInstance(Signature.ALG_RSA_SHA_PKCS1, false);
    }

    public void process(APDU apdu) {
        if (selectingApplet()) {
            return;
        }

        byte[] buffer = apdu.getBuffer();

        switch (buffer[ISO7816.OFFSET_INS]) {
            case SIGN_INS:
                signature.init(publicKey, Signature.MODE_SIGN);
                byte[] dataSignature = JCSystem.makeTransientByteArray((short) 128, JCSystem.CLEAR_ON_RESET);
                short signLen = signature.sign(buffer, ISO7816.OFFSET_CDATA, (byte) ISO7816.OFFSET_LC, dataSignature, (byte) 0);
                Util.arrayCopyNonAtomic(dataSignature, (short) 0, buffer, (short) 0, signLen);
                apdu.setOutgoingAndSend((short) 0, signLen);
                break;

            case VERIFY_INS:
                signature.init(privateKey, Signature.MODE_VERIFY);
                boolean isVerified = signature.verify(buffer, (short)ISO7816.OFFSET_CDATA, (short)0x80, buffer, (short)(ISO7816.OFFSET_CDATA + 0X80), (short)0X04);
                if (isVerified) {
                    ISOException.throwIt(SIGN_VERIFIED_SW);
                } else {
                    ISOException.throwIt(SIGN_NOT_VERIFIED_SW);
                }
                break;

            case RET_PUB_KEY_INS:
                break;

            default:
                ISOException.throwIt((short) ISO7816.SW_INS_NOT_SUPPORTED);
        }
    }
}


As the screenshot showed, I can select the applet successfully, but when I send data to sign a 2 bytes data. It returns 6F 00.
Can anyone tell me the reason? I also can't understand this program well, so if anyone can explain the detailed information/APDU to me, I will be much appreciated.

You do not have the required permissions to view the files attached to this post. Please login first.

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3055
Contact:

Re: My program returns 6F 00:No precise diagnosis, why?

Post by UNKNwYSHSA » Tue Dec 08, 2015 10:38 pm

It seems you are debugging with JCIDE, you can debug step by step, and locate which line the exception raised.
sense and simplicity

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 44 guests

JavaCard OS : Disclaimer