You are here

public static function ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_init_pull in Automatic Updates 7

Same name and namespace in other branches
  1. 8 vendor/paragonie/sodium_compat/src/Crypto.php \ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_init_pull()

Parameters

string $key:

string $header:

Return value

string Returns a state.

Throws

Exception

1 call to ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_init_pull()
ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_init_pull in vendor/paragonie/sodium_compat/src/Compat.php

File

vendor/paragonie/sodium_compat/src/Crypto.php, line 1271

Class

ParagonIE_Sodium_Crypto
Class ParagonIE_Sodium_Crypto

Code

public static function secretstream_xchacha20poly1305_init_pull($key, $header) {

  # crypto_core_hchacha20(state->k, in, k, NULL);
  $subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20(ParagonIE_Sodium_Core_Util::substr($header, 0, 16), $key);
  $state = new ParagonIE_Sodium_Core_SecretStream_State($subkey, ParagonIE_Sodium_Core_Util::substr($header, 16));
  $state
    ->counterReset();

  # memcpy(STATE_INONCE(state), in + crypto_core_hchacha20_INPUTBYTES,

  #     crypto_secretstream_xchacha20poly1305_INONCEBYTES);

  # memset(state->_pad, 0, sizeof state->_pad);

  # return 0;
  return $state
    ->toString();
}