WordPress at Your Fingertips
function is not described

ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_rekey() public WP 1.0

{} It's a method of the class: ParagonIE_Sodium_Crypto{}

No Hooks.

Return

null. Nothing.

Usage

$result = ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_rekey( $state );
$state(string) (required) (passed by reference — &)
-

Code of ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_rekey() WP 5.8.2

public static function secretstream_xchacha20poly1305_rekey(&$state)
{
    $st = ParagonIE_Sodium_Core_SecretStream_State::fromString($state);
    # unsigned char new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES +
    # crypto_secretstream_xchacha20poly1305_INONCEBYTES];
    # size_t        i;
    # for (i = 0U; i < crypto_stream_chacha20_ietf_KEYBYTES; i++) {
    #     new_key_and_inonce[i] = state->k[i];
    # }
    $new_key_and_inonce = $st->getKey();

    # for (i = 0U; i < crypto_secretstream_xchacha20poly1305_INONCEBYTES; i++) {
    #     new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES + i] =
    #         STATE_INONCE(state)[i];
    # }
    $new_key_and_inonce .= ParagonIE_Sodium_Core_Util::substR($st->getNonce(), 0, 8);

    # crypto_stream_chacha20_ietf_xor(new_key_and_inonce, new_key_and_inonce,
    #                                 sizeof new_key_and_inonce,
    #                                 state->nonce, state->k);

    $st->rekey(ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
        $new_key_and_inonce,
        $st->getCombinedNonce(),
        $st->getKey(),
        ParagonIE_Sodium_Core_Util::store64_le(0)
    ));

    # for (i = 0U; i < crypto_stream_chacha20_ietf_KEYBYTES; i++) {
    #     state->k[i] = new_key_and_inonce[i];
    # }
    # for (i = 0U; i < crypto_secretstream_xchacha20poly1305_INONCEBYTES; i++) {
    #     STATE_INONCE(state)[i] =
    #          new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES + i];
    # }
    # _crypto_secretstream_xchacha20poly1305_counter_reset(state);
    $st->counterReset();

    $state = $st->toString();
}