PoDoFo 1.0.0-dev
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Friends | List of all members
PoDoFo::PdfEncryptRC4 Class Referencefinal

A class that is used to encrypt a PDF file (RC4 40-bit and 128-bit) More...

#include <PdfEncrypt.h>

Inheritance diagram for PoDoFo::PdfEncryptRC4:
PoDoFo::PdfEncryptMD5Base PoDoFo::PdfEncrypt

Public Member Functions

std::unique_ptr< InputStreamCreateEncryptionInputStream (InputStream &inputStream, size_t inputLen, PdfEncryptContext &context, const PdfReference &objref) const override
 Create an InputStream that decrypts all data read from it using the current settings of the PdfEncrypt object.
 
std::unique_ptr< OutputStreamCreateEncryptionOutputStream (OutputStream &outputStream, PdfEncryptContext &context, const PdfReference &objref) const override
 Create an OutputStream that encrypts all data written to it using the current settings of the PdfEncrypt object.
 
size_t CalculateStreamOffset () const override
 Calculate stream offset.
 
size_t CalculateStreamLength (size_t length) const override
 Calculate stream size.
 
- Public Member Functions inherited from PoDoFo::PdfEncryptMD5Base
void CreateEncryptionDictionary (PdfDictionary &dictionary) const override
 Fill all keys into a encryption dictionary.
 
- Public Member Functions inherited from PoDoFo::PdfEncrypt
void EnsureEncryptionInitialized (const PdfString &documentId, PdfEncryptContext &context)
 Ensure encryption key and /O, /U, /OE, /UE values are initialized.
 
void Authenticate (const std::string_view &password, const PdfString &documentId, PdfEncryptContext &context) const
 Tries to authenticate a user using either the user or owner password.
 
PdfEncryptionAlgorithm GetEncryptAlgorithm () const
 Get the encryption algorithm of this object.
 
bool IsOwnerPasswordSet () const
 Checks if an owner password is set.
 
bool IsPrintAllowed () const
 Checks if printing this document is allowed.
 
bool IsEditAllowed () const
 Checks if modifying this document (besides annotations, form fields or changing pages) is allowed.
 
bool IsCopyAllowed () const
 Checks if text and graphics extraction is allowed.
 
bool IsEditNotesAllowed () const
 Checks if it is allowed to add or modify annotations or form fields Every PDF consuming applications has to adhere this value!
 
bool IsFillAndSignAllowed () const
 Checks if it is allowed to fill in existing form or signature fields Every PDF consuming applications has to adhere this value!
 
bool IsAccessibilityAllowed () const
 Checks if it is allowed to extract text and graphics to support users with disabilities Every PDF consuming applications has to adhere this value!
 
bool IsDocAssemblyAllowed () const
 Checks if it is allowed to insert, create, rotate, delete pages or add bookmarks Every PDF consuming applications has to adhere this value!
 
bool IsHighPrintAllowed () const
 Checks if it is allowed to print a high quality version of this document Every PDF consuming applications has to adhere this value!
 
void EncryptTo (charbuff &out, const bufferview &view, PdfEncryptContext &context, const PdfReference &objref) const
 Encrypt a character span.
 
void DecryptTo (charbuff &out, const bufferview &view, PdfEncryptContext &context, const PdfReference &objref) const
 Decrypt a character span.
 
unsigned GetKeyLengthBytes () const
 Get the encryption key length in bytes.
 
bufferview GetUValue () const
 Get the U object value (user)
 
bufferview GetOValue () const
 Get the O object value (owner)
 
PdfKeyLength GetKeyLength () const
 Get the length of the encryption key in bits.
 
PdfPermissions GetPValue () const
 Get the P object value (protection)
 
unsigned GetRevision () const
 Get the revision number of the encryption method.
 
bool IsMetadataEncrypted () const
 
bool IsParsed () const
 

Protected Member Functions

void Encrypt (const char *inStr, size_t inLen, PdfEncryptContext &context, const PdfReference &objref, char *outStr, size_t outLen) const override
 
void Decrypt (const char *inStr, size_t inLen, PdfEncryptContext &context, const PdfReference &objref, char *outStr, size_t &outLen) const override
 
void GenerateEncryptionKey (const std::string_view &documentId, PdfAuthResult authResult, PODOFO_CRYPT_CTX *ctx, unsigned char uValue[48], unsigned char oValue[48], unsigned char encryptionKey[32]) override
 
PdfAuthResult Authenticate (const std::string_view &password, const std::string_view &documentId, PODOFO_CRYPT_CTX *ctx, unsigned char encryptionKey[32]) const override
 
- Protected Member Functions inherited from PoDoFo::PdfEncryptMD5Base
void CreateObjKey (unsigned char objkey[16], unsigned &pnKeyLen, const unsigned char m_encryptionKey[32], const PdfReference &objref) const
 Create the encryption key for the current object.
 
- Protected Member Functions inherited from PoDoFo::PdfEncrypt
const unsigned charGetUValueRaw () const
 
const unsigned charGetOValueRaw () const
 
const std::string & GetUserPassword () const
 
const std::string & GetOwnerPassword () const
 
int64_t GetPValueForSerialization () const
 
void InitFromValues (PdfEncryptionAlgorithm algorithm, PdfKeyLength keyLength, unsigned char revision, PdfPermissions pValue, const bufferview &uValue, const bufferview &oValue, bool encryptedMetadata)
 Init from parsed values.
 
