Given the key in pem format similar to
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,DE1BB301BDE4BB45
msUEpZKZ0uaOmhGXBPnh2GoNSXyExdeqETd9w71l0G1bk1cCbiV4EOnmR7bcN+OE
(20 lines)
YoIx/E+tFHkt3gQcFhVUNgSOe/5+huXwRwUC5dthPzzZFlDCXHfwfrrBzOSGxZpX
uBs1JxY4qOLRdZVaZlQespForxBTYD6RuHi1UI5lqEW7363VyCLho9QYgGFM0LUi
qbln5WV37PTmayxMfzlGUB2XazwON+WU3obbXuCFXAy96Y6VGzv0lQ==
-----END RSA PRIVATE KEY-----
And the encrypted string(which was encrypted using the public key) I tried to decrypt with the following code
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
des.IV = HextoByte("DE1BB301BDE4BB45");
des.Padding = PaddingMode.None;
des.Mode = CipherMode.CBC;
des.Key = Convert.FromBase64String(//Key from above from ms.. to ==);
byte[] encrypted = Convert.FromBase64String("");
byte[] decrypted = des.CreateDecryptor().TransformFinalBlock(encrypt, 0, encrypt.Length);
string decryptedString = Encoding.UTF8.GetString(decrypted)
Which results in exception when assigning the key "Specified key is not a valid size for this algorithm"
The Key was generated using (Also tried with 192)
openssl genrsa -des3 -out Key.pem 2048
Public key was generated using
openssl rsa -in Key.pem -pubout > Key.pub
Would anyone be able to help me to point out what I am missing or doing wrong?
Thank you