PoDoFo
0.9.6
|
#include <PdfEncrypt.h>
Inherited by PoDoFo::PdfEncryptMD5Base.
Public Types | |
enum | EPdfKeyLength |
enum | EPdfPermissions { ePdfPermissions_Print = 0x00000004 , ePdfPermissions_Edit = 0x00000008 , ePdfPermissions_Copy = 0x00000010 , ePdfPermissions_EditNotes = 0x00000020 , ePdfPermissions_FillAndSign = 0x00000100 , ePdfPermissions_Accessible = 0x00000200 , ePdfPermissions_DocAssembly = 0x00000400 , ePdfPermissions_HighPrint = 0x00000800 } |
enum | EPdfEncryptAlgorithm { ePdfEncryptAlgorithm_RC4V1 = 1 , ePdfEncryptAlgorithm_RC4V2 = 2 , ePdfEncryptAlgorithm_AESV2 = 4 } |
Public Member Functions | |
virtual | ~PdfEncrypt ()=0 |
virtual void | GenerateEncryptionKey (const PdfString &documentId)=0 |
virtual void | CreateEncryptionDictionary (PdfDictionary &rDictionary) const =0 |
virtual PdfOutputStream * | CreateEncryptionOutputStream (PdfOutputStream *pOutputStream)=0 |
virtual PdfInputStream * | CreateEncryptionInputStream (PdfInputStream *pInputStream)=0 |
virtual bool | Authenticate (const std::string &password, const PdfString &documentId)=0 |
EPdfEncryptAlgorithm | GetEncryptAlgorithm () const |
bool | IsOwnerPasswordSet () const |
bool | IsPrintAllowed () const |
bool | IsEditAllowed () const |
bool | IsCopyAllowed () const |
bool | IsEditNotesAllowed () const |
bool | IsFillAndSignAllowed () const |
bool | IsAccessibilityAllowed () const |
bool | IsDocAssemblyAllowed () const |
bool | IsHighPrintAllowed () const |
const unsigned char * | GetUValue () const |
Get the U object value (user) | |
const unsigned char * | GetOValue () const |
Get the O object value (owner) | |
const unsigned char * | GetEncryptionKey () const |
Get the encryption key value (owner) | |
pdf_int32 | GetPValue () const |
Get the P object value (protection) | |
int | GetRevision () const |
Get the revision number of the encryption method. | |
int | GetKeyLength () const |
Get the key length of the encryption key in bits. | |
bool | IsMetadataEncrypted () const |
Is metadata encrypted. | |
virtual void | Encrypt (const unsigned char *inStr, pdf_long inLen, unsigned char *outStr, pdf_long outLen) const =0 |
Encrypt a wxString. More... | |
virtual void | Decrypt (const unsigned char *inStr, pdf_long inLen, unsigned char *outStr, pdf_long &outLen) const =0 |
Decrypt a character string. | |
virtual pdf_long | CalculateStreamLength (pdf_long length) const =0 |
Calculate stream size. | |
virtual pdf_long | CalculateStreamOffset () const =0 |
Calculate stream offset. | |
void | SetCurrentReference (const PdfReference &rRef) |
Static Public Member Functions | |
static PdfEncrypt * | CreatePdfEncrypt (const std::string &userPassword, const std::string &ownerPassword, int protection=ePdfPermissions_Print|ePdfPermissions_Edit|ePdfPermissions_Copy|ePdfPermissions_EditNotes|ePdfPermissions_FillAndSign|ePdfPermissions_Accessible|ePdfPermissions_DocAssembly|ePdfPermissions_HighPrint, EPdfEncryptAlgorithm eAlgorithm=ePdfEncryptAlgorithm_AESV2, EPdfKeyLength eKeyLength=ePdfKeyLength_40) |
static PdfEncrypt * | CreatePdfEncrypt (const PdfObject *pObject) |
static PdfEncrypt * | CreatePdfEncrypt (const PdfEncrypt &rhs) |
static int | GetEnabledEncryptionAlgorithms () |
static void | SetEnabledEncryptionAlgorithms (int nEncryptionAlgorithms) |
static bool | IsEncryptionEnabled (EPdfEncryptAlgorithm eAlgorithm) |
Protected Member Functions | |
bool | CheckKey (unsigned char key1[32], unsigned char key2[32]) |
Check two keys for equality. | |
Protected Attributes | |
EPdfEncryptAlgorithm | m_eAlgorithm |
The used encryption algorithm. | |
int | m_keyLength |
Length of encryption key. | |
int | m_rValue |
Revision. | |
pdf_int32 | m_pValue |
P entry in pdf document. | |
EPdfKeyLength | m_eKeyLength |
The key length. | |
std::string | m_userPass |
User password. | |
std::string | m_ownerPass |
Owner password. | |
unsigned char | m_uValue [48] |
U entry in pdf document. | |
unsigned char | m_oValue [48] |
O entry in pdf document. | |
unsigned char | m_encryptionKey [32] |
Encryption key. | |
PdfReference | m_curReference |
Reference of the current PdfObject. | |
std::string | m_documentId |
DocumentID of the current document | |
bool | m_bEncryptMetadata |
Is metadata encrypted. | |
Class representing PDF encryption methods. (For internal use only) Based on code from Ulrich Telle: http://wxcode.sourceforge.net/components/wxpdfdoc/ Original Copyright header: A class that is used to encrypt a PDF file and set document permissions on the PDF file.
As a user of this class, you have only to instantiate a object of this class and pass it to PdfWriter, PdfMemDocument, PdfStreamedDocument or PdfImmediateWriter. You do not have to call any other method of this class. The above classes know how to handle encryption using PdfEncrypt.
A enum specifying a valid keylength for a PDF encryption key. Keys must be in the range 40 to 128 bit and have to be a multiple of 8.
Adobe Reader supports only keys with 40, 128 or 256 bits!
Set user permissions/restrictions on a document
|
pure virtual |
Destruct the PdfEncrypt object
|
pure virtual |
Tries to authenticate a user using either the user or owner password
password | owner or user password |
documentId | the documentId of the PDF file |
Implemented in PoDoFo::PdfEncryptRC4, and PoDoFo::PdfEncryptAESV2.
|
pure virtual |
Fill all keys into a encryption dictionary. This dictionary is usually added to the PDF files trailer under the /Encryption key.
rDictionary | an empty dictionary which is filled with information about the used encryption algorithm |
|
pure virtual |
Create a PdfInputStream that decrypts all data read from it using the current settings of the PdfEncrypt object.
Warning: Currently only RC4 based encryption is supported using output streams!
pInputStream | the created PdfInputStream reads all decrypted data to this input stream. |
Implemented in PoDoFo::PdfEncryptRC4, and PoDoFo::PdfEncryptAESV2.
|
pure virtual |
Create a PdfOutputStream that encrypts all data written to it using the current settings of the PdfEncrypt object.
Warning: Currently only RC4 based encryption is supported using output streams!
pOutputStream | the created PdfOutputStream writes all encrypted data to this output stream. |
Implemented in PoDoFo::PdfEncryptRC4, and PoDoFo::PdfEncryptAESV2.
|
static |
Copy constructor
rhs | another PdfEncrypt object which is copied |
|
static |
Initialize a PdfEncrypt object from an encryption dictionary in a PDF file.
This is required for encrypting a PDF file, but handled internally in PdfParser for you.
Will use only encrypting algorithms that are enabled.
pObject | a PDF encryption dictionary |
|
static |
Create a PdfEncrypt object which can be used to encrypt a PDF file.
userPassword | the user password (if empty the user does not have to enter a password to open the document) |
ownerPassword | the owner password |
protection | several EPdfPermissions values or'ed together to set the users permissions for this document |
eAlgorithm | the revision of the encryption algorithm to be used |
eKeyLength | the length of the encryption key ranging from 40 to 128 bits (only used if eAlgorithm == ePdfEncryptAlgorithm_RC4V2) |
|
pure virtual |
Encrypt a wxString.
Encrypt a character string
Implemented in PoDoFo::PdfEncryptRC4, and PoDoFo::PdfEncryptAESV2.
|
pure virtual |
Generate encryption key from user and owner passwords and protection key
documentId | the documentId of the current document |
Implemented in PoDoFo::PdfEncryptRC4, and PoDoFo::PdfEncryptAESV2.
|
static |
Retrieve the list of encryption algorithms that are used when loading a PDF document.
By default all algorithms are enabled.
|
inline |
Get the encryption algorithm of this object.
|
inline |
Checks if it is allowed to extract text and graphics to support users with disabilities Every PDF consuming applications has to adhere this value!
|
inline |
Checks if text and graphics extraction is allowed. Every PDF consuming applications has to adhere this value!
|
inline |
Checks if it is allowed to insert, create, rotate, delete pages or add bookmarks Every PDF consuming applications has to adhere this value!
|
inline |
Checks if modifying this document (besides annotations, form fields or changing pages) is allowed. Every PDF consuming applications has to adhere this value!
|
inline |
Checks if it is allowed to add or modify annotations or form fields Every PDF consuming applications has to adhere this value!
|
static |
Test if a certain encryption algorithm is enabled for loading PDF documents.
|
inline |
Checks if it is allowed to fill in existing form or signature fields Every PDF consuming applications has to adhere this value!
|
inline |
Checks if it is allowed to print a high quality version of this document Every PDF consuming applications has to adhere this value!
|
inline |
Checks if an owner password is set. An application reading PDF must adhere to permissions for printing, copying, etc., unless the owner password was used to open it.
|
inline |
Checks if printing this document is allowed. Every PDF consuming applications has to adhere this value!
|
inline |
Set the reference of the object that is currently encrypted.
This value will be used in following calls of Encrypt to encrypt the object.
|
static |
Specify the list of encryption algorithms that should be used by PoDoFo when loading a PDF document.
This can be used to disable for example AES encryption/decryption which is unstable in certain cases.