getModulus and getExponent return error 6f00
I try to generate a RSA1024-Keypair on a JCOP-31 JavaCard. I thought all my used components are supported, but getting this error 6f00 I am not so sure any more.
Here is some of my code:
private RSAPrivateCrtKey PrivateRSAKey1024;
private RSAPublicKey PublicRSAKey1024;
private KeyPair keypair;
keypair =new KeyPair(KeyPair.ALG_RSA_CRT, (short)1024);
keypair.genKeyPair();
PrivateRSAKey1024 = (RSAPrivateCrtKey)keypair.getPrivate();
PublicRSAKey1024 = (RSAPublicKey)keypair.getPublic();
privatevoid getPublicKey(APDU apdu){
byte[] apduBuffer = apdu.getBuffer();
// get the element type and length
bytekeyElement = (byte)(apduBuffer[ISO7816.OFFSET_P2] & 0xFF);
// check correct type (modulus or exponent)
if((keyElement != 0x00) && (keyElement != 0x01))
ISOException.throwIt(ISO7816.SW_INCORRECT_P1P2);
// check elements request
byte[] temp =newbyte[4];
byte[] tempMod =newbyte[128];
if(keyElement == 0){
// retrieve modulus
apduBuffer[0] = (byte)((RSAPublicKey)PublicRSAKey1024).getModulus(temp, (short)1);
}else
// retrieve exponent
apduBuffer[0] = (byte)((RSAPublicKey)PublicRSAKey1024).getExponent(tempMod, (short)1);
// send the key element
apdu.setOutgoingAndSend((short)0, (short)((apduBuffer[0] & 0xFF) + 1));
}
Regards, Susanne

