PDF SDK Documentation

Comprehensive Guide for Developers: Features, Integration, and API Reference

Loading...
Searching...
No Matches
PDF::StdSecurityParams Struct Reference

Helper class that represents the data of the Standard Security Handler. More...

#include <pdfsdk/cxx/standard_security.h>

Inheritance diagram for PDF::StdSecurityParams:
PDStdSecurityParams

Public Types

enum class  PrintPermissions { None , LowResolution , HighResolution }
 Enum representing the print permissions for the Standard Security Handler. More...
 
enum class  EditPermissions {
  None , DocumentAssembly , FormFillAndSign , ReviewFormFillAndSign ,
  AnyButExtractPages
}
 Enum representing the edit permissions for the Standard Security Handler. More...
 
enum class  ExtractPermissions { None , Accessibility , Any }
 Enum representing the extraction permissions for the Standard Security Handler. More...
 

Public Member Functions

 StdSecurityParams ()
 Default constructor for StdSecurityParams.
 
void SetPermissions (PrintPermissions printPerms, EditPermissions editPerms, ExtractPermissions extractPerms)
 Set the permissions for the Standard Security Handler.
 
void SetCryptMethod (PDAtom method, int keyLen=0)
 Set the cryptographic method and key length for the Standard Security Handler.
 
void ResetToDefault ()
 Reset the Standard Security Handler parameters to their default values.
 
bool operator== (const StdSecurityParams &that) const
 
bool HasPasswords () const
 Check if the Standard Security Handler has either an owner or a user password set, or both.
 
std::wstring GetUserPassword () const
 Get the user password for the Standard Security Handler.
 
std::wstring GetOwnerPassword () const
 Get the owner password for the Standard Security Handler.
 
void SetUserPassword (const std::wstring &newUserPassword)
 Set the user password for the Standard Security Handler.
 
void SetOwnerPassword (const std::wstring &newOwnerPassword)
 Set the owner password for the Standard Security Handler.
 

Static Public Member Functions

static int GetDefaultKeyLengthByCryptMethod (PDAtom cryptMethod)
 Get the default key length of the file encryption key, based on the cryptographic method.
 
static int GetDefaultVersionByCryptMethod (PDAtom cryptMethod, int keyLen)
 Get the default version of the encryption algorithm used, based on the cryptographic method and key length.
 
static int GetDefaultRevisionByCryptMethod (PDAtom cryptMethod, int keyLen)
 Get the default standard security handler revision based on the cryptographic method and key length.
 
static PDStdPerms GetAllAllowedDefaultPermissions ()
 

Public Attributes

PDStdSecurityModifyFlags modifyFlags = 0
 
- Public Attributes inherited from PDStdSecurityParams
PDStdPassword userPassword
 
bool hasUserPassword
 
PDStdPassword ownerPassword
 
bool hasOwnerPassword
 
PDStdPerms permissions
 
int revision
 
int version
 
PDAtom cryptMethod
 
int keyLength
 
bool encryptMetadata
 
bool encryptAttachmentsOnly
 

Detailed Description

Helper class that represents the data of the Standard Security Handler.

The Security Handler is a software module that implements various aspects of the encryption process and controls access to the contents of an encrypted document. 'Standard' shall be the name of the built-in password-based security handler. One function of a security handler is to generate a file encryption key for use in encrypting and decrypting the contents of a document. Given a password string, the standard security handler computes a file encryption key. For more information refer to section 7.6.4 Standard security handler, from the ISO 32000-2:2020 (PDF 2.0) PDF Standard. All encryption related information is stored in the document's encryption dictionary. It is part of the document's trailer dictionary under it's 'Encrypt' entry. The encryption dictionary’s 'Filter' entry identifies the file’s security handler. For more information refer to section 7.6.2 Application of encryption from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.

Member Enumeration Documentation

◆ EditPermissions

Enum representing the edit permissions for the Standard Security Handler.

