setasign\SetaPDF2\Core\SecHandler\Standard

Arcfour40 Generator class for RC4 40 bit security handler

File: /SetaPDF v2/Core/SecHandler/Standard/Arcfour40.php
Old class name (alias): \SetaPDF_Core_SecHandler_Standard_Arcfour40

Class hierarchy

Implements

Summary

Static Properties

$_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

$_encryptionKey

$_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 key length to be used for en/decrypting stream

$_stringAlgorithm

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


Static Methods

create()

public static Arcfour40::create (
\SetaPDF_Core_Document $document,
string $ownerPassword,
string $userPassword = '',
int $permissions = 0,
string $passwordsEncoding = \setasign\SetaPDF2\Core\Encoding\Encoding::PDF_DOC
): \SetaPDF_Core_SecHandler_Standard_Arcfour40

Create method for RC4 40 bit security handler.

Parameters
$document : \SetaPDF_Core_Document
 
$ownerPassword : string

The owner password in encoding defined in $passwordsEncoding

$userPassword : string

The user password in encoding defined in $passwordsEncoding

$permissions : int
 
$passwordsEncoding : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\NotImplementedException

Throws \setasign\SetaPDF2\Core\Type\Exception

ensurePasswordEncoding()

public static \setasign\SetaPDF2\Core\SecHandler\Standard::ensurePasswordEncoding (
int $revision,
string $password,
string $encoding
): 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
 
$encoding : string
 
Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

ensurePermissions()

public static \setasign\SetaPDF2\Core\SecHandler\Standard::ensurePermissions (
int $permissions,
int $revision
): int

Ensures bits in the permission flag.

Parameters
$permissions : int
 
$revision : int
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

factory()

WARNING: This method is marked as deprecated!

Use self::create() instead

public static Arcfour40::factory (
\SetaPDF_Core_Document $document,
string $ownerPassword,
string $userPassword = '',
int $permissions = 0,
string $passwordsEncoding = \setasign\SetaPDF2\Core\Encoding\Encoding::PDF_DOC
): \SetaPDF_Core_SecHandler_Standard_Arcfour40
Parameters
$document : \SetaPDF_Core_Document
 
$ownerPassword : string

The owner password in encoding defined in $passwordsEncoding

$userPassword : string

The user password in encoding defined in $passwordsEncoding

$permissions : int
 
$passwordsEncoding : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\NotImplementedException

Throws \setasign\SetaPDF2\Core\Type\Exception


Methods

_authByOwnerPassword()

protected \setasign\SetaPDF2\Core\SecHandler\Standard::_authByOwnerPassword (
string $ownerPassword = ''
): string|bool

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 \setasign\SetaPDF2\Core\SecHandler\Exception

_authByUserPassword()

protected \setasign\SetaPDF2\Core\SecHandler\Standard::_authByUserPassword (
string $userPassword = ''
): string|bool

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 \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

_computeEncryptionKey()

protected \setasign\SetaPDF2\Core\SecHandler\Standard::_computeEncryptionKey (
string $password = ''
): string

Compute the encryption key based on a password.

Parameters
$password : string
 
Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

_computeHashR6()

protected \setasign\SetaPDF2\Core\SecHandler\AbstractHandler::_computeHashR6 (
string $data,
string $inputPassword,
string $userKey = ''
): string

Computes a hash for security handler revision 6.

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

_computeOValue()

protected \setasign\SetaPDF2\Core\SecHandler\Standard::_computeOValue (
string $userPassword,
string $ownerPassword = ''
): string

Compute the O value.

Parameters
$userPassword : string
 
$ownerPassword : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_computeUValue()

protected \setasign\SetaPDF2\Core\SecHandler\Standard::_computeUValue (
string $encryptionKey
): string

Compute the U value.

Parameters
$encryptionKey : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

_crypt()

protected \setasign\SetaPDF2\Core\SecHandler\AbstractHandler::_crypt (
string $data,
array $algorithm,
\SetaPDF_Core_Type_IndirectObject $param = null,
bool $encrypt = true
): string

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

Parameters
$data : string
 
$algorithm : array
 
$param : \SetaPDF_Core_Type_IndirectObject
 
$encrypt : bool
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

_getEncryptionKeyByUserPassword()

Get the encryption key by the user password.

Parameters
$password : string
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\NotImplementedException

auth()

public \setasign\SetaPDF2\Core\SecHandler\Standard::auth (
string $password = null,
?string $encoding = null
): bool

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 \setasign\SetaPDF2\Core\SecHandler\Exception

authByOwnerPassword()

public \setasign\SetaPDF2\Core\SecHandler\Standard::authByOwnerPassword (
string $password,
?string $encoding = null
): bool

Authenticate with the owner password.

Parameters
$password : string
 
$encoding : ?string
 
Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

authByUserPassword()

public \setasign\SetaPDF2\Core\SecHandler\Standard::authByUserPassword (
string $password,
null $encoding = null
): bool

Authenticate with the user password.

Parameters
$password : string
 
$encoding : null
 
Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

Throws \setasign\SetaPDF2\Core\Type\Exception

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

decryptStream()

Decrypt a stream.

Parameters
$data : string
 
$param : \SetaPDF_Core_Type_IndirectObject
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

decryptString()

Decrypt a string.

Parameters
$data : string
 
$param : \SetaPDF_Core_Type_IndirectObject
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

encryptStream()

Encrypt a stream.

Parameters
$data : string
 
$param : \SetaPDF_Core_Type_IndirectObject
 
Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

encryptString()

Encrypt a string.

Parameters
$data : string
 
$param : \SetaPDF_Core_Type_IndirectObject
 
Exceptions

Throws \setasign\SetaPDF2\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()

getEncryptionKey()

Get the encryption key if known/authenticated.

Exceptions

Throws \setasign\SetaPDF2\Core\SecHandler\Exception

getPdfVersion()

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

Exceptions

Throws \setasign\SetaPDF2\NotImplementedException

getPermission()

Queries if a permission is granted.

Parameters
$permission : int
 
Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

getRevision()

Get the revision of the security handler.

Exceptions

Throws \setasign\SetaPDF2\Core\Type\Exception

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.