setasign\SetaPDF2\Core\SecHandler
Standard Security handler class handling standard encryption features
File: /SetaPDF v2/Core/SecHandler/Standard.php
Old class name (alias):
\SetaPDF_Core_SecHandler_Standard
Class hierarchy
Implements
Summary
Methods
- __construct()
- _authByOwnerPassword()
- _authByUserPassword()
- _computeEncryptionKey()
- _computeHashR6()
- _computeOValue()
- _computeUValue()
- _crypt()
- _getEncryptionKeyByUserPassword()
- auth()
- authByOwnerPassword()
- authByUserPassword()
- decryptStream()
- decryptString()
- encryptStream()
- encryptString()
- getAuthMode()
- getDocument()
- getEncryptMetadata()
- getEncryptionDictionary()
- getEncryptionKey()
- getPdfVersion()
- getPermission()
- getPermissions()
- getRevision()
- getStreamAlgorithm()
- getStringAlgorithm()
- isAuth()
Static Properties
Properties
$_authMode
The auth mode
Says who is authenticated: user or owner
$_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 these things if a crypt filter is in use.
Static Methods
ensurePasswordEncoding()
string $password,
string $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 processed with the SASLprep profile if required.
Parameters
- $revision: int
- $password: string
- $encoding: string
Exceptions
ensurePermissions()
Ensures bits in the permission flag.
Parameters
- $permissions: int
- $revision: int
Exceptions
Throws Exception
Methods
__construct()
\setasign\SetaPDF2\Core\Type\PdfDictionary $encryptionDictionary
The constructor.
Parameters
- $document: \setasign\SetaPDF2\Core\Document
- $encryptionDictionary: \setasign\SetaPDF2\Core\Type\PdfDictionary
Exceptions
Throws Exception
_authByOwnerPassword()
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 \setasign\SetaPDF2\NotImplementedException
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws Exception
_authByUserPassword()
Internal method to authenticate with the user password.
Parameters
- $userPassword: string
Return Values
The encryption key if the authentication was successful. False if not.
Exceptions
Throws Exception
_computeEncryptionKey()
Compute the encryption key based on a password.
Parameters
- $password: ?string
Exceptions
Throws \setasign\SetaPDF2\NotImplementedException
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws Exception
_computeHashR6()
string $inputPassword,
string $userKey = ''
Computes a hash for security handler revision 6.
Parameters
- $data: string
- $inputPassword: string
- $userKey: string
_computeOValue()
Compute the O value.
Parameters
- $userPassword: string
- $ownerPassword: string
Exceptions
Throws Exception
_computeUValue()
_crypt()
array $algorithm,
?(\setasign\SetaPDF2\Core\Type\AbstractType & \setasign\SetaPDF2\Core\Type\IndirectObjectInterface) $param = null,
bool $encrypt = true
Encrypts or decrypts data using Algorithm 1 of the PDF specification.
Parameters
- $data: string
- $algorithm: array
- $param: ?(\setasign\SetaPDF2\Core\Type\AbstractType & \setasign\SetaPDF2\Core\Type\IndirectObjectInterface)
- $encrypt: bool
Exceptions
Throws Exception
_getEncryptionKeyByUserPassword()
Get the encryption key by the user password.
Parameters
- $password: string
Exceptions
Throws Exception
auth()
Authenticate against the security handler.
This method will try to auth first with the owner password.
If this fails it will try to auth to the user password.
Parameters
- $password: string
- $encoding: ?string
Return Values
Authentication was successful or not
Exceptions
Throws \setasign\SetaPDF2\NotImplementedException
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws Exception
authByOwnerPassword()
Authenticate with the owner password.
Parameters
- $password: string
- $encoding: ?string
Exceptions
Throws \setasign\SetaPDF2\NotImplementedException
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws Exception
authByUserPassword()
Authenticate with the user password.
Parameters
- $password: string
- $encoding: ?string
Exceptions
Throws \setasign\SetaPDF2\NotImplementedException
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws Exception
decryptStream()
?(\setasign\SetaPDF2\Core\Type\AbstractType & \setasign\SetaPDF2\Core\Type\IndirectObjectInterface) $param = null
Decrypt a stream.
Parameters
- $data: string
- $param: ?(\setasign\SetaPDF2\Core\Type\AbstractType & \setasign\SetaPDF2\Core\Type\IndirectObjectInterface)
Exceptions
Throws Exception
decryptString()
?(\setasign\SetaPDF2\Core\Type\AbstractType & \setasign\SetaPDF2\Core\Type\IndirectObjectInterface) $param = null
Decrypt a string.
Parameters
- $data: string
- $param: ?(\setasign\SetaPDF2\Core\Type\AbstractType & \setasign\SetaPDF2\Core\Type\IndirectObjectInterface)
Exceptions
Throws Exception
encryptStream()
?(\setasign\SetaPDF2\Core\Type\AbstractType & \setasign\SetaPDF2\Core\Type\IndirectObjectInterface) $param = null
Encrypt a stream.
Parameters
- $data: string
- $param: ?(\setasign\SetaPDF2\Core\Type\AbstractType & \setasign\SetaPDF2\Core\Type\IndirectObjectInterface)
Exceptions
Throws Exception
encryptString()
?(\setasign\SetaPDF2\Core\Type\AbstractType & \setasign\SetaPDF2\Core\Type\IndirectObjectInterface) $param = null
Encrypt a string.
Parameters
- $data: string
- $param: ?(\setasign\SetaPDF2\Core\Type\AbstractType & \setasign\SetaPDF2\Core\Type\IndirectObjectInterface)
Exceptions
Throws Exception
getAuthMode()
Get the auth method.
Return Values
"user", "owner" or an empty string if not authenticated.
getEncryptionDictionary()
Gets the encryption dictionary.
getEncryptionKey()
getPdfVersion()
Get the PDF version, which is needed for the currently used encryption algorithm.
Exceptions
isAuth()
Queries if the security handler is authenticated.
If not it tries by calling auth() without a password.
