Rsacryptoserviceprovider - Decrypt

Asked

Viewed 652 times

2

Using RSA encryption, I pass the encrypted data from client to the server decrypt. When trying to decrypt, it returns an exception CryptographicException with the message:

Specified invalid flags.

I have no idea Flag might be missing.

My code is as follows:

byte[] decryptedMessage;
RSACryptoServiceProvider asr = new RSACryptoServiceProvider(128);
decryptedMessage = asr.Decrypt(buffer, false);

in System.Security.Cryptography.CryptographicException.Throwcryptogaphicexception(Int32 hr) em System.Security.Cryptography.Utils. _GenerateKey(SafeProvHandle hProv, Int32 algid, CspProviderFlags flags, Int32 keySize, SafeKeyHandle& hKey) em System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle) in System.Security.Cryptography.RSACryptoServiceProvider.Getkeypair() in System.Security.Cryptography.RSACryptoServiceProvider.Decrypt(Byte[] rgb, Boolean fOAEP)

1 answer

0


  • This part all right, I had read about elsewhere, but what solution do I have then to decrypt the data ??

  • @Enzotiezzi Would it be possible to modify the client to use a larger key size? 128 bits for the RSA is terribly insecure... Otherwise, I imagine it will be necessary to seek an alternative implementation, or perhaps delegate the task to an external system (such as openssl).

  • i am using openssl, and sending encrypted data using RSA to the server from an Sslstream

Browser other questions tagged

You are not signed in. Login or sign up in order to post.