void InitFromScratch (const std::string_view &userPassword, const std::string_view &ownerPassword, PdfEncryptionAlgorithm algorithm, PdfKeyLength keyLength, unsigned char revision, PdfPermissions pValue, bool encryptedMetadata)
 Init from scratch with user/owner password.
 
bool CheckKey (const unsigned char key1[32], const unsigned char key2[32]) const
 

Friends

class PdfEncrypt
 

Additional Inherited Members

- Static Public Member Functions inherited from PoDoFo::PdfEncrypt
static std::unique_ptr< PdfEncryptCreate (const std::string_view &userPassword, const std::string_view &ownerPassword, PdfPermissions protection=PdfPermissions::Default, PdfEncryptionAlgorithm algorithm=PdfEncryptionAlgorithm::AESV3R6, PdfKeyLength keyLength=PdfKeyLength::Unknown)
 Create a PdfEncrypt object which can be used to encrypt a PDF file.
 
static std::unique_ptr< PdfEncryptCreateFromObject (const PdfObject &obj)
 Initialize a PdfEncrypt object from an encryption dictionary in a PDF file.
 
static PdfEncryptionAlgorithm GetEnabledEncryptionAlgorithms ()
 Retrieve the list of encryption algorithms that are used when loading a PDF document.
 
static bool IsEncryptionEnabled (PdfEncryptionAlgorithm algorithm)
 Test if a certain encryption algorithm is enabled for loading PDF documents.
 
- Protected Types inherited from PoDoFo::PdfEncrypt
enum class  PdfRC4Revision : uint8_t { R2 = 2 , R3 = 3 }
 
enum class  PdfAESV3Revision : uint8_t { R5 = 5 , R6 = 6 }
 
- Static Protected Member Functions inherited from PoDoFo::PdfEncryptMD5Base
static void ComputeOwnerKey (const unsigned char userPad[32], const unsigned char ownerPad[32], unsigned keylength, unsigned revision, bool authenticate, PODOFO_CRYPT_CTX *ctx, unsigned char ownerKey[32])
 
static void PadPassword (const std::string_view &password, unsigned char pswd[32])
 
static void ComputeEncryptionKey (const std::string_view &documentID, const unsigned char userPad[32], const unsigned char ownerKey[32], PdfPermissions pValue, unsigned keyLength, unsigned revision, bool encryptMetadata, PODOFO_CRYPT_CTX *ctx, unsigned char userKey[32], unsigned char encryptionKey[32])
 

Detailed Description

A class that is used to encrypt a PDF file (RC4 40-bit and 128-bit)

Client code is working only with PdfEncrypt class and knows nothing about PdfEncryptRC4, it is created through CreatePdfEncrypt factory method

Member Function Documentation

◆ Authenticate()

PdfAuthResult PdfEncryptRC4::Authenticate ( const std::string_view &  password,
const std::string_view &  documentId,
PODOFO_CRYPT_CTX *  ctx,
unsigned char  encryptionKey[32] 
) const
overrideprotectedvirtual

◆ CalculateStreamLength()

size_t PdfEncryptRC4::CalculateStreamLength ( size_t  length) const
overridevirtual

Calculate stream size.

Implements PoDoFo::PdfEncrypt.

◆ CalculateStreamOffset()

size_t PdfEncryptRC4::CalculateStreamOffset ( ) const
overridevirtual

Calculate stream offset.

Implements PoDoFo::PdfEncrypt.

◆ CreateEncryptionInputStream()

unique_ptr< InputStream > PdfEncryptRC4::CreateEncryptionInputStream ( InputStream inputStream,
size_t  inputLen,
PdfEncryptContext &  context,
const PdfReference objref 
) const
overridevirtual

Create an InputStream 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!

Parameters
inputStreamthe created InputStream reads all decrypted data to this input stream.
Returns
an InputStream that decrypts all data.

Implements PoDoFo::PdfEncrypt.

◆ CreateEncryptionOutputStream()

unique_ptr< OutputStream > PdfEncryptRC4::CreateEncryptionOutputStream ( OutputStream outputStream,
PdfEncryptContext &  context,
const PdfReference objref 
) const
overridevirtual

Create an OutputStream 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!

Parameters
outputStreamthe created OutputStream writes all encrypted data to this output stream.
Returns
a OutputStream that encrypts all data.

Implements PoDoFo::PdfEncrypt.

◆ Decrypt()

void PdfEncryptRC4::Decrypt ( const char inStr,
size_t  inLen,
PdfEncryptContext &  context,
const PdfReference objref,
char outStr,
size_t outLen 
) const
overrideprotectedvirtual

Implements PoDoFo::PdfEncrypt.

◆ Encrypt()

void PdfEncryptRC4::Encrypt ( const char inStr,
size_t  inLen,
PdfEncryptContext &  context,
const PdfReference objref,
char outStr,
size_t  outLen 
) const
overrideprotectedvirtual

Implements PoDoFo::PdfEncrypt.

◆ GenerateEncryptionKey()

void PdfEncryptRC4::GenerateEncryptionKey ( const std::string_view &  documentId,
PdfAuthResult  authResult,
PODOFO_CRYPT_CTX *  ctx,
unsigned char  uValue[48],
unsigned char  oValue[48],
unsigned char  encryptionKey[32] 
)
overrideprotectedvirtual

Implements PoDoFo::PdfEncrypt.


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