ParagonIE_Sodium_Compat
- Source
wp-includes/sodium_compat/src/Compat.php:31
Compatibility
- WordPress
- core
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Properties · 2
$disableFallbackForUnitTestsboolpublic static- This parameter prevents the use of the PECL extension.
$fastMultboolpublic static- Use fast multiplication rather than our constant-time multiplication implementation. Can be enabled at runtime. Only enable this if you are absolutely certain that there is no timing leak on your platform.
Methods · 128
- add()Add two numbers (little-endian unsigned), storing the value in the first parameter.
- base642bin()
- bin2base64()
- bin2hex()Cache-timing-safe implementation of bin2hex().
- compare()Compare two strings, in constant-time.
- crypto_aead_aegis128l_decrypt()Authenticated Encryption with Associated Data: Decryption
- crypto_aead_aegis128l_encrypt()Authenticated Encryption with Associated Data: Encryption
- crypto_aead_aegis128l_keygen()Return a secure random key for use with the AEGIS-128L symmetric AEAD interface.
- crypto_aead_aegis256_decrypt()Authenticated Encryption with Associated Data: Decryption
- crypto_aead_aegis256_encrypt()Authenticated Encryption with Associated Data: Encryption
- crypto_aead_aegis256_keygen()Return a secure random key for use with the AEGIS-256 symmetric AEAD interface.
- crypto_aead_aes256gcm_is_available()Is AES-256-GCM even available to use?
- crypto_aead_aes256gcm_decrypt()Authenticated Encryption with Associated Data: Decryption
- crypto_aead_aes256gcm_encrypt()Authenticated Encryption with Associated Data: Encryption
- crypto_aead_aes256gcm_keygen()Return a secure random key for use with the AES-256-GCM symmetric AEAD interface.
- crypto_aead_chacha20poly1305_decrypt()Authenticated Encryption with Associated Data: Decryption
- crypto_aead_chacha20poly1305_encrypt()Authenticated Encryption with Associated Data
- crypto_aead_chacha20poly1305_ietf_decrypt()Authenticated Encryption with Associated Data: Decryption
- crypto_aead_chacha20poly1305_keygen()Return a secure random key for use with the ChaCha20-Poly1305 symmetric AEAD interface.
- crypto_aead_chacha20poly1305_ietf_encrypt()Authenticated Encryption with Associated Data
- crypto_aead_chacha20poly1305_ietf_keygen()Return a secure random key for use with the ChaCha20-Poly1305 symmetric AEAD interface. (IETF version)
- crypto_aead_xchacha20poly1305_ietf_decrypt()Authenticated Encryption with Associated Data: Decryption
- crypto_aead_xchacha20poly1305_ietf_encrypt()Authenticated Encryption with Associated Data
- crypto_aead_xchacha20poly1305_ietf_keygen()Return a secure random key for use with the XChaCha20-Poly1305 symmetric AEAD interface.
- crypto_auth()Authenticate a message. Uses symmetric-key cryptography.
- crypto_auth_keygen()
- crypto_auth_verify()Verify the MAC of a message previously authenticated with crypto_auth.
- crypto_box()Authenticated asymmetric-key encryption. Both the sender and recipient may decrypt messages.
- crypto_box_seal()Anonymous public-key encryption. Only the recipient may decrypt messages.
- crypto_box_seal_open()Opens a message encrypted with crypto_box_seal(). Requires the recipient's keypair (sk || pk) to decrypt successfully.
- crypto_box_keypair()Generate a new random X25519 keypair.
- crypto_box_keypair_from_secretkey_and_publickey()Combine two keys into a keypair for use in library methods that expect a keypair. This doesn't necessarily have to be the same person's keys.
- crypto_box_open()Decrypt a message previously encrypted with crypto_box().
- crypto_box_publickey()Extract the public key from a crypto_box keypair.
- crypto_box_publickey_from_secretkey()Calculate the X25519 public key from a given X25519 secret key.
- crypto_box_secretkey()Extract the secret key from a crypto_box keypair.
- crypto_box_seed_keypair()Generate an X25519 keypair from a seed.
- crypto_generichash()Calculates a BLAKE2b hash, with an optional key.
- crypto_generichash_final()Get the final BLAKE2b hash output for a given context.
- crypto_generichash_init()Initialize a BLAKE2b hashing context, for use in a streaming interface.
- crypto_generichash_init_salt_personal()Initialize a BLAKE2b hashing context, for use in a streaming interface.
- crypto_generichash_update()Update a BLAKE2b hashing context with additional data.
- crypto_generichash_keygen()
- crypto_kdf_derive_from_key()
- crypto_kdf_keygen()
- crypto_kx()Perform a key exchange, between a designated client and a server.
- crypto_kx_seed_keypair()
- crypto_kx_keypair()
- crypto_kx_client_session_keys()
- crypto_kx_server_session_keys()
- crypto_kx_secretkey()
- crypto_kx_publickey()
- crypto_pwhash()
- crypto_pwhash_is_available()!Exclusive to sodium_compat!
- crypto_pwhash_str()
- crypto_pwhash_str_needs_rehash()Do we need to rehash this password?
- crypto_pwhash_str_verify()
- crypto_pwhash_scryptsalsa208sha256()
- crypto_pwhash_scryptsalsa208sha256_is_available()!Exclusive to sodium_compat!
- crypto_pwhash_scryptsalsa208sha256_str()
- crypto_pwhash_scryptsalsa208sha256_str_verify()
- crypto_scalarmult()Calculate the shared secret between your secret key and your recipient's public key.
- crypto_scalarmult_base()Calculate an X25519 public key from an X25519 secret key.
- crypto_secretbox()Authenticated symmetric-key encryption.
- crypto_secretbox_open()Decrypts a message previously encrypted with crypto_secretbox().
- crypto_secretbox_keygen()Return a secure random key for use with crypto_secretbox
- crypto_secretbox_xchacha20poly1305()Authenticated symmetric-key encryption.
- crypto_secretbox_xchacha20poly1305_open()Decrypts a message previously encrypted with crypto_secretbox_xchacha20poly1305().
- crypto_secretstream_xchacha20poly1305_init_push()
- crypto_secretstream_xchacha20poly1305_init_pull()
- crypto_secretstream_xchacha20poly1305_push()
- crypto_secretstream_xchacha20poly1305_pull()
- crypto_secretstream_xchacha20poly1305_keygen()
- crypto_secretstream_xchacha20poly1305_rekey()
- crypto_shorthash()Calculates a SipHash-2-4 hash of a message for a given key.
- crypto_shorthash_keygen()Return a secure random key for use with crypto_shorthash
- crypto_sign()Returns a signed message. You probably want crypto_sign_detached() instead, which only returns the signature.
- crypto_sign_open()Validates a signed message then returns the message.
- crypto_sign_keypair()Generate a new random Ed25519 keypair.
- crypto_sign_keypair_from_secretkey_and_publickey()
- crypto_sign_seed_keypair()Generate an Ed25519 keypair from a seed.
- crypto_sign_publickey()Extract an Ed25519 public key from an Ed25519 keypair.
- crypto_sign_publickey_from_secretkey()Calculate an Ed25519 public key from an Ed25519 secret key.
- crypto_sign_secretkey()Extract an Ed25519 secret key from an Ed25519 keypair.
- crypto_sign_detached()Calculate the Ed25519 signature of a message and return ONLY the signature.
- crypto_sign_verify_detached()Verify the Ed25519 signature of a message.
- crypto_sign_ed25519_pk_to_curve25519()Convert an Ed25519 public key to a Curve25519 public key
- crypto_sign_ed25519_sk_to_curve25519()Convert an Ed25519 secret key to a Curve25519 secret key
- crypto_stream()Expand a key and nonce into a keystream of pseudorandom bytes.
- crypto_stream_xor()DANGER! UNAUTHENTICATED ENCRYPTION!
- crypto_stream_keygen()Return a secure random key for use with crypto_stream
- crypto_stream_xchacha20()Expand a key and nonce into a keystream of pseudorandom bytes.
- crypto_stream_xchacha20_xor()DANGER! UNAUTHENTICATED ENCRYPTION!
- crypto_stream_xchacha20_xor_ic()DANGER! UNAUTHENTICATED ENCRYPTION!
- crypto_stream_xchacha20_keygen()Return a secure random key for use with crypto_stream_xchacha20
- hex2bin()Cache-timing-safe implementation of hex2bin().
- increment()Increase a string (little endian)
- is_zero()
- library_version_major()The equivalent to the libsodium minor version we aim to be compatible with (sans pwhash and memzero).
- library_version_minor()The equivalent to the libsodium minor version we aim to be compatible with (sans pwhash and memzero).
- memcmp()Compare two strings.
- memzero()It's actually not possible to zero memory buffers in PHP. You need the native library for that.
- pad()
- unpad()
- polyfill_is_fast()Will sodium_compat run fast on the current hardware and PHP configuration?
- randombytes_buf()Generate a string of bytes from the kernel's CSPRNG.
- randombytes_uniform()Generate an integer between 0 and $range (non-inclusive).
- randombytes_random16()Generate a random 16-bit integer.
- ristretto255_is_valid_point()
- ristretto255_add()
- ristretto255_sub()
- ristretto255_from_hash()
- ristretto255_random()
- ristretto255_scalar_random()
- ristretto255_scalar_invert()
- ristretto255_scalar_negate()
- ristretto255_scalar_complement()
- ristretto255_scalar_add()
- ristretto255_scalar_sub()
- ristretto255_scalar_mul()
- scalarmult_ristretto255()
- scalarmult_ristretto255_base()
- ristretto255_scalar_reduce()
- runtime_speed_test()Runtime testing method for 32-bit platforms.
- sub()Add two numbers (little-endian unsigned), storing the value in the first parameter.
- version_string()This emulates libsodium's version_string() function, except ours is prefixed with 'polyfill-'.
- use_fallback()Should we use the libsodium core function instead? This is always a good idea, if it's available. (Unless we're in the middle of running our unit test suite.)
- useNewSodiumAPI()Libsodium as implemented in PHP 7.2 and/or ext/sodium (via PECL)
Source code
class ParagonIE_Sodium_Compat{ /** * This parameter prevents the use of the PECL extension. * It should only be used for unit testing. * * @var bool */ public static $disableFallbackForUnitTests = false; /** * Use fast multiplication rather than our constant-time multiplication * implementation. Can be enabled at runtime. Only enable this if you * are absolutely certain that there is no timing leak on your platform. * * @var bool */ public static $fastMult = false; const LIBRARY_MAJOR_VERSION = 9; const LIBRARY_MINOR_VERSION = 1; const LIBRARY_VERSION_MAJOR = 9; const LIBRARY_VERSION_MINOR = 1; const VERSION_STRING = 'polyfill-1.0.8'; // From libsodium const BASE64_VARIANT_ORIGINAL = 1; const BASE64_VARIANT_ORIGINAL_NO_PADDING = 3; const BASE64_VARIANT_URLSAFE = 5; const BASE64_VARIANT_URLSAFE_NO_PADDING = 7; const CRYPTO_AEAD_AES256GCM_KEYBYTES = 32; const CRYPTO_AEAD_AES256GCM_NSECBYTES = 0; const CRYPTO_AEAD_AES256GCM_NPUBBYTES = 12; const CRYPTO_AEAD_AES256GCM_ABYTES = 16; const CRYPTO_AEAD_AEGIS128L_KEYBYTES = 16; const CRYPTO_AEAD_AEGIS128L_NSECBYTES = 0; const CRYPTO_AEAD_AEGIS128L_NPUBBYTES = 16; const CRYPTO_AEAD_AEGIS128L_ABYTES = 32; const CRYPTO_AEAD_AEGIS256_KEYBYTES = 32; const CRYPTO_AEAD_AEGIS256_NSECBYTES = 0; const CRYPTO_AEAD_AEGIS256_NPUBBYTES = 32; const CRYPTO_AEAD_AEGIS256_ABYTES = 32; const CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES = 32; const CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES = 0; const CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES = 8; const CRYPTO_AEAD_CHACHA20POLY1305_ABYTES = 16; const CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES = 32; const CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES = 0; const CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES = 12; const CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES = 16; const CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES = 32; const CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NSECBYTES = 0; const CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES = 24; const CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES = 16; const CRYPTO_AUTH_BYTES = 32; const CRYPTO_AUTH_KEYBYTES = 32; const CRYPTO_BOX_SEALBYTES = 16; const CRYPTO_BOX_SECRETKEYBYTES = 32; const CRYPTO_BOX_PUBLICKEYBYTES = 32; const CRYPTO_BOX_KEYPAIRBYTES = 64; const CRYPTO_BOX_MACBYTES = 16; const CRYPTO_BOX_NONCEBYTES = 24; const CRYPTO_BOX_SEEDBYTES = 32; const CRYPTO_CORE_RISTRETTO255_BYTES = 32; const CRYPTO_CORE_RISTRETTO255_SCALARBYTES = 32; const CRYPTO_CORE_RISTRETTO255_HASHBYTES = 64; const CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES = 64; const CRYPTO_KDF_BYTES_MIN = 16; const CRYPTO_KDF_BYTES_MAX = 64; const CRYPTO_KDF_CONTEXTBYTES = 8; const CRYPTO_KDF_KEYBYTES = 32; const CRYPTO_KX_BYTES = 32; const CRYPTO_KX_PRIMITIVE = 'x25519blake2b'; const CRYPTO_KX_SEEDBYTES = 32; const CRYPTO_KX_KEYPAIRBYTES = 64; const CRYPTO_KX_PUBLICKEYBYTES = 32; const CRYPTO_KX_SECRETKEYBYTES = 32; const CRYPTO_KX_SESSIONKEYBYTES = 32; const CRYPTO_GENERICHASH_BYTES = 32; const CRYPTO_GENERICHASH_BYTES_MIN = 16;Changelog
Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/sodium_compat/src/Compat.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.