I need decrypt text but I am getting the message The parameter is incorrect
.
The certificate is getting correctly, it is registered in windows.
Searching about the problem, I can read comment that suggest change the user in the application pool assigned to the web site in the IIS. I tried it but not work.
In the second image shows the size calculation, but I don't sure because subtract 11 to the KeySize
divition per 8.
I'm using VS2010 with .net 4. The asp.net proyect uses IIS like server, doesn't use Visual Studio Development Server
What can I try to solve the problem?
[SOLUTION]
The encrypted text assigned in Decrypt method was generated with a certificate obsolete.
The text was encrypted with a certificate but then it was changed, when tried decrypt the encripted text with other certificate the method fails.
This Exception happens if the private or public keys are changed.
When encrypting data using an asymmetric cryptosystem (i.e RSA in your case), the size of the output is the same as the modulus size. In addition, the size of the input must be less than or equals the modulus size. Therefore when you try to decrypt a cipher text, the size of the cipher text must equal the size of the modulus (i.e. 128 bytes in your case since the key size is 1024 bits).
So, you shouldn't be segmenting the data
variable, just feed it directly to the RSACryptoServiceProvider.Decrypt
.
Another thing to try is to supply true
for the fOAEP
parameter in the rsa.Decrypt
since decrypting an OAEP padded cipher text with fOAEP
set to false will cause the The parameter is incorrect
exception to be thrown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With