[英]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.