jlouis / enacl

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

Generic hash state needs to be 64-byte aligned #36

Closed hanssv closed 5 years ago

hanssv commented 5 years ago

At least according to: https://libsodium.gitbook.io/doc/hashing/generic_hashing

We noticed crashes when it was not 16-byte aligned - probably is architecture dependent. This makes the safe choice and always 64-byte align it.

hanssv commented 5 years ago

While fiddling with the code I also started wondering why generichash_update returns a new state - can the reference actually change or would it be more transparent not to return a state (and thus make it look more functional than it really is!) ?

jlouis commented 5 years ago

I think it was modeled on the crypto:..._update/2 style functions which returns a new hash-state. But it made me ponder as well, because the linearity is assumed.

I think the whole generichash interface is one of those I have yet to throw through QuickCheck, and it shows. It would probably have caught it earlier.

jlouis commented 5 years ago

Oh, and patch looks-good-to-me, I'll pull it in