*/
public CertificatePair generate(PrivateIdentityCertificate signingCertificate) {
keyPairGenerator.initialize(KEY_SIZE);
KeyPair kp = keyPairGenerator.genKeyPair();
RSAPrivateKeySpec signingRSAKey = new RSAPrivateKeySpec(signingCertificate.getModulus(), signingCertificate.getExponent());
try {
PrivateKey signingKey = keyFactory.generatePrivate(signingRSAKey);
RSAPublicKeySpec pub = keyFactory.getKeySpec(kp.getPublic(), RSAPublicKeySpec.class);
RSAPrivateKeySpec priv = keyFactory.getKeySpec(kp.getPrivate(), RSAPrivateKeySpec.class);
String uuid = UUID.randomUUID().toString();
signer.initSign(signingKey, new SecureRandom());
signer.update(uuid.getBytes(Charsets.UTF_8));
signer.update(pub.getModulus().toByteArray());
signer.update(pub.getPublicExponent().toByteArray());
byte[] rawSig = signer.sign();
BigInteger signature = new BigInteger(rawSig);
PublicIdentityCertificate publicCert = new PublicIdentityCertificate(uuid, pub.getModulus(), pub.getPublicExponent(), signature);
PrivateIdentityCertificate privateCert = new PrivateIdentityCertificate(priv.getModulus(), priv.getPrivateExponent());
return new CertificatePair(publicCert, privateCert);
} catch (InvalidKeySpecException e) {
throw new RuntimeException("Unexpected exception generating certificate", e);
} catch (InvalidKeyException e) {
throw new RuntimeException("Unexpected exception generating certificate", e);