#104: Problem with OpenSSL using MacRuby's internal conversion to and from NSData --------------------------------+------------------------------------------- Reporter: rich@infoether.com | Owner: lsansonetti@apple.com Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: --------------------------------+------------------------------------------- This code will reproduce the problem: require 'openssl' require 'digest/sha1' CRYPT = "aes256" password = 'test' gen_key = OpenSSL::Cipher::Cipher.new(CRYPT) gen_key.encrypt key_crypt = OpenSSL::Cipher::Cipher.new(CRYPT) key_crypt.encrypt key_crypt.key = Digest::SHA1.hexdigest(password+CRYPT)[2,32] key = key_crypt.update("KEY_"+OpenSSL::Random.random_bytes(key_crypt.key_len)) key << key_crypt.final #comment out next line and it works File.open("tmp.key", "wb") {|f| f.write(key)} key_decrypt = OpenSSL::Cipher::Cipher.new(CRYPT) key_decrypt.decrypt key_decrypt.key = Digest::SHA1.hexdigest(password+CRYPT)[2,32] db_key = key_decrypt.update(key) db_key << key_decrypt.final If you take out that file write operation, then this code will run. You leave it in and you get block_length error. I believe that has to do with internally converting objects to NSData when treated as binary. It still says the class is NSCFString but something is happening to it. -- Ticket URL: <https://www.macruby.org/trac/ticket/104> macruby <http://macruby.org/>