libsodium.js
libsodium.js copied to clipboard
crypto_pwhash() returns buffer of null bytes
I was testing some code using libsodium-wrappers (not the sumo version) inside Blisk (https://blisk.io/) which uses Chromium.
This code :
sodium.crypto_pwhash(32, password, "0000000000000000",
sodium.crypto_pwhash_OPSLIMIT_INTERACTIVE,
sodium.crypto_pwhash_MEMLIMIT_INTERACTIVE,
sodium.crypto_pwhash_ALG_DEFAULT)
is returning a buffer of the expected size but filled with only zero bytes. Uint8Array(32) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
.
Lowering memlimit
makes it work as expected.
The same code works properly on "regular" Chrome, so probably some memory limits triggered on Blisk.
I'd expect it to throw an error in case of memory exhaustion without having me to check the content of the returned buffer. I can see an "Invalid Operation" exception in case of memlimit being too small for instance. So error are being reported.
Any idea?
Thanks!
Do you know whether it is using the WebAssembly code or the JavaScript one?
I tried the same test case in chrome w/o wasm (--js-flags=--noexpose_wasm
), turns out it exposes the same issue.
Weird thing is that I restarted Blisk and it worked again. It's like when I tried yesterday WebAssembly refused to allocate more memory, or was disabled by Blisk for some reason.
Now, looking at the code, that would mean that argon successfully returned even though it couldn't allocate the requested memory.
Probably a duplicate of #310