我的目標(biāo)是生成 armoer 橢圓曲線 (ECC) 公鑰和私鑰。所以我已經(jīng)實(shí)現(xiàn)了 AsymmetricCipherKeyPair,現(xiàn)在我必須將它轉(zhuǎn)換為 OpenPGP 密鑰,以便將它傳遞給 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();生成密鑰對(duì)后,我必須將其轉(zhuǎn)換為 OpenPGP 密鑰對(duì),以便它可以在以下函數(shù)中傳遞。 PGPKeyPair eccKeyPair = new PGPKeyPair("openPGPPublicKey", "openPGPPrivateKey");此功能進(jìn)一步用于密鑰環(huán)生成。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));
1 回答

蝴蝶刀刀
TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超8個(gè)贊
在查看 API 文檔時(shí),我發(fā)現(xiàn):
已棄用。使用
BcPGPKeyPair
或JcaPGPKeyPair
視情況而定。
怎么樣BcPGPKeyPair
?
畢竟,您要使用 Bouncy Castle 的輕量級(jí) API 生成密鑰對(duì)。
添加回答
舉報(bào)
0/150
提交
取消