问题描述
我正在尝试使用 bouncycastle 生成 BcPGP 密钥对,但我找不到任何有关如何在不使用弃用材料的情况下执行此操作的文档。我正在使用以下函数在返回语句 unkNown key class
处抛出 PGP 异常。
这是异常的堆栈跟踪
org.bouncycastle.openpgp.PGPException: unkNown key class
at org.bouncycastle.openpgp.operator.bc.BcPGPKeyConverter.getPGPPrivateKey(UnkNown Source)
at org.bouncycastle.openpgp.operator.bc.BcPGPKeyPair.getPrivateKey(UnkNown Source)
at org.bouncycastle.openpgp.operator.bc.BcPGPKeyPair.<init>(UnkNown Source)
at Client.Encryptor.generateRsaKeys(Encryptor.java:31)
at Client.Encryptor.<init>(Encryptor.java:66)
at Client.Client.run(Client.java:70)
at Client.Main.main(Main.java:20)
和代码
private BcPGPKeyPair generateRsaKeys () throws PGPException {
RSAKeyPairGenerator gen = new RSAKeyPairGenerator();
gen.init(new RSAKeyGenerationParameters(BigInteger.valueOf(65537),new SecureRandom(),2048,5));
asymmetricCipherKeyPair keyPair = gen.generateKeyPair();
return new BcPGPKeyPair(PGPEncryptedData.AES_256,keyPair,new Date());
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)