|
@@ 1206-1224 (lines=19) @@
|
| 1203 |
|
* @return string |
| 1204 |
|
* @throws Error |
| 1205 |
|
*/ |
| 1206 |
|
public static function crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit) |
| 1207 |
|
{ |
| 1208 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($outlen, 'int', 1); |
| 1209 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 2); |
| 1210 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($salt, 'string', 3); |
| 1211 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 4); |
| 1212 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 5); |
| 1213 |
|
|
| 1214 |
|
if (self::isPhp72OrGreater()) { |
| 1215 |
|
return sodium_crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit); |
| 1216 |
|
} |
| 1217 |
|
if (self::use_fallback('crypto_pwhash')) { |
| 1218 |
|
return call_user_func('\\Sodium\\crypto_pwhash', $outlen, $passwd, $salt, $opslimit, $memlimit); |
| 1219 |
|
} |
| 1220 |
|
// This is the best we can do. |
| 1221 |
|
throw new Error( |
| 1222 |
|
'This is not implemented, as it is not possible to implement Argon2i with acceptable performance in pure-PHP' |
| 1223 |
|
); |
| 1224 |
|
} |
| 1225 |
|
|
| 1226 |
|
/** |
| 1227 |
|
* @param string $passwd |
|
@@ 1283-1301 (lines=19) @@
|
| 1280 |
|
* @return string |
| 1281 |
|
* @throws Error |
| 1282 |
|
*/ |
| 1283 |
|
public static function crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit) |
| 1284 |
|
{ |
| 1285 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($outlen, 'int', 1); |
| 1286 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 2); |
| 1287 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($salt, 'string', 3); |
| 1288 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 4); |
| 1289 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 5); |
| 1290 |
|
|
| 1291 |
|
if (self::isPhp72OrGreater()) { |
| 1292 |
|
return sodium_crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit); |
| 1293 |
|
} |
| 1294 |
|
if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256')) { |
| 1295 |
|
return call_user_func('\\Sodium\\crypto_pwhash_scryptsalsa208sha256', $outlen, $passwd, $salt, $opslimit, $memlimit); |
| 1296 |
|
} |
| 1297 |
|
// This is the best we can do. |
| 1298 |
|
throw new Error( |
| 1299 |
|
'This is not implemented, as it is not possible to implement Scrypt with acceptable performance in pure-PHP' |
| 1300 |
|
); |
| 1301 |
|
} |
| 1302 |
|
|
| 1303 |
|
/** |
| 1304 |
|
* @param string $passwd |