I have a question re. the use of Crypto in .net as follows. I have a .pem file which I am able to parse to a private key and would like to sign some data bytes. The code I'm using is below:
byte[] pemkey = Convert.FromBase64String(privateKeyString);
RSACryptoServiceProvider RSA = DecodeRSAPrivateKey(pemkey);//function to parse .pem file
byte[] fileBytes = File.ReadAllBytes(@"C:\...");
byte[] signature = RSA.SignData(fileBytes, HashAlgorithmName.SHA256, RSASignaturePadding.Pss);
When running this, at the last statement (RSA.SignData), I've got an exception CryptographicException is not handled: Specified padding mode is not valid for this algorithm.
I'm not sure what is missing from my code as my search on Google did not return much result.
Any help is appreciated. Many thanks