1 Reply Latest reply: Jan 13, 2013 12:02 PM by Hana Bizhani RSS

    JCWDE Keypair

      Hello guys,

      I made few lines of an appled that allow to generate a rsakey and with that key and the apdu that I send sign it but I'm not sure if the simulator is working right.
      I mean, I sent few times the same APDU but it returns me all the time the same answer :S. Yes the data that's is being signed is the same but every time I start the simulator I sent that APDU the private key to sign should be different generating a different signature no?

      My code is that:

      byte[] buffer = apdu.getBuffer();
           short lc=buffer[ISO7816.OFFSET_LC];
           byte[] retorn = new byte[64];
           KeyPair claus = new KeyPair (KeyPair.ALG_RSA, (short)512) ;
           PrivateKey privKey = claus.getPrivate();
      Signature signature = Signature.getInstance(Signature.ALG_RSA_SHA_PKCS1 , false);
      signature.init(privKey, Signature.MODE_SIGN);
      signature.sign(buffer, ISO7816.OFFSET_CDATA, lc, retorn, (short)0);

           apdu.setOutgoingLength((short) retorn.length);
           apdu.sendBytesLong(retorn, (short) 0, (short) retorn.length);      

      I understood something wrong?

      Thanks guys :)