BackupStreamCipher
in package
FinalYes
Reads and writes bounded-memory, authenticated backup archive streams.
Table of Contents
Constants
- ALGORITHM : mixed = 'XCHACHA20-POLY1305-SECRETSTREAM'
- MAGIC : mixed = "KMPBACKUP\x02"
- CHUNK_BYTES : mixed = 4 * 1024 * 1024
- MAX_HEADER_BYTES : mixed = 64 * 1024
Methods
- decryptFile() : bool
- Decrypt a version 2 archive. Returns false when the input uses the legacy JSON format.
- encryptFile() : void
- readExact() : string
- unpackLength() : int
- writeAll() : void
Constants
ALGORITHM
public
mixed
ALGORITHM
= 'XCHACHA20-POLY1305-SECRETSTREAM'
MAGIC
public
mixed
MAGIC
= "KMPBACKUP\x02"
CHUNK_BYTES
private
mixed
CHUNK_BYTES
= 4 * 1024 * 1024
MAX_HEADER_BYTES
private
mixed
MAX_HEADER_BYTES
= 64 * 1024
Methods
decryptFile()
Decrypt a version 2 archive. Returns false when the input uses the legacy JSON format.
public
decryptFile(string $inputPath, string $outputPath, string $dataEncryptionKey, string $aad, array<string, scalar> $expectedMetadata) : bool
Parameters
- $inputPath : string
- $outputPath : string
- $dataEncryptionKey : string
- $aad : string
- $expectedMetadata : array<string, scalar>
Return values
boolencryptFile()
public
encryptFile(string $inputPath, string $outputPath, string $dataEncryptionKey, string $aad, array<string, scalar> $archiveMetadata) : void
Parameters
- $inputPath : string
- $outputPath : string
- $dataEncryptionKey : string
- $aad : string
- $archiveMetadata : array<string, scalar>
readExact()
private
readExact(resource $stream, int $length, string $label) : string
Parameters
- $stream : resource
- $length : int
- $label : string
Return values
stringunpackLength()
private
unpackLength(string $bytes) : int
Parameters
- $bytes : string
Return values
intwriteAll()
private
writeAll(resource $stream, string $bytes) : void
Parameters
- $stream : resource
- $bytes : string