Logo Search packages:      
Sourcecode: libpodofo version File versions  Download package

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes

PoDoFo::PdfEncrypt Class Reference

#include <PdfEncrypt.h>

Inheritance diagram for PoDoFo::PdfEncrypt:
Inheritance graph
Collaboration diagram for PoDoFo::PdfEncrypt:
Collaboration graph

List of all members.

Public Types

enum  EPdfEncryptAlgorithm { ePdfEncryptAlgorithm_RC4V1 = 1, ePdfEncryptAlgorithm_RC4V2 = 2, ePdfEncryptAlgorithm_AESV2 = 4 }
enum  EPdfKeyLength {
  ePdfKeyLength_40 = 40, ePdfKeyLength_56 = 56, ePdfKeyLength_80 = 80, ePdfKeyLength_96 = 96,
  ePdfKeyLength_128 = 128
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

Public Member Functions

bool Authenticate (const std::string &password, const PdfString &documentId)
bool Authenticate (const std::string &documentID, const std::string &password, const std::string &uValue, const std::string &oValue, int pValue, int lengthValue, int rValue)
virtual pdf_long CalculateStreamLength (pdf_long length) const
 Calculate stream size.
virtual pdf_long CalculateStreamOffset () const
 Calculate stream offset.
virtual void CreateEncryptionDictionary (PdfDictionary &rDictionary) const =0
virtual PdfInputStreamCreateEncryptionInputStream (PdfInputStream *pInputStream)=0
virtual PdfOutputStreamCreateEncryptionOutputStream (PdfOutputStream *pOutputStream)=0
void Encrypt (std::string &str, pdf_long inputLen) const
 Encrypt a wxString.
virtual void Encrypt (unsigned char *str, pdf_long len) const =0
 Encrypt a character string.
void GenerateEncryptionKey (const PdfString &documentId)
EPdfEncryptAlgorithm GetEncryptAlgorithm () const
int GetKeyLength () const
 Get the key length of the encryption key in bits.
const unsigned char * GetOValue () const
 Get the O object value (owner)
int GetPValue () const
 Get the P object value (protection)
int GetRevision () const
 Get the revision number of the encryption method.
const unsigned char * GetUValue () const
 Get the U object value (user)
bool IsAccessibilityAllowed () const
bool IsCopyAllowed () const
bool IsDocAssemblyAllowed () const
bool IsEditAllowed () const
bool IsEditNotesAllowed () const
bool IsFillAndSignAllowed () const
bool IsHighPrintAllowed () const
bool IsPrintAllowed () const
const PdfEncryptoperator= (const PdfEncrypt &rhs)
void SetCurrentReference (const PdfReference &rRef)
virtual ~PdfEncrypt ()

Static Public Member Functions

static PdfEncryptCreatePdfEncrypt (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_RC4V1, EPdfKeyLength eKeyLength=ePdfKeyLength_40)
static PdfEncryptCreatePdfEncrypt (const PdfObject *pObject)
static PdfEncryptCreatePdfEncrypt (const PdfEncrypt &rhs)
static int GetEnabledEncryptionAlgorithms ()
static PdfString GetMD5String (const unsigned char *pBuffer, int nLength)
static bool IsEncryptionEnabled (EPdfEncryptAlgorithm eAlgorithm)
static void SetEnabledEncryptionAlgorithms (int nEncryptionAlgorithms)

Protected Member Functions

bool CheckKey (unsigned char key1[32], unsigned char key2[32])
 Check two keys for equality.
void ComputeEncryptionKey (const std::string &documentID, unsigned char userPad[32], unsigned char ownerKey[32], int pValue, int keyLength, int revision, unsigned char userKey[32])
 Compute encryption key and user key.
void ComputeOwnerKey (unsigned char userPad[32], unsigned char ownerPad[32], int keylength, int revision, bool authenticate, unsigned char ownerKey[32])
 Compute owner key.
void CreateObjKey (unsigned char objkey[16], int *pnKeyLen) const
void GenerateInitialVector (unsigned char iv[16])
 Generate initial vector.
void PadPassword (const std::string &password, unsigned char pswd[32])
 Pad a password to 32 characters.
 PdfEncrypt (const PdfEncrypt &rhs)
void RC4 (unsigned char *key, int keylen, unsigned char *textin, pdf_long textlen, unsigned char *textout)
 RC4 encryption.

Static Protected Member Functions

static void GetMD5Binary (const unsigned char *data, int length, unsigned char *digest)
 Calculate the binary MD5 message digest of the given data.

Protected Attributes

EPdfEncryptAlgorithm m_eAlgorithm
 The used encryption algorithm.
EPdfKeyLength m_eKeyLength
 The key length.
int m_keyLength
 Length of encryption key.
unsigned char m_oValue [32]
 O entry in pdf document.
std::string m_ownerPass
 Owner password.
int m_pValue
 P entry in pdf document.
unsigned char m_rc4key [16]
 last RC4 key
unsigned char m_rc4last [256]
 last RC4 state table
int m_rValue
std::string m_userPass
 User password.
unsigned char m_uValue [32]
 U entry in pdf document.

Private Attributes

PdfReference m_curReference
 Reference of the current PdfObject.
std::string m_documentId
 DocumentID of the current document.
unsigned char m_encryptionKey [16]
 Encryption key.

Static Private Attributes

static int s_nEnabledEncryptionAlgorithms
 Or'ed int containing the enabled encryption algorithms.

Detailed Description

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 permisions on the PDF file.

As a user of this class, you have only to instanciate 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.

Definition at line 61 of file PdfEncrypt.h.

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index