aes icon indicating copy to clipboard operation
aes copied to clipboard

Fix break AES-128-CBC on Ruby 2.5.3. Change hard code 32 key len by cipher key len returned by OpenSSL.

Open ntloi95 opened this issue 5 years ago • 4 comments

Regarding to the issue https://github.com/chicks/aes/issues/17 Error in Ruby 2.5.3, set cipher.key: Exception “key must be 16 bytes" OpenSSL::Cipher.new('AES-128-CBC') only accept key with length is 16 bytes.

While in the code, it return 32-byte-key with totally 16 trailing zero bytes: @key.unpack('a2'*32).map{|x| x.hex}.pack('c'*32) => "o\xA8\xBB\a#'\xF8\xD0\xE4\v\x85\xFA\xD9\x05\x10\xF9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"

ntloi95 avatar Oct 02 '20 11:10 ntloi95

@chicks any thoughts on this PR? I am running into the same problem with the hard coded value. The fix seems like a general improvement and it would be great if we could merge it.

dennissivia avatar Mar 09 '21 19:03 dennissivia

This project is deserted. :'( @dennissivia

ntloi95 avatar Mar 10 '21 15:03 ntloi95

@ntloi95 yeah, it seems so. And if nobody is at least merging fixes, I guess I have to switch to OpenSSL or another gem.

@vanaltj based on the last commit it seems that you also have permission to merge PRs? Can you take a look at this PR? That would be amazing.

dennissivia avatar Mar 10 '21 18:03 dennissivia

@ntloi95 I guess you are right. Seems as if it will take some time until the PR will be merged if it will ever happen. In my project I decided to create this monkey patch based on your solution. So I am not blocked and can take my time to replace the implementation with OpenSSL.

dennissivia avatar Mar 13 '21 12:03 dennissivia