- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VerificationOptions.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5
6 #ifndef PDFTRON_H_CPPPDFVerificationOptions
7 #define PDFTRON_H_CPPPDFVerificationOptions
8 #include <C/PDF/TRN_VerificationOptions.h>
9
10 #include <Common/BasicTypes.h>
11 #include <Common/UString.h>
12 #include <PDF/PDFDoc.h>
13 #include <Crypto/X509Certificate.h>
14
15 namespace pdftron { namespace PDF {
16
17
21 class VerificationOptions
22 {
23 public:
24 //enums:
25
26 // An enumeration representing the level of security to use when verifying digital signatures.
27 enum SecurityLevel {
28 // For compatibility with other vendors such as Acrobat, one can use e_compatibility_and_archiving.
29 e_compatibility_and_archiving = 0,
30 // The e_maximum mode is a highly-restrictive mode which disables many common features of PDF digital signatures.
31 e_maximum = 1
32 };
33
34 /* An enumeration representing the least-secure type of reference-time to use when verifying digital signatures.
35 One can choose the time of signing (not very secure), timestamp time (more secure), current time (most secure, lower verification rate).
36 Note: this is orthogonal to the expiry verification mode (shell/chain/hybrid). */
37 enum TimeMode {
38 /* If secure timestamp available, check signature certificates against the secure timestamp. Otherwise,
39 if available, check signature certificates against the signingTime attribute in the PKCS #7/CMS of the signature.
40 Otherwise, use the current time. This is the default option. Less secure. Suitable for archiving
41 and interoperability with other vendors. */
42 e_signing = 0,
43 /* If available, check signature certificates against the signingTime attribute in the PKCS #7/CMS data
44 of the signature. Otherwise, use the current time. */
45 e_timestamp = 1,
46 /* Check signature certificates against the current time.
47 This is the most secure, and the most restrictive option. */
48 e_current = 2
49 };
50
51 // An enumeration representing the level of trust associated with a particular certificate. Multiple flag values can be combined using bitwise operators.
52 enum CertificateTrustFlag {
53 e_signing_trust = 1, // analogous to "kPSSigTrustSigning" in FDF cert exchange specification. Automatically set even when not specified, just like in Acrobat.
54 e_certification_trust = 2, // analogous to "kPSSigTrustAuthenticDocuments" in FDF cert exchange specification. Allows certifications using this identity to be verified.
55 e_dynamic_content = 4, /* analogous to "kPSSigTrustDynamicContent" in FDF cert exchange specification. Just like in Acrobat, does not invalidate dynamic documents,
56 just intended to stop viewers from allowing its use on documents which are not trusted for it. */
57 e_javascript = 16, /* analogous to "kPSSigTrustJavaScript" in FDF cert exchange specification. Just like in Acrobat, does not invalidate JavaScript-containing documents,
58 just intended to stop viewers from allowing its use on documents which are not trusted for it. */
59 e_identity = 32, // analogous to "kPSSigTrustIdentity" in FDF cert exchange specification. If this flag is not set, all other flags are ignored, and certificate is used only for path building.
60 e_trust_anchor = 64, // analogous to "kPSSigTrustAnchor" in FDF cert exchange specification. If this flag is set, paths may end with this certificate, and no revocation checks are done for it.
61 e_default_trust = 97, // handy shortcut for what Acrobat does by default -- trust for everything except certification, javascript, and dynamic
62 e_complete_trust = 119 // another handy shortcut for testing
63 };
64 VerificationOptions(const VerificationOptions& other);
65 VerificationOptions(TRN_VerificationOptions impl);
66 VerificationOptions& operator= (const VerificationOptions& other);
67 ~VerificationOptions();
68
69 void Destroy();
70
71 //methods:
72
78 VerificationOptions(SecurityLevel level);
79
91 void AddTrustedCertificate(const UChar* in_certificate_buf, size_t in_buf_size, const UInt16 in_trust_flags = e_default_trust);
92
101 void AddTrustedCertificate(const UString& in_filepath, const UInt16 in_trust_flags = e_default_trust);
102
116 void AddTrustedCertificates(const UChar* in_P7C_binary_DER_certificates_file_data, const size_t in_size);
117
127 void LoadTrustList(const FDF::FDFDoc& in_fdf_cert_exchange_data);
128
134 void EnableModificationVerification(bool in_on_or_off);
135
141 void EnableDigestVerification(bool in_on_or_off);
142
148 void EnableTrustVerification(bool in_on_or_off);
149
155 void SetRevocationTimeout(const UInt32 in_revocation_timeout_milliseconds);
156
172 void EnableOnlineCRLRevocationChecking(bool in_on_or_off);
173
179 void EnableOnlineOCSPRevocationChecking(bool in_on_or_off);
180
181
198 void EnableOnlineRevocationChecking(bool in_on_or_off);
199
200
206 UInt32 GetTrustedCertificateCount();
207
214 Crypto::X509Certificate GetTrustedCertificate(const UInt32 index);
215
216
217 #ifndef SWIGHIDDEN
218 TRN_VerificationOptions m_impl;
219 #endif
220
221 private:
222
223 #ifndef SWIGHIDDEN
224 mutable bool m_owner;
225 #endif
226 };
227
228 #include <Impl/VerificationOptions.inl>
229 } //end pdftron
230 } //end PDF
231
232
233 #endif //PDFTRON_H_CPPPDFVerificationOptions
pdftron::PDF::VerificationOptions::e_signing_trust
Definition: VerificationOptions.h:53
pdftron::PDF::VerificationOptions::GetTrustedCertificate
Crypto::X509Certificate GetTrustedCertificate(const UInt32 index)
pdftron::PDF::VerificationOptions::e_timestamp
Definition: VerificationOptions.h:45
pdftron::FDF::FDFDoc
Definition: FDFDoc.h:45
pdftron::PDF::VerificationOptions::e_dynamic_content
Definition: VerificationOptions.h:55
pdftron::UInt16
TRN_UInt16 UInt16
Definition: BasicTypes.h:14
pdftron::PDF::VerificationOptions::e_default_trust
Definition: VerificationOptions.h:61
pdftron::Crypto::X509Certificate
Definition: X509Certificate.h:22
pdftron::PDF::VerificationOptions::EnableOnlineOCSPRevocationChecking
void EnableOnlineOCSPRevocationChecking(bool in_on_or_off)
pdftron::PDF::VerificationOptions::CertificateTrustFlag
CertificateTrustFlag
Definition: VerificationOptions.h:52
pdftron::PDF::VerificationOptions::e_maximum
Definition: VerificationOptions.h:31
UString.h
pdftron::PDF::VerificationOptions::EnableOnlineRevocationChecking
void EnableOnlineRevocationChecking(bool in_on_or_off)
pdftron::PDF::VerificationOptions::e_javascript
Definition: VerificationOptions.h:57
pdftron::PDF::VerificationOptions::SecurityLevel
SecurityLevel
Definition: VerificationOptions.h:27
pdftron::PDF::VerificationOptions::SetRevocationTimeout
void SetRevocationTimeout(const UInt32 in_revocation_timeout_milliseconds)
pdftron::PDF::VerificationOptions::GetTrustedCertificateCount
UInt32 GetTrustedCertificateCount()
pdftron::PDF::VerificationOptions::operator=
VerificationOptions & operator=(const VerificationOptions &other)
pdftron::PDF::VerificationOptions::m_impl
TRN_VerificationOptions m_impl
Definition: VerificationOptions.h:218
pdftron::PDF::VerificationOptions::e_certification_trust
Definition: VerificationOptions.h:54
pdftron::PDF::VerificationOptions
Definition: VerificationOptions.h:21
X509Certificate.h
pdftron::PDF::VerificationOptions::Destroy
void Destroy()
pdftron::PDF::VerificationOptions::e_current
Definition: VerificationOptions.h:48
pdftron::UInt32
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
pdftron::PDF::VerificationOptions::EnableOnlineCRLRevocationChecking
void EnableOnlineCRLRevocationChecking(bool in_on_or_off)
pdftron::PDF::VerificationOptions::~VerificationOptions
~VerificationOptions()
pdftron::PDF::VerificationOptions::e_trust_anchor
Definition: VerificationOptions.h:60
pdftron::PDF::VerificationOptions::AddTrustedCertificates
void AddTrustedCertificates(const UChar *in_P7C_binary_DER_certificates_file_data, const size_t in_size)
pdftron::UChar
TRN_UChar UChar
Definition: BasicTypes.h:12
PDFDoc.h
pdftron::PDF::VerificationOptions::e_compatibility_and_archiving
Definition: VerificationOptions.h:29
pdftron::PDF::VerificationOptions::VerificationOptions
VerificationOptions(const VerificationOptions &other)
pdftron::PDF::VerificationOptions::LoadTrustList
void LoadTrustList(const FDF::FDFDoc &in_fdf_cert_exchange_data)
BasicTypes.h
pdftron::PDF::VerificationOptions::TimeMode
TimeMode
Definition: VerificationOptions.h:37
pdftron::PDF::VerificationOptions::e_complete_trust
Definition: VerificationOptions.h:62
pdftron::PDF::VerificationOptions::AddTrustedCertificate
void AddTrustedCertificate(const UChar *in_certificate_buf, size_t in_buf_size, const UInt16 in_trust_flags=e_default_trust)
pdftron::PDF::VerificationOptions::EnableDigestVerification
void EnableDigestVerification(bool in_on_or_off)
pdftron::PDF::VerificationOptions::e_signing
Definition: VerificationOptions.h:42
pdftron::UString
Definition: UString.h:27
pdftron::PDF::VerificationOptions::EnableTrustVerification
void EnableTrustVerification(bool in_on_or_off)
pdftron::PDF::VerificationOptions::EnableModificationVerification
void EnableModificationVerification(bool in_on_or_off)
pdftron::PDF::VerificationOptions::e_identity
Definition: VerificationOptions.h:59