|
@@ 1233-1249 (lines=17) @@
|
| 1230 |
|
* @return string |
| 1231 |
|
* @throws Error |
| 1232 |
|
*/ |
| 1233 |
|
public static function crypto_pwhash_str($passwd, $opslimit, $memlimit) |
| 1234 |
|
{ |
| 1235 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1); |
| 1236 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2); |
| 1237 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3); |
| 1238 |
|
|
| 1239 |
|
if (self::isPhp72OrGreater()) { |
| 1240 |
|
return sodium_crypto_pwhash_str($passwd, $opslimit, $memlimit); |
| 1241 |
|
} |
| 1242 |
|
if (self::use_fallback('crypto_pwhash_str')) { |
| 1243 |
|
return call_user_func('\\Sodium\\crypto_pwhash_str', $passwd, $opslimit, $memlimit); |
| 1244 |
|
} |
| 1245 |
|
// This is the best we can do. |
| 1246 |
|
throw new Error( |
| 1247 |
|
'This is not implemented, as it is not possible to implement Argon2i with acceptable performance in pure-PHP' |
| 1248 |
|
); |
| 1249 |
|
} |
| 1250 |
|
|
| 1251 |
|
/** |
| 1252 |
|
* @param string $passwd |
|
@@ 1310-1326 (lines=17) @@
|
| 1307 |
|
* @return string |
| 1308 |
|
* @throws Error |
| 1309 |
|
*/ |
| 1310 |
|
public static function crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit) |
| 1311 |
|
{ |
| 1312 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1); |
| 1313 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2); |
| 1314 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3); |
| 1315 |
|
|
| 1316 |
|
if (self::isPhp72OrGreater()) { |
| 1317 |
|
return sodium_crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit); |
| 1318 |
|
} |
| 1319 |
|
if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256_str')) { |
| 1320 |
|
return call_user_func('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str', $passwd, $opslimit, $memlimit); |
| 1321 |
|
} |
| 1322 |
|
// This is the best we can do. |
| 1323 |
|
throw new Error( |
| 1324 |
|
'This is not implemented, as it is not possible to implement Scrypt with acceptable performance in pure-PHP' |
| 1325 |
|
); |
| 1326 |
|
} |
| 1327 |
|
|
| 1328 |
|
/** |
| 1329 |
|
* @param string $passwd |