PDF SDK Documentation

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

Loading...
Searching...
No Matches
security.h
Go to the documentation of this file.
1// Copyright (c) 2009-2025 Avanquest Software. All rights reserved.
2
3#ifndef PDFSDK_CORE_SECURITY_H_INCLUDED_
4#define PDFSDK_CORE_SECURITY_H_INCLUDED_
5
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17typedef enum PDPermReqObj {
18 kPDPermReqObjDoc,
19 kPDPermReqObjPage,
20 kPDPermReqObjContent,
21 kPDPermReqObjAnnot,
22 kPDPermReqObjForm,
23 kPDPermReqObjBookmark,
24 kPDPermReqObjAttachment
25} PDPermReqObj;
26
27typedef enum PDPermReqOp {
28 kPDPermReqOpInsert,
29 kPDPermReqOpDelete,
30 kPDPermReqOpMove,
31 kPDPermReqOpRotate,
32 kPDPermReqOpModify,
33 kPDPermReqOpExtract,
34 kPDPermReqOpAccessible,
35 kPDPermReqOpOpen,
36 kPDPermReqOpSecure,
37 kPDPermReqOpPrint,
38 kPDPermReqOpPrintHigh,
39 kPDPermReqOpFillIn,
40 kPDPermReqOpFullSave,
41 kPDPermReqOpCopy,
42 kPDPermReqOpCopyForAccessibility,
43 kPDPermReqOpCreationOfTemplatePages,
44 kPDPermReqOpAllowDocAssembly
45} PDPermReqOp;
46
47typedef PDErrCode(PDFSDK_CALLCONV* PDCryptNewAuthDataProc)(void* clientData, void** pAuthData);
48typedef PDErrCode(PDFSDK_CALLCONV* PDCryptFreeAuthDataProc)(void* authData);
49
50typedef PDErrCode(PDFSDK_CALLCONV* PDCryptNewSecurityDataProc)(void* clientData,
51 PDObject encryptDict,
52 void** pSecurityData);
53typedef PDErrCode(PDFSDK_CALLCONV* PDCryptCopySecurityDataProc)(void* securityData,
54 void** pSecurityData);
55typedef PDErrCode(PDFSDK_CALLCONV* PDCryptFreeSecurityDataProc)(void* securityData);
56
57typedef PDErrCode(PDFSDK_CALLCONV* PDCryptGetKeyDataProc)(void* securityData,
58 PDAtom cryptFilter,
59 PDObject decodeParms,
60 void* buffer,
61 size_t bufsize,
62 size_t* pSize,
63 PDAtom* pMethod);
64
65typedef PDErrCode(PDFSDK_CALLCONV* PDCryptEncryptProc)(void* securityData,
66 const void* input,
67 size_t inputSize,
68 void* output,
69 size_t outputSize,
70 uint32_t objnum,
71 uint16_t generation,
72 PDAtom cryptFilter,
73 PDObject decodeParms,
74 size_t* pOutputSize);
75
76typedef PDErrCode(PDFSDK_CALLCONV* PDCryptAuthorizeProc)(void* securityData,
77 PDPermReqObj object,
78 PDPermReqOp operation,
79 const void* authData,
80 bool* pGranted);
81
82typedef PDErrCode(PDFSDK_CALLCONV* PDCryptFillEncryptDictProc)(void* securityData,
83 PDDoc doc,
84 PDObject encryptDict);
85
86typedef PDErrCode(PDFSDK_CALLCONV* PDCryptEncryptMetadataProc)(void* securityData, bool* pEncrypt);
87
88typedef PDErrCode(PDFSDK_CALLCONV* PDCryptFreeClientDataProc)(void* clientData);
89
90typedef struct PDSecurityHandler {
91 PDCryptNewAuthDataProc newAuthData;
92 PDCryptFreeAuthDataProc freeAuthData;
93 PDCryptNewSecurityDataProc newSecurityData;
94 PDCryptCopySecurityDataProc copySecurityData;
95 PDCryptFreeSecurityDataProc freeSecurityData;
96 PDCryptGetKeyDataProc getCryptKey;
97 PDCryptEncryptProc encrypt;
98 PDCryptEncryptProc decrypt;
99 PDCryptFillEncryptDictProc fillEncryptDict;
100 PDCryptAuthorizeProc authorize;
101 PDCryptEncryptMetadataProc encryptMetadata;
102 PDCryptFreeClientDataProc freeClientData;
104
105typedef void* PDStdSecurityData;
106
107enum {
108 kPDStdPermOpen = 0x01,
109 kPDStdPermSecure = 0x02,
110 kPDStdPermPrint = 0x04,
111 kPDStdPermEdit = 0x08,
112 kPDStdPermCopy = 0x10,
113 kPDStdPermEditNotes = 0x20,
114 kPDStdPermSaveAs = 0x40,
115 kPDStdPermExt = 0x80,
116 kPDStdPermFillAndSign = 0x100,
117 kPDStdPermAccessible = 0x200,
118 kPDStdPermDocAssembly = 0x400,
119 kPDStdPermHighPrint = 0x800,
120 kPDStdPermOwner = 0x8000,
121 kPDStdPermFormSubmit = 0x10000,
122 kPDStdPermFormSpawnTempl = 0x20000
123};
124typedef uint32_t PDStdPerms;
125
126enum { kPDStdPasswordMaxChars = 255 };
127typedef wchar_t PDStdPassword[kPDStdPasswordMaxChars + 1];
128
136typedef struct
137{
141 PDStdPassword userPassword;
142
148
152 PDStdPassword ownerPassword;
153
154 /*
155 * Set to `true` if there is an owner password.
156 * If this is `true` but `ownerPassword` is empty then owner is not authorized yet
157 */
158 bool hasOwnerPassword;
159
163 PDStdPerms permissions;
164
169
176
183
191
197
203
205
206enum {
207 kPDStdSecurityModifyUserPassword = 0x01,
208 kPDStdSecurityModifyOwnerPassword = 0x02
209};
210typedef uint32_t PDStdSecurityModifyFlags;
211
228PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetNewSecurityHandler(PDDoc doc, PDAtom name, void* securityData);
229
250PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetSecurityHandlerData(PDDoc doc, void** pSecurityData);
251
262PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetSecurityHandlerName(PDDoc doc, PDAtom* pName);
263
283PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetNewSecurityHandlerData(PDDoc doc, void** pSecurityData);
284
295PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetNewSecurityHandlerName(PDDoc doc, PDAtom* pFilter);
296
297PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocEncryptionIsModified(PDDoc doc, bool* pValue);
298
299PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocPermRequest(PDDoc doc, PDPermReqObj permReqObj, PDPermReqOp permReqOp, const void* authData, bool* pGranted);
300PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocPermRequestSecurity(PDDoc doc, PDPermReqObj permReqObj, PDPermReqOp permReqOp, const void* authData, bool* pGranted);
301PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocPermRequestWithAuth(PDDoc doc, PDPermReqObj permReqObj, PDPermReqOp permReqOp, bool* pGranted);
302
303PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDSecurityRegisterHandler(PDAtom filter, const PDSecurityHandler* handler, void* clientData);
304PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDSecurityNewAuthData(PDAtom filter, void** pAuthData);
305PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDSecurityFreeAuthData(PDAtom filter, void* authData);
306
307PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStdSecurityDataNew(PDDoc doc, PDStdSecurityData* pSecurityData);
308PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStdSecurityDataUpdateParams(PDStdSecurityData securityData,
309 PDStdSecurityModifyFlags modifyFlags,
310 const PDStdSecurityParams* params);
311PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStdSecurityDataGetParams(PDStdSecurityData securityData, PDStdSecurityParams* pParams);
312PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStdSecurityDataFree(PDStdSecurityData securityData);
313
314PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDStdPasswordSetChars(PDStdPassword* authData, const wchar_t* chars);
315
316#ifdef __cplusplus
317}
318#endif
319
320#endif // PDFSDK_CORE_SECURITY_H_INCLUDED_
Document API.
int32_t PDErrCode
Definition errors.h:44
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetSecurityHandlerName(PDDoc doc, PDAtom *pName)
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetSecurityHandlerData(PDDoc doc, void **pSecurityData)
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetNewSecurityHandlerName(PDDoc doc, PDAtom *pFilter)
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocSetNewSecurityHandler(PDDoc doc, PDAtom name, void *securityData)
PDF_CORE_API PDErrCode PDFSDK_CALLCONV PDDocGetNewSecurityHandlerData(PDDoc doc, void **pSecurityData)
Definition objects.h:80
Definition security.h:90
Definition security.h:137
int version
Definition security.h:175
bool encryptMetadata
Definition security.h:196
bool encryptAttachmentsOnly
Definition security.h:202
PDStdPerms permissions
Definition security.h:163
PDAtom cryptMethod
Definition security.h:182
bool hasUserPassword
Definition security.h:147
int keyLength
Definition security.h:190
PDStdPassword ownerPassword
Definition security.h:152
PDStdPassword userPassword
Definition security.h:141
int revision
Definition security.h:168