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

Encounter error 6F 00 when importing RSA Private Key

JavaCard Applet Development Related Questions and Answers.
nikonai
Posts: 17
Joined: Mon Feb 22, 2016 4:37 am
Points :177
Contact:

Encounter error 6F 00 when importing RSA Private Key

Post by nikonai » Tue Oct 03, 2017 1:11 am

I am trying to import a 1024 bit RSA private CRT key from a java application, but I cannot get it to work, I only got 6F 00 error code.

Need it convert to hex-bytes? How do I convert it? Any help is much appreciated.

Here is section of my code:

Code: Select all

final static byte SET_PRIVATE_KEY= (byte) 0x22;
private RSAPrivateCrtKey PrivateRSAKey1024;
private RSAPublicKey PublicRSAKey1024;
private static Cipher cipher;
...
cipher = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, false );
PrivateRSAKey1024 = (RSAPrivateCrtKey) KeyBuilder.buildKey(KeyBuilder.TYPE_RSA_CRT_PRIVATE, (short)1024, false);
...
case SET_PRIVATE_KEY:     processSetPrivateKeyCRT(apdu);
                                             return;
...
private void processSetPrivateKeyCRT(APDU apdu)
     {
          byte baAPDUBuffer[] = apdu.getBuffer();         
 
         // get APDU data
         apdu.setIncomingAndReceive();
                   
          byte P1 = baAPDUBuffer[ISO7816.OFFSET_P1];
         
          short sLc = (short)(baAPDUBuffer[ISO7816.OFFSET_LC] & 0x00FF);
                   
          switch (P1)     {
          case 0x00: // Set P
               PrivateRSAKey1024.setP(baAPDUBuffer, ISO7816.OFFSET_CDATA, sLc);
               break;
          case 0x01: // Set Q
               PrivateRSAKey1024.setQ(baAPDUBuffer, ISO7816.OFFSET_CDATA, sLc);
               break;
          case 0x02: // Set dP
               PrivateRSAKey1024.setDP1(baAPDUBuffer, ISO7816.OFFSET_CDATA, sLc);
               break;
          case 0x03: // Set dQ
               PrivateRSAKey1024.setDQ1(baAPDUBuffer, ISO7816.OFFSET_CDATA, sLc);
               break;
          case 0x04: // Set invQ
               PrivateRSAKey1024.setPQ(baAPDUBuffer, ISO7816.OFFSET_CDATA, sLc);
               break;
          default:
               ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
          }         
     }

corleoner
Posts: 15
Joined: Fri Dec 11, 2015 2:22 am
Points :92
Contact:

Re: Encounter error 6F 00 when importing RSA Private Key

Post by corleoner » Tue Oct 03, 2017 7:11 am

Firstly you should find out which line throws the exception by using try/catch clause.

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

Re: Encounter error 6F 00 when importing RSA Private Key

Post by nikonai » Tue Oct 03, 2017 6:36 pm

It seems that I found the problem. It is the conversion of the BigInteger value into a hex byte. I will try to fix this now.

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 25 guests

JavaCard OS : Disclaimer