Class ParagonIE_Sodium_File

package WordPress
inherited_from \ParagonIE_Sodium_File

 Methods

abs()

abs(integer $integer, integer $size = 0) : integer
InheritedStatic

Parameters

$integer

integer

$size

integer

(16, 32, 64)

Returns

integer

Box a file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_box(), but produces the same result.

box(string $inputFile, string $outputFile, string $nonce, string $keyPair) : boolean
InheritedStatic

Parameters

$inputFile

string

Absolute path to a file on the filesystem

$outputFile

string

Absolute path to a file on the filesystem

$nonce

string

Number to be used only once

$keyPair

string

ECDH secret key and ECDH public key concatenated

Exceptions

\SodiumException
\TypeError

Returns

boolean

Open a boxed file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_box_open(), but produces the same result.

box_open(string $inputFile, string $outputFile, string $nonce, string $keypair) : boolean
InheritedStatic

Warning: Does not protect against TOCTOU attacks. You should just load the file into memory and use crypto_box_open() if you are worried about those.

Parameters

$inputFile

string

$outputFile

string

$nonce

string

$keypair

string

Exceptions

\SodiumException
\TypeError

Returns

boolean

Seal a file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_box_seal(), but produces the same result.

box_seal(string $inputFile, string $outputFile, string $publicKey) : boolean
InheritedStatic

Parameters

$inputFile

string

Absolute path to a file on the filesystem

$outputFile

string

Absolute path to a file on the filesystem

$publicKey

string

ECDH public key

Exceptions

\SodiumException
\TypeError

Returns

boolean

Open a sealed file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_box_seal_open(), but produces the same result.

box_seal_open(string $inputFile, string $outputFile, string $ecdhKeypair) : boolean
InheritedStatic

Warning: Does not protect against TOCTOU attacks. You should just load the file into memory and use crypto_box_seal_open() if you are worried about those.

Parameters

$inputFile

string

$outputFile

string

$ecdhKeypair

string

Exceptions

\SodiumException
\TypeError

Returns

boolean

If a variable does not match a given type, throw a TypeError.

declareScalarType(mixed $mixedVar = null, string $type = 'void', integer $argumentIndex = 0) : void
InheritedStatic

Parameters

$mixedVar

mixed

$type

string

$argumentIndex

integer

Exceptions

\TypeError
\SodiumException

Calculate the BLAKE2b hash of a file.

generichash(string $filePath, string|null $key = '', integer $outputLength = 32) : string
InheritedStatic
psalm-suppress FailedTypeResolution

Parameters

$filePath

string

Absolute path to a file on the filesystem

$key

stringnull

BLAKE2b key

$outputLength

integer

Length of hash output

Exceptions

\SodiumException
\TypeError

Returns

stringBLAKE2b hash

Evaluate whether or not two strings are equal (in constant-time)

hashEquals(string $left, string $right) : boolean
InheritedStatic

Parameters

$left

string

$right

string

Exceptions

\SodiumException
\TypeError

Returns

boolean

Encrypt a file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_secretbox(), but produces the same result.

secretbox(string $inputFile, string $outputFile, string $nonce, string $key) : boolean
InheritedStatic

Parameters

$inputFile

string

Absolute path to a file on the filesystem

$outputFile

string

Absolute path to a file on the filesystem

$nonce

string

Number to be used only once

$key

string

Encryption key

Exceptions

\SodiumException
\TypeError

Returns

boolean

Seal a file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_secretbox_open(), but produces the same result.

secretbox_open(string $inputFile, string $outputFile, string $nonce, string $key) : boolean
InheritedStatic

Warning: Does not protect against TOCTOU attacks. You should just load the file into memory and use crypto_secretbox_open() if you are worried about those.

Parameters

$inputFile

string

$outputFile

string

$nonce

string

$key

string

Exceptions

\SodiumException
\TypeError

Returns

boolean

Sign a file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_sign_detached(), but produces the same result.

sign(string $filePath, string $secretKey) : string
InheritedStatic

Parameters

$filePath

string

Absolute path to a file on the filesystem

$secretKey

string

Secret signing key

Exceptions

\SodiumException
\TypeError

Returns

stringEd25519 signature

Update a hash context with the contents of a file, without loading the entire file into memory.

updateHashWithFile(resource|object $hash, resource $fp, integer $size = 0) : resource | object
InheritedStatic
psalm-suppress PossiblyInvalidArgument PHP 7.2 changes from a resource to an object, which causes Psalm to complain about an error.
psalm-suppress TypeCoercion Ditto.

