I think there may be an issue around the lengths here. I'm struggling to compile on my mac, or would add tests and/or fix myself.
The length of several strings is measured with "length" in lib/argon2/ffi_engine.rb#L40 before being passed to a C interface that interprets this as a byte length. In Ruby 1.9 and higher, length is defined as the character length of the string, not the byte length. The bytesize method provides the equivalent for bytes:
This may cause errors, or allow an active attacker to produce distinct documents for which this library produces the same hash (effectively an error-based preimage attack).
Thank you for this report. I am writing a fix - but this DDoS that Linode is currently undergoing is making my development environment particularly poor.
I think there may be an issue around the lengths here. I'm struggling to compile on my mac, or would add tests and/or fix myself.
The length of several strings is measured with "length" in lib/argon2/ffi_engine.rb#L40 before being passed to a C interface that interprets this as a byte length. In Ruby 1.9 and higher, length is defined as the character length of the string, not the byte length. The bytesize method provides the equivalent for bytes:
http://apidock.com/ruby/String/bytesize
This may cause errors, or allow an active attacker to produce distinct documents for which this library produces the same hash (effectively an error-based preimage attack).