Changeset 49056
- Timestamp:
- 09/27/2020 04:44:01 AM (4 years ago)
- Location:
- trunk/src/wp-includes/sodium_compat
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/sodium_compat/autoload.php
r46858 r49056 1 1 <?php 2 2 3 if (!is_callable('sodiumCompatAutoloader')) { 4 /** 5 * Sodium_Compat autoloader. 6 * 7 * @param string $class Class name to be autoloaded. 8 * 9 * @return bool Stop autoloading? 10 */ 11 function sodiumCompatAutoloader($class) 12 { 13 $namespace = 'ParagonIE_Sodium_'; 14 // Does the class use the namespace prefix? 15 $len = strlen($namespace); 16 if (strncmp($namespace, $class, $len) !== 0) { 17 // no, move to the next registered autoloader 3 if (PHP_VERSION_ID < 70000) { 4 if (!is_callable('sodiumCompatAutoloader')) { 5 /** 6 * Sodium_Compat autoloader. 7 * 8 * @param string $class Class name to be autoloaded. 9 * 10 * @return bool Stop autoloading? 11 */ 12 function sodiumCompatAutoloader($class) 13 { 14 $namespace = 'ParagonIE_Sodium_'; 15 // Does the class use the namespace prefix? 16 $len = strlen($namespace); 17 if (strncmp($namespace, $class, $len) !== 0) { 18 // no, move to the next registered autoloader 19 return false; 20 } 21 22 // Get the relative class name 23 $relative_class = substr($class, $len); 24 25 // Replace the namespace prefix with the base directory, replace namespace 26 // separators with directory separators in the relative class name, append 27 // with .php 28 $file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php'; 29 // if the file exists, require it 30 if (file_exists($file)) { 31 require_once $file; 32 return true; 33 } 18 34 return false; 19 35 } 20 36 21 // Get the relative class name 22 $relative_class = substr($class, $len); 23 24 // Replace the namespace prefix with the base directory, replace namespace 25 // separators with directory separators in the relative class name, append 26 // with .php 27 $file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php'; 28 // if the file exists, require it 29 if (file_exists($file)) { 30 require_once $file; 31 return true; 32 } 33 return false; 37 // Now that we have an autoloader, let's register it! 38 spl_autoload_register('sodiumCompatAutoloader'); 34 39 } 35 36 // Now that we have an autoloader, let's register it! 37 spl_autoload_register('sodiumCompatAutoloader'); 40 } else { 41 require_once dirname(__FILE__) . '/autoload-php7.php'; 38 42 } 39 43 40 require_once dirname(__FILE__) . '/src/SodiumException.php'; 44 if (!class_exists('SodiumException', false)) { 45 require_once dirname(__FILE__) . '/src/SodiumException.php'; 46 } 41 47 if (PHP_VERSION_ID >= 50300) { 42 48 // Namespaces didn't exist before 5.3.0, so don't even try to use this -
trunk/src/wp-includes/sodium_compat/lib/php72compat.php
r46858 r49056 27 27 'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES', 28 28 'CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES', 29 'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES', 30 'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NSECBYTES', 31 'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES', 32 'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES', 29 33 'CRYPTO_AUTH_BYTES', 30 34 'CRYPTO_AUTH_KEYBYTES', … … 63 67 'CRYPTO_PWHASH_MEMLIMIT_SENSITIVE', 64 68 'CRYPTO_PWHASH_OPSLIMIT_SENSITIVE', 69 'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES', 70 'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX', 71 'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE', 72 'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE', 73 'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE', 74 'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE', 65 75 'CRYPTO_SCALARMULT_BYTES', 66 76 'CRYPTO_SCALARMULT_SCALARBYTES', … … 85 95 'CRYPTO_STREAM_KEYBYTES', 86 96 'CRYPTO_STREAM_NONCEBYTES', 97 'LIBRARY_MAJOR_VERSION', 98 'LIBRARY_MINOR_VERSION', 87 99 'LIBRARY_VERSION_MAJOR', 88 100 'LIBRARY_VERSION_MINOR', -
trunk/src/wp-includes/sodium_compat/src/Compat.php
r46858 r49056 45 45 public static $fastMult = false; 46 46 47 const LIBRARY_MAJOR_VERSION = 9; 48 const LIBRARY_MINOR_VERSION = 1; 47 49 const LIBRARY_VERSION_MAJOR = 9; 48 50 const LIBRARY_VERSION_MINOR = 1; … … 3118 3120 * 3119 3121 * @return int 3120 * @psalm-suppress MixedInferredReturnType3121 * @psalm-suppress UndefinedFunction3122 3122 */ 3123 3123 public static function library_version_major() 3124 3124 { 3125 if (self::useNewSodiumAPI() ) {3126 return sodium_library_version_major();3125 if (self::useNewSodiumAPI() && defined('SODIUM_LIBRARY_MAJOR_VERSION')) { 3126 return SODIUM_LIBRARY_MAJOR_VERSION; 3127 3127 } 3128 3128 if (self::use_fallback('library_version_major')) { 3129 /** @psalm-suppress UndefinedFunction */ 3129 3130 return (int) call_user_func('\\Sodium\\library_version_major'); 3130 3131 } … … 3137 3138 * 3138 3139 * @return int 3139 * @psalm-suppress MixedInferredReturnType3140 * @psalm-suppress UndefinedFunction3141 3140 */ 3142 3141 public static function library_version_minor() 3143 3142 { 3144 if (self::useNewSodiumAPI() ) {3145 return sodium_library_version_minor();3143 if (self::useNewSodiumAPI() && defined('SODIUM_LIBRARY_MINOR_VERSION')) { 3144 return SODIUM_LIBRARY_MINOR_VERSION; 3146 3145 } 3147 3146 if (self::use_fallback('library_version_minor')) { 3147 /** @psalm-suppress UndefinedFunction */ 3148 3148 return (int) call_user_func('\\Sodium\\library_version_minor'); 3149 3149 } -
trunk/src/wp-includes/sodium_compat/src/File.php
r46858 r49056 142 142 ParagonIE_Sodium_Compat::memzero($ephKeypair); 143 143 } catch (SodiumException $ex) { 144 unset($ephKeypair); 144 if (isset($ephKeypair)) { 145 unset($ephKeypair); 146 } 145 147 } 146 148 return $res; … … 329 331 ParagonIE_Sodium_Compat::memzero($ephKeypair); 330 332 } catch (SodiumException $ex) { 331 unset($ephKeypair); 333 if (isset($ephKeypair)) { 334 unset($ephKeypair); 335 } 332 336 } 333 337 return $res;
Note: See TracChangeset
for help on using the changeset viewer.