Edit File by line
/home/zeestwma/richards.../wp-inclu.../sodium_c.../src
File: File.php
$subkey = ParagonIE_Sodium_Core32_HSalsa20::hsalsa20($nonce, $key);
[1500] Fix | Delete
[1501] Fix | Delete
/** @var string $realNonce */
[1502] Fix | Delete
$realNonce = ParagonIE_Sodium_Core32_Util::substr($nonce, 16, 8);
[1503] Fix | Delete
[1504] Fix | Delete
/** @var string $block0 */
[1505] Fix | Delete
$block0 = ParagonIE_Sodium_Core32_Salsa20::salsa20(
[1506] Fix | Delete
64,
[1507] Fix | Delete
ParagonIE_Sodium_Core32_Util::substr($nonce, 16, 8),
[1508] Fix | Delete
$subkey
[1509] Fix | Delete
);
[1510] Fix | Delete
[1511] Fix | Delete
/* Verify the Poly1305 MAC -before- attempting to decrypt! */
[1512] Fix | Delete
$state = new ParagonIE_Sodium_Core32_Poly1305_State(self::substr($block0, 0, 32));
[1513] Fix | Delete
if (!self::onetimeauth_verify_core32($state, $ifp, $tag, $mlen)) {
[1514] Fix | Delete
throw new SodiumException('Invalid MAC');
[1515] Fix | Delete
}
[1516] Fix | Delete
[1517] Fix | Delete
/*
[1518] Fix | Delete
* Set the cursor to the end of the first half-block. All future bytes will
[1519] Fix | Delete
* generated from salsa20_xor_ic, starting from 1 (second block).
[1520] Fix | Delete
*/
[1521] Fix | Delete
$first32 = fread($ifp, 32);
[1522] Fix | Delete
if (!is_string($first32)) {
[1523] Fix | Delete
throw new SodiumException('Could not read input file');
[1524] Fix | Delete
}
[1525] Fix | Delete
$first32len = self::strlen($first32);
[1526] Fix | Delete
fwrite(
[1527] Fix | Delete
$ofp,
[1528] Fix | Delete
self::xorStrings(
[1529] Fix | Delete
self::substr($block0, 32, $first32len),
[1530] Fix | Delete
self::substr($first32, 0, $first32len)
[1531] Fix | Delete
)
[1532] Fix | Delete
);
[1533] Fix | Delete
$mlen -= 32;
[1534] Fix | Delete
[1535] Fix | Delete
/** @var int $iter */
[1536] Fix | Delete
$iter = 1;
[1537] Fix | Delete
[1538] Fix | Delete
/** @var int $incr */
[1539] Fix | Delete
$incr = self::BUFFER_SIZE >> 6;
[1540] Fix | Delete
[1541] Fix | Delete
/* Decrypts ciphertext, writes to output file. */
[1542] Fix | Delete
while ($mlen > 0) {
[1543] Fix | Delete
$blockSize = $mlen > self::BUFFER_SIZE
[1544] Fix | Delete
? self::BUFFER_SIZE
[1545] Fix | Delete
: $mlen;
[1546] Fix | Delete
$ciphertext = fread($ifp, $blockSize);
[1547] Fix | Delete
if (!is_string($ciphertext)) {
[1548] Fix | Delete
throw new SodiumException('Could not read input file');
[1549] Fix | Delete
}
[1550] Fix | Delete
$pBlock = ParagonIE_Sodium_Core32_Salsa20::salsa20_xor_ic(
[1551] Fix | Delete
$ciphertext,
[1552] Fix | Delete
$realNonce,
[1553] Fix | Delete
$iter,
[1554] Fix | Delete
$subkey
[1555] Fix | Delete
);
[1556] Fix | Delete
fwrite($ofp, $pBlock, $blockSize);
[1557] Fix | Delete
$mlen -= $blockSize;
[1558] Fix | Delete
$iter += $incr;
[1559] Fix | Delete
}
[1560] Fix | Delete
return true;
[1561] Fix | Delete
}
[1562] Fix | Delete
[1563] Fix | Delete
/**
[1564] Fix | Delete
* One-time message authentication for 32-bit systems
[1565] Fix | Delete
*
[1566] Fix | Delete
* @param ParagonIE_Sodium_Core32_Poly1305_State $state
[1567] Fix | Delete
* @param resource $ifp
[1568] Fix | Delete
* @param string $tag
[1569] Fix | Delete
* @param int $mlen
[1570] Fix | Delete
* @return bool
[1571] Fix | Delete
* @throws SodiumException
[1572] Fix | Delete
* @throws TypeError
[1573] Fix | Delete
*/
[1574] Fix | Delete
protected static function onetimeauth_verify_core32(
[1575] Fix | Delete
ParagonIE_Sodium_Core32_Poly1305_State $state,
[1576] Fix | Delete
$ifp,
[1577] Fix | Delete
$tag = '',
[1578] Fix | Delete
$mlen = 0
[1579] Fix | Delete
) {
[1580] Fix | Delete
/** @var int $pos */
[1581] Fix | Delete
$pos = self::ftell($ifp);
[1582] Fix | Delete
[1583] Fix | Delete
while ($mlen > 0) {
[1584] Fix | Delete
$blockSize = $mlen > self::BUFFER_SIZE
[1585] Fix | Delete
? self::BUFFER_SIZE
[1586] Fix | Delete
: $mlen;
[1587] Fix | Delete
$ciphertext = fread($ifp, $blockSize);
[1588] Fix | Delete
if (!is_string($ciphertext)) {
[1589] Fix | Delete
throw new SodiumException('Could not read input file');
[1590] Fix | Delete
}
[1591] Fix | Delete
$state->update($ciphertext);
[1592] Fix | Delete
$mlen -= $blockSize;
[1593] Fix | Delete
}
[1594] Fix | Delete
$res = ParagonIE_Sodium_Core32_Util::verify_16($tag, $state->finish());
[1595] Fix | Delete
[1596] Fix | Delete
fseek($ifp, $pos, SEEK_SET);
[1597] Fix | Delete
return $res;
[1598] Fix | Delete
}
[1599] Fix | Delete
[1600] Fix | Delete
/**
[1601] Fix | Delete
* @param resource $resource
[1602] Fix | Delete
* @return int
[1603] Fix | Delete
* @throws SodiumException
[1604] Fix | Delete
*/
[1605] Fix | Delete
private static function ftell($resource)
[1606] Fix | Delete
{
[1607] Fix | Delete
$return = ftell($resource);
[1608] Fix | Delete
if (!is_int($return)) {
[1609] Fix | Delete
throw new SodiumException('ftell() returned false');
[1610] Fix | Delete
}
[1611] Fix | Delete
return (int) $return;
[1612] Fix | Delete
}
[1613] Fix | Delete
}
[1614] Fix | Delete
[1615] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function