I need to know how to encrypt a message in AES-OpenSSL and decrypt in .NET (C# or VB) OR Know what is the difference between AES-OPENSSL and AES-.NET
Thank you!
In your comment, you ask for a way to encrypt in C# and Decrypt in OpenSSL. Here's a good implementation of EVP_BytesToKey in C#.
Now you just have to generate a random byte array in C#, then use these functions (EVP on OpenSSL side and the second one in C#) on both sides with your common random byte array.
Beware though, you have to use the same hash algorithm: in the given link, MD5 is used. You might have to change it to SHA1 depending on the one EVP_BytesToKey is using (or the other way round). The same way, you have to adapt the key and iv size in the Derive algorithm given in the post depending on your needs, here 32 and 32.
Hope that helped.
EDIT 1: I forgot. As owlstead said in his comment, Rijndael allows you to use a block size of 256 bits. However, AES block size is always fixed to 128 bits, so your block size MUST be 128 bits and your iv 16 bytes.
There is also a catch when you wish to use salt. OpenSSL prepends your encrypted byte array with a base64 encryption of "Salt__" and the actual salt array. You can find an example in this post.
EDIT 2: OpenSSL 1.1.0c changed the digest algorithm used in some internal components. Formerly, MD5 was used, and 1.1.0 switched to SHA256. Be careful the change is not affecting you in both EVP_BytesToKey
and commands like openssl enc
.