Make WordPress Core


Ignore:
Timestamp:
10/06/2025 03:46:40 PM (13 months ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Update sodium_compat to v1.23.0.

The previous version of sodium_compat was overly permissible with sodium_base642bin() when the *_NO_PADDING variants were specified, which was not compatible with ext-sodium. This has been fixed in version 1.22.0.

Version 1.23.0 includes some optimizations by replacing the array in the Curve25519 field element with 10 integer object properties instead. The result is a 7% to 12% speedup for the overall PHPUnit suite.

References:

Follow-up to [55699], [58752], [58753], [60787].

Props paragoninitiativeenterprises, SergeyBiryukov.
Fixes #64079.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/sodium_compat/src/File.php

    r58752 r60905  
    126126        }
    127127
     128        if (!file_exists($inputFile)) {
     129            throw new SodiumException('Input file does not exist');
     130        }
    128131        /** @var int $size */
    129132        $size = filesize($inputFile);
    … …  
    139142
    140143        /** @var resource $ofp */
    141         $ofp = fopen($outputFile, 'wb');
     144        $ofp = @fopen($outputFile, 'wb');
    142145        if (!is_resource($ofp)) {
    143146            fclose($ifp);
    … …  
    194197        }
    195198
     199        if (!file_exists($inputFile)) {
     200            throw new SodiumException('Input file does not exist');
     201        }
    196202        /** @var int $size */
    197203        $size = filesize($inputFile);
    … …  
    207213
    208214        /** @var resource $ofp */
    209         $ofp = fopen($outputFile, 'wb');
     215        $ofp = @fopen($outputFile, 'wb');
    210216        if (!is_resource($ofp)) {
    211217            fclose($ifp);
    … …  
    304310        $publicKey = ParagonIE_Sodium_Compat::crypto_box_publickey($ecdhKeypair);
    305311
     312        if (!file_exists($inputFile)) {
     313            throw new SodiumException('Input file does not exist');
     314        }
    306315        /** @var int $size */
    307316        $size = filesize($inputFile);
    … …  
    317326
    318327        /** @var resource $ofp */
    319         $ofp = fopen($outputFile, 'wb');
     328        $ofp = @fopen($outputFile, 'wb');
    320329        if (!is_resource($ofp)) {
    321330            fclose($ifp);
    … …  
    409418        }
    410419
     420        if (!file_exists($filePath)) {
     421            throw new SodiumException('File does not exist');
     422        }
    411423        /** @var int $size */
    412424        $size = filesize($filePath);
    … …  
    480492        }
    481493
     494        if (!file_exists($inputFile)) {
     495            throw new SodiumException('Input file does not exist');
     496        }
    482497        /** @var int $size */
    483498        $size = filesize($inputFile);
    … …  
    487502
    488503        /** @var resource $ifp */
    489         $ifp = fopen($inputFile, 'rb');
     504        $ifp = @fopen($inputFile, 'rb');
    490505        if (!is_resource($ifp)) {
    491506            throw new SodiumException('Could not open input file for reading');
    … …  
    544559        /* Input validation: */
    545560        if (self::strlen($nonce) !== ParagonIE_Sodium_Compat::CRYPTO_SECRETBOX_NONCEBYTES) {
    546             throw new TypeError('Argument 4 must be CRYPTO_SECRETBOX_NONCEBYTES bytes');
     561            throw new TypeError('Argument 3 must be CRYPTO_SECRETBOX_NONCEBYTES bytes');
    547562        }
    548563        if (self::strlen($key) !== ParagonIE_Sodium_Compat::CRYPTO_SECRETBOX_KEYBYTES) {
    549             throw new TypeError('Argument 4 must be CRYPTO_SECRETBOXBOX_KEYBYTES bytes');
    550         }
    551 
     564            throw new TypeError('Argument 4 must be CRYPTO_SECRETBOX_KEYBYTES bytes');
     565        }
     566
     567        if (!file_exists($inputFile)) {
     568            throw new SodiumException('Input file does not exist');
     569        }
    552570        /** @var int $size */
    553571        $size = filesize($inputFile);
    … …  
    563581
    564582        /** @var resource $ofp */
    565         $ofp = fopen($outputFile, 'wb');
     583        $ofp = @fopen($outputFile, 'wb');
    566584        if (!is_resource($ofp)) {
    567585            fclose($ifp);
    … …  
    614632        }
    615633
     634        if (!file_exists($filePath)) {
     635            throw new SodiumException('File does not exist');
     636        }
    616637        /** @var int $size */
    617638        $size = filesize($filePath);
    … …  
    745766        }
    746767
     768        if (!file_exists($filePath)) {
     769            throw new SodiumException('File does not exist');
     770        }
    747771        /** @var int $size */
    748772        $size = filesize($filePath);
Note: See TracChangeset for help on using the changeset viewer.