setasign\FpdiPdfParser\PdfParser\SecHandler

Standard Implementation for decryption of Standard PDF security.

File: /FPDI PDF-Parser v2/PdfParser/SecHandler/Standard.php

Class hierarchy

Summary

Constants

AES

public const int SecHandler::AES = 32

Encryption constant

AES_128

public const int SecHandler::AES_128 = 96

Encryption constant

AES_256

public const int SecHandler::AES_256 = 160

Encryption constant

ARCFOUR

public const int SecHandler::ARCFOUR = 4

Encryption constant

OWNER

public const string SecHandler::OWNER = 'owner'

Owner auth mode

USER

public const string SecHandler::USER = 'user'

User auth mode


Static Properties

$cipherChecks

static public array SecHandler::$cipherChecks = array()

An array to remember checks for supported ciphers.

$padding

static protected string Standard::$padding =

Properties

$auth

protected bool SecHandler::$auth = false

Defines if this security handler is authenticated

$authMode

protected ?string SecHandler::$authMode

The auth mode

Says who is authenticated: user or owner

$encryptionDictionary

$encryptionKey

protected string SecHandler::$encryptionKey

The encryption key

$fileIdentifier

protected string Standard::$fileIdentifier

$keyLength

protected int SecHandler::$keyLength = 5

The default key length in bytes

$streamAlgorithm

protected array SecHandler::$streamAlgorithm = array(...)

The algorithm and key length to be used for decrypting streams

$stringAlgorithm

protected array SecHandler::$stringAlgorithm = array(...)

The algorithm and key length to be used for decrypting strings


Static Methods

aesDecrypt()

public static SecHandler::aesDecrypt (
string $key,
string $data,
string $bits = '128'
): string
Parameters
$key: string
 
$data: string
 
$bits: string
 

arcfour()

public static SecHandler::arcfour (
string $key,
string $data
): string
Parameters
$key: string
 
$data: string
 
Exceptions

Throws SecHandlerException

checkCipherSupport()

public static SecHandler::checkCipherSupport (
string $cipher
): bool
Parameters
$cipher: string
 
Exceptions

Throws SecHandlerException

ensurePasswordEncoding()

public static Standard::ensurePasswordEncoding (
int $revision,
string $password
): string

This method ensures the correct encoding of a password.

Internally the password is converted into the required encoding for the desired revision, and it is processed with the SASLprep profile if required.

Parameters
$revision: int
 
$password: string

The password in UTF-8 encoding.

Exceptions

Throws SecHandlerException


Methods

auth()

public Standard::auth (
?string $password = null
): bool
Parameters
$password: ?string

The password in UTF-8 encoding

Exceptions

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException

Throws SecHandlerException

authByOwnerPassword()

public Standard::authByOwnerPassword (
string $password
): bool
Parameters
$password: string

The owner-password in UTF-8 encoding

Exceptions

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException

Throws SecHandlerException

authByUserPassword()

public Standard::authByUserPassword (
string $password
): bool
Parameters
$password: string

The user-password in UTF-8 encoding

Exceptions

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException

Throws SecHandlerException

computeEncryptionKey()

protected Standard::computeEncryptionKey (
$password = ''
): void
Parameters
$password
 

computeHashR6()

protected SecHandler::computeHashR6 (
string $data,
string $inputPassword,
string $userKey = ''
): string
Parameters
$data: string
 
$inputPassword: string
 
$userKey: string
 

computeUValue()

protected Standard::computeUValue (
$encryptionKey
): void
Parameters
$encryptionKey
 

createEncryptionKeyByOwnerPassword()

protected Standard::createEncryptionKeyByOwnerPassword (
string $ownerPassword = ''
): false|string
Parameters
$ownerPassword: string
 
Exceptions

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException

Throws SecHandlerException

createEncryptionKeyByUserPassword()

protected Standard::createEncryptionKeyByUserPassword (
string $userPassword = ''
): false|string
Parameters
$userPassword: string
 
Exceptions

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException

decrypt()

protected SecHandler::decrypt (
string $data,
array $algorithm,
int $objectNumber,
int $generationNumber
): string
Parameters
$data: string
 
$algorithm: array
 
$objectNumber: int
 
$generationNumber: int
 
Exceptions

Throws SecHandlerException

decryptEncryptionKeyR5R6()

protected Standard::decryptEncryptionKeyR5R6 (
string $value,
string $key
): false|string
Parameters
$value: string
 
$key: string
 
Exceptions

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException

decryptStream()

public SecHandler::decryptStream (
string $data,
int $objectNumber,
int $generationNumber
): string
Parameters
$data: string
 
$objectNumber: int
 
$generationNumber: int
 
Exceptions

Throws SecHandlerException

decryptString()

public SecHandler::decryptString (
string $data,
int $objectNumber,
int $generationNumber
): string
Parameters
$data: string
 
$objectNumber: int
 
$generationNumber: int
 
Exceptions

Throws SecHandlerException

getAuthMode()

public SecHandler::getAuthMode (
void
): ?string

Get the authentication mode (user or owner)

getRevision()

isAuth()

public SecHandler::isAuth (
void
): bool

Checks for authentication and tries to authenticate without arguments through the auth() method.

isMetadataEncrypted()

public SecHandler::isMetadataEncrypted (
void
): bool

Checks whether metadata is encrypted or not.

Exceptions

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException