Can System.Security.Cryptography.RSACryptoServiceProvider.Decrypt()
output incorrect data? Or will it always throw Exception with message "The parameter is incorrect" or any other Exception, whether it's unable to decrypt in a proper way?
Situation is:
RSACryptoServiceProvider.ExportParameters(true)
Is this even possible? What am I missing here?
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);
You cannot just replace the public exponent like you do after key generation (which happens in the constructor). By default a public exponent is likely set to 65537 (fifth prime of Fermat, F4) and you just set it to 0x65
. If the public and private key do not match then the calculations will fail.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.