将 PGP 公钥转换为 RSA 公钥 XML 格式

发布于 2024-11-09 08:09:18 字数 3030 浏览 2 评论 0原文

我在将 PGP 公钥转换为 RSA 公钥格式时遇到问题。以下 PGP 格式的公钥需要转换为 XML 格式。

如果你们中有人遇到过这样的情况,请帮助我。

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.1 (MingW32)

mQELBE2kxxwBCADjWSW/F/h9VkV9JizFwKXPzg1YlXyEmN/dGKTVBidOI3ZcrhQd
v3qhcWtNmBXz1BpO+YLy41AfJzysKNHrs23sMh8nKWlMSmKZZqVpimXCcCrKQ8Hi
uNNxcRN/hBdy5R4MN/N62hbFTgoZpGmrQjOXDSPozDeckQE7DjkGYvQAT63dT3jC
F99im/KC2GfHDxVh70+881ot+vUxKC6GRZAz6wth90M/5FzbKQt0GmFrq/XapqxK
ZQI5LLMzahdGzJTGEbfs8SlH6OAqZsgjgEKYaW3EooQVbrvGrdqna6PBkLbroCOl
EH/h6W9h42dFLb2OSV9OES7oidQATqzNC+oXAAYptE9CdWNrIENvbnN1bHRhbnRz
IC0gTXkgTWVkaWNhcmUgQWR2b2NhdGUgKE1NQSkgPHByb2RzdXBwb3J0QGJ1Y2tj
b25zdWx0YW50cy5jb20+iQE0BBMBAgAeBQJNpMccAhsDBgsJCAcDAgMVAgMDFgIB
Ah4BAheAAAoJEJrpFtACLTdGtKEH/3G4pB4UeiEsMwDYDO1YF4jkz2lqbItmCGek
WuVg7G1LGHgZm2cJVH0xSuTKY4WpaX1RX5iWhVgz0dSrDNkjOi3hlZJ49VzXZi8T
abQ+Uiqfu7QIWvSOmjhxdrl8FuC2ZpZLRWB93VFNGKM1qYrjphTW1uMCnU4WtkD0
e8d9M3VCC/uL72a0+0R2El80W55yZxvHD6JHlp82Gdn+sqsAEnUcg5c+USLcehgc
v931SE4VfcxW4PELcOp0gKb00Q4bWp09Is/NVR+kVUax5EaT2Wo5oe7cx8OgrzMs
5daypwibGoFCloFE4LH59hbahoM5s8Ya59YAYEBWA1u68DCBYqS5AQsETaTH1gEI
AMCvsxsZcm5kIdbXATuPJQ1PKDejeeF0t4f27vDqR9SOZKas2ExpWbmjSeF9EdJ5
e1QKm88/WSXeUuE4Sn2xBfZXfRvhWndQIs6pOi8licuht1WiuYWBlvPefMO1e15G
fHrghhQ4RcTLIG8SWDcVFbsnr92RDy8NV7qZd/N08dZ+IS7z2JV8hp8Ts0a9T01q
p1h6lCbr9CAABQmlihMQ+hM4LO9DjqDeR85I1NWNpODeoks8zx86S9xOlEBxmWg2
G90ahBxm3IsYW9KtDd+oro6s6GQroo+5C0bcHyVL6Dylmhkn4CYQ99WAzMtw3gQ8
IDFrLO7Vw1kMc+vR4LGMPpkABimJAR8EGAECAAkFAk2kx9YCGwwACgkQmukW0AIt
N0ZBxggAqLFdkvVHgsK8wx6WyZalRpimirVQxStPT8WWlGyg8zJIGxbAzC6f4Fml
IuXGQYse+D8LfL7leWCyGu71+IZb22XCQ7ZO2ogWl6txUO5jWgPkoPBi0XMK/tLu
pT1WP8/lzrh1XQgwvLME+dcTMeuqgV5uDUmhn2OX9j8N3iyZeOV84cFrYmgrNfHn
lHlGx2kyXhgUwfK6noIUljprImIjlntGL0sh6lxTiu5bWMpXJVeJdRjNXuf4G+2/
mLU7BfsNP5jDr3+isTTLcOlZR0PHiAywIFPA2VOMTscB6nNEHiu8FLNFnY+QgboT
uC4E2095FYSXRMXc/rif7+d5+NApAg==
=+Q6Q
-----END PGP PUBLIC KEY BLOCK-----