For more information refer to section 7.6.4.2 Standard encryption dictionary, Table 21 — Additional encryption dictionary entries for the standard security handler, key P, Table 22 — Standard security handler user access permissions, bit positions 4 and 6, 9, 11, from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.

Enumerator
None 

No changes allowed.

DocumentAssembly 

Creating, inserting, deleting, and rotating pages.

FormFillAndSign 

Filling-in form fields and signing.

ReviewFormFillAndSign 

Commenting, filling-in form fields, and signing existing signature fields.

AnyButExtractPages 

Any permissions except extract pages.

◆ ExtractPermissions

Enum representing the extraction permissions for the Standard Security Handler.

For more information refer to section 7.6.4.2 Standard encryption dictionary, Table 21 — Additional encryption dictionary entries for the standard security handler, key P, Table 22 — Standard security handler user access permissions, bit position 5, from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.

Enumerator
None 

Extraction not allowed.

Accessibility 

Enable copying of text, images, and other content.

Any 

Enable copying of any content.

◆ PrintPermissions

Enum representing the print permissions for the Standard Security Handler.

For more information refer to section 7.6.4.2 Standard encryption dictionary, Table 21 — Additional encryption dictionary entries for the standard security handler, key P, Table 22 — Standard security handler user access permissions, bit positions 3 and 12, from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.

Enumerator
None 

No print permissions.

LowResolution 

Low resolution print permissions.

HighResolution 

High resolution print permissions.

Constructor & Destructor Documentation

◆ StdSecurityParams()

PDF::StdSecurityParams::StdSecurityParams ( )
inline

Default constructor for StdSecurityParams.

The default is to use kPDCryptMethod_AESV3 with no password.

Member Function Documentation

◆ GetDefaultKeyLengthByCryptMethod()

int PDF::StdSecurityParams::GetDefaultKeyLengthByCryptMethod ( PDAtom cryptMethod)
inlinestatic

Get the default key length of the file encryption key, based on the cryptographic method.

This function returns the default file encryption key length in bytes based on the specified cryptographic method. This is the 'Length' entry in the file's encryption dictionary. For more information refer to section 7.6.2 Application of encryption, Table 20 — Entries common to all encryption dictionaries, key Length, from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.

Parameters
[in]cryptMethodThe cryptographic method. One of V2, AESV2, AESV3.
Returns
The default key length in bytes (i.e. 32 bytes is 256 bits)

◆ GetDefaultRevisionByCryptMethod()

int PDF::StdSecurityParams::GetDefaultRevisionByCryptMethod ( PDAtom cryptMethod,
int keyLen )
inlinestatic

Get the default standard security handler revision based on the cryptographic method and key length.

This represents the R entry in the standard security handler dictionary. For more information refer to section 7.6.4.2 Standard encryption dictionary, Table 21 — Additional encryption dictionary entries for the standard security handler, key R. If the cryptographic method is AESV2, the default revision is 4. If the cryptographic method is AESV3 and the key length is greater than 5, the default revision is 6. If the key length is greater than 5, the default revision is 3. Otherwise it is 2. Use of security handler revisions 1, 2, 3, 4 and 5 is deprecated in PDF 2.0. For more information refer to section 7.6.4 Standard security handler, 7.6.4.1 General, from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.

Parameters
[in]cryptMethodThe cryptographic method.
[in]keyLenThe key length in bytes.
Returns
The default revision.

◆ GetDefaultVersionByCryptMethod()

int PDF::StdSecurityParams::GetDefaultVersionByCryptMethod ( PDAtom cryptMethod,
int keyLen )
inlinestatic

Get the default version of the encryption algorithm used, based on the cryptographic method and key length.

