0

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...

Eve
  • 101
  • 2
  • 13
  • The problem here is that you are using the wrong class... You are using classes for public key encryption. You need the other classes (the ones used for symmetric cyphers, like DES/AES). There should be a `OpenSSL.Crypto.Cypher` class, but I don't know if your wrapper supports the Ghost89. **you should put the link to the wrapper you use when you ask infos about it** – xanatos Mar 14 '17 at 12:58
  • https://github.com/openssl-net/openssl-net -this one – Eve Mar 14 '17 at 13:08
  • There is the possibility that the version of OpenSSL given in the .NET library doesn't support Ghost... (the Ghost support WAS optional). The message seems to say it... – xanatos Mar 14 '17 at 13:52

0 Answers0