需要将其转换为 RSAKeyValue XML 格式,如下所示。

<RSAKeyValue>
    <Modulus>151Vw6Kq51bpblahblahblahWCkPmD345ncclzFrmeb9fjpE+B6VsIAqP3kahu00p33BmFpDpXOcgi uRC2En0HoGqyZB9ifvNlPhT7flZ1uVuC9JtywG3FmYRsqbpJuT7VTIAHYExU6T/FyRuyIbhdUVwhue7ARaObsEWszE1IoM7+XcYYs=</Modulus>
    <Exponent>AQAB</Exponent>
    <P>+7OU6YErvfk84O/2bX5s2753xE+pdiyJl3j8gy4zMh4UKeKVhyxgSJJCvNTl9XVIya6xnCWPkHVy8ylNqyLiHQ==</P>
    <Q>20v7/nODe/jKcbsiYEwzGXp0ZyiG17JqzOBKrDFu6bwPiAEHzZln0CYfUn0E hJdCmetaq9WFXk27mbK3Z6aBxw==</Q>
    <DP>RpoN6B26dlRGFlZZCkePI2he0esCfsppYdqnAejgpWs4 frM2/C6fZ1vXan5RbrOSUjg1S7ZhecToFHr+dUWYpQ== </DP>
    <DQ>ayaHbF7YwfxgPo3nUBIrbamNstH0gPQmhxCYq+ZDgWV oWVXXkDgCp4vZBh8b1AVsf3SmCwv7bIaiwYi3YKfVBQ==</DQ
    <InverseQ>YjvieMYPEDdUHqSZRWAsFlEESd3NczFCrbBaS HzbsbOZeDrccvUfoOP2jeIhuMt0qQwMqXY/NJau9Ldwdx7xNw==</InverseQ>
    <D>wEg6bM5LVSWoQgWpoldz5dQWfQjqQVc8WzKpDA HQ8ejsm0ug4ZwRcRRnKZs3o7OTsiAJCfjqT9ij1gKMoeLrXIM1 RDOcAYBxI0qwWdRrr3sbar7ntMYmy4tlTTf8/G+ypw+CJi1gz2umswcx4MHhNTUGTUHSmjEjDTFfh3sW64k= </D>
</RSAKeyValue>

I am faced with a problem on converting PGP Public keys to RSA Public Key format. Following public key in PGP format that need to be converted to XML format.

Please help me, if any of you had encountered such scenarios.

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.1 (MingW32)

mQELBE2kxxwBCADjWSW/F/h9VkV9JizFwKXPzg1YlXyEmN/dGKTVBidOI3ZcrhQd
v3qhcWtNmBXz1BpO+YLy41AfJzysKNHrs23sMh8nKWlMSmKZZqVpimXCcCrKQ8Hi
uNNxcRN/hBdy5R4MN/N62hbFTgoZpGmrQjOXDSPozDeckQE7DjkGYvQAT63dT3jC
F99im/KC2GfHDxVh70+881ot+vUxKC6GRZAz6wth90M/5FzbKQt0GmFrq/XapqxK
ZQI5LLMzahdGzJTGEbfs8SlH6OAqZ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Yse+D8LfL7leWCyGu71+IZb22XCQ7ZO2ogWl6txUO5jWgPkoPBi0XMK/tLu
pT1WP8/lzrh1XQgwvLME+dcTMeuqgV5uDUmhn2OX9j8N3iyZeOV84cFrYmgrNfHn
lHlGx2kyXhgUwfK6noIUljprImIjlntGL0sh6lxTiu5bWMpXJVeJdRjNXuf4G+2/
mLU7BfsNP5jDr3+isTTLcOlZR0PHiAywIFPA2VOMTscB6nNEHiu8FLNFnY+QgboT
uC4E2095FYSXRMXc/rif7+d5+NApAg==
=+Q6Q
-----END PGP PUBLIC KEY BLOCK-----

