From: Nathan Taylor-Hoover Date: 2007-06-15T05:33:34+09:00 Subject: Re: ezcrypto ------=_Part_48094_10757745.1181853215420 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Without seeing your code I can only speculate what the root problem is, but from the > 256 byte error description it sounds like you are using a block cipher that expects you to hand it 256 byte max chunks of data at a time. I would look at trying to use a stream cipher that allows a variable amount of data to be passed to it. My knowledge of the openssl lib is not deep so I can't really show this in code right now but I will try to put an example up later today. I can say however that using a crypto library is more complex than just creating an object and handing it a (key, plaintext, salt) type argument. You have to understand the default cipher that is being used by the method during creation or you will not pass the data in the expected format. There is more to the implementation than the crypto algorithm of choice. Blowfish is a block cipher algorithm, yet there are multiple "block modes" that it uses. I.E. ECB (*electronic codebook)*, CBC (*cipher-block chaining)*, OFB (*output feedback)*, CFB (*cipher feedback)*. Wikipedia.orghas a pretty good explanation of the modes. http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation You do not need to understand the mathematical formulas to implement, however you should have a basic understanding of each mode to choose the proper one for your implementation. From the few minutes I've looked at the openssl documentation it looks like you have to specify a mode and then depending on the mode chose you have a setup phase, encryption phase, and decryption phase. I also looked at a few lines of the ezcrypto binding and it looks like doesn't do anything except wrap the C API for openssl so this link should give you a basic idea of what you're looking for in implementation. http://www.openssl.org/docs/crypto/blowfish.html Unfortunately as you've previously stated the Ruby specific documentation is almost nil on this subject. I will try to put something small up tonight. - Nathan On 6/14/07, Jim Bob wrote: > > Hmmm I get the same problem, seems like it dies if the file is greater > than 256 bytes, dunno if that means much. > > I don't think what Jason said is very relevant, and their does seem to > be an issue. The documentation is typically bad and I personally do > find that very annoying, people can find the time to write blogs and > publish this stuff but can't spend 10 minutes writing some simple sample > code. I have posted on the relevant ruby forge forum but I would not > expect to get a message anytime soon. > > Fixing the bug might well be very time consuming as it is a wrapper > around Openssl, and we don't know if the issue is with that or ezcrypto. > > Move on then I guess, but to what? The crypto gem works okay if you only > need to crypt small files but is very slow on big files, not practical > for our plans. > > Look at OpenSSL gem directly I guess, but you will have a hard time > finding useful documentation for that either me thinks. > > Anyone know how to crypt files with Blowfish using Openssl, to late at > night now for me to try that! > > Jim. > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_48094_10757745.1181853215420--