You are here

protected static function ParagonIE_Sodium_File::onetimeauth_verify_core32 in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/paragonie/sodium_compat/src/File.php \ParagonIE_Sodium_File::onetimeauth_verify_core32()

One-time message authentication for 32-bit systems

Parameters

ParagonIE_Sodium_Core32_Poly1305_State $state:

resource $ifp:

string $tag:

int $mlen:

Return value

bool

Throws

SodiumException

TypeError

1 call to ParagonIE_Sodium_File::onetimeauth_verify_core32()
ParagonIE_Sodium_File::secretbox_decrypt_core32 in vendor/paragonie/sodium_compat/src/File.php
Decrypt a file (32-bit)

File

vendor/paragonie/sodium_compat/src/File.php, line 1519

Class

ParagonIE_Sodium_File
Class ParagonIE_Sodium_File

Code

protected static function onetimeauth_verify_core32(ParagonIE_Sodium_Core32_Poly1305_State $state, $ifp, $tag = '', $mlen = 0) {

  /** @var int $pos */
  $pos = self::ftell($ifp);

  /** @var int $iter */
  $iter = 1;

  /** @var int $incr */
  $incr = self::BUFFER_SIZE >> 6;
  while ($mlen > 0) {
    $blockSize = $mlen > self::BUFFER_SIZE ? self::BUFFER_SIZE : $mlen;
    $ciphertext = fread($ifp, $blockSize);
    if (!is_string($ciphertext)) {
      throw new SodiumException('Could not read input file');
    }
    $state
      ->update($ciphertext);
    $mlen -= $blockSize;
    $iter += $incr;
  }
  $res = ParagonIE_Sodium_Core32_Util::verify_16($tag, $state
    ->finish());
  fseek($ifp, $pos, SEEK_SET);
  return $res;
}