ParagonIE_Sodium_Crypto32
- Source
wp-includes/sodium_compat/src/Crypto32.php:15
Class ParagonIE_Sodium_Crypto
Description
ATTENTION!
If you are using this library, you should be using ParagonIE_Sodium_Compat in your code, not this class.
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).
Methods · 41
- aead_chacha20poly1305_decrypt()AEAD Decryption with ChaCha20-Poly1305
- aead_chacha20poly1305_encrypt()AEAD Encryption with ChaCha20-Poly1305
- aead_chacha20poly1305_ietf_decrypt()AEAD Decryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
- aead_chacha20poly1305_ietf_encrypt()AEAD Encryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
- aead_xchacha20poly1305_ietf_decrypt()AEAD Decryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
- aead_xchacha20poly1305_ietf_encrypt()AEAD Encryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
- auth()HMAC-SHA-512-256 (a.k.a. the leftmost 256 bits of HMAC-SHA-512)
- auth_verify()HMAC-SHA-512-256 validation. Constant-time via hash_equals().
- box()X25519 key exchange followed by XSalsa20Poly1305 symmetric encryption
- box_seal()X25519-XSalsa20-Poly1305 with one ephemeral X25519 keypair.
- box_seal_open()Opens a message encrypted via box_seal().
- box_beforenm()Used by crypto_box() to get the crypto_secretbox() key.
- box_keypair()
- box_seed_keypair()
- box_keypair_from_secretkey_and_publickey()
- box_secretkey()
- box_publickey()
- box_publickey_from_secretkey()
- box_open()Decrypt a message encrypted with box().
- generichash()Calculate a BLAKE2b hash.
- generichash_final()Finalize a BLAKE2b hashing context, returning the hash.
- generichash_init()Initialize a hashing context for BLAKE2b.
- generichash_init_salt_personal()Initialize a hashing context for BLAKE2b.
- generichash_update()Update a hashing context for BLAKE2b with $message
- keyExchange()Libsodium's crypto_kx().
- scalarmult()ECDH over Curve25519
- scalarmult_base()ECDH over Curve25519, using the basepoint.
- scalarmult_throw_if_zero()This throws an Error if a zero public key was passed to the function.
- secretbox()XSalsa20-Poly1305 authenticated symmetric-key encryption.
- secretbox_open()Decrypt a ciphertext generated via secretbox().
- secretbox_xchacha20poly1305()XChaCha20-Poly1305 authenticated symmetric-key encryption.
- secretbox_xchacha20poly1305_open()Decrypt a ciphertext generated via secretbox_xchacha20poly1305().
- secretstream_xchacha20poly1305_init_push()
- secretstream_xchacha20poly1305_init_pull()
- secretstream_xchacha20poly1305_push()
- secretstream_xchacha20poly1305_pull()
- secretstream_xchacha20poly1305_rekey()
- sign_detached()Detached Ed25519 signature.
- sign()Attached Ed25519 signature. (Returns a signed message.)
- sign_open()Opens a signed message. If valid, returns the message.
- sign_verify_detached()Verify a detached signature of a given message and public key.
Source code
abstract class ParagonIE_Sodium_Crypto32{ const aead_chacha20poly1305_KEYBYTES = 32; const aead_chacha20poly1305_NSECBYTES = 0; const aead_chacha20poly1305_NPUBBYTES = 8; const aead_chacha20poly1305_ABYTES = 16; const aead_chacha20poly1305_IETF_KEYBYTES = 32; const aead_chacha20poly1305_IETF_NSECBYTES = 0; const aead_chacha20poly1305_IETF_NPUBBYTES = 12; const aead_chacha20poly1305_IETF_ABYTES = 16; const aead_xchacha20poly1305_IETF_KEYBYTES = 32; const aead_xchacha20poly1305_IETF_NSECBYTES = 0; const aead_xchacha20poly1305_IETF_NPUBBYTES = 24; const aead_xchacha20poly1305_IETF_ABYTES = 16; const box_curve25519xsalsa20poly1305_SEEDBYTES = 32; const box_curve25519xsalsa20poly1305_PUBLICKEYBYTES = 32; const box_curve25519xsalsa20poly1305_SECRETKEYBYTES = 32; const box_curve25519xsalsa20poly1305_BEFORENMBYTES = 32; const box_curve25519xsalsa20poly1305_NONCEBYTES = 24; const box_curve25519xsalsa20poly1305_MACBYTES = 16; const box_curve25519xsalsa20poly1305_BOXZEROBYTES = 16; const box_curve25519xsalsa20poly1305_ZEROBYTES = 32; const onetimeauth_poly1305_BYTES = 16; const onetimeauth_poly1305_KEYBYTES = 32; const secretbox_xsalsa20poly1305_KEYBYTES = 32; const secretbox_xsalsa20poly1305_NONCEBYTES = 24; const secretbox_xsalsa20poly1305_MACBYTES = 16; const secretbox_xsalsa20poly1305_BOXZEROBYTES = 16; const secretbox_xsalsa20poly1305_ZEROBYTES = 32; const secretbox_xchacha20poly1305_KEYBYTES = 32; const secretbox_xchacha20poly1305_NONCEBYTES = 24; const secretbox_xchacha20poly1305_MACBYTES = 16; const secretbox_xchacha20poly1305_BOXZEROBYTES = 16; const secretbox_xchacha20poly1305_ZEROBYTES = 32; const stream_salsa20_KEYBYTES = 32; /** * AEAD Decryption with ChaCha20-Poly1305 * * @internal Do not use this directly. Use ParagonIE_Sodium_Compat. * * @param string $message * @param string $ad * @param string $nonce * @param string $key * @return string * @throws SodiumException * @throws TypeError */ public static function aead_chacha20poly1305_decrypt( $message = '', $ad = '', $nonce = '', $key = '' ) { /** @var int $len - Length of message (ciphertext + MAC) */ $len = ParagonIE_Sodium_Core32_Util::strlen($message); /** @var int $clen - Length of ciphertext */ $clen = $len - self::aead_chacha20poly1305_ABYTES; /** @var int $adlen - Length of associated data */ $adlen = ParagonIE_Sodium_Core32_Util::strlen($ad); /** @var string $mac - Message authentication code */ $mac = ParagonIE_Sodium_Core32_Util::substr( $message, $clen, self::aead_chacha20poly1305_ABYTES ); /** @var string $ciphertext - The encrypted message (sans MAC) */ $ciphertext = ParagonIE_Sodium_Core32_Util::substr($message, 0, $clen);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/Crypto32.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.