I want to protect my RSA private key with a password (who wouldn't) but the following C# fails:
SecureString pw = new SecureString(); pw.AppendChar('x'); CspParameters prms = new CspParameters(); prms.KeyPassword = pw; RSACryptoServiceProvider crypto = new RSACryptoServiceProvider(prms); byte[] encrypted = crypto.Encrypt(Encoding.ASCII.GetBytes("encryptme"), true); ...with the CryptographicException: "Invalid type specified". If I take the KeyPassword assignment out it works fine.
What am I, or Microsoft, doing wrong?