ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_init_push() public WP 1.0
{} It's a method of the class: ParagonIE_Sodium_Crypto{}
No Hooks.
Return
Array
Usage
$result = ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_init_push( $key );
- $key(string) (required)
- -
Code of ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_init_push() ParagonIE Sodium Crypto::secretstream xchacha20poly1305 init push WP 5.7
public static function secretstream_xchacha20poly1305_init_push($key)
{
# randombytes_buf(out, crypto_secretstream_xchacha20poly1305_HEADERBYTES);
$out = random_bytes(24);
# crypto_core_hchacha20(state->k, out, k, NULL);
$subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20($out, $key);
$state = new ParagonIE_Sodium_Core_SecretStream_State(
$subkey,
ParagonIE_Sodium_Core_Util::substr($out, 16, 8) . str_repeat("\0", 4)
);
# _crypto_secretstream_xchacha20poly1305_counter_reset(state);
$state->counterReset();
# memcpy(STATE_INONCE(state), out + crypto_core_hchacha20_INPUTBYTES,
# crypto_secretstream_xchacha20poly1305_INONCEBYTES);
# memset(state->_pad, 0, sizeof state->_pad);
return array(
$state->toString(),
$out
);
}