PoDoFo  1.0.0-dev
PdfEncrypt.h
1 
7 #ifndef PDF_ENCRYPT_H
8 #define PDF_ENCRYPT_H
9 
10 #include "PdfString.h"
11 #include "PdfReference.h"
12 
13 // Define an opaque type for the internal PoDoFo encryption context
14 #ifndef PODOFO_CRYPT_CTX
15 #define PODOFO_CRYPT_CTX void
16 #endif // PODOFO_CRYPT_CTX
17 
18 namespace PoDoFo
19 {
20 
21 class PdfDictionary;
22 class InputStream;
23 class PdfObject;
24 class OutputStream;
25 
26 /* Class representing PDF encryption methods. (For internal use only)
27  * Based on code from Ulrich Telle: http://wxcode.sourceforge.net/components/wxpdfdoc/
28  * Original Copyright header:
29  * Name: pdfencrypt.h
30  * Purpose:
31  * Author: Ulrich Telle
32  * Modified by:
33  * Created: 2005-08-16
34  * Copyright: (c) Ulrich Telle
35  * Licence: wxWindows licence
36  */
37 
40 enum class PdfKeyLength : uint16_t
41 {
42  Unknown = 0,
43  L40 = 40,
44  L48 = 48,
45  L56 = 56,
46  L64 = 64,
47  L72 = 72,
48  L80 = 80,
49  L88 = 88,
50  L96 = 96,
51  L104 = 104,
52  L112 = 112,
53  L120 = 120,
54  L128 = 128,
55 #ifdef PODOFO_HAVE_LIBIDN
56  L256 = 256
57 #endif //PODOFO_HAVE_LIBIDN
58 };
59 
62 // ISO 32000-2:2020 7.6.4.2 "Standard encryption dictionary":
63 // "The value of the P entry shall be interpreted as an unsigned
64 // 32-bit quantity containing a set of flags."
65 enum class PdfPermissions : uint32_t
66 {
67  None = 0,
68  Print = 0x00000004,
69  Edit = 0x00000008,
70  Copy = 0x00000010,
71  EditNotes = 0x00000020,
72  FillAndSign = 0x00000100,
73  Accessible = 0x00000200,
74  DocAssembly = 0x00000400,
75  HighPrint = 0x00000800,
76  Default = Print
77  | Edit
78  | Copy
79  | EditNotes
80  | FillAndSign
81  | Accessible
82  | DocAssembly
83  | HighPrint
84 };
85 
89 enum class PdfEncryptionAlgorithm : uint8_t
90 {
91  None = 0,
92  RC4V1 = 1,
93  RC4V2 = 2,
94  AESV2 = 4,
95 #ifdef PODOFO_HAVE_LIBIDN
96  AESV3R5 = 8,
97  AESV3R6 = 16,
98 #endif //PODOFO_HAVE_LIBIDN
99 };
100 
101 enum class PdfAuthResult : uint8_t
102 {
103  Unkwnon = 0,
104  Failed,
105  User,
106  Owner,
107 };
108 
109 class PdfEncryptContext;
110 
121 class PODOFO_API PdfEncrypt
122 {
123  friend class PdfEncryptMD5Base;
124  friend class PdfEncryptAESV3;
125  PODOFO_PRIVATE_FRIEND(class PdfEncryptSession);
126 
127 public:
128  virtual ~PdfEncrypt();
129 
144  static std::unique_ptr<PdfEncrypt> Create(const std::string_view& userPassword,
145  const std::string_view& ownerPassword,
146  PdfPermissions protection = PdfPermissions::Default,
148  PdfKeyLength keyLength = PdfKeyLength::Unknown);
149 
161  static std::unique_ptr<PdfEncrypt> CreateFromObject(const PdfObject& obj);
162 
174  static PdfEncryptionAlgorithm GetEnabledEncryptionAlgorithms();
175 
183  static bool IsEncryptionEnabled(PdfEncryptionAlgorithm algorithm);
184 
189  void EnsureEncryptionInitialized(const PdfString& documentId, PdfEncryptContext& context);
190 
199  void Authenticate(const std::string_view& password, const PdfString& documentId, PdfEncryptContext& context) const;
200 
208  virtual void CreateEncryptionDictionary(PdfDictionary& dictionary) const = 0;
209 
220  virtual std::unique_ptr<InputStream> CreateEncryptionInputStream(InputStream& inputStream, size_t inputLen,
221  PdfEncryptContext& context, const PdfReference& objref) const = 0;
222 
233  virtual std::unique_ptr<OutputStream> CreateEncryptionOutputStream(OutputStream& outputStream,
234  PdfEncryptContext& context, const PdfReference& objref) const = 0;
235 
239  inline PdfEncryptionAlgorithm GetEncryptAlgorithm() const { return m_Algorithm; }
240 
250  bool IsOwnerPasswordSet() const;
251 
259  bool IsPrintAllowed() const;
260 
268  bool IsEditAllowed() const;
269 
277  bool IsCopyAllowed() const;
278 
286  bool IsEditNotesAllowed() const;
287 
295  bool IsFillAndSignAllowed() const;
296 
304  bool IsAccessibilityAllowed() const;
305 
313  bool IsDocAssemblyAllowed() const;
314 
322  bool IsHighPrintAllowed() const;
323 
326  void EncryptTo(charbuff& out, const bufferview& view, PdfEncryptContext& context, const PdfReference& objref) const;
327 
330  void DecryptTo(charbuff& out, const bufferview& view, PdfEncryptContext& context, const PdfReference& objref) const;
331 
334  virtual size_t CalculateStreamLength(size_t length) const = 0;
335 
338  virtual size_t CalculateStreamOffset() const = 0;
339 
343  unsigned GetKeyLengthBytes() const;
344 
347  bufferview GetUValue() const;
348 
351  bufferview GetOValue() const;
352 
353 public:
356  PdfKeyLength GetKeyLength() const { return m_KeyLength; }
357 
360  inline PdfPermissions GetPValue() const { return m_pValue; }
361 
364  inline unsigned GetRevision() const { return m_rValue; }
365 
366  inline bool IsMetadataEncrypted() const { return m_EncryptMetadata; }
367 
368  inline bool IsParsed() const { return m_IsParsed; }
369 
370 protected:
371  inline const unsigned char* GetUValueRaw() const { return m_uValue; }
372 
373  inline const unsigned char* GetOValueRaw() const { return m_oValue; }
374 
375  inline const std::string& GetUserPassword() const { return m_userPass; }
376 
377  inline const std::string& GetOwnerPassword() const { return m_ownerPass; }
378 
379  int64_t GetPValueForSerialization() const;
380 
381 protected:
385  void InitFromValues(PdfEncryptionAlgorithm algorithm, PdfKeyLength keyLength, unsigned char revision,
386  PdfPermissions pValue, const bufferview& uValue, const bufferview& oValue,
387  bool encryptedMetadata);
388 
393  void InitFromScratch(const std::string_view& userPassword, const std::string_view& ownerPassword,
394  PdfEncryptionAlgorithm algorithm, PdfKeyLength keyLength, unsigned char revision,
395  PdfPermissions pValue, bool encryptedMetadata);
396 
397  virtual void Decrypt(const char* inStr, size_t inLen, PdfEncryptContext& context,
398  const PdfReference& objref, char* outStr, size_t& outLen) const = 0;
399 
400  virtual void Encrypt(const char* inStr, size_t inLen, PdfEncryptContext& context,
401  const PdfReference& objref, char* outStr, size_t outLen) const = 0;
402 
403  virtual PdfAuthResult Authenticate(const std::string_view& password, const std::string_view& documentId,
404  PODOFO_CRYPT_CTX* ctx, unsigned char encryptionKey[32]) const = 0;
405 
406  virtual void GenerateEncryptionKey(
407  const std::string_view& documentId, PdfAuthResult authResult, PODOFO_CRYPT_CTX* ctx,
408  unsigned char uValue[48], unsigned char oValue[48], unsigned char encryptionKey[32]) = 0;
409 
410  // Check two keys for equality
411  bool CheckKey(const unsigned char key1[32], const unsigned char key2[32]) const;
412 
413  enum class PdfRC4Revision
414  {
415  R2 = 2,
416  R3 = 3,
417  };
418 
419 #ifdef PODOFO_HAVE_LIBIDN
420  enum class PdfAESV3Revision
421  {
422  R5 = 5,
423  R6 = 6,
424  };
425 #endif //PODOFO_HAVE_LIBIDN
426 
427 private:
428  PdfEncrypt();
429 
430  PdfEncrypt(const PdfEncrypt& rhs) = default;
431 
432  PdfEncrypt& operator=(PdfEncrypt& rhs) = delete;
433 
434 private:
435  static std::unique_ptr<PdfEncrypt> CreateFromEncrypt(const PdfEncrypt& rhs);
436 
437  void clearSensitiveInfo();
438 
439 private:
440  PdfEncryptionAlgorithm m_Algorithm; // The used encryption algorithm
441  unsigned char m_rValue; // Revision
442  PdfKeyLength m_KeyLength; // The encryption key length, as enum value
443  PdfPermissions m_pValue; // P entry in pdf document
444  unsigned char m_uValue[48]; // U entry in pdf document
445  unsigned char m_oValue[48]; // O entry in pdf document
446  unsigned char m_uValueSize;
447  unsigned char m_oValueSize;
448  bool m_EncryptMetadata; // Is metadata encrypted
449  bool m_IsParsed; // True if the object is created from parsed values
450  bool m_initialized; // True if the object O/U values were filled
451  std::string m_userPass; // User password
452  std::string m_ownerPass; // Owner password
453 
454 };
455 
456 class PODOFO_API PdfEncryptContext final
457 {
458  friend class PdfEncrypt;
459  friend class PdfEncryptRC4;
460  friend class PdfEncryptAESV2;
461  friend class PdfEncryptAESV3;
462 
463 public:
464  PdfEncryptContext();
465 
466  ~PdfEncryptContext();
467 
468  PdfEncryptContext(const PdfEncryptContext&);
469 
470  PdfEncryptContext& operator=(const PdfEncryptContext&);
471 
472 public:
473  inline PdfAuthResult GetAuthResult() { return m_AuthResult; }
474 
475  inline const std::string GetDocumentId() { return m_documentId; }
476 
477  bool IsAuthenticated() const;
478 
479 private:
480  inline const unsigned char* GetEncryptionKey() const { return m_encryptionKey; }
481 
482  PODOFO_CRYPT_CTX* GetCryptCtx();
483 
484  template <typename T>
485  T& GetCustomCtx()
486  {
487  if (m_customCtx == nullptr)
488  {
489  m_customCtx = ::operator new(sizeof(T));
490  m_customCtxSize = sizeof(T);
491  }
492 
493  return *(T*)m_customCtx;
494  }
495 
496 private:
497  unsigned char m_encryptionKey[32]; // Encryption key
498  std::string m_documentId; // DocumentID of the current document
499  PdfAuthResult m_AuthResult;
500  PODOFO_CRYPT_CTX* m_cryptCtx;
501  void* m_customCtx;
502  size_t m_customCtxSize;
503 };
504 
505 #ifdef PODOFO_HAVE_LIBIDN
506 
514 #endif // PODOFO_HAVE_LIBIDN
515 
516 class PdfEncryptMD5Base : public PdfEncrypt
517 {
518  friend class PdfEncryptRC4;
519  friend class PdfEncryptAESV2;
520 
521 private:
522  PdfEncryptMD5Base();
523 
524  PdfEncryptMD5Base(const PdfEncryptMD5Base& rhs);
525 
526 public:
527  void CreateEncryptionDictionary(PdfDictionary& dictionary) const override;
528 
529  // NOTE: We must declare again without body otherwise the other Authenticate overload hides it
530  PdfAuthResult Authenticate(const std::string_view& password, const std::string_view& documentId,
531  PODOFO_CRYPT_CTX* ctx, unsigned char encryptionKey[32]) const override = 0;
532 
533 protected:
534  // Compute owner key
535  static void ComputeOwnerKey(const unsigned char userPad[32], const unsigned char ownerPad[32],
536  unsigned keylength, unsigned revision, bool authenticate, PODOFO_CRYPT_CTX* ctx, unsigned char ownerKey[32]);
537 
538  // Pad a password to 32 characters
539  static void PadPassword(const std::string_view& password, unsigned char pswd[32]);
540 
541  // Compute encryption key and user key
542  static void ComputeEncryptionKey(const std::string_view& documentID,
543  const unsigned char userPad[32], const unsigned char ownerKey[32],
544  PdfPermissions pValue, unsigned keyLength, unsigned revision,
545  bool encryptMetadata, PODOFO_CRYPT_CTX* ctx,
546  unsigned char userKey[32], unsigned char encryptionKey[32]);
547 
553  void CreateObjKey(unsigned char objkey[16], unsigned& pnKeyLen,
554  const unsigned char m_encryptionKey[32], const PdfReference& objref) const;
555 };
556 
563 class PdfEncryptAESV2 final : public PdfEncryptMD5Base
564 {
565  friend class PdfEncrypt;
566 
567 private:
568  PdfEncryptAESV2(PdfString oValue, PdfString uValue, PdfPermissions pValue, bool encryptMetadata);
569  PdfEncryptAESV2(const std::string_view& userPassword, const std::string_view& ownerPassword,
570  PdfPermissions protection);
571  PdfEncryptAESV2(const PdfEncryptAESV2& rhs);
572 
573 public:
574  std::unique_ptr<InputStream> CreateEncryptionInputStream(InputStream& inputStream, size_t inputLen,
575  PdfEncryptContext& context, const PdfReference& objref) const override;
576  std::unique_ptr<OutputStream> CreateEncryptionOutputStream(OutputStream& outputStream,
577  PdfEncryptContext& context, const PdfReference& objref) const override;
578 
579  size_t CalculateStreamOffset() const override;
580 
581  size_t CalculateStreamLength(size_t length) const override;
582 
583 protected:
584  void Encrypt(const char* inStr, size_t inLen, PdfEncryptContext& context,
585  const PdfReference& objref, char* outStr, size_t outLen) const override;
586  void Decrypt(const char* inStr, size_t inLen, PdfEncryptContext& context,
587  const PdfReference& objref, char* outStr, size_t& outLen) const override;
588 
589  void GenerateEncryptionKey(const std::string_view& documentId, PdfAuthResult authResult, PODOFO_CRYPT_CTX* ctx,
590  unsigned char uValue[48], unsigned char oValue[48], unsigned char encryptionKey[32]) override;
591 
592  PdfAuthResult Authenticate(const std::string_view& password, const std::string_view& documentId,
593  PODOFO_CRYPT_CTX* ctx, unsigned char encryptionKey[32]) const override;
594 
595 private:
596  void generateInitialVector(const std::string_view& documentId, unsigned char iv[]) const;
597 };
598 
599 #ifdef PODOFO_HAVE_LIBIDN
600 
607 class PdfEncryptAESV3 final : public PdfEncrypt
608 {
609  friend class PdfEncrypt;
610 
611 private:
612  PdfEncryptAESV3(PdfString oValue, PdfString oeValue, PdfString uValue, PdfString ueValue,
613  PdfPermissions pValue, PdfString permsValue, PdfAESV3Revision rev);
614  PdfEncryptAESV3(const std::string_view& userPassword, const std::string_view& ownerPassword,
615  PdfAESV3Revision rev, PdfPermissions protection);
616  PdfEncryptAESV3(const PdfEncryptAESV3& rhs);
617 
618 public:
619  std::unique_ptr<InputStream> CreateEncryptionInputStream(InputStream& inputStream, size_t inputLen,
620  PdfEncryptContext& context, const PdfReference& objref) const override;
621  std::unique_ptr<OutputStream> CreateEncryptionOutputStream(OutputStream& outputStream,
622  PdfEncryptContext& context, const PdfReference& objref) const override;
623 
624  size_t CalculateStreamOffset() const override;
625 
626  size_t CalculateStreamLength(size_t length) const override;
627 
628  void CreateEncryptionDictionary(PdfDictionary& dictionary) const override;
629 
630  // Get the UE object value (user)
631  bufferview GetUEValue() const;
632 
633  // Get the OE object value (owner)
634  bufferview GetOEValue() const;
635 
636  // Get the Perms object value (encrypted protection)
637  bufferview GetPermsValue() const;
638 
639 protected:
640  // Encrypt a character string
641  void Encrypt(const char* inStr, size_t inLen, PdfEncryptContext& context,
642  const PdfReference& objref, char* outStr, size_t outLen) const override;
643  void Decrypt(const char* inStr, size_t inLen, PdfEncryptContext& context,
644  const PdfReference& objref, char* outStr, size_t& outLen) const override;
645 
646  PdfAuthResult Authenticate(const std::string_view& password, const std::string_view& documentId,
647  PODOFO_CRYPT_CTX* ctx, unsigned char encryptionKey[32]) const override;
648 
649  void GenerateEncryptionKey(const std::string_view& documentId, PdfAuthResult authResult, PODOFO_CRYPT_CTX* ctx,
650  unsigned char uValue[48], unsigned char oValue[48], unsigned char encryptionKey[32]) override;
651 
652 private:
653  // Generate initial vector
654  static void generateInitialVector(unsigned char iv[]);
655 
656  // Preprocess password for use in EAS-256 Algorithm
657  // outBuf needs to be at least 127 bytes long
658  static void preprocessPassword(const std::string_view& password, unsigned char* outBuf, unsigned& len);
659 
660  // Compute encryption key to be used with AES-256
661  static void computeEncryptionKey(unsigned keyLength, unsigned char encryptionKey[32]);
662 
663  // Compute hash for password and salt with optional uValue
664  static void computeHash(const unsigned char* pswd, unsigned pswdLen, unsigned revision,
665  const unsigned char salt[8], const unsigned char uValue[48], unsigned char hashValue[32]);
666 
667  // Generate the U and UE entries
668  static void computeUserKey(const unsigned char* userpswd, unsigned len, unsigned revision,
669  unsigned keyLength, const unsigned char encryptionKey[32],
670  unsigned char uValue[48], unsigned char ueValue[32]);
671 
672  // Generate the O and OE entries
673  static void computeOwnerKey(const unsigned char* userpswd, unsigned len, unsigned revision,
674  unsigned keyLength, const unsigned char encryptionKey[32], const unsigned char uValue[48],
675  unsigned char oValue[48], unsigned char oeValue[32]);
676 
677 private:
678  unsigned char m_ueValue[32]; // UE entry in pdf document
679  unsigned char m_oeValue[32]; // OE entry in pdf document
680  unsigned char m_permsValue[16]; // Perms entry in pdf document
681 };
682 
683 #endif // PODOFO_HAVE_LIBIDN
684 
691 class PdfEncryptRC4 final : public PdfEncryptMD5Base
692 {
693  friend class PdfEncrypt;
694 
695 private:
696  PdfEncryptRC4(PdfString oValue, PdfString uValue, PdfPermissions pValue,
697  PdfRC4Revision revision, PdfEncryptionAlgorithm algorithm,
698  unsigned keyLength, bool encryptMetadata);
699  PdfEncryptRC4(const std::string_view& userPassword, const std::string_view& ownerPassword,
700  PdfPermissions protection,
701  PdfEncryptionAlgorithm algorithm,
702  PdfKeyLength keyLength);
703  PdfEncryptRC4(const PdfEncryptRC4& rhs) = default;
704 
705 public:
706  std::unique_ptr<InputStream> CreateEncryptionInputStream(InputStream& inputStream, size_t inputLen,
707  PdfEncryptContext& context, const PdfReference& objref) const override;
708 
709  std::unique_ptr<OutputStream> CreateEncryptionOutputStream(OutputStream& outputStream,
710  PdfEncryptContext& context, const PdfReference& objref) const override;
711 
712  size_t CalculateStreamOffset() const override;
713 
714  size_t CalculateStreamLength(size_t length) const override;
715 
716 protected:
717  void Encrypt(const char* inStr, size_t inLen, PdfEncryptContext& context,
718  const PdfReference& objref, char* outStr, size_t outLen) const override;
719 
720  void Decrypt(const char* inStr, size_t inLen, PdfEncryptContext& context,
721  const PdfReference& objref, char* outStr, size_t& outLen) const override;
722 
723  void GenerateEncryptionKey(const std::string_view& documentId, PdfAuthResult authResult, PODOFO_CRYPT_CTX* ctx,
724  unsigned char uValue[48], unsigned char oValue[48], unsigned char encryptionKey[32]) override;
725 
726  PdfAuthResult Authenticate(const std::string_view& password, const std::string_view& documentId,
727  PODOFO_CRYPT_CTX* ctx, unsigned char encryptionKey[32]) const override;
728 
729 private:
730  static unsigned normalizeKeyLength(unsigned keyLength);
731 };
732 
733 }
734 ENABLE_BITMASK_OPERATORS(PoDoFo::PdfPermissions);
735 ENABLE_BITMASK_OPERATORS(PoDoFo::PdfEncryptionAlgorithm);
736 
737 #endif // PDF_ENCRYPT_H
An interface for reading blocks of data from a data source.
Definition: InputStream.h:20
An interface for writing blocks of data to a data source.
Definition: OutputStream.h:18
The PDF dictionary data type of PoDoFo (inherits from PdfDataContainer, the base class for such repre...
Definition: PdfDictionary.h:82
A class that is used to encrypt a PDF file (AES-128)
Definition: PdfEncrypt.h:564
size_t CalculateStreamLength(size_t length) const override
Calculate stream size.
Definition: PdfEncrypt.cpp:1402
std::unique_ptr< OutputStream > CreateEncryptionOutputStream(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 PdfEncr...
Definition: PdfEncrypt.cpp:1420
std::unique_ptr< InputStream > CreateEncryptionInputStream(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 PdfEncryp...
Definition: PdfEncrypt.cpp:1411
size_t CalculateStreamOffset() const override
Calculate stream offset.
Definition: PdfEncrypt.cpp:1343
A class that is used to encrypt a PDF file (RC4 40-bit and 128-bit)
Definition: PdfEncrypt.h:692
size_t CalculateStreamOffset() const override
Calculate stream offset.
Definition: PdfEncrypt.cpp:1091
std::unique_ptr< OutputStream > CreateEncryptionOutputStream(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 PdfEncr...
Definition: PdfEncrypt.cpp:1209
std::unique_ptr< InputStream > CreateEncryptionInputStream(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 PdfEncryp...
Definition: PdfEncrypt.cpp:1117
size_t CalculateStreamLength(size_t length) const override
Calculate stream size.
Definition: PdfEncrypt.cpp:1096
A bundle of the encrypt object together a context.
Definition: PdfEncryptSession.h:18
A class that is used to encrypt a PDF file and set document permissions on the PDF file.
Definition: PdfEncrypt.h:122
virtual std::unique_ptr< InputStream > CreateEncryptionInputStream(InputStream &inputStream, size_t inputLen, PdfEncryptContext &context, const PdfReference &objref) const =0
Create an InputStream that decrypts all data read from it using the current settings of the PdfEncryp...
virtual size_t CalculateStreamLength(size_t length) const =0
Calculate stream size.
unsigned GetRevision() const
Get the revision number of the encryption method.
Definition: PdfEncrypt.h:364
virtual size_t CalculateStreamOffset() const =0
Calculate stream offset.
virtual std::unique_ptr< OutputStream > CreateEncryptionOutputStream(OutputStream &outputStream, PdfEncryptContext &context, const PdfReference &objref) const =0
Create an OutputStream that encrypts all data written to it using the current settings of the PdfEncr...
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.
PdfPermissions GetPValue() const
Get the P object value (protection)
Definition: PdfEncrypt.h:360
virtual void CreateEncryptionDictionary(PdfDictionary &dictionary) const =0
Fill all keys into a encryption dictionary.
PdfKeyLength GetKeyLength() const
Get the length of the encryption key in bits.
Definition: PdfEncrypt.h:356
PdfEncryptionAlgorithm GetEncryptAlgorithm() const
Get the encryption algorithm of this object.
Definition: PdfEncrypt.h:239
This class represents a PDF indirect Object in memory.
Definition: PdfObject.h:35
A reference is a pointer to a object in the PDF file of the form "4 0 R", where 4 is the object numbe...
Definition: PdfReference.h:24
A string that can be written to a PDF document.
Definition: PdfString.h:24
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition: basetypes.h:38
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16
PdfEncryptionAlgorithm
The encryption algorithm.
Definition: PdfEncrypt.h:90
@ AESV2
AES encryption with a 128 bit key (PDF1.6)
@ RC4V1
RC4 Version 1 encryption using a 40bit key.
@ RC4V2
RC4 Version 2 encryption using a key with 40-128bit.
@ None
Do not add a default appearrance.
@ Create
Create a new file or truncate existing one for writing/reading.
cspan< char > bufferview
Convenient read-only char buffer span.
Definition: basetypes.h:19
PdfPermissions
Set user permissions/restrictions on a document.
Definition: PdfEncrypt.h:66
@ Print
Allow printing the document.
@ FillAndSign
Fill in existing form or signature fields.
@ HighPrint
Print a high resolution version of the document.
@ Copy
Allow text and graphic extraction.
@ DocAssembly
Assemble the document: insert, create, rotate delete pages or add bookmarks.
@ Edit
Allow modifying the document besides annotations, form fields or changing pages.
@ EditNotes
Add or modify text annotations or form fields (if PdfPermissions::Edit is set also allow to create in...
@ Accessible
Extract text and graphics to support user with disabilities.
PdfKeyLength
A enum specifying a valid keylength for a PDF encryption key.
Definition: PdfEncrypt.h:41
PdfAuthResult
Definition: PdfEncrypt.h:102
@ User
Success authenticating a user for this PDF.
@ Owner
Success authenticating the owner for this PDF.
@ Failed
Failed to authenticate to this PDF.