SetaPDF_Core_SecHandler_Standard_Arcfour128Cf Generator class for RC4 128 bit security handler with crypt filters

File: /SetaPDF/Core/SecHandler/Standard/Arcfour128Cf.php

Class hierarchy

Implements

Summary

Static Properties

$_padding

The padding string


Properties

$_auth

Defines if this security handler is authenticated

$_authMode

Says who is authenticated: user or owner

$_document

The document to which this security handler is attached

$_encryptMetadata

Metadata are encrypted or not

$_encryptionKey

The encryption key

$_keyLength

This value is still needed if crypt filters are in use: - It is needed to compute the encryption key. - It is needed to compute the O value It is NOT documented which key length should be used for this things if a crypt filter is in use.

$_streamAlgorithm

The algorithm an key length to be used for en/decrypting stream

$_stringAlgorithm

The algorithm an key length to be used for en/decrypting strings


Static Methods

ensurePermissions()

static public int SetaPDF_Core_SecHandler_Standard::ensurePermissions ( $permissions $permissions, $revision $revision )

Ensures bits in the permission flag.

Parameters
$permissions : $permissions
 
$revision : $revision
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

factory()

static public SetaPDF_Core_SecHandler_Standard_Arcfour128Cf SetaPDF_Core_SecHandler_Standard_Arcfour128Cf::factory ( SetaPDF_Core_Document $document, string $ownerPassword [, string $userPassword = '' [, integer $permissions = 0 [, boolean $encryptMetadata = true ]]] )

Factory method for RC4 128 bit security handler with crypt filters.

Parameters
$document : SetaPDF_Core_Document
 
$ownerPassword : string

The owner password in PDFDocEncoding

$userPassword : string

The user password in PDFDocEncoding

$permissions : integer
 
$encryptMetadata : boolean
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception


Methods

__construct()

The constructor.

Parameters
$document : SetaPDF_Core_Document
 
$encryptionDictionary : SetaPDF_Core_Type_Dictionary
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

_authByOwnerPassword()

protected string|boolean SetaPDF_Core_SecHandler_Standard::_authByOwnerPassword ( [ string $ownerPassword = '' ] )

Internal method to authenticate with the owner password.

Parameters
$ownerPassword : string
 
Return Values

The encryption key if the authentication was successful.
False if not.

Exceptions

Throws SetaPDF_Exception_NotImplemented

_authByUserPassword()

protected string|boolean SetaPDF_Core_SecHandler_Standard::_authByUserPassword ( [ string $userPassword = '' ] )

Internal method to authenticate with the user password.

Parameters
$userPassword : string
 
Return Values

The encryption key if the authentication was successful.
False if not.

_computeEncryptionKey()

protected string SetaPDF_Core_SecHandler_Standard::_computeEncryptionKey ( [ string $password = '' ] )

Compute the encryption key based on a password.

Parameters
$password : string
 
Exceptions

Throws SetaPDF_Exception_NotImplemented

_computeHashR6()

protected string SetaPDF_Core_SecHandler_AbstractHandler::_computeHashR6 ( string $data, string $inputPassword [, string $userKey = '' ] )

Computes a hash for security handler revision 6.

Parameters
$data : string
 
$inputPassword : string
 
$userKey : string
 

_computeOValue()

protected string SetaPDF_Core_SecHandler_Standard::_computeOValue ( string $userPassword [, string $ownerPassword = '' ] )

Compute the O value.

Parameters
$userPassword : string
 
$ownerPassword : string
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

_computeUValue()

protected string SetaPDF_Core_SecHandler_Standard::_computeUValue ( string $encryptionKey )

Compute the U value.

Parameters
$encryptionKey : string
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

_crypt()

protected string SetaPDF_Core_SecHandler_AbstractHandler::_crypt ( string $data, array $algorithm [, SetaPDF_Core_Type_IndirectObject $param = null [, boolean $encrypt = true ]] )

Encrypts or decrypts data using Algorithm 1 of the PDF specification.

Parameters
$data : string
 
$algorithm : array
 
$param : SetaPDF_Core_Type_IndirectObject
 
$encrypt : boolean
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

_getEncryptionKeyByUserPassword()

protected string SetaPDF_Core_SecHandler_Standard::_getEncryptionKeyByUserPassword ( [ string $password = '' ] )

Get the encryption key by the user password.

Parameters
$password : string
 

auth()

public boolean SetaPDF_Core_SecHandler_Standard::auth ( [ string $data = null ] )

Authenticate against the security handler.

This method will try to auth first with the owner password.

If this will fail it will try to auth to the user password.

Parameters
$data : string

The password to authenticate with

Return Values

Authentication was successful or not

authByOwnerPassword()

public boolean SetaPDF_Core_SecHandler_Standard::authByOwnerPassword ( string $password )

Authenticate with the owner password.

Parameters
$password : string
 

authByUserPassword()

public boolean SetaPDF_Core_SecHandler_Standard::authByUserPassword ( string $password )

Authenticate with the user password.

Parameters
$password : string
 

decryptStream()

Decrypt a stream.

Parameters
$data : string
 
$param : SetaPDF_Core_Type_IndirectObject
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

decryptString()

Decrypt a string.

Parameters
$data : string
 
$param : SetaPDF_Core_Type_IndirectObject
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

encryptStream()

Encrypt a stream.

Parameters
$data : string
 
$param : SetaPDF_Core_Type_IndirectObject
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

encryptString()

Encrypt a string.

Parameters
$data : string
 
$param : SetaPDF_Core_Type_IndirectObject
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

generateRandomBytes()

Generate random bytes.

Internally the method tries to use PHPs internal available methods for pseudo-random bytes creation: random_bytes(), openssl_random_pseudo_bytes(), mcrypt_create_iv(). If none of these methods is available a random string is generated by using mt_rand().

Parameters
$length : $length
 

getAuthMode()

Get the auth method.

Return Values

"user", "owner" or an empty string if not authenticated.

getDocument()

Returns the document instance of this security handler.

getEncryptMetadata()

Returns true if the metadata are/will be encrypted.

getEncryptionDictionary()

getEncryptionKey()

Get the encryption key if known/authenticated.

Exceptions

Throws SetaPDF_Core_SecHandler_Exception

getPdfVersion()

Get the PDF version, which is needed for the currently used encryption algorithm.

Exceptions

Throws SetaPDF_Exception_NotImplemented

getPermission()

public boolean SetaPDF_Core_SecHandler_AbstractHandler::getPermission ( integer $permission )

Queries if a permission is granted.

Parameters
$permission : integer
 

getPermissions()

getRevision()

Get the revision of the security handler.

getStreamAlgorithm()

Get the stream algorithm data.

getStringAlgorithm()

Get the string algorithm data.

isAuth()

Queries if the security handler is authenticated.

If not it tries by calling auth() without a password.