Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

ECDSA Issue

Algorithm School

Moderator: UNKNwYSHSA

nikonai
Posts: 17
Joined: Mon Feb 22, 2016 4:37 am
Points :177
Contact:

ECDSA Issue

Post by nikonai » Tue Nov 08, 2016 1:24 am

I am using ECDSA to do signature. However, it always threw 6F00 during Install. I tried to debug and found the problem caused by the code below. I wonder how I can modify to avoid the problem? Please help me regarding this issue.

Code: Select all

objECDSAKeyPair= new KeyPair(KeyPair.ALG_EC_FP, KeyBuilder.LENGTH_EC_FP_192);


My code:

Code: Select all

package Test;
   
    import javacard.framework.*;
    import javacard.security.*;
    import javacardx.crypto.*;
   
    public class Test extends Applet{
   
    private byte[] PLAINTEXT ;
    private ECPrivateKey objECDSAPriKey=null;   // Object for ECDSA Private Key
    private ECPublicKey objECDSAPubKey=null;    // Object for ECDSA Public Key
    private KeyPair objECDSAKeyPair=null;       // Object for ECDSA Key Pair
    private Signature objECDSASign=null;        // Object for ECDSA Signature
   
    final static short BAS =  0;
   
    public static void install(byte[] bArray, short bOffset, byte bLength){
      new Test(bArray, bOffset, bLength);
    }
   
    private Test(byte bArray[], short bOffset, byte bLength){
      PLAINTEXT = new byte[0x100] ; // Data file
      Util.arrayFillNonAtomic(PLAINTEXT,  BAS, (short)0x100, (byte)0);
 
      objECDSAKeyPair= new KeyPair(KeyPair.ALG_EC_FP, KeyBuilder.LENGTH_EC_FP_192);
   
      // Create Signature Object
      objECDSASign = Signature.getInstance(Signature.ALG_ECDSA_SHA, false);
   
      register();
    }
   
    public void process(APDU apdu){
      byte buf[] = apdu.getBuffer();
   
      switch(buf[1])
      {
      case (byte)0xA4: break;
   
      case (byte)0x46:
      objECDSAKeyPair.genKeyPair();
      objECDSAPriKey = (ECPrivateKey)objECDSAKeyPair.getPrivate();
      objECDSAPubKey = (ECPublicKey)objECDSAKeyPair.getPublic();
      break;
   
      case (byte)0x2E:
      short Le = apdu.setOutgoing();
      short sSignLen=0 ;
   
      // Init with Private Key
      objECDSASign.init(objECDSAPriKey, Signature.MODE_SIGN);
      //objECDSASign.init(objECDSAKeyPair.getPrivate(), Signature.MODE_SIGN);
   
      // Sign Data
      sSignLen = objECDSASign.sign(PLAINTEXT, BAS, Le, buf, BAS);
   
      apdu.setOutgoingLength(sSignLen);
      apdu.sendBytes(BAS, sSignLen);
      break;
   
      default:
      ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
      }
   
      return;
    } }

Tarantino
Posts: 101
Joined: Wed Aug 19, 2015 1:56 am
Points :478
Contact:

Re: ECDSA Issue

Post by Tarantino » Tue Nov 08, 2016 3:42 am

Use ALG_EC_F2M instead.
The greatest glory in living lies not in never falling, but in rising every time we fall.--Nelson Mandela

nikonai
Posts: 17
Joined: Mon Feb 22, 2016 4:37 am
Points :177
Contact:

Re: ECDSA Issue

Post by nikonai » Tue Nov 08, 2016 5:21 am

I tried, 6F00 was still there. :cry:

Thelogan
Posts: 40
Joined: Thu Aug 20, 2015 4:48 am
Points :250
Contact:

Re: ECDSA Issue

Post by Thelogan » Wed Nov 09, 2016 5:47 am

You need to set specific parameters for ECC. Set those parameters that are present in the ECKey interface in the public key. These parameters are not stored on the card

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

Re: ECDSA Issue

Post by UNKNwYSHSA » Thu Nov 17, 2016 2:37 am

Are you using JCOP card?
JCOP card not set curve parameters automatically, as Thelogan said.
You have to set curve parameters yourself in the code.
sense and simplicity

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 20 guests

JavaCard OS : Disclaimer