This need to be converted to RSAKeyValue XML format like the one below.

<RSAKeyValue>
    <Modulus>151Vw6Kq51bpblahblahblahWCkPmD345ncclzFrmeb9fjpE+B6VsIAqP3kahu00p33BmFpDpXOcgi uRC2En0HoGqyZB9ifvNlPhT7flZ1uVuC9JtywG3FmYRsqbpJuT7VTIAHYExU6T/FyRuyIbhdUVwhue7ARaObsEWszE1IoM7+XcYYs=</Modulus>
    <Exponent>AQAB</Exponent>
    <P>+7OU6YErvfk84O/2bX5s2753xE+pdiyJl3j8gy4zMh4UKeKVhyxgSJJCvNTl9XVIya6xnCWPkHVy8ylNqyLiHQ==</P>
    <Q>20v7/nODe/jKcbsiYEwzGXp0ZyiG17JqzOBKrDFu6bwPiAEHzZln0CYfUn0E hJdCmetaq9WFXk27mbK3Z6aBxw==</Q>
    <DP>RpoN6B26dlRGFlZZCkePI2he0esCfsppYdqnAejgpWs4 frM2/C6fZ1vXan5RbrOSUjg1S7ZhecToFHr+dUWYpQ== </DP>
    <DQ>ayaHbF7YwfxgPo3nUBIrbamNstH0gPQmhxCYq+ZDgWV oWVXXkDgCp4vZBh8b1AVsf3SmCwv7bIaiwYi3YKfVBQ==</DQ
    <InverseQ>YjvieMYPEDdUHqSZRWAsFlEESd3NczFCrbBaS HzbsbOZeDrccvUfoOP2jeIhuMt0qQwMqXY/NJau9Ldwdx7xNw==</InverseQ>
    <D>wEg6bM5LVSWoQgWpoldz5dQWfQjqQVc8WzKpDA HQ8ejsm0ug4ZwRcRRnKZs3o7OTsiAJCfjqT9ij1gKMoeLrXIM1 RDOcAYBxI0qwWdRrr3sbar7ntMYmy4tlTTf8/G+ypw+CJi1gz2umswcx4MHhNTUGTUHSmjEjDTFfh3sW64k= </D>
</RSAKeyValue>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

秋凉 2024-11-16 08:09:18

虽然通常可以从 OpenPGP RSA 密钥中提取密钥材料(请注意,OpenPGP 还可以使用 DSS/Elgamal 密钥),但您的示例有些不一致,因为它声明了 public em> OpenPGP 密钥和私有 RSA/XML 密钥。因此,我认为在继续之前先解决这些问题是有意义的(因为不可能从 RSA 公钥获得 RSA 私钥)。

While generally it is possible to extract key material from an OpenPGP RSA key (note that OpenPGP also gets use of DSS/Elgamal keys), your example is somewhat inconsistent, as it states public OpenPGP key and private RSA/XML key. So I think it makes sense to sort these things out before you continue (as it is impossible to get private RSA key from a public RSA key).

心病无药医 2024-11-16 08:09:18

终于从这篇 SO 帖子中得到了我想要的东西。

BouncyCastle RSAPrivateKey 到 .NET RSAPrivateKey

Finally got what I was looking for from this SO post.

BouncyCastle RSAPrivateKey to .NET RSAPrivateKey

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文