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)
This part all right, I had read about elsewhere, but what solution do I have then to decrypt the data ??
– Enzo Tiezzi
@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).
– mgibsonbr
i am using openssl, and sending encrypted data using RSA to the server from an Sslstream
– Enzo Tiezzi