Page 1 of 1

Error 6F00 when generating and verifying a signature

Posted: Wed Aug 16, 2017 11:11 pm
by tomc2016
I am going to generate and verify a signature for some dummy data on a Java Card. It's strange that I always got error code 6F00. I also tried to debug the applet to confirm where the problem is, but failed. Any clue?

Code: Select all

private void signIt(APDU apdu) {
         
          byte[] buffer = apdu.getBuffer();
           
          RSASign = Signature.getInstance(Signature.ALG_RSA_MD5_PKCS1, true);

          RSASign.init(priv, Signature.MODE_SIGN);
     
          byte[] inputData = {0x01, 0x02, 0x03};
          byte[] sig_buffer = new byte[50];
         
                //ISOException.throwIt((short)0x1234); is thrown here

          RSASign.sign(inputData, (short)0, (short)(inputData.length), sig_buffer, (short)0);
             //ISOException.throwIt((short)0x1234); not thrown anymore - Instead 6F00 is thrown     

          Sig = sig_buffer;
     }

     private void verifyIt(APDU apdu) {
         
          byte[] buffer = apdu.getBuffer();
         
          byte[] inputData = {0x01, 0x02, 0x03};
         
          // sigOffset correct?
          if (RSASign.verify(inputData, (short)0, (short)(inputData.length), realSig,
                   (short)0, (short)(realSig.length)) != true) {
                        ISOException.throwIt(SW_WRONG_SIGNATURE); //unknown error thrown again
         }
         
     }

Re: Error 6F00 when generating and verifying a signature

Posted: Thu Aug 17, 2017 5:12 am
by lostsiwonlw
Try to change the sig_buffer to a bigger balue. RSA Signature alone is 128 Bytes.

Re: Error 6F00 when generating and verifying a signature

Posted: Thu Aug 17, 2017 6:04 am
by tomc2016
I changed the sig_buffer to 200, and the sign function is working now :D ,but the verify function still throws error 0x6F00.