Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Replace copied scrypt implementation with call to libsodium
Summary:
libsodium actually uses the same implementation; using libsodium means we don't
need to maintain a copy ourselves.
Keep the `pickparams` implementation though, as that's not exposed in libsodium.
We should deprecate this extension, and strongly encourage directly using `ext_sodium` instead from Hack code; stored hashes from `ext_scrypt` can be verified like this:
```
$enc = scrypt_enc('foo', random_bytes(SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES));
list($_, $algo, $n, $r, $p, $salt, $out) = explode('$', $enc);
invariant($algo === 's', 'did not get an scrypt result');
$salt = base64_decode($salt);
$out = base64_decode($out);
$opslimit = (1 << $n) * $r * $p * 4;
$memlimit = (1 << $n) * $r * 128;
$sodium = sodium_crypto_pwhash_scryptsalsa208sha256(strlen($out), 'foo', $salt, $opslimit, $memlimit);
\var_dump($sodium === $out);
```
This also makes the scrypt extension depend on libsodium; this is fine, libsodium's going to be a hard dependency for HHVM anyway when the proxygen pin is next updated.
Reviewed By: alexeyt
Differential Revision: D15702142
fbshipit-source-id: 2dcad7c6cb273d4ce4b3479ffa445841fa2d1107- Loading branch information