Last Updated
Viewed 13 Times

I want to understand why we need openssl.rb in bitcoin-ruby project. Is Ruby SSL implementation not enough?

I created a file using: echo "test" | openssl enc -aes256 -salt -a -k test

Decryption code:

  def decrypt_string(b64_text, decryption_key)
    encrypted_text = Base64.decode64(b64_text)
    _header = encrypted_text[0, 8]
    salt = encrypted_text[8, 8]
    payload = encrypted_text[16..-1]

    decipher ='aes-256-cbc').decrypt

    d_1 = + salt).digest
    d_2 = + decryption_key + salt).digest

    decipher.key = (d_1 + d_2)
    decipher.iv = + decryption_key + salt).digest

    decipher.update(payload) +

But when I call: decrypt_string('U2FsdGVkX1+5Sar5DYmbDtze7yvHKdq/ZuZIVnkImDc=', 'test')

I get OpenSSL::Cipher::CipherError: bad decrypt

I can not use external gems and do not want to make an OS call. How do you use the built in openssl library?

when running a Rails server, I get the following error: no such file to load -- openssl

I try a solution I find online. I go to ~/.rvm/src/ruby-1.9.2-head/ext/openssl. I type : ruby extconf.rb, but I get the following:

=== OpenSSL for Ruby configurator ===
=== Checking for system dependent stuff... ===
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for assert.h... yes
=== Checking for required stuff... ===
checking for openssl/ssl.h... no
=== Checking for required stuff failed. ===
Makefile wasn't created. Fix the errors above.

I cannot use make nor make install.

When I run 'sudo gem install rails', this error occurs:

ERROR:  While executing gem ... (OpenSSL::SSL::SSLError)
    SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A

BTW, I'm running Ruby version 1.9.3p0, Gem version 2.0.3, and OpenSSL version OpenSSL 1.0.1.

Any advice?

Similar Question 6 (1 solutions) : Ruby OpenSSL, print issuer and subject of pem file

Similar Question 8 (1 solutions) : Ruby Error reading in Certificate File with OpenSSL

Similar Question 9 (1 solutions) : How do I refactor OpenSSL pkcs5_keyivgen in ruby?