Upgrade/Install: Update sodium_compat to v1.21.1.

The latest version of sodium_compat includes support for AEGIS and preliminary support for PHP 8.4.

Additionally, the PHP 8.2+ `SensitiveParameter` attribute is now applied where appropriate to functions in the public API. This attribute is used to mark parameters that are sensitive and should be redacted from stack traces.

References:
* [https://github.com/paragonie/sodium_compat/releases/tag/v1.21.0 sodium_compat 1.21.0 release notes]
* [https://github.com/paragonie/sodium_compat/releases/tag/v1.21.1 sodium_compat 1.21.1 release notes]
* [https://github.com/paragonie/sodium_compat/compare/v1.20.0...v1.21.1 Full list of changes in sodium_compat 1.21.1]

Follow-up to [49741], [51002], [51591], [52988], [54150], [54310], [55699].

Props jrf, dd32, paragoninitiativeenterprises.
Fixes #61686.
Built from https://develop.svn.wordpress.org/trunk@58752


git-svn-id: http://core.svn.wordpress.org/trunk@58154 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2024-07-18 13:00:16 +00:00
parent ab39abeed7
commit f0b4b44d1e
15 changed files with 1537 additions and 664 deletions

View File

@ -54,6 +54,9 @@ if (PHP_VERSION_ID >= 50300) {
// unless PHP >= 5.3.0
require_once dirname(__FILE__) . '/lib/namespaced.php';
require_once dirname(__FILE__) . '/lib/sodium_compat.php';
if (!defined('SODIUM_CRYPTO_AEAD_AEGIS128L_KEYBYTES')) {
require_once dirname(__FILE__) . '/lib/php84compat_const.php';
}
} else {
require_once dirname(__FILE__) . '/src/PHP52/SplFixedArray.php';
}
@ -71,5 +74,8 @@ if (PHP_VERSION_ID < 70200 || !extension_loaded('sodium')) {
// Older versions of {PHP, ext/sodium} will not define these
require_once(dirname(__FILE__) . '/lib/php72compat.php');
}
if (PHP_VERSION_ID < 80400 || !extension_loaded('sodium')) {
require_once dirname(__FILE__) . '/lib/php84compat.php';
}
require_once(dirname(__FILE__) . '/lib/stream-xchacha20.php');
require_once(dirname(__FILE__) . '/lib/ristretto255.php');

View File

@ -14,14 +14,14 @@ foreach (array(
'BASE64_VARIANT_ORIGINAL_NO_PADDING',
'BASE64_VARIANT_URLSAFE',
'BASE64_VARIANT_URLSAFE_NO_PADDING',
'CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES',
'CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES',
'CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES',
'CRYPTO_AEAD_CHACHA20POLY1305_ABYTES',
'CRYPTO_AEAD_AES256GCM_KEYBYTES',
'CRYPTO_AEAD_AES256GCM_NSECBYTES',
'CRYPTO_AEAD_AES256GCM_NPUBBYTES',
'CRYPTO_AEAD_AES256GCM_ABYTES',
'CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES',
'CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES',
'CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES',
'CRYPTO_AEAD_CHACHA20POLY1305_ABYTES',
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES',
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES',
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES',
@ -115,8 +115,12 @@ if (!is_callable('sodium_add')) {
* @return void
* @throws SodiumException
*/
function sodium_add(&$string1, $string2)
{
function sodium_add(
#[\SensitiveParameter]
&$string1,
#[\SensitiveParameter]
$string2
) {
ParagonIE_Sodium_Compat::add($string1, $string2);
}
}
@ -130,8 +134,12 @@ if (!is_callable('sodium_base642bin')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_base642bin($string, $variant, $ignore ='')
{
function sodium_base642bin(
#[\SensitiveParameter]
$string,
$variant,
$ignore =''
) {
return ParagonIE_Sodium_Compat::base642bin($string, $variant, $ignore);
}
}
@ -144,8 +152,11 @@ if (!is_callable('sodium_bin2base64')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_bin2base64($string, $variant)
{
function sodium_bin2base64(
#[\SensitiveParameter]
$string,
$variant
) {
return ParagonIE_Sodium_Compat::bin2base64($string, $variant);
}
}
@ -157,8 +168,10 @@ if (!is_callable('sodium_bin2hex')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_bin2hex($string)
{
function sodium_bin2hex(
#[\SensitiveParameter]
$string
) {
return ParagonIE_Sodium_Compat::bin2hex($string);
}
}
@ -171,8 +184,12 @@ if (!is_callable('sodium_compare')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_compare($string1, $string2)
{
function sodium_compare(
#[\SensitiveParameter]
$string1,
#[\SensitiveParameter]
$string2
) {
return ParagonIE_Sodium_Compat::compare($string1, $string2);
}
}
@ -185,8 +202,13 @@ if (!is_callable('sodium_crypto_aead_aes256gcm_decrypt')) {
* @param string $key
* @return string|bool
*/
function sodium_crypto_aead_aes256gcm_decrypt($ciphertext, $additional_data, $nonce, $key)
{
function sodium_crypto_aead_aes256gcm_decrypt(
$ciphertext,
$additional_data,
$nonce,
#[\SensitiveParameter]
$key
) {
try {
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt(
$ciphertext,
@ -215,8 +237,14 @@ if (!is_callable('sodium_crypto_aead_aes256gcm_encrypt')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_aead_aes256gcm_encrypt($message, $additional_data, $nonce, $key)
{
function sodium_crypto_aead_aes256gcm_encrypt(
#[\SensitiveParameter]
$message,
$additional_data,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $additional_data, $nonce, $key);
}
}
@ -239,8 +267,13 @@ if (!is_callable('sodium_crypto_aead_chacha20poly1305_decrypt')) {
* @param string $key
* @return string|bool
*/
function sodium_crypto_aead_chacha20poly1305_decrypt($ciphertext, $additional_data, $nonce, $key)
{
function sodium_crypto_aead_chacha20poly1305_decrypt(
$ciphertext,
$additional_data,
$nonce,
#[\SensitiveParameter]
$key
) {
try {
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt(
$ciphertext,
@ -266,8 +299,14 @@ if (!is_callable('sodium_crypto_aead_chacha20poly1305_encrypt')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_aead_chacha20poly1305_encrypt($message, $additional_data, $nonce, $key)
{
function sodium_crypto_aead_chacha20poly1305_encrypt(
#[\SensitiveParameter]
$message,
$additional_data,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt(
$message,
$additional_data,
@ -296,8 +335,13 @@ if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_decrypt')) {
* @param string $key
* @return string|bool
*/
function sodium_crypto_aead_chacha20poly1305_ietf_decrypt($message, $additional_data, $nonce, $key)
{
function sodium_crypto_aead_chacha20poly1305_ietf_decrypt(
$message,
$additional_data,
$nonce,
#[\SensitiveParameter]
$key
) {
try {
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt(
$message,
@ -323,8 +367,14 @@ if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_encrypt')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_aead_chacha20poly1305_ietf_encrypt($message, $additional_data, $nonce, $key)
{
function sodium_crypto_aead_chacha20poly1305_ietf_encrypt(
#[\SensitiveParameter]
$message,
$additional_data,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt(
$message,
$additional_data,
@ -353,8 +403,13 @@ if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) {
* @param string $key
* @return string|bool
*/
function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($ciphertext, $additional_data, $nonce, $key)
{
function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt(
$ciphertext,
$additional_data,
$nonce,
#[\SensitiveParameter]
$key
) {
try {
return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt(
$ciphertext,
@ -382,9 +437,11 @@ if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) {
* @throws TypeError
*/
function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt(
#[\SensitiveParameter]
$message,
$additional_data,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt(
@ -416,8 +473,11 @@ if (!is_callable('sodium_crypto_auth')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_auth($message, $key)
{
function sodium_crypto_auth(
$message,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_auth($message, $key);
}
}
@ -442,8 +502,12 @@ if (!is_callable('sodium_crypto_auth_verify')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_auth_verify($mac, $message, $key)
{
function sodium_crypto_auth_verify(
$mac,
$message,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key);
}
}
@ -457,8 +521,13 @@ if (!is_callable('sodium_crypto_box')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_box($message, $nonce, $key_pair)
{
function sodium_crypto_box(
#[\SensitiveParameter]
$message,
$nonce,
#[\SensitiveParameter]
$key_pair
) {
return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $key_pair);
}
}
@ -483,8 +552,11 @@ if (!is_callable('sodium_crypto_box_keypair_from_secretkey_and_publickey')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_box_keypair_from_secretkey_and_publickey($secret_key, $public_key)
{
function sodium_crypto_box_keypair_from_secretkey_and_publickey(
#[\SensitiveParameter]
$secret_key,
$public_key
) {
return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($secret_key, $public_key);
}
}
@ -496,8 +568,12 @@ if (!is_callable('sodium_crypto_box_open')) {
* @param string $key_pair
* @return string|bool
*/
function sodium_crypto_box_open($ciphertext, $nonce, $key_pair)
{
function sodium_crypto_box_open(
$ciphertext,
$nonce,
#[\SensitiveParameter]
$key_pair
) {
try {
return ParagonIE_Sodium_Compat::crypto_box_open($ciphertext, $nonce, $key_pair);
} catch (Error $ex) {
@ -515,8 +591,10 @@ if (!is_callable('sodium_crypto_box_publickey')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_box_publickey($key_pair)
{
function sodium_crypto_box_publickey(
#[\SensitiveParameter]
$key_pair
) {
return ParagonIE_Sodium_Compat::crypto_box_publickey($key_pair);
}
}
@ -528,8 +606,10 @@ if (!is_callable('sodium_crypto_box_publickey_from_secretkey')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_box_publickey_from_secretkey($secret_key)
{
function sodium_crypto_box_publickey_from_secretkey(
#[\SensitiveParameter]
$secret_key
) {
return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($secret_key);
}
}
@ -542,8 +622,11 @@ if (!is_callable('sodium_crypto_box_seal')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_box_seal($message, $public_key)
{
function sodium_crypto_box_seal(
#[\SensitiveParameter]
$message,
$public_key
) {
return ParagonIE_Sodium_Compat::crypto_box_seal($message, $public_key);
}
}
@ -555,8 +638,11 @@ if (!is_callable('sodium_crypto_box_seal_open')) {
* @return string|bool
* @throws SodiumException
*/
function sodium_crypto_box_seal_open($message, $key_pair)
{
function sodium_crypto_box_seal_open(
$message,
#[\SensitiveParameter]
$key_pair
) {
try {
return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $key_pair);
} catch (SodiumException $ex) {
@ -575,8 +661,10 @@ if (!is_callable('sodium_crypto_box_secretkey')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_box_secretkey($key_pair)
{
function sodium_crypto_box_secretkey(
#[\SensitiveParameter]
$key_pair
) {
return ParagonIE_Sodium_Compat::crypto_box_secretkey($key_pair);
}
}
@ -588,8 +676,10 @@ if (!is_callable('sodium_crypto_box_seed_keypair')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_box_seed_keypair($seed)
{
function sodium_crypto_box_seed_keypair(
#[\SensitiveParameter]
$seed
) {
return ParagonIE_Sodium_Compat::crypto_box_seed_keypair($seed);
}
}
@ -603,8 +693,12 @@ if (!is_callable('sodium_crypto_generichash')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_generichash($message, $key = null, $length = 32)
{
function sodium_crypto_generichash(
$message,
#[\SensitiveParameter]
$key = null,
$length = 32
) {
return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $length);
}
}
@ -631,8 +725,11 @@ if (!is_callable('sodium_crypto_generichash_init')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_generichash_init($key = null, $length = 32)
{
function sodium_crypto_generichash_init(
#[\SensitiveParameter]
$key = null,
$length = 32
) {
return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $length);
}
}
@ -656,8 +753,11 @@ if (!is_callable('sodium_crypto_generichash_update')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_generichash_update(&$state, $message = '')
{
function sodium_crypto_generichash_update(
#[\SensitiveParameter]
&$state,
$message = ''
) {
ParagonIE_Sodium_Compat::crypto_generichash_update($state, $message);
}
}
@ -682,8 +782,13 @@ if (!is_callable('sodium_crypto_kdf_derive_from_key')) {
* @return string
* @throws Exception
*/
function sodium_crypto_kdf_derive_from_key($subkey_length, $subkey_id, $context, $key)
{
function sodium_crypto_kdf_derive_from_key(
$subkey_length,
$subkey_id,
$context,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key(
$subkey_length,
$subkey_id,
@ -703,8 +808,13 @@ if (!is_callable('sodium_crypto_kx')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_kx($my_secret, $their_public, $client_public, $server_public)
{
function sodium_crypto_kx(
#[\SensitiveParameter]
$my_secret,
$their_public,
$client_public,
$server_public
) {
return ParagonIE_Sodium_Compat::crypto_kx(
$my_secret,
$their_public,
@ -719,8 +829,10 @@ if (!is_callable('sodium_crypto_kx_seed_keypair')) {
* @return string
* @throws Exception
*/
function sodium_crypto_kx_seed_keypair($seed)
{
function sodium_crypto_kx_seed_keypair(
#[\SensitiveParameter]
$seed
) {
return ParagonIE_Sodium_Compat::crypto_kx_seed_keypair($seed);
}
}
@ -741,8 +853,11 @@ if (!is_callable('sodium_crypto_kx_client_session_keys')) {
* @return array{0: string, 1: string}
* @throws SodiumException
*/
function sodium_crypto_kx_client_session_keys($client_key_pair, $server_key)
{
function sodium_crypto_kx_client_session_keys(
#[\SensitiveParameter]
$client_key_pair,
$server_key
) {
return ParagonIE_Sodium_Compat::crypto_kx_client_session_keys($client_key_pair, $server_key);
}
}
@ -753,8 +868,11 @@ if (!is_callable('sodium_crypto_kx_server_session_keys')) {
* @return array{0: string, 1: string}
* @throws SodiumException
*/
function sodium_crypto_kx_server_session_keys($server_key_pair, $client_key)
{
function sodium_crypto_kx_server_session_keys(
#[\SensitiveParameter]
$server_key_pair,
$client_key
) {
return ParagonIE_Sodium_Compat::crypto_kx_server_session_keys($server_key_pair, $client_key);
}
}
@ -764,8 +882,10 @@ if (!is_callable('sodium_crypto_kx_secretkey')) {
* @return string
* @throws Exception
*/
function sodium_crypto_kx_secretkey($key_pair)
{
function sodium_crypto_kx_secretkey(
#[\SensitiveParameter]
$key_pair
) {
return ParagonIE_Sodium_Compat::crypto_kx_secretkey($key_pair);
}
}
@ -775,8 +895,10 @@ if (!is_callable('sodium_crypto_kx_publickey')) {
* @return string
* @throws Exception
*/
function sodium_crypto_kx_publickey($key_pair)
{
function sodium_crypto_kx_publickey(
#[\SensitiveParameter]
$key_pair
) {
return ParagonIE_Sodium_Compat::crypto_kx_publickey($key_pair);
}
}
@ -793,8 +915,15 @@ if (!is_callable('sodium_crypto_pwhash')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_pwhash($length, $passwd, $salt, $opslimit, $memlimit, $algo = null)
{
function sodium_crypto_pwhash(
$length,
#[\SensitiveParameter]
$passwd,
$salt,
$opslimit,
$memlimit,
$algo = null
) {
return ParagonIE_Sodium_Compat::crypto_pwhash($length, $passwd, $salt, $opslimit, $memlimit, $algo);
}
}
@ -808,8 +937,12 @@ if (!is_callable('sodium_crypto_pwhash_str')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_pwhash_str($passwd, $opslimit, $memlimit)
{
function sodium_crypto_pwhash_str(
#[\SensitiveParameter]
$passwd,
$opslimit,
$memlimit
) {
return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit);
}
}
@ -823,8 +956,12 @@ if (!is_callable('sodium_crypto_pwhash_str_needs_rehash')) {
*
* @throws SodiumException
*/
function sodium_crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit)
{
function sodium_crypto_pwhash_str_needs_rehash(
#[\SensitiveParameter]
$hash,
$opslimit,
$memlimit
) {
return ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit);
}
}
@ -837,8 +974,12 @@ if (!is_callable('sodium_crypto_pwhash_str_verify')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_pwhash_str_verify($passwd, $hash)
{
function sodium_crypto_pwhash_str_verify(
#[\SensitiveParameter]
$passwd,
#[\SensitiveParameter]
$hash
) {
return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash);
}
}
@ -854,8 +995,14 @@ if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_pwhash_scryptsalsa208sha256($length, $passwd, $salt, $opslimit, $memlimit)
{
function sodium_crypto_pwhash_scryptsalsa208sha256(
$length,
#[\SensitiveParameter]
$passwd,
$salt,
$opslimit,
$memlimit
) {
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256(
$length,
$passwd,
@ -875,8 +1022,12 @@ if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256_str')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit)
{
function sodium_crypto_pwhash_scryptsalsa208sha256_str(
#[\SensitiveParameter]
$passwd,
$opslimit,
$memlimit
) {
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit);
}
}
@ -889,8 +1040,12 @@ if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256_str_verify')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash)
{
function sodium_crypto_pwhash_scryptsalsa208sha256_str_verify(
#[\SensitiveParameter]
$passwd,
#[\SensitiveParameter]
$hash
) {
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash);
}
}
@ -903,8 +1058,11 @@ if (!is_callable('sodium_crypto_scalarmult')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_scalarmult($n, $p)
{
function sodium_crypto_scalarmult(
#[\SensitiveParameter]
$n,
$p
) {
return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p);
}
}
@ -916,8 +1074,10 @@ if (!is_callable('sodium_crypto_scalarmult_base')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_scalarmult_base($n)
{
function sodium_crypto_scalarmult_base(
#[\SensitiveParameter]
$n
) {
return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n);
}
}
@ -931,8 +1091,13 @@ if (!is_callable('sodium_crypto_secretbox')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_secretbox($message, $nonce, $key)
{
function sodium_crypto_secretbox(
#[\SensitiveParameter]
$message,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key);
}
}
@ -955,8 +1120,12 @@ if (!is_callable('sodium_crypto_secretbox_open')) {
* @param string $key
* @return string|bool
*/
function sodium_crypto_secretbox_open($ciphertext, $nonce, $key)
{
function sodium_crypto_secretbox_open(
$ciphertext,
$nonce,
#[\SensitiveParameter]
$key
) {
try {
return ParagonIE_Sodium_Compat::crypto_secretbox_open($ciphertext, $nonce, $key);
} catch (Error $ex) {
@ -972,8 +1141,10 @@ if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_init_push')) {
* @return array<int, string>
* @throws SodiumException
*/
function sodium_crypto_secretstream_xchacha20poly1305_init_push($key)
{
function sodium_crypto_secretstream_xchacha20poly1305_init_push(
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_init_push($key);
}
}
@ -987,7 +1158,9 @@ if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_push')) {
* @throws SodiumException
*/
function sodium_crypto_secretstream_xchacha20poly1305_push(
#[\SensitiveParameter]
&$state,
#[\SensitiveParameter]
$message,
$additional_data = '',
$tag = 0
@ -1007,8 +1180,11 @@ if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_init_pull')) {
* @return string
* @throws Exception
*/
function sodium_crypto_secretstream_xchacha20poly1305_init_pull($header, $key)
{
function sodium_crypto_secretstream_xchacha20poly1305_init_pull(
$header,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_init_pull($header, $key);
}
}
@ -1020,8 +1196,12 @@ if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_pull')) {
* @return bool|array{0: string, 1: int}
* @throws SodiumException
*/
function sodium_crypto_secretstream_xchacha20poly1305_pull(&$state, $ciphertext, $additional_data = '')
{
function sodium_crypto_secretstream_xchacha20poly1305_pull(
#[\SensitiveParameter]
&$state,
$ciphertext,
$additional_data = ''
) {
return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_pull(
$state,
$ciphertext,
@ -1035,8 +1215,10 @@ if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_rekey')) {
* @return void
* @throws SodiumException
*/
function sodium_crypto_secretstream_xchacha20poly1305_rekey(&$state)
{
function sodium_crypto_secretstream_xchacha20poly1305_rekey(
#[\SensitiveParameter]
&$state
) {
ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_rekey($state);
}
}
@ -1059,8 +1241,11 @@ if (!is_callable('sodium_crypto_shorthash')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_shorthash($message, $key = '')
{
function sodium_crypto_shorthash(
$message,
#[\SensitiveParameter]
$key = ''
) {
return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key);
}
}
@ -1084,8 +1269,11 @@ if (!is_callable('sodium_crypto_sign')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_sign($message, $secret_key)
{
function sodium_crypto_sign(
$message,
#[\SensitiveParameter]
$secret_key
) {
return ParagonIE_Sodium_Compat::crypto_sign($message, $secret_key);
}
}
@ -1098,8 +1286,11 @@ if (!is_callable('sodium_crypto_sign_detached')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_sign_detached($message, $secret_key)
{
function sodium_crypto_sign_detached(
$message,
#[\SensitiveParameter]
$secret_key
) {
return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $secret_key);
}
}
@ -1112,8 +1303,11 @@ if (!is_callable('sodium_crypto_sign_keypair_from_secretkey_and_publickey')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_sign_keypair_from_secretkey_and_publickey($secret_key, $public_key)
{
function sodium_crypto_sign_keypair_from_secretkey_and_publickey(
#[\SensitiveParameter]
$secret_key,
$public_key
) {
return ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey($secret_key, $public_key);
}
}
@ -1155,8 +1349,10 @@ if (!is_callable('sodium_crypto_sign_publickey')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_sign_publickey($key_pair)
{
function sodium_crypto_sign_publickey(
#[\SensitiveParameter]
$key_pair
) {
return ParagonIE_Sodium_Compat::crypto_sign_publickey($key_pair);
}
}
@ -1168,8 +1364,10 @@ if (!is_callable('sodium_crypto_sign_publickey_from_secretkey')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_sign_publickey_from_secretkey($secret_key)
{
function sodium_crypto_sign_publickey_from_secretkey(
#[\SensitiveParameter]
$secret_key
) {
return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($secret_key);
}
}
@ -1181,8 +1379,10 @@ if (!is_callable('sodium_crypto_sign_secretkey')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_sign_secretkey($key_pair)
{
function sodium_crypto_sign_secretkey(
#[\SensitiveParameter]
$key_pair
) {
return ParagonIE_Sodium_Compat::crypto_sign_secretkey($key_pair);
}
}
@ -1194,8 +1394,10 @@ if (!is_callable('sodium_crypto_sign_seed_keypair')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_sign_seed_keypair($seed)
{
function sodium_crypto_sign_seed_keypair(
#[\SensitiveParameter]
$seed
) {
return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed);
}
}
@ -1235,8 +1437,10 @@ if (!is_callable('sodium_crypto_sign_ed25519_sk_to_curve25519')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_sign_ed25519_sk_to_curve25519($secret_key)
{
function sodium_crypto_sign_ed25519_sk_to_curve25519(
#[\SensitiveParameter]
$secret_key
) {
return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($secret_key);
}
}
@ -1250,8 +1454,12 @@ if (!is_callable('sodium_crypto_stream')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_stream($length, $nonce, $key)
{
function sodium_crypto_stream(
$length,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_stream($length, $nonce, $key);
}
}
@ -1276,8 +1484,13 @@ if (!is_callable('sodium_crypto_stream_xor')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_stream_xor($message, $nonce, $key)
{
function sodium_crypto_stream_xor(
#[\SensitiveParameter]
$message,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key);
}
}
@ -1291,8 +1504,11 @@ if (!is_callable('sodium_hex2bin')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_hex2bin($string, $ignore = '')
{
function sodium_hex2bin(
#[\SensitiveParameter]
$string,
$ignore = ''
) {
return ParagonIE_Sodium_Compat::hex2bin($string, $ignore);
}
}
@ -1304,8 +1520,10 @@ if (!is_callable('sodium_increment')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_increment(&$string)
{
function sodium_increment(
#[\SensitiveParameter]
&$string
) {
ParagonIE_Sodium_Compat::increment($string);
}
}
@ -1348,8 +1566,12 @@ if (!is_callable('sodium_memcmp')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_memcmp($string1, $string2)
{
function sodium_memcmp(
#[\SensitiveParameter]
$string1,
#[\SensitiveParameter]
$string2
) {
return ParagonIE_Sodium_Compat::memcmp($string1, $string2);
}
}
@ -1363,8 +1585,10 @@ if (!is_callable('sodium_memzero')) {
*
* @psalm-suppress ReferenceConstraintViolation
*/
function sodium_memzero(&$string)
{
function sodium_memzero(
#[\SensitiveParameter]
&$string
) {
ParagonIE_Sodium_Compat::memzero($string);
}
}
@ -1377,8 +1601,11 @@ if (!is_callable('sodium_pad')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_pad($unpadded, $block_size)
{
function sodium_pad(
#[\SensitiveParameter]
$unpadded,
$block_size
) {
return ParagonIE_Sodium_Compat::pad($unpadded, $block_size, true);
}
}
@ -1391,8 +1618,11 @@ if (!is_callable('sodium_unpad')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_unpad($padded, $block_size)
{
function sodium_unpad(
#[\SensitiveParameter]
$padded,
$block_size
) {
return ParagonIE_Sodium_Compat::unpad($padded, $block_size, true);
}
}

View File

@ -47,8 +47,12 @@ if (!is_callable('sodium_crypto_core_ristretto255_add')) {
* @return string
* @throws SodiumException
*/
function sodium_crypto_core_ristretto255_add($p, $q)
{
function sodium_crypto_core_ristretto255_add(
#[\SensitiveParameter]
$p,
#[\SensitiveParameter]
$q
) {
return ParagonIE_Sodium_Compat::ristretto255_add($p, $q, true);
}
}
@ -60,8 +64,10 @@ if (!is_callable('sodium_crypto_core_ristretto255_from_hash')) {
* @return string
* @throws SodiumException
*/
function sodium_crypto_core_ristretto255_from_hash($s)
{
function sodium_crypto_core_ristretto255_from_hash(
#[\SensitiveParameter]
$s
) {
return ParagonIE_Sodium_Compat::ristretto255_from_hash($s, true);
}
}
@ -73,8 +79,10 @@ if (!is_callable('sodium_crypto_core_ristretto255_is_valid_point')) {
* @return bool
* @throws SodiumException
*/
function sodium_crypto_core_ristretto255_is_valid_point($s)
{
function sodium_crypto_core_ristretto255_is_valid_point(
#[\SensitiveParameter]
$s
) {
return ParagonIE_Sodium_Compat::ristretto255_is_valid_point($s, true);
}
}
@ -99,8 +107,12 @@ if (!is_callable('sodium_crypto_core_ristretto255_scalar_add')) {
* @return string
* @throws SodiumException
*/
function sodium_crypto_core_ristretto255_scalar_add($x, $y)
{
function sodium_crypto_core_ristretto255_scalar_add(
#[\SensitiveParameter]
$x,
#[\SensitiveParameter]
$y
) {
return ParagonIE_Sodium_Compat::ristretto255_scalar_add($x, $y, true);
}
}
@ -112,8 +124,10 @@ if (!is_callable('sodium_crypto_core_ristretto255_scalar_complement')) {
* @return string
* @throws SodiumException
*/
function sodium_crypto_core_ristretto255_scalar_complement($s)
{
function sodium_crypto_core_ristretto255_scalar_complement(
#[\SensitiveParameter]
$s
) {
return ParagonIE_Sodium_Compat::ristretto255_scalar_complement($s, true);
}
}
@ -125,8 +139,10 @@ if (!is_callable('sodium_crypto_core_ristretto255_scalar_invert')) {
* @return string
* @throws SodiumException
*/
function sodium_crypto_core_ristretto255_scalar_invert($p)
{
function sodium_crypto_core_ristretto255_scalar_invert(
#[\SensitiveParameter]
$p
) {
return ParagonIE_Sodium_Compat::ristretto255_scalar_invert($p, true);
}
}
@ -139,8 +155,12 @@ if (!is_callable('sodium_crypto_core_ristretto255_scalar_mul')) {
* @return string
* @throws SodiumException
*/
function sodium_crypto_core_ristretto255_scalar_mul($x, $y)
{
function sodium_crypto_core_ristretto255_scalar_mul(
#[\SensitiveParameter]
$x,
#[\SensitiveParameter]
$y
) {
return ParagonIE_Sodium_Compat::ristretto255_scalar_mul($x, $y, true);
}
}
@ -152,8 +172,10 @@ if (!is_callable('sodium_crypto_core_ristretto255_scalar_negate')) {
* @return string
* @throws SodiumException
*/
function sodium_crypto_core_ristretto255_scalar_negate($s)
{
function sodium_crypto_core_ristretto255_scalar_negate(
#[\SensitiveParameter]
$s
) {
return ParagonIE_Sodium_Compat::ristretto255_scalar_negate($s, true);
}
}
@ -177,8 +199,10 @@ if (!is_callable('sodium_crypto_core_ristretto255_scalar_reduce')) {
* @return string
* @throws SodiumException
*/
function sodium_crypto_core_ristretto255_scalar_reduce($s)
{
function sodium_crypto_core_ristretto255_scalar_reduce(
#[\SensitiveParameter]
$s
) {
return ParagonIE_Sodium_Compat::ristretto255_scalar_reduce($s, true);
}
}
@ -191,8 +215,12 @@ if (!is_callable('sodium_crypto_core_ristretto255_scalar_sub')) {
* @return string
* @throws SodiumException
*/
function sodium_crypto_core_ristretto255_scalar_sub($x, $y)
{
function sodium_crypto_core_ristretto255_scalar_sub(
#[\SensitiveParameter]
$x,
#[\SensitiveParameter]
$y
) {
return ParagonIE_Sodium_Compat::ristretto255_scalar_sub($x, $y, true);
}
}
@ -205,8 +233,12 @@ if (!is_callable('sodium_crypto_core_ristretto255_sub')) {
* @return string
* @throws SodiumException
*/
function sodium_crypto_core_ristretto255_sub($p, $q)
{
function sodium_crypto_core_ristretto255_sub(
#[\SensitiveParameter]
$p,
#[\SensitiveParameter]
$q
) {
return ParagonIE_Sodium_Compat::ristretto255_sub($p, $q, true);
}
}
@ -219,8 +251,12 @@ if (!is_callable('sodium_crypto_scalarmult_ristretto255')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_scalarmult_ristretto255($n, $p)
{
function sodium_crypto_scalarmult_ristretto255(
#[\SensitiveParameter]
$n,
#[\SensitiveParameter]
$p
) {
return ParagonIE_Sodium_Compat::scalarmult_ristretto255($n, $p, true);
}
}
@ -232,8 +268,10 @@ if (!is_callable('sodium_crypto_scalarmult_ristretto255_base')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_scalarmult_ristretto255_base($n)
{
function sodium_crypto_scalarmult_ristretto255_base(
#[\SensitiveParameter]
$n
) {
return ParagonIE_Sodium_Compat::scalarmult_ristretto255_base($n, true);
}
}

View File

@ -20,8 +20,10 @@ if (!is_callable('\\Sodium\\bin2hex')) {
* @throws \SodiumException
* @throws \TypeError
*/
function bin2hex($string)
{
function bin2hex(
#[\SensitiveParameter]
$string
) {
return ParagonIE_Sodium_Compat::bin2hex($string);
}
}
@ -34,8 +36,12 @@ if (!is_callable('\\Sodium\\compare')) {
* @throws \SodiumException
* @throws \TypeError
*/
function compare($a, $b)
{
function compare(
#[\SensitiveParameter]
$a,
#[\SensitiveParameter]
$b
) {
return ParagonIE_Sodium_Compat::compare($a, $b);
}
}
@ -48,8 +54,13 @@ if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_decrypt')) {
* @param string $key
* @return string|bool
*/
function crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key)
{
function crypto_aead_aes256gcm_decrypt(
$message,
$assocData,
$nonce,
#[\SensitiveParameter]
$key
) {
try {
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key);
} catch (\TypeError $ex) {
@ -70,8 +81,14 @@ if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_encrypt')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key)
{
function crypto_aead_aes256gcm_encrypt(
#[\SensitiveParameter]
$message,
$assocData,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key);
}
}
@ -94,8 +111,13 @@ if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_decrypt')) {
* @param string $key
* @return string|bool
*/
function crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key)
{
function crypto_aead_chacha20poly1305_decrypt(
$message,
$assocData,
$nonce,
#[\SensitiveParameter]
$key
) {
try {
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key);
} catch (\TypeError $ex) {
@ -116,8 +138,14 @@ if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_encrypt')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key)
{
function crypto_aead_chacha20poly1305_encrypt(
#[\SensitiveParameter]
$message,
$assocData,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key);
}
}
@ -130,8 +158,13 @@ if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_decrypt')) {
* @param string $key
* @return string|bool
*/
function crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key)
{
function crypto_aead_chacha20poly1305_ietf_decrypt(
$message,
$assocData,
$nonce,
#[\SensitiveParameter]
$key
) {
try {
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key);
} catch (\TypeError $ex) {
@ -152,8 +185,14 @@ if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_encrypt')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key)
{
function crypto_aead_chacha20poly1305_ietf_encrypt(
#[\SensitiveParameter]
$message,
$assocData,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key);
}
}
@ -166,8 +205,11 @@ if (!is_callable('\\Sodium\\crypto_auth')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_auth($message, $key)
{
function crypto_auth(
$message,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_auth($message, $key);
}
}
@ -181,8 +223,12 @@ if (!is_callable('\\Sodium\\crypto_auth_verify')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_auth_verify($mac, $message, $key)
{
function crypto_auth_verify(
$mac,
$message,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key);
}
}
@ -196,8 +242,13 @@ if (!is_callable('\\Sodium\\crypto_box')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_box($message, $nonce, $kp)
{
function crypto_box(
#[\SensitiveParameter]
$message,
$nonce,
#[\SensitiveParameter]
$kp
) {
return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp);
}
}
@ -222,8 +273,11 @@ if (!is_callable('\\Sodium\\crypto_box_keypair_from_secretkey_and_publickey')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_box_keypair_from_secretkey_and_publickey($sk, $pk)
{
function crypto_box_keypair_from_secretkey_and_publickey(
#[\SensitiveParameter]
$sk,
$pk
) {
return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk);
}
}
@ -235,8 +289,13 @@ if (!is_callable('\\Sodium\\crypto_box_open')) {
* @param string $kp
* @return string|bool
*/
function crypto_box_open($message, $nonce, $kp)
{
function crypto_box_open(
#[\SensitiveParameter]
$message,
$nonce,
#[\SensitiveParameter]
$kp
) {
try {
return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp);
} catch (\TypeError $ex) {
@ -254,8 +313,10 @@ if (!is_callable('\\Sodium\\crypto_box_publickey')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_box_publickey($keypair)
{
function crypto_box_publickey(
#[\SensitiveParameter]
$keypair
) {
return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair);
}
}
@ -267,8 +328,10 @@ if (!is_callable('\\Sodium\\crypto_box_publickey_from_secretkey')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_box_publickey_from_secretkey($sk)
{
function crypto_box_publickey_from_secretkey(
#[\SensitiveParameter]
$sk
) {
return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($sk);
}
}
@ -281,8 +344,11 @@ if (!is_callable('\\Sodium\\crypto_box_seal')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_box_seal($message, $publicKey)
{
function crypto_box_seal(
#[\SensitiveParameter]
$message,
$publicKey
) {
return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey);
}
}
@ -293,8 +359,11 @@ if (!is_callable('\\Sodium\\crypto_box_seal_open')) {
* @param string $kp
* @return string|bool
*/
function crypto_box_seal_open($message, $kp)
{
function crypto_box_seal_open(
$message,
#[\SensitiveParameter]
$kp
) {
try {
return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp);
} catch (\TypeError $ex) {
@ -312,8 +381,10 @@ if (!is_callable('\\Sodium\\crypto_box_secretkey')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_box_secretkey($keypair)
{
function crypto_box_secretkey(
#[\SensitiveParameter]
$keypair
) {
return ParagonIE_Sodium_Compat::crypto_box_secretkey($keypair);
}
}
@ -327,8 +398,12 @@ if (!is_callable('\\Sodium\\crypto_generichash')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_generichash($message, $key = null, $outLen = 32)
{
function crypto_generichash(
$message,
#[\SensitiveParameter]
$key = null,
$outLen = 32
) {
return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $outLen);
}
}
@ -341,8 +416,11 @@ if (!is_callable('\\Sodium\\crypto_generichash_final')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_generichash_final(&$ctx, $outputLength = 32)
{
function crypto_generichash_final(
#[\SensitiveParameter]
&$ctx,
$outputLength = 32
) {
return ParagonIE_Sodium_Compat::crypto_generichash_final($ctx, $outputLength);
}
}
@ -355,8 +433,11 @@ if (!is_callable('\\Sodium\\crypto_generichash_init')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_generichash_init($key = null, $outLen = 32)
{
function crypto_generichash_init(
#[\SensitiveParameter]
$key = null,
$outLen = 32
) {
return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $outLen);
}
}
@ -369,8 +450,11 @@ if (!is_callable('\\Sodium\\crypto_generichash_update')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_generichash_update(&$ctx, $message = '')
{
function crypto_generichash_update(
#[\SensitiveParameter]
&$ctx,
$message = ''
) {
ParagonIE_Sodium_Compat::crypto_generichash_update($ctx, $message);
}
}
@ -385,8 +469,13 @@ if (!is_callable('\\Sodium\\crypto_kx')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_kx($my_secret, $their_public, $client_public, $server_public)
{
function crypto_kx(
#[\SensitiveParameter]
$my_secret,
$their_public,
$client_public,
$server_public
) {
return ParagonIE_Sodium_Compat::crypto_kx(
$my_secret,
$their_public,
@ -408,8 +497,14 @@ if (!is_callable('\\Sodium\\crypto_pwhash')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit)
{
function crypto_pwhash(
$outlen,
#[\SensitiveParameter]
$passwd,
$salt,
$opslimit,
$memlimit
) {
return ParagonIE_Sodium_Compat::crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit);
}
}
@ -423,8 +518,12 @@ if (!is_callable('\\Sodium\\crypto_pwhash_str')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_pwhash_str($passwd, $opslimit, $memlimit)
{
function crypto_pwhash_str(
#[\SensitiveParameter]
$passwd,
$opslimit,
$memlimit
) {
return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit);
}
}
@ -437,8 +536,12 @@ if (!is_callable('\\Sodium\\crypto_pwhash_str_verify')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_pwhash_str_verify($passwd, $hash)
{
function crypto_pwhash_str_verify(
#[\SensitiveParameter]
$passwd,
#[\SensitiveParameter]
$hash
) {
return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash);
}
}
@ -454,8 +557,15 @@ if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit)
{
function crypto_pwhash_scryptsalsa208sha256(
$outlen,
#[\SensitiveParameter]
$passwd,
#[\SensitiveParameter]
$salt,
$opslimit,
$memlimit
) {
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit);
}
}
@ -469,8 +579,12 @@ if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit)
{
function crypto_pwhash_scryptsalsa208sha256_str(
#[\SensitiveParameter]
$passwd,
$opslimit,
$memlimit
) {
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit);
}
}
@ -483,8 +597,12 @@ if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash)
{
function crypto_pwhash_scryptsalsa208sha256_str_verify(
#[\SensitiveParameter]
$passwd,
#[\SensitiveParameter]
$hash
) {
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash);
}
}
@ -497,8 +615,11 @@ if (!is_callable('\\Sodium\\crypto_scalarmult')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_scalarmult($n, $p)
{
function crypto_scalarmult(
#[\SensitiveParameter]
$n,
$p
) {
return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p);
}
}
@ -510,8 +631,10 @@ if (!is_callable('\\Sodium\\crypto_scalarmult_base')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_scalarmult_base($n)
{
function crypto_scalarmult_base(
#[\SensitiveParameter]
$n
) {
return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n);
}
}
@ -525,8 +648,13 @@ if (!is_callable('\\Sodium\\crypto_secretbox')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_secretbox($message, $nonce, $key)
{
function crypto_secretbox(
#[\SensitiveParameter]
$message,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key);
}
}
@ -538,8 +666,12 @@ if (!is_callable('\\Sodium\\crypto_secretbox_open')) {
* @param string $key
* @return string|bool
*/
function crypto_secretbox_open($message, $nonce, $key)
{
function crypto_secretbox_open(
$message,
$nonce,
#[\SensitiveParameter]
$key
) {
try {
return ParagonIE_Sodium_Compat::crypto_secretbox_open($message, $nonce, $key);
} catch (\TypeError $ex) {
@ -558,8 +690,11 @@ if (!is_callable('\\Sodium\\crypto_shorthash')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_shorthash($message, $key = '')
{
function crypto_shorthash(
$message,
#[\SensitiveParameter]
$key = ''
) {
return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key);
}
}
@ -572,8 +707,11 @@ if (!is_callable('\\Sodium\\crypto_sign')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_sign($message, $sk)
{
function crypto_sign(
$message,
#[\SensitiveParameter]
$sk
) {
return ParagonIE_Sodium_Compat::crypto_sign($message, $sk);
}
}
@ -586,8 +724,11 @@ if (!is_callable('\\Sodium\\crypto_sign_detached')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_sign_detached($message, $sk)
{
function crypto_sign_detached(
$message,
#[\SensitiveParameter]
$sk
) {
return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $sk);
}
}
@ -629,8 +770,10 @@ if (!is_callable('\\Sodium\\crypto_sign_publickey')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_sign_publickey($keypair)
{
function crypto_sign_publickey(
#[\SensitiveParameter]
$keypair
) {
return ParagonIE_Sodium_Compat::crypto_sign_publickey($keypair);
}
}
@ -642,8 +785,10 @@ if (!is_callable('\\Sodium\\crypto_sign_publickey_from_secretkey')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_sign_publickey_from_secretkey($sk)
{
function crypto_sign_publickey_from_secretkey(
#[\SensitiveParameter]
$sk
) {
return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($sk);
}
}
@ -655,8 +800,10 @@ if (!is_callable('\\Sodium\\crypto_sign_secretkey')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_sign_secretkey($keypair)
{
function crypto_sign_secretkey(
#[\SensitiveParameter]
$keypair
) {
return ParagonIE_Sodium_Compat::crypto_sign_secretkey($keypair);
}
}
@ -668,8 +815,10 @@ if (!is_callable('\\Sodium\\crypto_sign_seed_keypair')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_sign_seed_keypair($seed)
{
function crypto_sign_seed_keypair(
#[\SensitiveParameter]
$seed
) {
return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed);
}
}
@ -709,8 +858,10 @@ if (!is_callable('\\Sodium\\crypto_sign_ed25519_sk_to_curve25519')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_sign_ed25519_sk_to_curve25519($sk)
{
function crypto_sign_ed25519_sk_to_curve25519(
#[\SensitiveParameter]
$sk
) {
return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($sk);
}
}
@ -724,8 +875,12 @@ if (!is_callable('\\Sodium\\crypto_stream')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_stream($len, $nonce, $key)
{
function crypto_stream(
$len,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_stream($len, $nonce, $key);
}
}
@ -739,8 +894,13 @@ if (!is_callable('\\Sodium\\crypto_stream_xor')) {
* @throws \SodiumException
* @throws \TypeError
*/
function crypto_stream_xor($message, $nonce, $key)
{
function crypto_stream_xor(
#[\SensitiveParameter]
$message,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key);
}
}
@ -752,8 +912,10 @@ if (!is_callable('\\Sodium\\hex2bin')) {
* @throws \SodiumException
* @throws \TypeError
*/
function hex2bin($string)
{
function hex2bin(
#[\SensitiveParameter]
$string
) {
return ParagonIE_Sodium_Compat::hex2bin($string);
}
}
@ -766,8 +928,12 @@ if (!is_callable('\\Sodium\\memcmp')) {
* @throws \SodiumException
* @throws \TypeError
*/
function memcmp($a, $b)
{
function memcmp(
#[\SensitiveParameter]
$a,
#[\SensitiveParameter]
$b
) {
return ParagonIE_Sodium_Compat::memcmp($a, $b);
}
}
@ -783,8 +949,10 @@ if (!is_callable('\\Sodium\\memzero')) {
* @psalm-suppress MissingReturnType
* @psalm-suppress ReferenceConstraintViolation
*/
function memzero(&$str)
{
function memzero(
#[\SensitiveParameter]
&$str
) {
ParagonIE_Sodium_Compat::memzero($str);
}
}

View File

@ -10,8 +10,12 @@ if (!is_callable('sodium_crypto_stream_xchacha20')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_stream_xchacha20($len, $nonce, $key)
{
function sodium_crypto_stream_xchacha20(
$len,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_stream_xchacha20($len, $nonce, $key, true);
}
}
@ -36,8 +40,13 @@ if (!is_callable('sodium_crypto_stream_xchacha20_xor')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_stream_xchacha20_xor($message, $nonce, $key)
{
function sodium_crypto_stream_xchacha20_xor(
#[\SensitiveParameter]
$message,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor($message, $nonce, $key, true);
}
}
@ -52,8 +61,14 @@ if (!is_callable('sodium_crypto_stream_xchacha20_xor_ic')) {
* @throws SodiumException
* @throws TypeError
*/
function sodium_crypto_stream_xchacha20_xor_ic($message, $nonce, $counter, $key)
{
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);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,213 +0,0 @@
<?php
/**
* Class ParagonIE_Sodium_Core_Base64
*
* Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
* Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
*
* We have to copy/paste the contents into the variant files because PHP 5.2
* doesn't support late static binding, and we have no better workaround
* available that won't break PHP 7+. Therefore, we're forced to duplicate code.
*/
abstract class ParagonIE_Sodium_Core_Base64_Common
{
/**
* Encode into Base64
*
* Base64 character set "[A-Z][a-z][0-9]+/"
*
* @param string $src
* @return string
* @throws TypeError
*/
public static function encode($src)
{
return self::doEncode($src, true);
}
/**
* Encode into Base64, no = padding
*
* Base64 character set "[A-Z][a-z][0-9]+/"
*
* @param string $src
* @return string
* @throws TypeError
*/
public static function encodeUnpadded($src)
{
return self::doEncode($src, false);
}
/**
* @param string $src
* @param bool $pad Include = padding?
* @return string
* @throws TypeError
*/
protected static function doEncode($src, $pad = true)
{
$dest = '';
$srcLen = ParagonIE_Sodium_Core_Util::strlen($src);
// Main loop (no padding):
for ($i = 0; $i + 3 <= $srcLen; $i += 3) {
/** @var array<int, int> $chunk */
$chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, 3));
$b0 = $chunk[1];
$b1 = $chunk[2];
$b2 = $chunk[3];
$dest .=
self::encode6Bits( $b0 >> 2 ) .
self::encode6Bits((($b0 << 4) | ($b1 >> 4)) & 63) .
self::encode6Bits((($b1 << 2) | ($b2 >> 6)) & 63) .
self::encode6Bits( $b2 & 63);
}
// The last chunk, which may have padding:
if ($i < $srcLen) {
/** @var array<int, int> $chunk */
$chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, $srcLen - $i));
$b0 = $chunk[1];
if ($i + 1 < $srcLen) {
$b1 = $chunk[2];
$dest .=
self::encode6Bits($b0 >> 2) .
self::encode6Bits((($b0 << 4) | ($b1 >> 4)) & 63) .
self::encode6Bits(($b1 << 2) & 63);
if ($pad) {
$dest .= '=';
}
} else {
$dest .=
self::encode6Bits( $b0 >> 2) .
self::encode6Bits(($b0 << 4) & 63);
if ($pad) {
$dest .= '==';
}
}
}
return $dest;
}
/**
* decode from base64 into binary
*
* Base64 character set "./[A-Z][a-z][0-9]"
*
* @param string $src
* @param bool $strictPadding
* @return string
* @throws RangeException
* @throws TypeError
* @psalm-suppress RedundantCondition
*/
public static function decode($src, $strictPadding = false)
{
// Remove padding
$srcLen = ParagonIE_Sodium_Core_Util::strlen($src);
if ($srcLen === 0) {
return '';
}
if ($strictPadding) {
if (($srcLen & 3) === 0) {
if ($src[$srcLen - 1] === '=') {
$srcLen--;
if ($src[$srcLen - 1] === '=') {
$srcLen--;
}
}
}
if (($srcLen & 3) === 1) {
throw new RangeException(
'Incorrect padding'
);
}
if ($src[$srcLen - 1] === '=') {
throw new RangeException(
'Incorrect padding'
);
}
} else {
$src = rtrim($src, '=');
$srcLen = ParagonIE_Sodium_Core_Util::strlen($src);
}
$err = 0;
$dest = '';
// Main loop (no padding):
for ($i = 0; $i + 4 <= $srcLen; $i += 4) {
/** @var array<int, int> $chunk */
$chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, 4));
$c0 = self::decode6Bits($chunk[1]);
$c1 = self::decode6Bits($chunk[2]);
$c2 = self::decode6Bits($chunk[3]);
$c3 = self::decode6Bits($chunk[4]);
$dest .= pack(
'CCC',
((($c0 << 2) | ($c1 >> 4)) & 0xff),
((($c1 << 4) | ($c2 >> 2)) & 0xff),
((($c2 << 6) | $c3 ) & 0xff)
);
$err |= ($c0 | $c1 | $c2 | $c3) >> 8;
}
// The last chunk, which may have padding:
if ($i < $srcLen) {
/** @var array<int, int> $chunk */
$chunk = unpack('C*', ParagonIE_Sodium_Core_Util::substr($src, $i, $srcLen - $i));
$c0 = self::decode6Bits($chunk[1]);
if ($i + 2 < $srcLen) {
$c1 = self::decode6Bits($chunk[2]);
$c2 = self::decode6Bits($chunk[3]);
$dest .= pack(
'CC',
((($c0 << 2) | ($c1 >> 4)) & 0xff),
((($c1 << 4) | ($c2 >> 2)) & 0xff)
);
$err |= ($c0 | $c1 | $c2) >> 8;
} elseif ($i + 1 < $srcLen) {
$c1 = self::decode6Bits($chunk[2]);
$dest .= pack(
'C',
((($c0 << 2) | ($c1 >> 4)) & 0xff)
);
$err |= ($c0 | $c1) >> 8;
} elseif ($i < $srcLen && $strictPadding) {
$err |= 1;
}
}
/** @var bool $check */
$check = ($err === 0);
if (!$check) {
throw new RangeException(
'Base64::decode() only expects characters in the correct base64 alphabet'
);
}
return $dest;
}
/**
* Uses bitwise operators instead of table-lookups to turn 6-bit integers
* into 8-bit integers.
*
* Base64 character set:
* [A-Z] [a-z] [0-9] + /
* 0x41-0x5a, 0x61-0x7a, 0x30-0x39, 0x2b, 0x2f
*
* @param int $src
* @return int
*/
abstract protected static function decode6Bits($src);
/**
* Uses bitwise operators instead of table-lookups to turn 8-bit integers
* into 6-bit integers.
*
* @param int $src
* @return string
*/
abstract protected static function encode6Bits($src);
}

View File

@ -40,26 +40,38 @@ class ParagonIE_Sodium_Core_Curve25519_Ge_Cached
* @param ParagonIE_Sodium_Core_Curve25519_Fe|null $T2d
*/
public function __construct(
ParagonIE_Sodium_Core_Curve25519_Fe $YplusX = null,
ParagonIE_Sodium_Core_Curve25519_Fe $YminusX = null,
ParagonIE_Sodium_Core_Curve25519_Fe $Z = null,
ParagonIE_Sodium_Core_Curve25519_Fe $T2d = null
$YplusX = null,
$YminusX = null,
$Z = null,
$T2d = null
) {
if ($YplusX === null) {
$YplusX = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($YplusX instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 1 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->YplusX = $YplusX;
if ($YminusX === null) {
$YminusX = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($YminusX instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 2 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->YminusX = $YminusX;
if ($Z === null) {
$Z = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($Z instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 3 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->Z = $Z;
if ($T2d === null) {
$T2d = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($T2d instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 4 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->T2d = $T2d;
}
}

View File

@ -39,26 +39,38 @@ class ParagonIE_Sodium_Core_Curve25519_Ge_P1p1
* @param ParagonIE_Sodium_Core_Curve25519_Fe|null $t
*/
public function __construct(
ParagonIE_Sodium_Core_Curve25519_Fe $x = null,
ParagonIE_Sodium_Core_Curve25519_Fe $y = null,
ParagonIE_Sodium_Core_Curve25519_Fe $z = null,
ParagonIE_Sodium_Core_Curve25519_Fe $t = null
$x = null,
$y = null,
$z = null,
$t = null
) {
if ($x === null) {
$x = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($x instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 1 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->X = $x;
if ($y === null) {
$y = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($y instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 2 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->Y = $y;
if ($z === null) {
$z = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($z instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 3 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->Z = $z;
if ($t === null) {
$t = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($t instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 4 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->T = $t;
}
}

View File

@ -34,21 +34,30 @@ class ParagonIE_Sodium_Core_Curve25519_Ge_P2
* @param ParagonIE_Sodium_Core_Curve25519_Fe|null $z
*/
public function __construct(
ParagonIE_Sodium_Core_Curve25519_Fe $x = null,
ParagonIE_Sodium_Core_Curve25519_Fe $y = null,
ParagonIE_Sodium_Core_Curve25519_Fe $z = null
$x = null,
$y = null,
$z = null
) {
if ($x === null) {
$x = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($x instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 1 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->X = $x;
if ($y === null) {
$y = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($y instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 2 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->Y = $y;
if ($z === null) {
$z = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($z instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 3 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->Z = $z;
}
}

View File

@ -40,26 +40,38 @@ class ParagonIE_Sodium_Core_Curve25519_Ge_P3
* @param ParagonIE_Sodium_Core_Curve25519_Fe|null $t
*/
public function __construct(
ParagonIE_Sodium_Core_Curve25519_Fe $x = null,
ParagonIE_Sodium_Core_Curve25519_Fe $y = null,
ParagonIE_Sodium_Core_Curve25519_Fe $z = null,
ParagonIE_Sodium_Core_Curve25519_Fe $t = null
$x = null,
$y = null,
$z = null,
$t = null
) {
if ($x === null) {
$x = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($x instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 1 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->X = $x;
if ($y === null) {
$y = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($y instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 2 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->Y = $y;
if ($z === null) {
$z = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($z instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 3 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->Z = $z;
if ($t === null) {
$t = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($t instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 4 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->T = $t;
}
}

View File

@ -34,21 +34,30 @@ class ParagonIE_Sodium_Core_Curve25519_Ge_Precomp
* @param ParagonIE_Sodium_Core_Curve25519_Fe $xy2d
*/
public function __construct(
ParagonIE_Sodium_Core_Curve25519_Fe $yplusx = null,
ParagonIE_Sodium_Core_Curve25519_Fe $yminusx = null,
ParagonIE_Sodium_Core_Curve25519_Fe $xy2d = null
$yplusx = null,
$yminusx = null,
$xy2d = null
) {
if ($yplusx === null) {
$yplusx = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($yplusx instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 1 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->yplusx = $yplusx;
if ($yminusx === null) {
$yminusx = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($yminusx instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 2 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->yminusx = $yminusx;
if ($xy2d === null) {
$xy2d = new ParagonIE_Sodium_Core_Curve25519_Fe();
}
if (!($xy2d instanceof ParagonIE_Sodium_Core_Curve25519_Fe)) {
throw new TypeError('Argument 3 must be an instance of ParagonIE_Sodium_Core_Curve25519_Fe');
}
$this->xy2d = $xy2d;
}
}

View File

@ -9,6 +9,8 @@ if (class_exists('ParagonIE_Sodium_Core_Util', false)) {
*/
abstract class ParagonIE_Sodium_Core_Util
{
const U32_MAX = 0xFFFFFFFF;
/**
* @param int $integer
* @param int $size (16, 32, 64)
@ -33,6 +35,28 @@ abstract class ParagonIE_Sodium_Core_Util
);
}
/**
* @param string $a
* @param string $b
* @return string
* @throws SodiumException
*/
public static function andStrings($a, $b)
{
/* Type checks: */
if (!is_string($a)) {
throw new TypeError('Argument 1 must be a string');
}
if (!is_string($b)) {
throw new TypeError('Argument 2 must be a string');
}
$len = self::strlen($a);
if (self::strlen($b) !== $len) {
throw new SodiumException('Both strings must be of equal length to combine with bitwise AND');
}
return $a & $b;
}
/**
* Convert a binary string into a hexadecimal string without cache-timing
* leaks

View File

@ -25,8 +25,13 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
* @throws SodiumException
* @throws TypeError
*/
public static function box($inputFile, $outputFile, $nonce, $keyPair)
{
public static function box(
$inputFile,
$outputFile,
$nonce,
#[\SensitiveParameter]
$keyPair
) {
/* Type checks: */
if (!is_string($inputFile)) {
throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
@ -91,8 +96,13 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
* @throws SodiumException
* @throws TypeError
*/
public static function box_open($inputFile, $outputFile, $nonce, $keypair)
{
public static function box_open(
$inputFile,
$outputFile,
$nonce,
#[\SensitiveParameter]
$keypair
) {
/* Type checks: */
if (!is_string($inputFile)) {
throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
@ -161,8 +171,12 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
* @throws SodiumException
* @throws TypeError
*/
public static function box_seal($inputFile, $outputFile, $publicKey)
{
public static function box_seal(
$inputFile,
$outputFile,
#[\SensitiveParameter]
$publicKey
) {
/* Type checks: */
if (!is_string($inputFile)) {
throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
@ -265,8 +279,12 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
* @throws SodiumException
* @throws TypeError
*/
public static function box_seal_open($inputFile, $outputFile, $ecdhKeypair)
{
public static function box_seal_open(
$inputFile,
$outputFile,
#[\SensitiveParameter]
$ecdhKeypair
) {
/* Type checks: */
if (!is_string($inputFile)) {
throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
@ -350,8 +368,12 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
* @throws TypeError
* @psalm-suppress FailedTypeResolution
*/
public static function generichash($filePath, $key = '', $outputLength = 32)
{
public static function generichash(
$filePath,
#[\SensitiveParameter]
$key = '',
$outputLength = 32
) {
/* Type checks: */
if (!is_string($filePath)) {
throw new TypeError('Argument 1 must be a string, ' . gettype($filePath) . ' given.');
@ -428,8 +450,13 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
* @throws SodiumException
* @throws TypeError
*/
public static function secretbox($inputFile, $outputFile, $nonce, $key)
{
public static function secretbox(
$inputFile,
$outputFile,
$nonce,
#[\SensitiveParameter]
$key
) {
/* Type checks: */
if (!is_string($inputFile)) {
throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given..');
@ -493,8 +520,13 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
* @throws SodiumException
* @throws TypeError
*/
public static function secretbox_open($inputFile, $outputFile, $nonce, $key)
{
public static function secretbox_open(
$inputFile,
$outputFile,
$nonce,
#[\SensitiveParameter]
$key
) {
/* Type checks: */
if (!is_string($inputFile)) {
throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
@ -560,8 +592,11 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
* @throws SodiumException
* @throws TypeError
*/
public static function sign($filePath, $secretKey)
{
public static function sign(
$filePath,
#[\SensitiveParameter]
$secretKey
) {
/* Type checks: */
if (!is_string($filePath)) {
throw new TypeError('Argument 1 must be a string, ' . gettype($filePath) . ' given.');
@ -656,8 +691,11 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
* @throws TypeError
* @throws Exception
*/
public static function verify($sig, $filePath, $publicKey)
{
public static function verify(
$sig,
$filePath,
$publicKey
) {
/* Type checks: */
if (!is_string($sig)) {
throw new TypeError('Argument 1 must be a string, ' . gettype($sig) . ' given.');

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-alpha-58750';
$wp_version = '6.7-alpha-58752';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.