Keats / rust-bcrypt

Easily hash and verify passwords using Bcrypt
MIT License
340 stars 49 forks source link

Do passwords need to be null terminated? #76

Open alanhe opened 1 year ago

alanhe commented 1 year ago

When password has more than 72 bytes, it is truncated and the assumption may not hold true. I wonder if L109 is necessary.

https://github.com/Keats/rust-bcrypt/blob/b6af5e5311598aee52d0bcfac1e22e13b1d10946/src/lib.rs#L106-L114

Keats commented 1 year ago

I'm not sure tbh, we should see how other implementations handle it. From what I remember, it should be 71 bytes + 0 so yeah it might not be correct.

alanhe commented 1 year ago

By the Go implementation, I think it's 72 bytes + 0


It's not bothering me -- just out of curiosity 😄

Keats commented 1 year ago

I guess it's an issue in this crate then, the push should be after the truncation. I guess no one really encode things that are more than 72 bytes in practice.

Keats commented 1 year ago

I guess we should hash a password from the C++/Go implementation that has more than 72 bytes and ensure we can verify them