You are here

protected static function ParagonIE_Sodium_Compat::use_fallback in Automatic Updates 7

Same name and namespace in other branches
  1. 8 vendor/paragonie/sodium_compat/src/Compat.php \ParagonIE_Sodium_Compat::use_fallback()

Should we use the libsodium core function instead? This is always a good idea, if it's available. (Unless we're in the middle of running our unit test suite.)

If ext/libsodium is available, use it. Return TRUE. Otherwise, we have to use the code provided herein. Return FALSE.

Parameters

string $sodium_func_name:

Return value

bool

60 calls to ParagonIE_Sodium_Compat::use_fallback()
ParagonIE_Sodium_Compat::bin2hex in vendor/paragonie/sodium_compat/src/Compat.php
Cache-timing-safe implementation of bin2hex().
ParagonIE_Sodium_Compat::compare in vendor/paragonie/sodium_compat/src/Compat.php
Compare two strings, in constant-time. Compared to memcmp(), compare() is more useful for sorting.
ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available in vendor/paragonie/sodium_compat/src/Compat.php
Is AES-256-GCM even available to use?
ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt in vendor/paragonie/sodium_compat/src/Compat.php
Authenticated Encryption with Associated Data: Decryption
ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt in vendor/paragonie/sodium_compat/src/Compat.php
Authenticated Encryption with Associated Data

... See full list

File

vendor/paragonie/sodium_compat/src/Compat.php, line 3521

Class

ParagonIE_Sodium_Compat

Code

protected static function use_fallback($sodium_func_name = '') {
  static $res = null;
  if ($res === null) {
    $res = extension_loaded('libsodium') && PHP_VERSION_ID >= 50300;
  }
  if ($res === false) {

    // No libsodium installed
    return false;
  }
  if (self::$disableFallbackForUnitTests) {

    // Don't fallback. Use the PHP implementation.
    return false;
  }
  if (!empty($sodium_func_name)) {
    return is_callable('\\Sodium\\' . $sodium_func_name);
  }
  return true;
}