【问题标题】:Sign a string against an RSA Public Key针对 RSA 公钥对字符串进行签名
【发布时间】:2014-08-03 13:39:09
【问题描述】:

我正在使用 C#,并尝试使用从 PuTTY 密钥生成器生成的密钥对字符串进行签名。我不太确定自己在做什么,因为我看不到如何将密钥导入 RsaEngine

我查看了以下内容:

AsymmetricKeyParameter key = new RsaKeyParameters(false, ???, ???);
RsaEngine rsa = new RsaEngine();
rsa.Init(true, key);

但似乎 RsaKeyParameter 和 AsymmetricKeyParameter 采用模数和指数,我不知道如何从我已经生成的密钥中获取?我可能使用了错误的类,所以如果有人对此有任何指示,那就太好了

我看了:RSA signing and verification with C#,BouncyCastle and imported RSA key - Working Python example and non-working C# code sample inside,但答案不存在:

ConvertToRSAPrivateKey

【问题讨论】:

  • 始终指定一些关注者数量较多的标签,否则您的问题将“被忽视”。
  • @JamieH,您是否尝试过查看 RSACryptoServiceProvider (msdn.microsoft.com/en-us/library/…)? BC 中的 RsaEngine 对于通用的“我需要签署数据”的要求来说看起来太低了。

标签: c# cryptography digital-signature bouncycastle


【解决方案1】:

您可以先convert the PuttyGen keys into OpenSSH compatible keys,然后将这种有据可查的格式转换为 C#。

我能想到的最好的是this class of the SSH.NET library code

同时,请注意,您最好在要使用的实际库中生成密钥。密钥格式,尤其是私钥格式,并不总是兼容的。

【讨论】:

  • 警告:我实际上没有尝试过上述解决方案。请说明成功。
猜你喜欢
  • 2023-04-02
  • 2011-03-11
  • 1970-01-01
  • 2013-06-06
  • 1970-01-01
  • 1970-01-01
  • 2019-03-13
  • 2011-01-22
  • 1970-01-01
相关资源
最近更新 更多