|
@@ 143-156 (lines=14) @@
|
| 140 |
|
* > 0 if the right operand is less than the left |
| 141 |
|
* @throws TypeError |
| 142 |
|
*/ |
| 143 |
|
public static function compare($left, $right) |
| 144 |
|
{ |
| 145 |
|
/* Type checks: */ |
| 146 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($left, 'string', 1); |
| 147 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($right, 'string', 2); |
| 148 |
|
|
| 149 |
|
if (self::isPhp72OrGreater()) { |
| 150 |
|
return sodium_compare($left, $right); |
| 151 |
|
} |
| 152 |
|
if (self::use_fallback('compare')) { |
| 153 |
|
return call_user_func('\\Sodium\\compare', $left, $right); |
| 154 |
|
} |
| 155 |
|
return ParagonIE_Sodium_Core_Util::compare($left, $right); |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
/** |
| 159 |
|
* Authenticated Encryption with Associated Data: Decryption |
|
@@ 1257-1272 (lines=16) @@
|
| 1254 |
|
* @return bool |
| 1255 |
|
* @throws Error |
| 1256 |
|
*/ |
| 1257 |
|
public static function crypto_pwhash_str_verify($passwd, $hash) |
| 1258 |
|
{ |
| 1259 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1); |
| 1260 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2); |
| 1261 |
|
|
| 1262 |
|
if (self::isPhp72OrGreater()) { |
| 1263 |
|
return sodium_crypto_pwhash_str_verify($passwd, $hash); |
| 1264 |
|
} |
| 1265 |
|
if (self::use_fallback('crypto_pwhash_str_verify')) { |
| 1266 |
|
return call_user_func('\\Sodium\\crypto_pwhash_str_verify', $passwd, $hash); |
| 1267 |
|
} |
| 1268 |
|
// This is the best we can do. |
| 1269 |
|
throw new Error( |
| 1270 |
|
'This is not implemented, as it is not possible to implement Argon2i with acceptable performance in pure-PHP' |
| 1271 |
|
); |
| 1272 |
|
} |
| 1273 |
|
|
| 1274 |
|
/** |
| 1275 |
|
* @param int $outlen |
|
@@ 1334-1349 (lines=16) @@
|
| 1331 |
|
* @return bool |
| 1332 |
|
* @throws Error |
| 1333 |
|
*/ |
| 1334 |
|
public static function crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash) |
| 1335 |
|
{ |
| 1336 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1); |
| 1337 |
|
ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2); |
| 1338 |
|
|
| 1339 |
|
if (self::isPhp72OrGreater()) { |
| 1340 |
|
return sodium_crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash); |
| 1341 |
|
} |
| 1342 |
|
if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256_str_verify')) { |
| 1343 |
|
return call_user_func('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify', $passwd, $hash); |
| 1344 |
|
} |
| 1345 |
|
// This is the best we can do. |
| 1346 |
|
throw new Error( |
| 1347 |
|
'This is not implemented, as it is not possible to implement Scrypt with acceptable performance in pure-PHP' |
| 1348 |
|
); |
| 1349 |
|
} |
| 1350 |
|
|
| 1351 |
|
/** |
| 1352 |
|
* Calculate the shared secret between your secret key and your |