我的目標是生成 armoer 橢圓曲線 (ECC) 公鑰和私鑰。所以我已經實現了 AsymmetricCipherKeyPair,現在我必須將它轉換為 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();生成密鑰對后,我必須將其轉換為 OpenPGP 密鑰對,以便它可以在以下函數中傳遞。 PGPKeyPair eccKeyPair = new PGPKeyPair("openPGPPublicKey", "openPGPPrivateKey");此功能進一步用于密鑰環生成。PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator (PGPSignature.DEFAULT_CERTIFICATION, eccKeyPair , "[email protected]", null, null, null, new BcPGPContentSignerBuilder(PGPPublicKey.EC, HashAlgorithmTags.SHA256), new BcPBESecretKeyEncryptorBuilder(PGPEncryptedData.AES_256).build(passPhrase));
1 回答
蝴蝶刀刀
TA貢獻1801條經驗 獲得超8個贊
在查看 API 文檔時,我發現:
已棄用。使用
BcPGPKeyPair或JcaPGPKeyPair視情況而定。
怎么樣BcPGPKeyPair?
畢竟,您要使用 Bouncy Castle 的輕量級 API 生成密鑰對。
添加回答
舉報
0/150
提交
取消
