libsodium-jni
libsodium-jni copied to clipboard
Key derivations failures could lead to all zero byte keys
crypto_pwhash can return non-zero error codes in the event of an failure.
The function returns 0 on success, and -1 if the computation didn't complete, usually because the operating system refused to allocate the amount of requested memory.
That case is not handled at all here. If this function fails to derive the key, this will return an all zero key silently instead of signaling an error to the caller.
https://github.com/joshjdevl/libsodium-jni/blob/master/src/main/java/org/libsodium/jni/crypto/Hash.java#L51
This is unrelated, but I think crypto_pwhash_alg_default is (as of 1.0.9) Argon2. So isn't this function misnamed?