C#RSA提取私钥公钥 [英] c# RSA extract public key from private key

查看:1469
本文介绍了C#RSA提取私钥公钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法提取在C#中的私钥公钥? Becouse如果我这样做 ToXMLString()然后我可以设置,如果我想保存私钥公钥信息。所以,现在的IM思想,有没有办法提取公私密钥?

Is there a way to extract public key from private key in c#? Becouse if i do ToXMLString() then i can set if i want public key information saved with the private key. So now im thinking that is there a way to extract public key from private?

推荐答案

有关RSA正常的私有密钥格式包括公钥(以下简称公开指数是在某种程度上能抵抗计时攻击执行私钥操作的有用)。因此,能够提取私钥公钥

The normal private key format for RSA includes the public key (the "public exponent" is useful for implementation of private key operations in a way which resists timing attacks). Therefore, it is possible to extract the public key from the private key.

(这在理论上是可能有一个纯RSA私钥,它不包括公共指数,但它也有缺点,如抗侧信道攻击更难保护,性能降低。因此,在他们的脑子没有人做到这一点。你可以假设,当你有私钥你确实有完整的密钥对。)

(It is theoretically possible to have a "pure RSA private key" which does NOT include the public exponent, but it has drawbacks, such as much harder protection against side-channel attacks, and reduced performance. Therefore nobody in their right mind does that. You can assume that when you have the private key you actually have the complete key pair.)

在C#/。NET标准库,公共和私有RSA密钥可以表示为XML字符串( ToXmlString() FromXmlString())或自定义的 RSAParameters 结构( ExportParameters() ImportParameters())。如果你能得到完整的私钥,那么你只需要挑公共字段(模数和公共指数),这构成了共同的公共密钥。需要注意的是的RSACryptoServiceProvider 可能是一个潜在的RSA实现,它可以拒绝导出私钥(但通常会接受导出公共密钥)的接口。

In the C#/.NET standard library, public and private RSA keys can be represented as XML strings (ToXmlString() and FromXmlString()) or a custom RSAParameters structure (ExportParameters() and ImportParameters()). If you can obtain the complete private key then you just have to pick the public fields (modulus and public exponent), which constitute together the public key. Note that RSACryptoServiceProvider may be an interface to an underlying RSA implementation which could refuse to export the private key (but will usually accept to export the public key).

这篇关于C#RSA提取私钥公钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