This function returns the default version based on the specified cryptographic method and key length. This represents the V entry in the encryption dictionary. For more information refer to section 7.6.2 Application of encryption, Table 20 — Entries common to all encryption dictionaries, key V. If the cryptographic method is AESV2, the default version is 4. If the cryptographic method is AESV3 and the key length is greater than 5, the default version is 5. If the key length is greater than 5, the default version is 2, otherwise it is 1. If a version of 4 or 5 is specified, the standard security handler shall support crypt filters, which provide finer granularity control of encryption within a PDF file. For more information refer to section, 7.6.6 Crypt filters, from the ISO 32000-2:2020 (PDF 2.0) PDF Standard.

Parameters
[in]cryptMethodThe cryptographic method.
[in]keyLenThe key length in bytes. This is the 'Length' entry of the encryption dictionary.
Returns
The default version. Values less than 5 are deprecated in PDF 2.0.

◆ GetOwnerPassword()

std::wstring PDF::StdSecurityParams::GetOwnerPassword ( ) const
inline

Get the owner password for the Standard Security Handler.

This function retrieves the owner password for the Standard Security Handler. If the owner password is set, it returns the password as a wide string. If the owner password is not set, it returns an empty wide string.

Returns
The owner password as a wide string, or an empty wide string if not set.

◆ GetUserPassword()

std::wstring PDF::StdSecurityParams::GetUserPassword ( ) const
inline

Get the user password for the Standard Security Handler.

This function retrieves the user password for the Standard Security Handler. If the user password is set, it returns the password as a wide string. If the user password is not set, it returns an empty wide string.

Returns
The user password as a wide string, or an empty wide string if not set.

◆ HasPasswords()

bool PDF::StdSecurityParams::HasPasswords ( ) const
inline

Check if the Standard Security Handler has either an owner or a user password set, or both.

Returns
True if any of the passwords are set, false otherwise.

◆ ResetToDefault()

void PDF::StdSecurityParams::ResetToDefault ( )
inline

Reset the Standard Security Handler parameters to their default values.

This function resets the Standard Security Handler parameters to their default values. It sets the user password and owner password to empty strings, sets the permissions to the default allowed permissions, sets the cryptographic method to AESV3 with a key length of 32 bytes, sets the version to 5, sets the revision to 6, enables metadata encryption, and disables attachment-only encryption.

◆ SetCryptMethod()

void PDF::StdSecurityParams::SetCryptMethod ( PDAtom method,
int keyLen = 0 )
inline

Set the cryptographic method and key length for the Standard Security Handler.

This function sets the cryptographic method and key length for the Standard Security Handler. If the key length is not provided, it will be set to the default key length based on the cryptographic method.

Parameters
[in]methodThe cryptographic method. One of V2, AESV2, AESV3.
[in]keyLen[Optional] The key length in bytes.

◆ SetOwnerPassword()

void PDF::StdSecurityParams::SetOwnerPassword ( const std::wstring & newOwnerPassword)
inline

Set the owner password for the Standard Security Handler.

Parameters
[in]newOwnerPasswordA reference to the new owner password as a wide string. Documents in which only file attachments are encrypted shall use the same user and owner passwords.

◆ SetPermissions()

void PDF::StdSecurityParams::SetPermissions ( PrintPermissions printPerms,
EditPermissions editPerms,
ExtractPermissions extractPerms )
inline

Set the permissions for the Standard Security Handler.

This function sets the permissions for the Standard Security Handler based on the specified print permissions, edit permissions, and extraction permissions.

Parameters
[in]printPermsThe print permissions. One of None/Low Resolution/High Resolution.
See also
PrintPermissions
Parameters
[in]editPermsThe edit permissions.
See also
EditPermissions
Parameters
[in]extractPermsThe extraction permissions.
See also
ExtractPermissions

◆ SetUserPassword()

void PDF::StdSecurityParams::SetUserPassword ( const std::wstring & newUserPassword)
inline

Set the user password for the Standard Security Handler.

Parameters
[in]newUserPasswordA reference to the new user password as a wide string. Documents in which only file attachments are encrypted shall use the same user and owner passwords.

The documentation for this struct was generated from the following file: