changes for filter and print

This commit is contained in:
2024-09-29 16:59:27 +05:45
parent 497f567cba
commit 684e01bf48
1335 changed files with 38709 additions and 74987 deletions

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);
}
}
@ -1360,9 +1582,13 @@ if (!is_callable('sodium_memzero')) {
* @return void
* @throws SodiumException
* @throws TypeError
*
* @psalm-suppress ReferenceConstraintViolation
*/
function sodium_memzero(&$string)
{
function sodium_memzero(
#[\SensitiveParameter]
&$string
) {
ParagonIE_Sodium_Compat::memzero($string);
}
}
@ -1375,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);
}
}
@ -1389,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

@ -0,0 +1,130 @@
<?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')) {
/**
* @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(
$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]
$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(
$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]
$message,
$additional_data,
$nonce,
#[\SensitiveParameter]
$key
) {
return ParagonIE_Sodium_Compat::crypto_aead_aegis256_encrypt(
$message,
$additional_data,
$nonce,
$key
);
}
}

View File

@ -0,0 +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_AEGIS256_KEYBYTES = 32;
const SODIUM_CRYPTO_AEAD_AEGIS256_NSECBYTES = 0;
const SODIUM_CRYPTO_AEAD_AEGIS256_NPUBBYTES = 32;
const SODIUM_CRYPTO_AEAD_AEGIS256_ABYTES = 32;

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);
}
}