Encounter error 6F 00 when importing RSA Private Key
Posted: 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:
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);
}
}