setasign\FpdiPdfParser\PdfParser\SecHandler

Standard Implementation for decryptiong 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

$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

protected \setasign\Fpdi\PdfParser\Type\PdfDictionary SecHandler::$encryptionDictionary

The encryption dictionary

$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

ensure32BitInteger()

private static Standard::ensure32BitInteger (
$value
): void
Parameters
$value
 

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 pocessed with the SASLprep profile if requried.

Parameters
$revision : int
 
$password : string

The password in UTF-8 encoding.

Exceptions

Throws SecHandlerException

factory()

public static SecHandler::factory (
\setasign\FpdiPdfParser\PdfParser\PdfParser $parser,
\setasign\Fpdi\PdfParser\Type\PdfDictionary $encryptionDictionary
): Standard
Parameters
$parser : \setasign\FpdiPdfParser\PdfParser\PdfParser
 
$encryptionDictionary : \setasign\Fpdi\PdfParser\Type\PdfDictionary
 
Exceptions

Throws \setasign\Fpdi\PdfParser\PdfParserException

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException

Throws SecHandlerException

Throws \setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException

getStringValue()

private static Standard::getStringValue (
string $value
): string
Parameters
$value : string
 

Methods

__construct()

public Standard::__construct (
\setasign\FpdiPdfParser\PdfParser\PdfParser $parser,
\setasign\Fpdi\PdfParser\Type\PdfDictionary $encryptionDictionary
)
Parameters
$parser : \setasign\FpdiPdfParser\PdfParser\PdfParser
 
$encryptionDictionary : \setasign\Fpdi\PdfParser\Type\PdfDictionary
 
Exceptions

Throws SecHandlerException

Throws \setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException

Throws \setasign\Fpdi\PdfParser\PdfParserException

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException

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)

getEncryptionDictionary()

public SecHandler::getEncryptionDictionary (
void
): \setasign\Fpdi\PdfParser\Type\PdfDictionary

getRevision()

public Standard::getRevision (
void
): mixed
Exceptions

Throws \setasign\Fpdi\PdfParser\Type\PdfTypeException

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