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

Card throws an exception thrown when loading the signature on the card

Algorithm School

Moderator: UNKNwYSHSA

Riddle
Posts: 12
Joined: Mon Dec 28, 2015 11:41 pm
Points :70
Contact:

Card throws an exception thrown when loading the signature on the card

Post by Riddle » Mon Dec 28, 2015 11:53 pm

I try to load the signature on the card which is a 64 bytes RSA SHA1 signature.

Here is section of my apple.

Code: Select all

RSAPrivateKey  rsa_PrivateKey;
RSAPublicKey rsa_PublicKey;
KeyPair rsa_KeyPair;
Cipher cipherRSA;
Signature sig;
short expo;
short PIN;
byte[] pinSig = new byte[64];

public short verify (byte[] pin){

    sig = Signature.getInstance(Signature.ALG_RSA_SHA_PKCS1, false);
    sig.init(rsa_PublicKey, Signature.MODE_VERIFY);
    if( sig.verify(pin, (short)0, (short)pin.length, pinSig, (short)0, (short)pinSig.length)){
        return 1;
    }else{
        return 0;
    }
}

public void setpinSig( byte[] sig){


    pinSig = sig;
}

public void setPIN(short pin){

    PIN = pin;

}

public short isPIN(short pin){

    if ( pin != PIN )return 0;

    return 1;

}


When I called setpinSig method, I got an exception thrown on card. I don't know how to fix this problem.
Could anyone help me out?
checkFieldStore -> Security exception
throw_error(SECURITY_EXCEPTION)

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: Card throws an exception thrown when loading the signature on the card

Post by mabel » Thu Dec 31, 2015 1:34 am

If the pinSig value is always 64 bytes long, you should use the following implementation.

Code: Select all

public void setpinSig( byte[] sig)
{
        javacard.framework.Util.arrayCopy(sig, (short) 0,
        pinSig, (short) 0, (short) 64);
}

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 55 guests

JavaCard OS : Disclaimer