jlouis / enacl

Erlang bindings for NaCl / libsodium
MIT License
197 stars 59 forks source link

Erratic results using pwhash_str_verify/1 when supplying printable bitstring #28

Closed ghost closed 6 years ago

ghost commented 6 years ago

When supplying a printable bitstring to pwhash_str_verify/1 the return is sometimes true and sometimes false. Can not replicate this behavior using the binary as returned by pwhash_str/1.

Example:

Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Interactive Elixir (1.6.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :enacl.pwhash_str_verify("$argon2id$v=19$m=65536,t=2,p=1$39gbxAJq7dxSB8ycRRwZKg$2x5eXfGN0uSh2ywUe7pU9eb6wKAykhY3Ewu4LrSwt7Y", "foo")
true
iex(2)> :enacl.pwhash_str_verify("$argon2id$v=19$m=65536,t=2,p=1$39gbxAJq7dxSB8ycRRwZKg$2x5eXfGN0uSh2ywUe7pU9eb6wKAykhY3Ewu4LrSwt7Y", "foo")
false
iex(3)> :enacl.pwhash_str_verify("$argon2id$v=19$m=65536,t=2,p=1$39gbxAJq7dxSB8ycRRwZKg$2x5eXfGN0uSh2ywUe7pU9eb6wKAykhY3Ewu4LrSwt7Y", "foo")
true
iex(4)> :enacl.pwhash_str_verify("$argon2id$v=19$m=65536,t=2,p=1$39gbxAJq7dxSB8ycRRwZKg$2x5eXfGN0uSh2ywUe7pU9eb6wKAykhY3Ewu4LrSwt7Y", "foo")
false
iex(5)>
jlouis commented 6 years ago

Please keep these coming. I might have time to look into it soon. I don't think this is under quickcheck control, so that might be why there is a bug here.

On Tue, Apr 24, 2018 at 8:06 PM Bryan Paxton notifications@github.com wrote:

When supplying a printable bitstring to pwhash_str_verify/1 the return is sometimes true and sometimes false. Can not replicate this behavior using the binary as returned by pwhash_str/1.

Example:

Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Interactive Elixir (1.6.4) - press Ctrl+C to exit (type h() ENTER for help) iex(1)> :enacl.pwhash_str_verify("$argon2id$v=19$m=65536,t=2,p=1$39gbxAJq7dxSB8ycRRwZKg$2x5eXfGN0uSh2ywUe7pU9eb6wKAykhY3Ewu4LrSwt7Y", "foo") true iex(2)> :enacl.pwhash_str_verify("$argon2id$v=19$m=65536,t=2,p=1$39gbxAJq7dxSB8ycRRwZKg$2x5eXfGN0uSh2ywUe7pU9eb6wKAykhY3Ewu4LrSwt7Y", "foo") false iex(3)> :enacl.pwhash_str_verify("$argon2id$v=19$m=65536,t=2,p=1$39gbxAJq7dxSB8ycRRwZKg$2x5eXfGN0uSh2ywUe7pU9eb6wKAykhY3Ewu4LrSwt7Y", "foo") true iex(4)> :enacl.pwhash_str_verify("$argon2id$v=19$m=65536,t=2,p=1$39gbxAJq7dxSB8ycRRwZKg$2x5eXfGN0uSh2ywUe7pU9eb6wKAykhY3Ewu4LrSwt7Y", "foo") false iex(5)>

ā€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jlouis/enacl/issues/28, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAWH-Yvqx583Wf7V52NtA2L3Ja_AFKSks5tr2mPgaJpZM4TiKCM .

ghost commented 6 years ago

@jlouis Will do. Hopefully will send some PRs up soon. Thanks for the work on this šŸ˜€

ghost commented 6 years ago

I believe this is going to be related to iex and not enacl. When I try this in a script or module (calling pwhash_str_verify in succession on the same data) it's always true.