wp/wp-includes/sodium_compat/src/File.php
changeset 22 8c2e4d02f4ef
parent 19 3d72ae0968f4
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    23      *
    23      *
    24      * @return bool
    24      * @return bool
    25      * @throws SodiumException
    25      * @throws SodiumException
    26      * @throws TypeError
    26      * @throws TypeError
    27      */
    27      */
    28     public static function box($inputFile, $outputFile, $nonce, $keyPair)
    28     public static function box(
    29     {
    29         $inputFile,
       
    30         $outputFile,
       
    31         $nonce,
       
    32         #[\SensitiveParameter]
       
    33         $keyPair
       
    34     ) {
    30         /* Type checks: */
    35         /* Type checks: */
    31         if (!is_string($inputFile)) {
    36         if (!is_string($inputFile)) {
    32             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
    37             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
    33         }
    38         }
    34         if (!is_string($outputFile)) {
    39         if (!is_string($outputFile)) {
    89      * @param string $keypair
    94      * @param string $keypair
    90      * @return bool
    95      * @return bool
    91      * @throws SodiumException
    96      * @throws SodiumException
    92      * @throws TypeError
    97      * @throws TypeError
    93      */
    98      */
    94     public static function box_open($inputFile, $outputFile, $nonce, $keypair)
    99     public static function box_open(
    95     {
   100         $inputFile,
       
   101         $outputFile,
       
   102         $nonce,
       
   103         #[\SensitiveParameter]
       
   104         $keypair
       
   105     ) {
    96         /* Type checks: */
   106         /* Type checks: */
    97         if (!is_string($inputFile)) {
   107         if (!is_string($inputFile)) {
    98             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
   108             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
    99         }
   109         }
   100         if (!is_string($outputFile)) {
   110         if (!is_string($outputFile)) {
   159      *
   169      *
   160      * @return bool
   170      * @return bool
   161      * @throws SodiumException
   171      * @throws SodiumException
   162      * @throws TypeError
   172      * @throws TypeError
   163      */
   173      */
   164     public static function box_seal($inputFile, $outputFile, $publicKey)
   174     public static function box_seal(
   165     {
   175         $inputFile,
       
   176         $outputFile,
       
   177         #[\SensitiveParameter]
       
   178         $publicKey
       
   179     ) {
   166         /* Type checks: */
   180         /* Type checks: */
   167         if (!is_string($inputFile)) {
   181         if (!is_string($inputFile)) {
   168             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
   182             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
   169         }
   183         }
   170         if (!is_string($outputFile)) {
   184         if (!is_string($outputFile)) {
   263      * @param string $ecdhKeypair
   277      * @param string $ecdhKeypair
   264      * @return bool
   278      * @return bool
   265      * @throws SodiumException
   279      * @throws SodiumException
   266      * @throws TypeError
   280      * @throws TypeError
   267      */
   281      */
   268     public static function box_seal_open($inputFile, $outputFile, $ecdhKeypair)
   282     public static function box_seal_open(
   269     {
   283         $inputFile,
       
   284         $outputFile,
       
   285         #[\SensitiveParameter]
       
   286         $ecdhKeypair
       
   287     ) {
   270         /* Type checks: */
   288         /* Type checks: */
   271         if (!is_string($inputFile)) {
   289         if (!is_string($inputFile)) {
   272             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
   290             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
   273         }
   291         }
   274         if (!is_string($outputFile)) {
   292         if (!is_string($outputFile)) {
   348      * @return string                   BLAKE2b hash
   366      * @return string                   BLAKE2b hash
   349      * @throws SodiumException
   367      * @throws SodiumException
   350      * @throws TypeError
   368      * @throws TypeError
   351      * @psalm-suppress FailedTypeResolution
   369      * @psalm-suppress FailedTypeResolution
   352      */
   370      */
   353     public static function generichash($filePath, $key = '', $outputLength = 32)
   371     public static function generichash(
   354     {
   372         $filePath,
       
   373         #[\SensitiveParameter]
       
   374         $key = '',
       
   375         $outputLength = 32
       
   376     ) {
   355         /* Type checks: */
   377         /* Type checks: */
   356         if (!is_string($filePath)) {
   378         if (!is_string($filePath)) {
   357             throw new TypeError('Argument 1 must be a string, ' . gettype($filePath) . ' given.');
   379             throw new TypeError('Argument 1 must be a string, ' . gettype($filePath) . ' given.');
   358         }
   380         }
   359         if (!is_string($key)) {
   381         if (!is_string($key)) {
   426      *
   448      *
   427      * @return bool
   449      * @return bool
   428      * @throws SodiumException
   450      * @throws SodiumException
   429      * @throws TypeError
   451      * @throws TypeError
   430      */
   452      */
   431     public static function secretbox($inputFile, $outputFile, $nonce, $key)
   453     public static function secretbox(
   432     {
   454         $inputFile,
       
   455         $outputFile,
       
   456         $nonce,
       
   457         #[\SensitiveParameter]
       
   458         $key
       
   459     ) {
   433         /* Type checks: */
   460         /* Type checks: */
   434         if (!is_string($inputFile)) {
   461         if (!is_string($inputFile)) {
   435             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given..');
   462             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given..');
   436         }
   463         }
   437         if (!is_string($outputFile)) {
   464         if (!is_string($outputFile)) {
   491      * @param string $key
   518      * @param string $key
   492      * @return bool
   519      * @return bool
   493      * @throws SodiumException
   520      * @throws SodiumException
   494      * @throws TypeError
   521      * @throws TypeError
   495      */
   522      */
   496     public static function secretbox_open($inputFile, $outputFile, $nonce, $key)
   523     public static function secretbox_open(
   497     {
   524         $inputFile,
       
   525         $outputFile,
       
   526         $nonce,
       
   527         #[\SensitiveParameter]
       
   528         $key
       
   529     ) {
   498         /* Type checks: */
   530         /* Type checks: */
   499         if (!is_string($inputFile)) {
   531         if (!is_string($inputFile)) {
   500             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
   532             throw new TypeError('Argument 1 must be a string, ' . gettype($inputFile) . ' given.');
   501         }
   533         }
   502         if (!is_string($outputFile)) {
   534         if (!is_string($outputFile)) {
   558      *
   590      *
   559      * @return string           Ed25519 signature
   591      * @return string           Ed25519 signature
   560      * @throws SodiumException
   592      * @throws SodiumException
   561      * @throws TypeError
   593      * @throws TypeError
   562      */
   594      */
   563     public static function sign($filePath, $secretKey)
   595     public static function sign(
   564     {
   596         $filePath,
       
   597         #[\SensitiveParameter]
       
   598         $secretKey
       
   599     ) {
   565         /* Type checks: */
   600         /* Type checks: */
   566         if (!is_string($filePath)) {
   601         if (!is_string($filePath)) {
   567             throw new TypeError('Argument 1 must be a string, ' . gettype($filePath) . ' given.');
   602             throw new TypeError('Argument 1 must be a string, ' . gettype($filePath) . ' given.');
   568         }
   603         }
   569         if (!is_string($secretKey)) {
   604         if (!is_string($secretKey)) {
   654      * @return bool
   689      * @return bool
   655      * @throws SodiumException
   690      * @throws SodiumException
   656      * @throws TypeError
   691      * @throws TypeError
   657      * @throws Exception
   692      * @throws Exception
   658      */
   693      */
   659     public static function verify($sig, $filePath, $publicKey)
   694     public static function verify(
   660     {
   695         $sig,
       
   696         $filePath,
       
   697         $publicKey
       
   698     ) {
   661         /* Type checks: */
   699         /* Type checks: */
   662         if (!is_string($sig)) {
   700         if (!is_string($sig)) {
   663             throw new TypeError('Argument 1 must be a string, ' . gettype($sig) . ' given.');
   701             throw new TypeError('Argument 1 must be a string, ' . gettype($sig) . ' given.');
   664         }
   702         }
   665         if (!is_string($filePath)) {
   703         if (!is_string($filePath)) {