My goal is to genrate armoer eliptical curve (ECC) public and private key. So I have implemented the AsymmetricCipherKeyPair, now I have to convert it to OpenPGP Key so pass it for the KeyRingGenrator.
X9ECParameters parms = ECNamedCurveTable.getByOID(new ASN1ObjectIdentifier("curve25519"));
ECParameterSpec domainparams = EC5Util.convertToSpec(parms);
ECDomainParameters domainParams = EC5Util.getDomainParameters(null,domainparams);
SecureRandom secureRandom = new SecureRandom();
ECKeyGenerationParameters keyParams = new ECKeyGenerationParameters(domainParams, secureRandom);
ECKeyPairGenerator generator = new ECKeyPairGenerator();
generator.init(keyParams);
AsymmetricCipherKeyPair keyPair = generator.generateKeyPair();
After generation of the keyPair, I have to convert it into OpenPGP key pairs so that it could be passed in the following function.
PGPKeyPair eccKeyPair = new PGPKeyPair("openPGPPublicKey", "openPGPPrivateKey");
This function is further used for key ring generation.
PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator (PGPSignature.DEFAULT_CERTIFICATION,
eccKeyPair ,
"umaimaahmed1@gmail.com", null, null,
null, new BcPGPContentSignerBuilder(PGPPublicKey.EC,
HashAlgorithmTags.SHA256),
new BcPBESecretKeyEncryptorBuilder(PGPEncryptedData.AES_256).build(passPhrase));