Upgrade/Install: Update sodium_compat to v1.13.0.
This includes a few autoloader fixes and improvements. A full list of changes in this update can be found on GitHub: https://github.com/paragonie/sodium_compat/compare/v1.12.1...v1.13.0 See #51399. Built from https://develop.svn.wordpress.org/trunk@49056 git-svn-id: http://core.svn.wordpress.org/trunk@48818 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0db3f859ea
commit
67752b98e0
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
This file should only ever be loaded on PHP 7+
|
||||||
|
*/
|
||||||
|
if (PHP_VERSION_ID < 70000) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
spl_autoload_register(function ($class) {
|
||||||
|
$namespace = 'ParagonIE_Sodium_';
|
||||||
|
// Does the class use the namespace prefix?
|
||||||
|
$len = strlen($namespace);
|
||||||
|
if (strncmp($namespace, $class, $len) !== 0) {
|
||||||
|
// no, move to the next registered autoloader
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the relative class name
|
||||||
|
$relative_class = substr($class, $len);
|
||||||
|
|
||||||
|
// Replace the namespace prefix with the base directory, replace namespace
|
||||||
|
// separators with directory separators in the relative class name, append
|
||||||
|
// with .php
|
||||||
|
$file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php';
|
||||||
|
// if the file exists, require it
|
||||||
|
if (file_exists($file)) {
|
||||||
|
require_once $file;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
|
@ -1,43 +1,49 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!is_callable('sodiumCompatAutoloader')) {
|
if (PHP_VERSION_ID < 70000) {
|
||||||
/**
|
if (!is_callable('sodiumCompatAutoloader')) {
|
||||||
* Sodium_Compat autoloader.
|
/**
|
||||||
*
|
* Sodium_Compat autoloader.
|
||||||
* @param string $class Class name to be autoloaded.
|
*
|
||||||
*
|
* @param string $class Class name to be autoloaded.
|
||||||
* @return bool Stop autoloading?
|
*
|
||||||
*/
|
* @return bool Stop autoloading?
|
||||||
function sodiumCompatAutoloader($class)
|
*/
|
||||||
{
|
function sodiumCompatAutoloader($class)
|
||||||
$namespace = 'ParagonIE_Sodium_';
|
{
|
||||||
// Does the class use the namespace prefix?
|
$namespace = 'ParagonIE_Sodium_';
|
||||||
$len = strlen($namespace);
|
// Does the class use the namespace prefix?
|
||||||
if (strncmp($namespace, $class, $len) !== 0) {
|
$len = strlen($namespace);
|
||||||
// no, move to the next registered autoloader
|
if (strncmp($namespace, $class, $len) !== 0) {
|
||||||
|
// no, move to the next registered autoloader
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the relative class name
|
||||||
|
$relative_class = substr($class, $len);
|
||||||
|
|
||||||
|
// Replace the namespace prefix with the base directory, replace namespace
|
||||||
|
// separators with directory separators in the relative class name, append
|
||||||
|
// with .php
|
||||||
|
$file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php';
|
||||||
|
// if the file exists, require it
|
||||||
|
if (file_exists($file)) {
|
||||||
|
require_once $file;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the relative class name
|
// Now that we have an autoloader, let's register it!
|
||||||
$relative_class = substr($class, $len);
|
spl_autoload_register('sodiumCompatAutoloader');
|
||||||
|
|
||||||
// Replace the namespace prefix with the base directory, replace namespace
|
|
||||||
// separators with directory separators in the relative class name, append
|
|
||||||
// with .php
|
|
||||||
$file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php';
|
|
||||||
// if the file exists, require it
|
|
||||||
if (file_exists($file)) {
|
|
||||||
require_once $file;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
// Now that we have an autoloader, let's register it!
|
require_once dirname(__FILE__) . '/autoload-php7.php';
|
||||||
spl_autoload_register('sodiumCompatAutoloader');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/src/SodiumException.php';
|
if (!class_exists('SodiumException', false)) {
|
||||||
|
require_once dirname(__FILE__) . '/src/SodiumException.php';
|
||||||
|
}
|
||||||
if (PHP_VERSION_ID >= 50300) {
|
if (PHP_VERSION_ID >= 50300) {
|
||||||
// Namespaces didn't exist before 5.3.0, so don't even try to use this
|
// Namespaces didn't exist before 5.3.0, so don't even try to use this
|
||||||
// unless PHP >= 5.3.0
|
// unless PHP >= 5.3.0
|
||||||
|
|
|
@ -26,6 +26,10 @@ foreach (array(
|
||||||
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES',
|
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES',
|
||||||
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES',
|
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES',
|
||||||
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES',
|
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES',
|
||||||
|
'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES',
|
||||||
|
'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NSECBYTES',
|
||||||
|
'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES',
|
||||||
|
'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES',
|
||||||
'CRYPTO_AUTH_BYTES',
|
'CRYPTO_AUTH_BYTES',
|
||||||
'CRYPTO_AUTH_KEYBYTES',
|
'CRYPTO_AUTH_KEYBYTES',
|
||||||
'CRYPTO_BOX_SEALBYTES',
|
'CRYPTO_BOX_SEALBYTES',
|
||||||
|
@ -62,6 +66,12 @@ foreach (array(
|
||||||
'CRYPTO_PWHASH_OPSLIMIT_MODERATE',
|
'CRYPTO_PWHASH_OPSLIMIT_MODERATE',
|
||||||
'CRYPTO_PWHASH_MEMLIMIT_SENSITIVE',
|
'CRYPTO_PWHASH_MEMLIMIT_SENSITIVE',
|
||||||
'CRYPTO_PWHASH_OPSLIMIT_SENSITIVE',
|
'CRYPTO_PWHASH_OPSLIMIT_SENSITIVE',
|
||||||
|
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES',
|
||||||
|
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX',
|
||||||
|
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE',
|
||||||
|
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE',
|
||||||
|
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE',
|
||||||
|
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE',
|
||||||
'CRYPTO_SCALARMULT_BYTES',
|
'CRYPTO_SCALARMULT_BYTES',
|
||||||
'CRYPTO_SCALARMULT_SCALARBYTES',
|
'CRYPTO_SCALARMULT_SCALARBYTES',
|
||||||
'CRYPTO_SHORTHASH_BYTES',
|
'CRYPTO_SHORTHASH_BYTES',
|
||||||
|
@ -84,6 +94,8 @@ foreach (array(
|
||||||
'CRYPTO_SIGN_KEYPAIRBYTES',
|
'CRYPTO_SIGN_KEYPAIRBYTES',
|
||||||
'CRYPTO_STREAM_KEYBYTES',
|
'CRYPTO_STREAM_KEYBYTES',
|
||||||
'CRYPTO_STREAM_NONCEBYTES',
|
'CRYPTO_STREAM_NONCEBYTES',
|
||||||
|
'LIBRARY_MAJOR_VERSION',
|
||||||
|
'LIBRARY_MINOR_VERSION',
|
||||||
'LIBRARY_VERSION_MAJOR',
|
'LIBRARY_VERSION_MAJOR',
|
||||||
'LIBRARY_VERSION_MINOR',
|
'LIBRARY_VERSION_MINOR',
|
||||||
'VERSION_STRING'
|
'VERSION_STRING'
|
||||||
|
|
|
@ -44,6 +44,8 @@ class ParagonIE_Sodium_Compat
|
||||||
*/
|
*/
|
||||||
public static $fastMult = false;
|
public static $fastMult = false;
|
||||||
|
|
||||||
|
const LIBRARY_MAJOR_VERSION = 9;
|
||||||
|
const LIBRARY_MINOR_VERSION = 1;
|
||||||
const LIBRARY_VERSION_MAJOR = 9;
|
const LIBRARY_VERSION_MAJOR = 9;
|
||||||
const LIBRARY_VERSION_MINOR = 1;
|
const LIBRARY_VERSION_MINOR = 1;
|
||||||
const VERSION_STRING = 'polyfill-1.0.8';
|
const VERSION_STRING = 'polyfill-1.0.8';
|
||||||
|
@ -3117,15 +3119,14 @@ class ParagonIE_Sodium_Compat
|
||||||
* with (sans pwhash and memzero).
|
* with (sans pwhash and memzero).
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
* @psalm-suppress MixedInferredReturnType
|
|
||||||
* @psalm-suppress UndefinedFunction
|
|
||||||
*/
|
*/
|
||||||
public static function library_version_major()
|
public static function library_version_major()
|
||||||
{
|
{
|
||||||
if (self::useNewSodiumAPI()) {
|
if (self::useNewSodiumAPI() && defined('SODIUM_LIBRARY_MAJOR_VERSION')) {
|
||||||
return sodium_library_version_major();
|
return SODIUM_LIBRARY_MAJOR_VERSION;
|
||||||
}
|
}
|
||||||
if (self::use_fallback('library_version_major')) {
|
if (self::use_fallback('library_version_major')) {
|
||||||
|
/** @psalm-suppress UndefinedFunction */
|
||||||
return (int) call_user_func('\\Sodium\\library_version_major');
|
return (int) call_user_func('\\Sodium\\library_version_major');
|
||||||
}
|
}
|
||||||
return self::LIBRARY_VERSION_MAJOR;
|
return self::LIBRARY_VERSION_MAJOR;
|
||||||
|
@ -3136,15 +3137,14 @@ class ParagonIE_Sodium_Compat
|
||||||
* with (sans pwhash and memzero).
|
* with (sans pwhash and memzero).
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
* @psalm-suppress MixedInferredReturnType
|
|
||||||
* @psalm-suppress UndefinedFunction
|
|
||||||
*/
|
*/
|
||||||
public static function library_version_minor()
|
public static function library_version_minor()
|
||||||
{
|
{
|
||||||
if (self::useNewSodiumAPI()) {
|
if (self::useNewSodiumAPI() && defined('SODIUM_LIBRARY_MINOR_VERSION')) {
|
||||||
return sodium_library_version_minor();
|
return SODIUM_LIBRARY_MINOR_VERSION;
|
||||||
}
|
}
|
||||||
if (self::use_fallback('library_version_minor')) {
|
if (self::use_fallback('library_version_minor')) {
|
||||||
|
/** @psalm-suppress UndefinedFunction */
|
||||||
return (int) call_user_func('\\Sodium\\library_version_minor');
|
return (int) call_user_func('\\Sodium\\library_version_minor');
|
||||||
}
|
}
|
||||||
return self::LIBRARY_VERSION_MINOR;
|
return self::LIBRARY_VERSION_MINOR;
|
||||||
|
|
|
@ -141,7 +141,9 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
|
||||||
ParagonIE_Sodium_Compat::memzero($nonce);
|
ParagonIE_Sodium_Compat::memzero($nonce);
|
||||||
ParagonIE_Sodium_Compat::memzero($ephKeypair);
|
ParagonIE_Sodium_Compat::memzero($ephKeypair);
|
||||||
} catch (SodiumException $ex) {
|
} catch (SodiumException $ex) {
|
||||||
unset($ephKeypair);
|
if (isset($ephKeypair)) {
|
||||||
|
unset($ephKeypair);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
@ -328,7 +330,9 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
|
||||||
ParagonIE_Sodium_Compat::memzero($nonce);
|
ParagonIE_Sodium_Compat::memzero($nonce);
|
||||||
ParagonIE_Sodium_Compat::memzero($ephKeypair);
|
ParagonIE_Sodium_Compat::memzero($ephKeypair);
|
||||||
} catch (SodiumException $ex) {
|
} catch (SodiumException $ex) {
|
||||||
unset($ephKeypair);
|
if (isset($ephKeypair)) {
|
||||||
|
unset($ephKeypair);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.6-alpha-49055';
|
$wp_version = '5.6-alpha-49056';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue