Projects
Home     Blog     Install     New Ticket     View Tickets     Browse Source

Ticket #104 (new defect)

Opened 5 months ago

Last modified 3 months ago

Problem with OpenSSL using MacRuby's internal conversion to and from NSData

Reported by: rich@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 0.4
Component: MacRuby Keywords:
Cc:

Description

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.

Attachments

tmp.rb (0.6 KB) - added by rich@… 5 months ago.
example code

Change History

Changed 5 months ago by rich@…

example code

Changed 4 months ago by lsansonetti@…

  • milestone set to MacRuby 0.3

Changed 3 months ago by lsansonetti@…

  • milestone changed from MacRuby 0.3 to MacRuby 0.4
Note: See TracTickets for help on using tickets.