Parameters

$hash

resourceobject

$fp

resource

$size

integer

Exceptions

\SodiumException
\TypeError

Returns

resourceobjectResource on PHP < 7.2, HashContext object on PHP >= 7.2

Verify a file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_sign_verify_detached(), but produces the same result.

verify(string $sig, string $filePath, string $publicKey) : boolean
InheritedStatic

Parameters

$sig

string

Ed25519 signature

$filePath

string

Absolute path to a file on the filesystem

$publicKey

string

Signing public key

Exceptions

\SodiumException
\TypeError
\Exception

Returns

boolean

Verify a file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_sign_verify_detached(), but produces the same result. (32-bit)

verify_core32(string $sig, string $filePath, string $publicKey) : boolean
InheritedStatic

Parameters

$sig

string

Ed25519 signature

$filePath

string

Absolute path to a file on the filesystem

$publicKey

string

Signing public key

Exceptions

\SodiumException
\Exception

Returns

boolean

box_decrypt()

box_decrypt(resource $ifp, resource $ofp, integer $mlen, string $nonce, string $boxKeypair) : boolean
InheritedStatic

Parameters

$ifp

resource

$ofp

resource

$mlen

integer

$nonce

string

$boxKeypair

string

Exceptions

\SodiumException
\TypeError

Returns

boolean

box_encrypt()

box_encrypt(resource $ifp, resource $ofp, integer $mlen, string $nonce, string $boxKeypair) : boolean
InheritedStatic

Parameters

$ifp

resource

$ofp

resource

$mlen

integer

$nonce

string

$boxKeypair

string

Exceptions

\SodiumException
\TypeError

Returns

boolean

onetimeauth_verify()

onetimeauth_verify(\ParagonIE_Sodium_Core_Poly1305_State $state, resource $ifp, string $tag = '', integer $mlen = 0) : boolean
InheritedStatic

Parameters

$state

\ParagonIE_Sodium_Core_Poly1305_State

$ifp

resource

$tag

string

$mlen

integer

Exceptions

\SodiumException
\TypeError

Returns

boolean

One-time message authentication for 32-bit systems

onetimeauth_verify_core32(\ParagonIE_Sodium_Core32_Poly1305_State $state, resource $ifp, string $tag = '', integer $mlen = 0) : boolean
InheritedStatic

Parameters

$state

\ParagonIE_Sodium_Core32_Poly1305_State

$ifp

resource

$tag

string

$mlen

integer

Exceptions

\SodiumException
\TypeError

Returns

boolean

Decrypt a file

secretbox_decrypt(resource $ifp, resource $ofp, integer $mlen, string $nonce, string $key) : boolean
InheritedStatic

Parameters

$ifp

resource

$ofp

resource

$mlen

integer

$nonce

string

$key

string

Exceptions

\SodiumException
\TypeError

Returns

boolean

Decrypt a file (32-bit)

secretbox_decrypt_core32(resource $ifp, resource $ofp, integer $mlen, string $nonce, string $key) : boolean
InheritedStatic

Parameters

$ifp

resource

$ofp

resource

$mlen

integer

$nonce

string

$key

string

Exceptions

\SodiumException
\TypeError

Returns

boolean

Encrypt a file

secretbox_encrypt(resource $ifp, resource $ofp, integer $mlen, string $nonce, string $key) : boolean
InheritedStatic

Parameters

$ifp

resource

$ofp

resource

$mlen

integer

$nonce

string

$key

string

Exceptions

\SodiumException
\TypeError

Returns

boolean

Encrypt a file (32-bit)

secretbox_encrypt_core32(resource $ifp, resource $ofp, integer $mlen, string $nonce, string $key) : boolean
InheritedStatic

Parameters

$ifp

resource

$ofp

resource

$mlen

integer

$nonce

string

$key

string

Exceptions

\SodiumException
\TypeError

Returns

boolean

Sign a file (rather than a string). Uses less memory than ParagonIE_Sodium_Compat::crypto_sign_detached(), but produces the same result. (32-bit)

sign_core32(string $filePath, string $secretKey) : string
InheritedStatic

Parameters

$filePath

string

Absolute path to a file on the filesystem

$secretKey

string

Secret signing key

Exceptions

\SodiumException
\TypeError

Returns

stringEd25519 signature

 Constants

 

BUFFER_SIZE

BUFFER_SIZE = 8192