Encryption/decryption doesn’t work well between two different openssl versions

The default digest was changed from MD5 to SHA256 in Openssl 1.1 Try using -md md5 cgs@ubuntu:~$ echo “it-works!” > file.txt cgs@ubuntu:~$ LD_LIBRARY_PATH=~/openssl-1.1.0/ openssl-1.1.0/apps/openssl aes-256-cbc -a -salt -in ~/file.txt -out ~/file.txt.enc -md md5 enter aes-256-cbc encryption password: Verifying – enter aes-256-cbc encryption password: cgs@ubuntu:~$ LD_LIBRARY_PATH=~/openssl-1.0.1f/ openssl-1.0.1f/apps/openssl aes-256-cbc -a -in ~/file.txt.enc -d enter aes-256-cbc decryption password: … Read more

Preparing for removal of Mcrypt in PHP 7.2

You can’t convert it, because Rijndael-256 is not AES-256, and the OpenSSL extension doesn’t ship with Rijndael-256 support. AES-256 is Rijndael-128 with a 256-bit (32-byte) key. Unfortunately, you’ll have to re-encrypt all of your data. Edit: Also, the scheme you’re currently using has some problems: It lacks authentication (HMACs are the easiest way to do … Read more

Python referencing old SSL version

Got this working after several days. MAC OS X El Captian or greater sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7 sudo rm -rf “/Applications/Python 2.7” cd /usr/local/bin/ ls -l /usr/local/bin | grep ‘../Library/Frameworks/Python.framework/Versions/2.7’ | awk ‘{print $9}’ | tr -d @ | xargs rm brew uninstall python brew uninstall openssl brew link –force openssl Now install python and … Read more

Upgrading my encryption library from Mcrypt to OpenSSL

This code for your decryption routine works for me: public function decrypt($data, $key) { $salt = substr($data, 0, 128); $enc = substr($data, 128, -64); $mac = substr($data, -64); list ($cipherKey, $macKey, $iv) = $this->getKeys($salt, $key); if ($mac !== hash_hmac(‘sha512’, $enc, $macKey, true)) { return false; } $dec = openssl_decrypt($enc, $this->cipher, $cipherKey, OPENSSL_RAW_DATA, $iv); return $dec; … Read more

Using openssl to get the certificate from a server

With SNI If the remote server is using SNI (that is, sharing multiple SSL hosts on a single IP address) you will need to send the correct hostname in order to get the right certificate. openssl s_client -showcerts -servername www.example.com -connect www.example.com:443 </dev/null Without SNI If the remote server is not using SNI, then you … Read more

Updating openssl in python 2.7

Please refer to http://rkulla.blogspot.kr/2014/03/the-path-to-homebrew.html After upgrading openssl to 1.0.1j by homebrew on MAC, but system python still referred to old version 0.9.8. It turned out the python referred to openssl. So I have installed new python with brewed openssl and finished this issue on Mac, not yet Ubuntu. On Mac OS X version 10.10 and … Read more