kpg.initialize(keySize);
KeyPair kp = kpg.genKeyPair();
KeyFactory keyFactory = KeyFactory.getInstance(keyType);
RSAPublicKeySpec pub = keyFactory.getKeySpec(kp.getPublic(), RSAPublicKeySpec.class);
// <IBM JDK does not seem to support RSAPrivateKeySpec.class>
RSAPrivateKeySpec pvt;
try {
pvt = keyFactory.getKeySpec(kp.getPrivate(), RSAPrivateKeySpec.class);
}
catch(Exception e) {
pvt = keyFactory.getKeySpec(kp.getPrivate(), RSAPrivateCrtKeySpec.class);
}
// </IBM JDK does not seem to support RSAPrivateKeySpec.class>
putKeyToFile(filePub, pub.getModulus(), pub.getPublicExponent(),pubFilePermissions);
putKeyToFile(filePvt, pvt.getModulus(), pvt.getPrivateExponent(),pvtFilePermissions);
}
}
}
catch(CryptoException e) {
throw e;