update
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Sodium;
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . '/autoload.php';
|
||||
|
||||
use ParagonIE_Sodium_Compat;
|
||||
|
||||
const CRYPTO_AEAD_AES256GCM_KEYBYTES = ParagonIE_Sodium_Compat::CRYPTO_AEAD_AES256GCM_KEYBYTES;
|
||||
const CRYPTO_AEAD_AES256GCM_NSECBYTES = ParagonIE_Sodium_Compat::CRYPTO_AEAD_AES256GCM_NSECBYTES;
|
||||
const CRYPTO_AEAD_AES256GCM_NPUBBYTES = ParagonIE_Sodium_Compat::CRYPTO_AEAD_AES256GCM_NPUBBYTES;
|
||||
|
||||
@@ -1,45 +1,48 @@
|
||||
<?php
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . '/autoload.php';
|
||||
|
||||
require_once \dirname(\dirname(__FILE__)) . '/autoload.php';
|
||||
if (\PHP_VERSION_ID < 50300) {
|
||||
return;
|
||||
if (PHP_VERSION_ID < 50300) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* This file is just for convenience, to allow developers to reduce verbosity when
|
||||
* they add this project to their libraries.
|
||||
*
|
||||
* Replace this:
|
||||
*
|
||||
* $x = ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_encrypt(...$args);
|
||||
*
|
||||
* with this:
|
||||
*
|
||||
* use ParagonIE\Sodium\Compat;
|
||||
*
|
||||
* $x = Compat::crypto_aead_xchacha20poly1305_encrypt(...$args);
|
||||
*/
|
||||
spl_autoload_register(function ($class) {
|
||||
if ($class[0] === '\\') {
|
||||
$class = substr($class, 1);
|
||||
}
|
||||
/*
|
||||
* This file is just for convenience, to allow developers to reduce verbosity when
|
||||
* they add this project to their libraries.
|
||||
*
|
||||
* Replace this:
|
||||
*
|
||||
* $x = ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_encrypt(...$args);
|
||||
*
|
||||
* with this:
|
||||
*
|
||||
* use ParagonIE\Sodium\Compat;
|
||||
*
|
||||
* $x = Compat::crypto_aead_xchacha20poly1305_encrypt(...$args);
|
||||
*/
|
||||
\spl_autoload_register(function ($class) {
|
||||
if ($class[0] === '\\') {
|
||||
$class = \substr($class, 1);
|
||||
}
|
||||
$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(\dirname(__FILE__)) . '/namespaced/' . \str_replace('\\', '/', $relative_class) . '.php';
|
||||
// if the file exists, require it
|
||||
if (\file_exists($file)) {
|
||||
require_once $file;
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
});
|
||||
$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(dirname(__FILE__)) . '/namespaced/' . str_replace('\\', '/', $relative_class) . '.php';
|
||||
// if the file exists, require it
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,92 +1,92 @@
|
||||
<?php
|
||||
|
||||
const SODIUM_LIBRARY_MAJOR_VERSION = 9;
|
||||
const SODIUM_LIBRARY_MINOR_VERSION = 1;
|
||||
const SODIUM_LIBRARY_VERSION = '1.0.8';
|
||||
|
||||
const SODIUM_LIBRARY_MAJOR_VERSION = 9;
|
||||
const SODIUM_LIBRARY_MINOR_VERSION = 1;
|
||||
const SODIUM_LIBRARY_VERSION = '1.0.8';
|
||||
const SODIUM_BASE64_VARIANT_ORIGINAL = 1;
|
||||
const SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING = 3;
|
||||
const SODIUM_BASE64_VARIANT_URLSAFE = 5;
|
||||
const SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING = 7;
|
||||
const SODIUM_CRYPTO_AEAD_AES256GCM_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_AES256GCM_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_AES256GCM_NPUBBYTES = 12;
|
||||
const SODIUM_CRYPTO_AEAD_AES256GCM_ABYTES = 16;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES = 8;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_ABYTES = 16;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES = 12;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES = 16;
|
||||
const SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES = 24;
|
||||
const SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES = 16;
|
||||
const SODIUM_CRYPTO_AUTH_BYTES = 32;
|
||||
const SODIUM_CRYPTO_AUTH_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_BOX_SEALBYTES = 16;
|
||||
const SODIUM_CRYPTO_BOX_SECRETKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_BOX_PUBLICKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_BOX_KEYPAIRBYTES = 64;
|
||||
const SODIUM_CRYPTO_BOX_MACBYTES = 16;
|
||||
const SODIUM_CRYPTO_BOX_NONCEBYTES = 24;
|
||||
const SODIUM_CRYPTO_BOX_SEEDBYTES = 32;
|
||||
const SODIUM_CRYPTO_KDF_BYTES_MIN = 16;
|
||||
const SODIUM_CRYPTO_KDF_BYTES_MAX = 64;
|
||||
const SODIUM_CRYPTO_KDF_CONTEXTBYTES = 8;
|
||||
const SODIUM_CRYPTO_KDF_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_KX_BYTES = 32;
|
||||
const SODIUM_CRYPTO_KX_PRIMITIVE = 'x25519blake2b';
|
||||
const SODIUM_CRYPTO_KX_SEEDBYTES = 32;
|
||||
const SODIUM_CRYPTO_KX_KEYPAIRBYTES = 64;
|
||||
const SODIUM_CRYPTO_KX_PUBLICKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_KX_SECRETKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_KX_SESSIONKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_GENERICHASH_BYTES = 32;
|
||||
const SODIUM_CRYPTO_GENERICHASH_BYTES_MIN = 16;
|
||||
const SODIUM_CRYPTO_GENERICHASH_BYTES_MAX = 64;
|
||||
const SODIUM_CRYPTO_GENERICHASH_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_GENERICHASH_KEYBYTES_MIN = 16;
|
||||
const SODIUM_CRYPTO_GENERICHASH_KEYBYTES_MAX = 64;
|
||||
const SODIUM_CRYPTO_PWHASH_SALTBYTES = 16;
|
||||
const SODIUM_CRYPTO_PWHASH_STRPREFIX = '$argon2id$';
|
||||
const SODIUM_CRYPTO_PWHASH_ALG_ARGON2I13 = 1;
|
||||
const SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13 = 2;
|
||||
const SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE = 33554432;
|
||||
const SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE = 4;
|
||||
const SODIUM_CRYPTO_PWHASH_MEMLIMIT_MODERATE = 134217728;
|
||||
const SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE = 6;
|
||||
const SODIUM_CRYPTO_PWHASH_MEMLIMIT_SENSITIVE = 536870912;
|
||||
const SODIUM_CRYPTO_PWHASH_OPSLIMIT_SENSITIVE = 8;
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES = 32;
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX = '$7$';
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE = 534288;
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE = 16777216;
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE = 33554432;
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE = 1073741824;
|
||||
const SODIUM_CRYPTO_SCALARMULT_BYTES = 32;
|
||||
const SODIUM_CRYPTO_SCALARMULT_SCALARBYTES = 32;
|
||||
const SODIUM_CRYPTO_SHORTHASH_BYTES = 8;
|
||||
const SODIUM_CRYPTO_SHORTHASH_KEYBYTES = 16;
|
||||
const SODIUM_CRYPTO_SECRETBOX_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_SECRETBOX_MACBYTES = 16;
|
||||
const SODIUM_CRYPTO_SECRETBOX_NONCEBYTES = 24;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES = 17;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES = 24;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PUSH = 0;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PULL = 1;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY = 2;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL = 3;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX = 0x3fffffff80;
|
||||
const SODIUM_CRYPTO_SIGN_BYTES = 64;
|
||||
const SODIUM_CRYPTO_SIGN_SEEDBYTES = 32;
|
||||
const SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_SIGN_SECRETKEYBYTES = 64;
|
||||
const SODIUM_CRYPTO_SIGN_KEYPAIRBYTES = 96;
|
||||
const SODIUM_CRYPTO_STREAM_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_STREAM_NONCEBYTES = 24;
|
||||
const SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_STREAM_XCHACHA20_NONCEBYTES = 24;
|
||||
const SODIUM_BASE64_VARIANT_ORIGINAL = 1;
|
||||
const SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING = 3;
|
||||
const SODIUM_BASE64_VARIANT_URLSAFE = 5;
|
||||
const SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING = 7;
|
||||
const SODIUM_CRYPTO_AEAD_AES256GCM_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_AES256GCM_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_AES256GCM_NPUBBYTES = 12;
|
||||
const SODIUM_CRYPTO_AEAD_AES256GCM_ABYTES = 16;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES = 8;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_ABYTES = 16;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES = 12;
|
||||
const SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES = 16;
|
||||
const SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES = 24;
|
||||
const SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES = 16;
|
||||
const SODIUM_CRYPTO_AUTH_BYTES = 32;
|
||||
const SODIUM_CRYPTO_AUTH_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_BOX_SEALBYTES = 16;
|
||||
const SODIUM_CRYPTO_BOX_SECRETKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_BOX_PUBLICKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_BOX_KEYPAIRBYTES = 64;
|
||||
const SODIUM_CRYPTO_BOX_MACBYTES = 16;
|
||||
const SODIUM_CRYPTO_BOX_NONCEBYTES = 24;
|
||||
const SODIUM_CRYPTO_BOX_SEEDBYTES = 32;
|
||||
const SODIUM_CRYPTO_KDF_BYTES_MIN = 16;
|
||||
const SODIUM_CRYPTO_KDF_BYTES_MAX = 64;
|
||||
const SODIUM_CRYPTO_KDF_CONTEXTBYTES = 8;
|
||||
const SODIUM_CRYPTO_KDF_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_KX_BYTES = 32;
|
||||
const SODIUM_CRYPTO_KX_PRIMITIVE = 'x25519blake2b';
|
||||
const SODIUM_CRYPTO_KX_SEEDBYTES = 32;
|
||||
const SODIUM_CRYPTO_KX_KEYPAIRBYTES = 64;
|
||||
const SODIUM_CRYPTO_KX_PUBLICKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_KX_SECRETKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_KX_SESSIONKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_GENERICHASH_BYTES = 32;
|
||||
const SODIUM_CRYPTO_GENERICHASH_BYTES_MIN = 16;
|
||||
const SODIUM_CRYPTO_GENERICHASH_BYTES_MAX = 64;
|
||||
const SODIUM_CRYPTO_GENERICHASH_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_GENERICHASH_KEYBYTES_MIN = 16;
|
||||
const SODIUM_CRYPTO_GENERICHASH_KEYBYTES_MAX = 64;
|
||||
const SODIUM_CRYPTO_PWHASH_SALTBYTES = 16;
|
||||
const SODIUM_CRYPTO_PWHASH_STRPREFIX = '$argon2id$';
|
||||
const SODIUM_CRYPTO_PWHASH_ALG_ARGON2I13 = 1;
|
||||
const SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13 = 2;
|
||||
const SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE = 33554432;
|
||||
const SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE = 4;
|
||||
const SODIUM_CRYPTO_PWHASH_MEMLIMIT_MODERATE = 134217728;
|
||||
const SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE = 6;
|
||||
const SODIUM_CRYPTO_PWHASH_MEMLIMIT_SENSITIVE = 536870912;
|
||||
const SODIUM_CRYPTO_PWHASH_OPSLIMIT_SENSITIVE = 8;
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES = 32;
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX = '$7$';
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE = 534288;
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE = 16777216;
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE = 33554432;
|
||||
const SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE = 1073741824;
|
||||
const SODIUM_CRYPTO_SCALARMULT_BYTES = 32;
|
||||
const SODIUM_CRYPTO_SCALARMULT_SCALARBYTES = 32;
|
||||
const SODIUM_CRYPTO_SHORTHASH_BYTES = 8;
|
||||
const SODIUM_CRYPTO_SHORTHASH_KEYBYTES = 16;
|
||||
const SODIUM_CRYPTO_SECRETBOX_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_SECRETBOX_MACBYTES = 16;
|
||||
const SODIUM_CRYPTO_SECRETBOX_NONCEBYTES = 24;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES = 17;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES = 24;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PUSH = 0;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PULL = 1;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY = 2;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL = 3;
|
||||
const SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX = 0x3fffffff80;
|
||||
const SODIUM_CRYPTO_SIGN_BYTES = 64;
|
||||
const SODIUM_CRYPTO_SIGN_SEEDBYTES = 32;
|
||||
const SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_SIGN_SECRETKEYBYTES = 64;
|
||||
const SODIUM_CRYPTO_SIGN_KEYPAIRBYTES = 96;
|
||||
const SODIUM_CRYPTO_STREAM_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_STREAM_NONCEBYTES = 24;
|
||||
const SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_STREAM_XCHACHA20_NONCEBYTES = 24;
|
||||
|
||||
@@ -1,104 +1,130 @@
|
||||
<?php
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . '/autoload.php';
|
||||
|
||||
require_once \dirname(\dirname(__FILE__)) . '/autoload.php';
|
||||
/**
|
||||
* This file will monkey patch the pure-PHP implementation in place of the
|
||||
* PECL functions and constants, but only if they do not already exist.
|
||||
*
|
||||
* Thus, the functions or constants just proxy to the appropriate
|
||||
* ParagonIE_Sodium_Compat method or class constant, respectively.
|
||||
*/
|
||||
foreach (array(
|
||||
'CRYPTO_AEAD_AESGIS128L_KEYBYTES',
|
||||
'CRYPTO_AEAD_AESGIS128L_NSECBYTES',
|
||||
'CRYPTO_AEAD_AESGIS128L_NPUBBYTES',
|
||||
'CRYPTO_AEAD_AESGIS128L_ABYTES',
|
||||
'CRYPTO_AEAD_AESGIS256_KEYBYTES',
|
||||
'CRYPTO_AEAD_AESGIS256_NSECBYTES',
|
||||
'CRYPTO_AEAD_AESGIS256_NPUBBYTES',
|
||||
'CRYPTO_AEAD_AESGIS256_ABYTES',
|
||||
) as $constant
|
||||
) {
|
||||
if (!defined("SODIUM_$constant") && defined("ParagonIE_Sodium_Compat::$constant")) {
|
||||
define("SODIUM_$constant", constant("ParagonIE_Sodium_Compat::$constant"));
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_aead_aegis128l_decrypt')) {
|
||||
/**
|
||||
* This file will monkey patch the pure-PHP implementation in place of the
|
||||
* PECL functions and constants, but only if they do not already exist.
|
||||
*
|
||||
* Thus, the functions or constants just proxy to the appropriate
|
||||
* ParagonIE_Sodium_Compat method or class constant, respectively.
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_aegis128l_decrypt()
|
||||
* @param string $ciphertext
|
||||
* @param string $additional_data
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
foreach (array('CRYPTO_AEAD_AESGIS128L_KEYBYTES', 'CRYPTO_AEAD_AESGIS128L_NSECBYTES', 'CRYPTO_AEAD_AESGIS128L_NPUBBYTES', 'CRYPTO_AEAD_AESGIS128L_ABYTES', 'CRYPTO_AEAD_AESGIS256_KEYBYTES', 'CRYPTO_AEAD_AESGIS256_NSECBYTES', 'CRYPTO_AEAD_AESGIS256_NPUBBYTES', 'CRYPTO_AEAD_AESGIS256_ABYTES') as $constant) {
|
||||
if (!\defined("SODIUM_{$constant}") && \defined("ParagonIE_Sodium_Compat::{$constant}")) {
|
||||
\define("SODIUM_{$constant}", \constant("ParagonIE_Sodium_Compat::{$constant}"));
|
||||
}
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_aead_aegis128l_decrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_aegis128l_decrypt()
|
||||
* @param string $ciphertext
|
||||
* @param string $additional_data
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_aead_aegis128l_decrypt(
|
||||
function sodium_crypto_aead_aegis128l_decrypt(
|
||||
$ciphertext,
|
||||
$additional_data,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_aead_aegis128l_decrypt(
|
||||
$ciphertext,
|
||||
$additional_data,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::crypto_aead_aegis128l_decrypt($ciphertext, $additional_data, $nonce, $key);
|
||||
}
|
||||
);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_aead_aegis128l_encrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_aegis128l_encrypt()
|
||||
* @param string $message
|
||||
* @param string $additional_data
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_aead_aegis128l_encrypt(
|
||||
#[\SensitiveParameter]
|
||||
}
|
||||
if (!is_callable('sodium_crypto_aead_aegis128l_encrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_aegis128l_encrypt()
|
||||
* @param string $message
|
||||
* @param string $additional_data
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_aead_aegis128l_encrypt(
|
||||
#[\SensitiveParameter]
|
||||
$message,
|
||||
$additional_data,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_aead_aegis128l_encrypt(
|
||||
$message,
|
||||
$additional_data,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::crypto_aead_aegis128l_encrypt($message, $additional_data, $nonce, $key);
|
||||
}
|
||||
);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_aead_aegis256_decrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_aegis256_encrypt()
|
||||
* @param string $ciphertext
|
||||
* @param string $additional_data
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_aead_aegis256_decrypt(
|
||||
}
|
||||
if (!is_callable('sodium_crypto_aead_aegis256_decrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_aegis256_encrypt()
|
||||
* @param string $ciphertext
|
||||
* @param string $additional_data
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_aead_aegis256_decrypt(
|
||||
$ciphertext,
|
||||
$additional_data,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_aead_aegis256_decrypt(
|
||||
$ciphertext,
|
||||
$additional_data,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::crypto_aead_aegis256_decrypt($ciphertext, $additional_data, $nonce, $key);
|
||||
}
|
||||
);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_aead_aegis256_encrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_aegis256_encrypt()
|
||||
* @param string $message
|
||||
* @param string $additional_data
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_aead_aegis256_encrypt(
|
||||
#[\SensitiveParameter]
|
||||
}
|
||||
if (!is_callable('sodium_crypto_aead_aegis256_encrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_aegis256_encrypt()
|
||||
* @param string $message
|
||||
* @param string $additional_data
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_aead_aegis256_encrypt(
|
||||
#[\SensitiveParameter]
|
||||
$message,
|
||||
$additional_data,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_aead_aegis256_encrypt(
|
||||
$message,
|
||||
$additional_data,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::crypto_aead_aegis256_encrypt($message, $additional_data, $nonce, $key);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS128L_KEYBYTES = 16;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS128L_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS128L_NPUBBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS128L_ABYTES = 32;
|
||||
|
||||
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS128L_KEYBYTES = 16;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS128L_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS128L_NPUBBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS128L_ABYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS256_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS256_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS256_NPUBBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS256_ABYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS256_KEYBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS256_NSECBYTES = 0;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS256_NPUBBYTES = 32;
|
||||
const SODIUM_CRYPTO_AEAD_AEGIS256_ABYTES = 32;
|
||||
|
||||
@@ -1,272 +1,277 @@
|
||||
<?php
|
||||
|
||||
if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_BYTES')) {
|
||||
define(
|
||||
'SODIUM_CRYPTO_CORE_RISTRETTO255_BYTES',
|
||||
ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_BYTES
|
||||
);
|
||||
define('SODIUM_COMPAT_POLYFILLED_RISTRETTO255', true);
|
||||
}
|
||||
if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_HASHBYTES')) {
|
||||
define(
|
||||
'SODIUM_CRYPTO_CORE_RISTRETTO255_HASHBYTES',
|
||||
ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_HASHBYTES
|
||||
);
|
||||
}
|
||||
if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_SCALARBYTES')) {
|
||||
define(
|
||||
'SODIUM_CRYPTO_CORE_RISTRETTO255_SCALARBYTES',
|
||||
ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_SCALARBYTES
|
||||
);
|
||||
}
|
||||
if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES')) {
|
||||
define(
|
||||
'SODIUM_CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES',
|
||||
ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES
|
||||
);
|
||||
}
|
||||
if (!defined('SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES')) {
|
||||
define(
|
||||
'SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES',
|
||||
ParagonIE_Sodium_Compat::CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES
|
||||
);
|
||||
}
|
||||
if (!defined('SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_BYTES')) {
|
||||
define(
|
||||
'SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_BYTES',
|
||||
ParagonIE_Sodium_Compat::CRYPTO_SCALARMULT_RISTRETTO255_BYTES
|
||||
);
|
||||
}
|
||||
|
||||
if (!\defined('SODIUM_CRYPTO_CORE_RISTRETTO255_BYTES')) {
|
||||
\define('SODIUM_CRYPTO_CORE_RISTRETTO255_BYTES', \ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_BYTES);
|
||||
\define('SODIUM_COMPAT_POLYFILLED_RISTRETTO255', \true);
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_add')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_add()
|
||||
*
|
||||
* @param string $p
|
||||
* @param string $q
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_add(
|
||||
#[\SensitiveParameter]
|
||||
$p,
|
||||
#[\SensitiveParameter]
|
||||
$q
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::ristretto255_add($p, $q, true);
|
||||
}
|
||||
if (!\defined('SODIUM_CRYPTO_CORE_RISTRETTO255_HASHBYTES')) {
|
||||
\define('SODIUM_CRYPTO_CORE_RISTRETTO255_HASHBYTES', \ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_HASHBYTES);
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_from_hash')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_from_hash()
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_from_hash(
|
||||
#[\SensitiveParameter]
|
||||
$s
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::ristretto255_from_hash($s, true);
|
||||
}
|
||||
if (!\defined('SODIUM_CRYPTO_CORE_RISTRETTO255_SCALARBYTES')) {
|
||||
\define('SODIUM_CRYPTO_CORE_RISTRETTO255_SCALARBYTES', \ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_SCALARBYTES);
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_is_valid_point')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_is_valid_point()
|
||||
*
|
||||
* @param string $s
|
||||
* @return bool
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_is_valid_point(
|
||||
#[\SensitiveParameter]
|
||||
$s
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::ristretto255_is_valid_point($s, true);
|
||||
}
|
||||
if (!\defined('SODIUM_CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES')) {
|
||||
\define('SODIUM_CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES', \ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES);
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_random')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_random()
|
||||
*
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_random()
|
||||
{
|
||||
return ParagonIE_Sodium_Compat::ristretto255_random(true);
|
||||
}
|
||||
if (!\defined('SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES')) {
|
||||
\define('SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES', \ParagonIE_Sodium_Compat::CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES);
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_scalar_add')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_add()
|
||||
*
|
||||
* @param string $x
|
||||
* @param string $y
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_add(
|
||||
#[\SensitiveParameter]
|
||||
$x,
|
||||
#[\SensitiveParameter]
|
||||
$y
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::ristretto255_scalar_add($x, $y, true);
|
||||
}
|
||||
if (!\defined('SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_BYTES')) {
|
||||
\define('SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_BYTES', \ParagonIE_Sodium_Compat::CRYPTO_SCALARMULT_RISTRETTO255_BYTES);
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_scalar_complement')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_complement()
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_complement(
|
||||
#[\SensitiveParameter]
|
||||
$s
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::ristretto255_scalar_complement($s, true);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_add')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_add()
|
||||
*
|
||||
* @param string $p
|
||||
* @param string $q
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_add(
|
||||
#[\SensitiveParameter]
|
||||
$p,
|
||||
#[\SensitiveParameter]
|
||||
$q
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_add($p, $q, \true);
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_scalar_invert')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_invert()
|
||||
*
|
||||
* @param string $p
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_invert(
|
||||
#[\SensitiveParameter]
|
||||
$p
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::ristretto255_scalar_invert($p, true);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_from_hash')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_from_hash()
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_from_hash(
|
||||
#[\SensitiveParameter]
|
||||
$s
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_from_hash($s, \true);
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_scalar_mul')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_mul()
|
||||
*
|
||||
* @param string $x
|
||||
* @param string $y
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_mul(
|
||||
#[\SensitiveParameter]
|
||||
$x,
|
||||
#[\SensitiveParameter]
|
||||
$y
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::ristretto255_scalar_mul($x, $y, true);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_is_valid_point')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_is_valid_point()
|
||||
*
|
||||
* @param string $s
|
||||
* @return bool
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_is_valid_point(
|
||||
#[\SensitiveParameter]
|
||||
$s
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_is_valid_point($s, \true);
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_scalar_negate')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_negate()
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_negate(
|
||||
#[\SensitiveParameter]
|
||||
$s
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::ristretto255_scalar_negate($s, true);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_random')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_random()
|
||||
*
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_random()
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_random(\true);
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_scalar_random')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_random()
|
||||
*
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_random()
|
||||
{
|
||||
return ParagonIE_Sodium_Compat::ristretto255_scalar_random(true);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_scalar_add')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_add()
|
||||
*
|
||||
* @param string $x
|
||||
* @param string $y
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_add(
|
||||
#[\SensitiveParameter]
|
||||
$x,
|
||||
#[\SensitiveParameter]
|
||||
$y
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_scalar_add($x, $y, \true);
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_scalar_reduce')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_reduce()
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_reduce(
|
||||
#[\SensitiveParameter]
|
||||
$s
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::ristretto255_scalar_reduce($s, true);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_scalar_complement')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_complement()
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_complement(
|
||||
#[\SensitiveParameter]
|
||||
$s
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_scalar_complement($s, \true);
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_scalar_sub')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_sub()
|
||||
*
|
||||
* @param string $x
|
||||
* @param string $y
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_sub(
|
||||
#[\SensitiveParameter]
|
||||
$x,
|
||||
#[\SensitiveParameter]
|
||||
$y
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::ristretto255_scalar_sub($x, $y, true);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_scalar_invert')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_invert()
|
||||
*
|
||||
* @param string $p
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_invert(
|
||||
#[\SensitiveParameter]
|
||||
$p
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_scalar_invert($p, \true);
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_core_ristretto255_sub')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_sub()
|
||||
*
|
||||
* @param string $p
|
||||
* @param string $q
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_sub(
|
||||
#[\SensitiveParameter]
|
||||
$p,
|
||||
#[\SensitiveParameter]
|
||||
$q
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::ristretto255_sub($p, $q, true);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_scalar_mul')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_mul()
|
||||
*
|
||||
* @param string $x
|
||||
* @param string $y
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_mul(
|
||||
#[\SensitiveParameter]
|
||||
$x,
|
||||
#[\SensitiveParameter]
|
||||
$y
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_scalar_mul($x, $y, \true);
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_scalarmult_ristretto255')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_scalarmult_ristretto255()
|
||||
* @param string $n
|
||||
* @param string $p
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_scalarmult_ristretto255(
|
||||
#[\SensitiveParameter]
|
||||
$n,
|
||||
#[\SensitiveParameter]
|
||||
$p
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::scalarmult_ristretto255($n, $p, true);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_scalar_negate')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_negate()
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_negate(
|
||||
#[\SensitiveParameter]
|
||||
$s
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_scalar_negate($s, \true);
|
||||
}
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_scalar_random')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_random()
|
||||
*
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_random()
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_scalar_random(\true);
|
||||
}
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_scalar_reduce')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_reduce()
|
||||
*
|
||||
* @param string $s
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_reduce(
|
||||
#[\SensitiveParameter]
|
||||
$s
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_scalar_reduce($s, \true);
|
||||
}
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_scalar_sub')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_scalar_sub()
|
||||
*
|
||||
* @param string $x
|
||||
* @param string $y
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_scalar_sub(
|
||||
#[\SensitiveParameter]
|
||||
$x,
|
||||
#[\SensitiveParameter]
|
||||
$y
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_scalar_sub($x, $y, \true);
|
||||
}
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_core_ristretto255_sub')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::ristretto255_sub()
|
||||
*
|
||||
* @param string $p
|
||||
* @param string $q
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
*/
|
||||
function sodium_crypto_core_ristretto255_sub(
|
||||
#[\SensitiveParameter]
|
||||
$p,
|
||||
#[\SensitiveParameter]
|
||||
$q
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::ristretto255_sub($p, $q, \true);
|
||||
}
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_scalarmult_ristretto255')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_scalarmult_ristretto255()
|
||||
* @param string $n
|
||||
* @param string $p
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_scalarmult_ristretto255(
|
||||
#[\SensitiveParameter]
|
||||
$n,
|
||||
#[\SensitiveParameter]
|
||||
$p
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::scalarmult_ristretto255($n, $p, \true);
|
||||
}
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_scalarmult_ristretto255_base')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_scalarmult_ristretto255_base()
|
||||
* @param string $n
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_scalarmult_ristretto255_base(
|
||||
#[\SensitiveParameter]
|
||||
$n
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::scalarmult_ristretto255_base($n, \true);
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_scalarmult_ristretto255_base')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_scalarmult_ristretto255_base()
|
||||
* @param string $n
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_scalarmult_ristretto255_base(
|
||||
#[\SensitiveParameter]
|
||||
$n
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::scalarmult_ristretto255_base($n, true);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Sodium;
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . '/autoload.php';
|
||||
|
||||
use ParagonIE_Sodium_Compat;
|
||||
|
||||
/**
|
||||
* This file will monkey patch the pure-PHP implementation in place of the
|
||||
* PECL functions, but only if they do not already exist.
|
||||
@@ -11,7 +12,7 @@ use ParagonIE_Sodium_Compat;
|
||||
* Thus, the functions just proxy to the appropriate ParagonIE_Sodium_Compat
|
||||
* method.
|
||||
*/
|
||||
if (!is_callable('\Sodium\bin2hex')) {
|
||||
if (!is_callable('\\Sodium\\bin2hex')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::bin2hex()
|
||||
* @param string $string
|
||||
@@ -22,12 +23,11 @@ if (!is_callable('\Sodium\bin2hex')) {
|
||||
function bin2hex(
|
||||
#[\SensitiveParameter]
|
||||
$string
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::bin2hex($string);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\compare')) {
|
||||
if (!is_callable('\\Sodium\\compare')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::compare()
|
||||
* @param string $a
|
||||
@@ -41,12 +41,11 @@ if (!is_callable('\Sodium\compare')) {
|
||||
$a,
|
||||
#[\SensitiveParameter]
|
||||
$b
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::compare($a, $b);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_aead_aes256gcm_decrypt')) {
|
||||
if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_decrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt()
|
||||
* @param string $message
|
||||
@@ -61,18 +60,17 @@ if (!is_callable('\Sodium\crypto_aead_aes256gcm_decrypt')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
try {
|
||||
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key);
|
||||
} catch (\TypeError $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
} catch (\SodiumException $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_aead_aes256gcm_encrypt')) {
|
||||
if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_encrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt()
|
||||
* @param string $message
|
||||
@@ -90,12 +88,11 @@ if (!is_callable('\Sodium\crypto_aead_aes256gcm_encrypt')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_aead_aes256gcm_is_available')) {
|
||||
if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_is_available')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available()
|
||||
* @return bool
|
||||
@@ -105,7 +102,7 @@ if (!is_callable('\Sodium\crypto_aead_aes256gcm_is_available')) {
|
||||
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available();
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_aead_chacha20poly1305_decrypt')) {
|
||||
if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_decrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt()
|
||||
* @param string $message
|
||||
@@ -120,18 +117,17 @@ if (!is_callable('\Sodium\crypto_aead_chacha20poly1305_decrypt')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
try {
|
||||
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key);
|
||||
} catch (\TypeError $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
} catch (\SodiumException $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_aead_chacha20poly1305_encrypt')) {
|
||||
if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_encrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt()
|
||||
* @param string $message
|
||||
@@ -149,12 +145,11 @@ if (!is_callable('\Sodium\crypto_aead_chacha20poly1305_encrypt')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_aead_chacha20poly1305_ietf_decrypt')) {
|
||||
if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_decrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt()
|
||||
* @param string $message
|
||||
@@ -169,18 +164,17 @@ if (!is_callable('\Sodium\crypto_aead_chacha20poly1305_ietf_decrypt')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
try {
|
||||
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key);
|
||||
} catch (\TypeError $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
} catch (\SodiumException $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_aead_chacha20poly1305_ietf_encrypt')) {
|
||||
if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_encrypt')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt()
|
||||
* @param string $message
|
||||
@@ -198,12 +192,11 @@ if (!is_callable('\Sodium\crypto_aead_chacha20poly1305_ietf_encrypt')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_auth')) {
|
||||
if (!is_callable('\\Sodium\\crypto_auth')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_auth()
|
||||
* @param string $message
|
||||
@@ -216,12 +209,11 @@ if (!is_callable('\Sodium\crypto_auth')) {
|
||||
$message,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_auth($message, $key);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_auth_verify')) {
|
||||
if (!is_callable('\\Sodium\\crypto_auth_verify')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_auth_verify()
|
||||
* @param string $mac
|
||||
@@ -236,12 +228,11 @@ if (!is_callable('\Sodium\crypto_auth_verify')) {
|
||||
$message,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_box')) {
|
||||
if (!is_callable('\\Sodium\\crypto_box')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_box()
|
||||
* @param string $message
|
||||
@@ -257,12 +248,11 @@ if (!is_callable('\Sodium\crypto_box')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$kp
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_box_keypair')) {
|
||||
if (!is_callable('\\Sodium\\crypto_box_keypair')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_box_keypair()
|
||||
* @return string
|
||||
@@ -274,7 +264,7 @@ if (!is_callable('\Sodium\crypto_box_keypair')) {
|
||||
return ParagonIE_Sodium_Compat::crypto_box_keypair();
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_box_keypair_from_secretkey_and_publickey')) {
|
||||
if (!is_callable('\\Sodium\\crypto_box_keypair_from_secretkey_and_publickey')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey()
|
||||
* @param string $sk
|
||||
@@ -287,12 +277,11 @@ if (!is_callable('\Sodium\crypto_box_keypair_from_secretkey_and_publickey')) {
|
||||
#[\SensitiveParameter]
|
||||
$sk,
|
||||
$pk
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_box_open')) {
|
||||
if (!is_callable('\\Sodium\\crypto_box_open')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_box_open()
|
||||
* @param string $message
|
||||
@@ -306,18 +295,17 @@ if (!is_callable('\Sodium\crypto_box_open')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$kp
|
||||
)
|
||||
{
|
||||
) {
|
||||
try {
|
||||
return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp);
|
||||
} catch (\TypeError $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
} catch (\SodiumException $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_box_publickey')) {
|
||||
if (!is_callable('\\Sodium\\crypto_box_publickey')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_box_publickey()
|
||||
* @param string $keypair
|
||||
@@ -328,12 +316,11 @@ if (!is_callable('\Sodium\crypto_box_publickey')) {
|
||||
function crypto_box_publickey(
|
||||
#[\SensitiveParameter]
|
||||
$keypair
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_box_publickey_from_secretkey')) {
|
||||
if (!is_callable('\\Sodium\\crypto_box_publickey_from_secretkey')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey()
|
||||
* @param string $sk
|
||||
@@ -344,12 +331,11 @@ if (!is_callable('\Sodium\crypto_box_publickey_from_secretkey')) {
|
||||
function crypto_box_publickey_from_secretkey(
|
||||
#[\SensitiveParameter]
|
||||
$sk
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($sk);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_box_seal')) {
|
||||
if (!is_callable('\\Sodium\\crypto_box_seal')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_box_seal_open()
|
||||
* @param string $message
|
||||
@@ -362,12 +348,11 @@ if (!is_callable('\Sodium\crypto_box_seal')) {
|
||||
#[\SensitiveParameter]
|
||||
$message,
|
||||
$publicKey
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_box_seal_open')) {
|
||||
if (!is_callable('\\Sodium\\crypto_box_seal_open')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_box_seal_open()
|
||||
* @param string $message
|
||||
@@ -378,18 +363,17 @@ if (!is_callable('\Sodium\crypto_box_seal_open')) {
|
||||
$message,
|
||||
#[\SensitiveParameter]
|
||||
$kp
|
||||
)
|
||||
{
|
||||
) {
|
||||
try {
|
||||
return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp);
|
||||
} catch (\TypeError $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
} catch (\SodiumException $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_box_secretkey')) {
|
||||
if (!is_callable('\\Sodium\\crypto_box_secretkey')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_box_secretkey()
|
||||
* @param string $keypair
|
||||
@@ -400,12 +384,11 @@ if (!is_callable('\Sodium\crypto_box_secretkey')) {
|
||||
function crypto_box_secretkey(
|
||||
#[\SensitiveParameter]
|
||||
$keypair
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_box_secretkey($keypair);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_generichash')) {
|
||||
if (!is_callable('\\Sodium\\crypto_generichash')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_generichash()
|
||||
* @param string $message
|
||||
@@ -420,12 +403,11 @@ if (!is_callable('\Sodium\crypto_generichash')) {
|
||||
#[\SensitiveParameter]
|
||||
$key = null,
|
||||
$outLen = 32
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $outLen);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_generichash_final')) {
|
||||
if (!is_callable('\\Sodium\\crypto_generichash_final')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_generichash_final()
|
||||
* @param string|null $ctx
|
||||
@@ -438,12 +420,11 @@ if (!is_callable('\Sodium\crypto_generichash_final')) {
|
||||
#[\SensitiveParameter]
|
||||
&$ctx,
|
||||
$outputLength = 32
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_generichash_final($ctx, $outputLength);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_generichash_init')) {
|
||||
if (!is_callable('\\Sodium\\crypto_generichash_init')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_generichash_init()
|
||||
* @param string|null $key
|
||||
@@ -456,12 +437,11 @@ if (!is_callable('\Sodium\crypto_generichash_init')) {
|
||||
#[\SensitiveParameter]
|
||||
$key = null,
|
||||
$outLen = 32
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $outLen);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_generichash_update')) {
|
||||
if (!is_callable('\\Sodium\\crypto_generichash_update')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_generichash_update()
|
||||
* @param string|null $ctx
|
||||
@@ -474,12 +454,11 @@ if (!is_callable('\Sodium\crypto_generichash_update')) {
|
||||
#[\SensitiveParameter]
|
||||
&$ctx,
|
||||
$message = ''
|
||||
)
|
||||
{
|
||||
) {
|
||||
ParagonIE_Sodium_Compat::crypto_generichash_update($ctx, $message);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_kx')) {
|
||||
if (!is_callable('\\Sodium\\crypto_kx')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_kx()
|
||||
* @param string $my_secret
|
||||
@@ -496,12 +475,17 @@ if (!is_callable('\Sodium\crypto_kx')) {
|
||||
$their_public,
|
||||
$client_public,
|
||||
$server_public
|
||||
)
|
||||
{
|
||||
return ParagonIE_Sodium_Compat::crypto_kx($my_secret, $their_public, $client_public, $server_public, \true);
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_kx(
|
||||
$my_secret,
|
||||
$their_public,
|
||||
$client_public,
|
||||
$server_public,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_pwhash')) {
|
||||
if (!is_callable('\\Sodium\\crypto_pwhash')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_pwhash()
|
||||
* @param int $outlen
|
||||
@@ -520,12 +504,11 @@ if (!is_callable('\Sodium\crypto_pwhash')) {
|
||||
$salt,
|
||||
$opslimit,
|
||||
$memlimit
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_pwhash_str')) {
|
||||
if (!is_callable('\\Sodium\\crypto_pwhash_str')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_pwhash_str()
|
||||
* @param string $passwd
|
||||
@@ -540,12 +523,11 @@ if (!is_callable('\Sodium\crypto_pwhash_str')) {
|
||||
$passwd,
|
||||
$opslimit,
|
||||
$memlimit
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_pwhash_str_verify')) {
|
||||
if (!is_callable('\\Sodium\\crypto_pwhash_str_verify')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_pwhash_str_verify()
|
||||
* @param string $passwd
|
||||
@@ -559,12 +541,11 @@ if (!is_callable('\Sodium\crypto_pwhash_str_verify')) {
|
||||
$passwd,
|
||||
#[\SensitiveParameter]
|
||||
$hash
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_pwhash_scryptsalsa208sha256')) {
|
||||
if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256()
|
||||
* @param int $outlen
|
||||
@@ -584,12 +565,11 @@ if (!is_callable('\Sodium\crypto_pwhash_scryptsalsa208sha256')) {
|
||||
$salt,
|
||||
$opslimit,
|
||||
$memlimit
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_pwhash_scryptsalsa208sha256_str')) {
|
||||
if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str()
|
||||
* @param string $passwd
|
||||
@@ -604,12 +584,11 @@ if (!is_callable('\Sodium\crypto_pwhash_scryptsalsa208sha256_str')) {
|
||||
$passwd,
|
||||
$opslimit,
|
||||
$memlimit
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_pwhash_scryptsalsa208sha256_str_verify')) {
|
||||
if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify()
|
||||
* @param string $passwd
|
||||
@@ -623,12 +602,11 @@ if (!is_callable('\Sodium\crypto_pwhash_scryptsalsa208sha256_str_verify')) {
|
||||
$passwd,
|
||||
#[\SensitiveParameter]
|
||||
$hash
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_scalarmult')) {
|
||||
if (!is_callable('\\Sodium\\crypto_scalarmult')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_scalarmult()
|
||||
* @param string $n
|
||||
@@ -641,12 +619,11 @@ if (!is_callable('\Sodium\crypto_scalarmult')) {
|
||||
#[\SensitiveParameter]
|
||||
$n,
|
||||
$p
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_scalarmult_base')) {
|
||||
if (!is_callable('\\Sodium\\crypto_scalarmult_base')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_scalarmult_base()
|
||||
* @param string $n
|
||||
@@ -657,12 +634,11 @@ if (!is_callable('\Sodium\crypto_scalarmult_base')) {
|
||||
function crypto_scalarmult_base(
|
||||
#[\SensitiveParameter]
|
||||
$n
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_secretbox')) {
|
||||
if (!is_callable('\\Sodium\\crypto_secretbox')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_secretbox()
|
||||
* @param string $message
|
||||
@@ -678,12 +654,11 @@ if (!is_callable('\Sodium\crypto_secretbox')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_secretbox_open')) {
|
||||
if (!is_callable('\\Sodium\\crypto_secretbox_open')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_secretbox_open()
|
||||
* @param string $message
|
||||
@@ -696,18 +671,17 @@ if (!is_callable('\Sodium\crypto_secretbox_open')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
try {
|
||||
return ParagonIE_Sodium_Compat::crypto_secretbox_open($message, $nonce, $key);
|
||||
} catch (\TypeError $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
} catch (\SodiumException $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_shorthash')) {
|
||||
if (!is_callable('\\Sodium\\crypto_shorthash')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_shorthash()
|
||||
* @param string $message
|
||||
@@ -720,12 +694,11 @@ if (!is_callable('\Sodium\crypto_shorthash')) {
|
||||
$message,
|
||||
#[\SensitiveParameter]
|
||||
$key = ''
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_sign')) {
|
||||
if (!is_callable('\\Sodium\\crypto_sign')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_sign()
|
||||
* @param string $message
|
||||
@@ -738,12 +711,11 @@ if (!is_callable('\Sodium\crypto_sign')) {
|
||||
$message,
|
||||
#[\SensitiveParameter]
|
||||
$sk
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_sign($message, $sk);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_sign_detached')) {
|
||||
if (!is_callable('\\Sodium\\crypto_sign_detached')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_sign_detached()
|
||||
* @param string $message
|
||||
@@ -756,12 +728,11 @@ if (!is_callable('\Sodium\crypto_sign_detached')) {
|
||||
$message,
|
||||
#[\SensitiveParameter]
|
||||
$sk
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $sk);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_sign_keypair')) {
|
||||
if (!is_callable('\\Sodium\\crypto_sign_keypair')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_sign_keypair()
|
||||
* @return string
|
||||
@@ -773,7 +744,7 @@ if (!is_callable('\Sodium\crypto_sign_keypair')) {
|
||||
return ParagonIE_Sodium_Compat::crypto_sign_keypair();
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_sign_open')) {
|
||||
if (!is_callable('\\Sodium\\crypto_sign_open')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_sign_open()
|
||||
* @param string $signedMessage
|
||||
@@ -785,13 +756,13 @@ if (!is_callable('\Sodium\crypto_sign_open')) {
|
||||
try {
|
||||
return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $pk);
|
||||
} catch (\TypeError $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
} catch (\SodiumException $ex) {
|
||||
return \false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_sign_publickey')) {
|
||||
if (!is_callable('\\Sodium\\crypto_sign_publickey')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_sign_publickey()
|
||||
* @param string $keypair
|
||||
@@ -802,12 +773,11 @@ if (!is_callable('\Sodium\crypto_sign_publickey')) {
|
||||
function crypto_sign_publickey(
|
||||
#[\SensitiveParameter]
|
||||
$keypair
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_sign_publickey($keypair);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_sign_publickey_from_secretkey')) {
|
||||
if (!is_callable('\\Sodium\\crypto_sign_publickey_from_secretkey')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey()
|
||||
* @param string $sk
|
||||
@@ -818,12 +788,11 @@ if (!is_callable('\Sodium\crypto_sign_publickey_from_secretkey')) {
|
||||
function crypto_sign_publickey_from_secretkey(
|
||||
#[\SensitiveParameter]
|
||||
$sk
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($sk);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_sign_secretkey')) {
|
||||
if (!is_callable('\\Sodium\\crypto_sign_secretkey')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_sign_secretkey()
|
||||
* @param string $keypair
|
||||
@@ -834,12 +803,11 @@ if (!is_callable('\Sodium\crypto_sign_secretkey')) {
|
||||
function crypto_sign_secretkey(
|
||||
#[\SensitiveParameter]
|
||||
$keypair
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_sign_secretkey($keypair);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_sign_seed_keypair')) {
|
||||
if (!is_callable('\\Sodium\\crypto_sign_seed_keypair')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_sign_seed_keypair()
|
||||
* @param string $seed
|
||||
@@ -850,12 +818,11 @@ if (!is_callable('\Sodium\crypto_sign_seed_keypair')) {
|
||||
function crypto_sign_seed_keypair(
|
||||
#[\SensitiveParameter]
|
||||
$seed
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_sign_verify_detached')) {
|
||||
if (!is_callable('\\Sodium\\crypto_sign_verify_detached')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_sign_verify_detached()
|
||||
* @param string $signature
|
||||
@@ -870,7 +837,7 @@ if (!is_callable('\Sodium\crypto_sign_verify_detached')) {
|
||||
return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $pk);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_sign_ed25519_pk_to_curve25519')) {
|
||||
if (!is_callable('\\Sodium\\crypto_sign_ed25519_pk_to_curve25519')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519()
|
||||
* @param string $pk
|
||||
@@ -883,7 +850,7 @@ if (!is_callable('\Sodium\crypto_sign_ed25519_pk_to_curve25519')) {
|
||||
return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($pk);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_sign_ed25519_sk_to_curve25519')) {
|
||||
if (!is_callable('\\Sodium\\crypto_sign_ed25519_sk_to_curve25519')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519()
|
||||
* @param string $sk
|
||||
@@ -894,12 +861,11 @@ if (!is_callable('\Sodium\crypto_sign_ed25519_sk_to_curve25519')) {
|
||||
function crypto_sign_ed25519_sk_to_curve25519(
|
||||
#[\SensitiveParameter]
|
||||
$sk
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($sk);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_stream')) {
|
||||
if (!is_callable('\\Sodium\\crypto_stream')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_stream()
|
||||
* @param int $len
|
||||
@@ -914,12 +880,11 @@ if (!is_callable('\Sodium\crypto_stream')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_stream($len, $nonce, $key);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\crypto_stream_xor')) {
|
||||
if (!is_callable('\\Sodium\\crypto_stream_xor')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_stream_xor()
|
||||
* @param string $message
|
||||
@@ -935,12 +900,11 @@ if (!is_callable('\Sodium\crypto_stream_xor')) {
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\hex2bin')) {
|
||||
if (!is_callable('\\Sodium\\hex2bin')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::hex2bin()
|
||||
* @param string $string
|
||||
@@ -951,12 +915,11 @@ if (!is_callable('\Sodium\hex2bin')) {
|
||||
function hex2bin(
|
||||
#[\SensitiveParameter]
|
||||
$string
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::hex2bin($string);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\memcmp')) {
|
||||
if (!is_callable('\\Sodium\\memcmp')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::memcmp()
|
||||
* @param string $a
|
||||
@@ -970,12 +933,11 @@ if (!is_callable('\Sodium\memcmp')) {
|
||||
$a,
|
||||
#[\SensitiveParameter]
|
||||
$b
|
||||
)
|
||||
{
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::memcmp($a, $b);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\memzero')) {
|
||||
if (!is_callable('\\Sodium\\memzero')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::memzero()
|
||||
* @param string $str
|
||||
@@ -990,12 +952,11 @@ if (!is_callable('\Sodium\memzero')) {
|
||||
function memzero(
|
||||
#[\SensitiveParameter]
|
||||
&$str
|
||||
)
|
||||
{
|
||||
) {
|
||||
ParagonIE_Sodium_Compat::memzero($str);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\randombytes_buf')) {
|
||||
if (!is_callable('\\Sodium\\randombytes_buf')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::randombytes_buf()
|
||||
* @param int $amount
|
||||
@@ -1007,7 +968,8 @@ if (!is_callable('\Sodium\randombytes_buf')) {
|
||||
return ParagonIE_Sodium_Compat::randombytes_buf($amount);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\randombytes_uniform')) {
|
||||
|
||||
if (!is_callable('\\Sodium\\randombytes_uniform')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::randombytes_uniform()
|
||||
* @param int $upperLimit
|
||||
@@ -1020,7 +982,8 @@ if (!is_callable('\Sodium\randombytes_uniform')) {
|
||||
return ParagonIE_Sodium_Compat::randombytes_uniform($upperLimit);
|
||||
}
|
||||
}
|
||||
if (!is_callable('\Sodium\randombytes_random16')) {
|
||||
|
||||
if (!is_callable('\\Sodium\\randombytes_random16')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::randombytes_random16()
|
||||
* @return int
|
||||
@@ -1030,6 +993,7 @@ if (!is_callable('\Sodium\randombytes_random16')) {
|
||||
return ParagonIE_Sodium_Compat::randombytes_random16();
|
||||
}
|
||||
}
|
||||
if (!defined('\Sodium\CRYPTO_AUTH_BYTES')) {
|
||||
|
||||
if (!defined('\\Sodium\\CRYPTO_AUTH_BYTES')) {
|
||||
require_once dirname(__FILE__) . '/constants.php';
|
||||
}
|
||||
|
||||
@@ -1,78 +1,74 @@
|
||||
<?php
|
||||
|
||||
|
||||
if (!\is_callable('sodium_crypto_stream_xchacha20')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20()
|
||||
* @param int $len
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_stream_xchacha20(
|
||||
$len,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::crypto_stream_xchacha20($len, $nonce, $key, \true);
|
||||
}
|
||||
if (!is_callable('sodium_crypto_stream_xchacha20')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20()
|
||||
* @param int $len
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_stream_xchacha20(
|
||||
$len,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_stream_xchacha20($len, $nonce, $key, true);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_stream_xchacha20_keygen')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen()
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
function sodium_crypto_stream_xchacha20_keygen()
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen();
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_stream_xchacha20_keygen')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen()
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
function sodium_crypto_stream_xchacha20_keygen()
|
||||
{
|
||||
return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen();
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_stream_xchacha20_xor')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor()
|
||||
* @param string $message
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_stream_xchacha20_xor(
|
||||
#[\SensitiveParameter]
|
||||
$message,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor($message, $nonce, $key, \true);
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_stream_xchacha20_xor')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor()
|
||||
* @param string $message
|
||||
* @param string $nonce
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_stream_xchacha20_xor(
|
||||
#[\SensitiveParameter]
|
||||
$message,
|
||||
$nonce,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor($message, $nonce, $key, true);
|
||||
}
|
||||
if (!\is_callable('sodium_crypto_stream_xchacha20_xor_ic')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor_ic()
|
||||
* @param string $message
|
||||
* @param string $nonce
|
||||
* @param int $counter
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_stream_xchacha20_xor_ic(
|
||||
#[\SensitiveParameter]
|
||||
$message,
|
||||
$nonce,
|
||||
$counter,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
)
|
||||
{
|
||||
return \ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor_ic($message, $nonce, $counter, $key, \true);
|
||||
}
|
||||
}
|
||||
if (!is_callable('sodium_crypto_stream_xchacha20_xor_ic')) {
|
||||
/**
|
||||
* @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor_ic()
|
||||
* @param string $message
|
||||
* @param string $nonce
|
||||
* @param int $counter
|
||||
* @param string $key
|
||||
* @return string
|
||||
* @throws SodiumException
|
||||
* @throws TypeError
|
||||
*/
|
||||
function sodium_crypto_stream_xchacha20_xor_ic(
|
||||
#[\SensitiveParameter]
|
||||
$message,
|
||||
$nonce,
|
||||
$counter,
|
||||
#[\SensitiveParameter]
|
||||
$key
|
||||
) {
|
||||
return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor_ic($message, $nonce, $counter, $key, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user