There's an issue with enacl:pwhash() when Ops|Mem limits are specified only on Windows amd64.
The issue is that Ops|Mem limits are parsed using enif_get_ulong().
unsigned long on Windows is 4-bytes wide even on 64-bit systems.
enacl:pwhash() doesn't behave as expected even for 4-byte integers that are supplied for Ops|Mem limits.
Why?
The parsed result is stored in a size_t 8-byte wide (uninitialized) integer r.
The uninitialized 4 bytes contain random bits and other 4 bytes contain the parsed unsigned long returned by enif_get_ulong.
As a result depending on the contents of the uninitialized 4 bytes, the resultant r that is returned for limit may cross
crypto_pwhash_OPSLIMIT_MAX|crypto_pwhash_MEMLIMIT_MAX
This can be fixed by using enacl_get_uint64() when sizeof(size_t) == 8 and enacl_get_uint() when sizeof(size_t) == 4.
This bug is to track the issue.
There's an issue with enacl:pwhash() when Ops|Mem limits are specified only on Windows amd64. The issue is that Ops|Mem limits are parsed using enif_get_ulong().
unsigned long on Windows is 4-bytes wide even on 64-bit systems.
enacl:pwhash() doesn't behave as expected even for 4-byte integers that are supplied for Ops|Mem limits. Why?
The parsed result is stored in a size_t 8-byte wide (uninitialized) integer r. The uninitialized 4 bytes contain random bits and other 4 bytes contain the parsed unsigned long returned by enif_get_ulong. As a result depending on the contents of the uninitialized 4 bytes, the resultant r that is returned for limit may cross crypto_pwhash_OPSLIMIT_MAX|crypto_pwhash_MEMLIMIT_MAX
This can be fixed by using enacl_get_uint64() when sizeof(size_t) == 8 and enacl_get_uint() when sizeof(size_t) == 4. This bug is to track the issue.