[英]Can RSACryptoServiceProvider.Decrypt() return incorrect data?
System.Security.Cryptography.RSACryptoServiceProvider.Decrypt()
output 数据是否不正确? 或者它是否总是会抛出带有消息“参数不正确”或任何其他异常的异常,无论它是否无法以正确的方式解密?
情况是:
RSACryptoServiceProvider.ExportParameters(true)
生成 RSA 对这甚至可能吗? 我在这里想念什么?
using System.Security.Cryptography;
var provider = new RSACryptoServiceProvider(2048);
var rsaParams = provider.ExportParameters(true);
rsaParams.Exponent = new byte[] { 0x65 };
byte[] publicKey = rsaParams.Modulus;
// Send public key to the other side with exponent 0x65,
// Decrypt received data
byte[] decryptedData = provider.Decrypt(encryptedData, false);
您不能像在密钥生成之后那样替换公共指数(这发生在构造函数中)。 默认情况下,公共指数可能设置为 65537(费马的第五个素数,F4),您只需将其设置为0x65
。 如果公钥和私钥不匹配,则计算将失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.