SetaPDF_Core_SecHandler_Standard_Aes256R5 Generator class for AES 256 bit security handler (revision 5 - DEPRECTAED IN ISO/DIS 32000-2)

File: /SetaPDF v2/Core/SecHandler/Standard/Aes256R5.php

Class hierarchy

Implements

Summary

Static Properties

$_padding

static protected string SetaPDF_Core_SecHandler_Standard::$_padding =

The padding string


Properties

$_auth

Defines if this security handler is authenticated

$_authMode

The auth mode

Says who is authenticated: user or owner

$_document

The document to which this security handler is attached

$_encryptMetadata

Metadata are encrypted or not

$_encryptionDictionary

$_encryptionKey

The encryption key

$_keyLength

The key length in bytes

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

ensurePasswordEncoding()

public static SetaPDF_Core_SecHandler_Standard::ensurePasswordEncoding (
$revision, $password, $encoding
):

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
 
$password
 
$encoding
 
Exceptions

Throws SetaPDF_Exception_NotImplemented

ensurePermissions()

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

Ensures bits in the permission flag.

Parameters
$permissions
 
$revision
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

factory()

public static SetaPDF_Core_SecHandler_Standard_Aes256R5::factory (
SetaPDF_Core_Document $document, $ownerPassword [, $userPassword = '' [, $permissions = 0 [, $encryptMetadata = true [, $passwordsEncoding = 'utf-8' ]]]]
):

Factory method for AES 256 bit security handler. (revision 5 - DEPRECTAED IN ISO/DIS 32000-2)

Parameters
$document : SetaPDF_Core_Document
 
$ownerPassword

The owner password in encoding defined in $passwordsEncoding

$userPassword

The user password in encoding defined in $passwordsEncoding

$permissions
 
$encryptMetadata
 
$passwordsEncoding
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

Throws SetaPDF_Exception_NotImplemented


Methods

__construct()

The constructor.

Parameters
$document : SetaPDF_Core_Document
 
$encryptionDictionary : SetaPDF_Core_Type_Dictionary
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

_authByOwnerPassword()

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

Internal method to authenticate with the owner password.

Parameters
$ownerPassword
 
Return Values

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

Exceptions

Throws SetaPDF_Exception_NotImplemented

_authByUserPassword()

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

Internal method to authenticate with the user password.

Parameters
$userPassword
 
Return Values

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

_computeEncryptionKey()

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

Compute the encryption key based on a password.

Parameters
$password
 
Exceptions

Throws SetaPDF_Exception_NotImplemented

_computeHashR6()

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

Computes a hash for security handler revision 6.

Parameters
$data
 
$inputPassword
 
$userKey
 

_computeOValue()

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

Compute the O value.

Parameters
$userPassword
 
$ownerPassword
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

_computeUValue()

protected SetaPDF_Core_SecHandler_Standard::_computeUValue (
$encryptionKey
):

Compute the U value.

Parameters
$encryptionKey
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

_crypt()

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

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

Parameters
$data
 
$algorithm
 
$param
 
$encrypt
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

_getEncryptionKeyByUserPassword()

Get the encryption key by the user password.

Parameters
$password
 

auth()

public SetaPDF_Core_SecHandler_Standard::auth (
[ $password = null [, $encoding = 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
$password
 
$encoding
 
Return Values

Authentication was successful or not

Exceptions

Throws SetaPDF_Exception_NotImplemented

authByOwnerPassword()

public SetaPDF_Core_SecHandler_Standard::authByOwnerPassword (
$password [, $encoding = null ]
):

Authenticate with the owner password.

Parameters
$password
 
$encoding
 
Exceptions

Throws SetaPDF_Exception_NotImplemented

authByUserPassword()

public SetaPDF_Core_SecHandler_Standard::authByUserPassword (
$password [, $encoding = null ]
):

Authenticate with the user password.

Parameters
$password
 
$encoding
 
Exceptions

Throws SetaPDF_Exception_NotImplemented

decryptStream()

public SetaPDF_Core_SecHandler_AbstractHandler::decryptStream (
$data [, $param = null ]
):

Decrypt a stream.

Parameters
$data
 
$param
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

decryptString()

public SetaPDF_Core_SecHandler_AbstractHandler::decryptString (
$data [, $param = null ]
):

Decrypt a string.

Parameters
$data
 
$param
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

encryptStream()

public SetaPDF_Core_SecHandler_AbstractHandler::encryptStream (
$data [, $param = null ]
):

Encrypt a stream.

Parameters
$data
 
$param
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

encryptString()

public SetaPDF_Core_SecHandler_AbstractHandler::encryptString (
$data [, $param = null ]
):

Encrypt a string.

Parameters
$data
 
$param
 
Exceptions

Throws SetaPDF_Core_SecHandler_Exception

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()

Gets the encryption dictionary.

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()

Queries if a permission is granted.

Parameters
$permission
 

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.