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.

Error sw 6F00 when using ECDSA to implement the signing code

Algorithm School

Moderator: UNKNwYSHSA

User avatar
Marshaldll
Posts: 13
Joined: Thu Jun 11, 2015 2:53 am
Points :32
Contact:

Error sw 6F00 when using ECDSA to implement the signing code

Post by Marshaldll » Mon Nov 23, 2015 7:33 am

I am using ECDSA to implement the signing code. But I always get the error sw "6F00" during install phase --------> objECDSAKeyPair= new KeyPair(KeyPair.ALG_EC_FP, KeyBuilder.LENGTH_EC_FP_192);
Could you tell me where I made mistake? Is there anything wrong?

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;   
private ECPublicKey objECDSAPubKey=null;   
private KeyPair objECDSAKeyPair=null;       
private Signature objECDSASign=null;       

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);         

  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 ;

  objECDSASign.init(objECDSAPriKey, Signature.MODE_SIGN);
  //objECDSASign.init(objECDSAKeyPair.getPrivate(), Signature.MODE_SIGN);

  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;
} }

BirdKing
Posts: 86
Joined: Wed Nov 04, 2015 7:23 am
Points :656
Contact:

Re: Error sw 6F00 when using ECDSA to implement the signing code

Post by BirdKing » Tue Nov 24, 2015 9:28 pm

your construction function is private.....

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 23 guests

JavaCard OS : Disclaimer