I have an encrypted base64
file "PersonalCodes.txt"
and a private key to it "private.key"
. The key is in .pem (---begin private key -- etc.)
and is encrypted with -gost89
.
I need to use an OpenSSL.NET for this (apparently System.Security.Cryptography
have no support on .pem
keys) For the simple openssl client , the commands will be:
base64 -d -in "PersonalCodes.txt" -out "PersonalCodesOUT.txt"
smime -decrypt -in "PersonalCodesOUT.txt" -inform der -inkey "private.key" -out "DecryptedCodes.txt"
First one is decrypting from base64 -ok. easy. Next one is decrypting with gost89 key.
As for the .NET
- honestly , i'm completely frustrated. I added a reference to an openssl wrapper
, and found an example how to get a key from file :
byte[] b = System.IO.File.ReadAllBytes(@"D:\private.key");
OpenSSL.Core.BIO bio = new OpenSSL.Core.BIO(b);
OpenSSL.Crypto.CryptoKey key = OpenSSL.Crypto.CryptoKey.FromPrivateKey(bio, "");
But this gives me an exception : unsupported private key algorithm
According to google - i need to help openssl to see gost89
How should i do that in c#
?
Moreover, can anyone help me with a the last command - decrypting with a private key in openssl.net
? Ty...
-------------------------------------------------------------------------------
Found this implementation of the gost89 : https://github.com/embedthis/packages/blob/master/openssl/openssl-1.0.1c/engines/ccgost/gost89.c
However it also doesnt give a function to decrypt a file with key...