gpt4 book ai didi

java - 如何将 Bouncy CaSTLe PGP key 存储在 Java keystore 中?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:39:23 25 4
gpt4 key购买 nike

我有一个 JKS keystore ,它在我的应用程序中保留了几个私钥/公钥对。这已经使用 keystore 的密码进行了保护。我正在添加用于使用 Bouncy CaSTLe 执行 OpenPGP 的 key ,并且我需要生成几个 key 以用于 Bouncy CaSTLe PGP。我知道我可以将这些 key 存储为单独的文件,但这些文件需要使用密码单独保护,这让用户很头疼。我只想将 PGP key 存储在现有的 keystore 中。我已经阅读了关于 Stackoverflow 的几个回复,暗示它是可能的,但没有关于如何的明确答案。那么我可以将 PGP key 存储在现有的 keystore 中吗?

这是我的想法。 Bouncy CaSTLe 的 PGP 类不实现 key 或证书。它确实有 JcaPGPKeyPair 可以包装一个 PrivateKey/PublicKey 实例。所以我可以在 JCE 中创建 key ,然后使用 JcaPGPKeyPair 将 JCE key “导入”到 BC PGP 基础结构中。完成后,我会丢弃所有 BC PGP 实例,并在我再次需要它们时重新创建。可能使用 JcaPGPKeyConverter 来完成 JCE key 和 PGP key 之间的繁重转换?

我可以将 2 个 JCE RSA 或 DSA key 对用于 PGP 想要使用的签名和加密 key 吗?将它们保存在 keystore 中,并在我想使用这些 key 时按需重建 PGP 基础结构?

最佳答案

I'd like to simply store the PGP keys in the existing Keystore. I've read several responses on Stackoverflow alluding to it being possible, but no definitive answer about how. So can I store the PGP keys in the existing Keystore?

Java keystore 不支持 OpenPGP key 。 OpenPGP 是另一个与 X.509 不兼容的标准。

Bouncy Castle's classes for PGP do not implement Key or Certificate. It does have JcaPGPKeyPair which can wrap a PrivateKey/PublicKey instance. So I could create keys within JCE, then "import" the JCE keys into the BC PGP infrastructure using JcaPGPKeyPair. Once I'm done I throw away all of the BC PGP instances and recreate when I need them again. Possibly using JcaPGPKeyConverter to do the heavy lifting of converting between JCE keys and PGP keys?

Could I use 2 JCE RSA or DSA keypairs for both signature and encryption keys PGP wants to use? Keep those in the Keystore and simply reconstruct the PGP infrastructure on demand when I want to use those keys?

您可能会提取构成公钥和私钥的纯数字,但会丢失有关用户 ID、时间戳等的所有信息,您每次都必须重建这些信息。我不会走这样一条脆弱且容易出错的道路。 OpenPGP 和 X.509 key 属性没有真正的映射,证书( key 签名)的情况更糟。

关于java - 如何将 Bouncy CaSTLe PGP key 存储在 Java keystore 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35928359/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com