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

asked Mar 14, 2017 at 12:25
3
  • 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 Commented Mar 14, 2017 at 12:58
  • github.com/openssl-net/openssl-net -this one Commented Mar 14, 2017 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... Commented Mar 14, 2017 at 13:52

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.