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-2023 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 
22 {
23 public:
24  //enums:
25 
26  // An enumeration representing the level of security to use when verifying digital signatures.
28  // For compatibility with other vendors such as Acrobat, one can use e_compatibility_and_archiving.
30  // The e_maximum mode is a highly-restrictive mode which disables many common features of PDF digital signatures.
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. */
46  /* Check signature certificates against the current time.
47  This is the most secure, and the most restrictive option. */
49  };
50 
51  // An enumeration representing the level of trust associated with a particular certificate. Multiple flag values can be combined using bitwise operators.
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  };
65  VerificationOptions(TRN_VerificationOptions impl);
68 
69  void Destroy();
70 
71  //methods:
72 
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 
207 
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
Crypto::X509Certificate GetTrustedCertificate(const UInt32 index)
TRN_UInt16 UInt16
Definition: BasicTypes.h:14
void EnableOnlineOCSPRevocationChecking(bool in_on_or_off)
void EnableOnlineRevocationChecking(bool in_on_or_off)
void SetRevocationTimeout(const UInt32 in_revocation_timeout_milliseconds)
VerificationOptions & operator=(const VerificationOptions &other)
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
void EnableOnlineCRLRevocationChecking(bool in_on_or_off)
void AddTrustedCertificates(const UChar *in_P7C_binary_DER_certificates_file_data, const size_t in_size)
TRN_UChar UChar
Definition: BasicTypes.h:12
VerificationOptions(const VerificationOptions &other)
void LoadTrustList(const FDF::FDFDoc &in_fdf_cert_exchange_data)
void AddTrustedCertificate(const UChar *in_certificate_buf, size_t in_buf_size, const UInt16 in_trust_flags=e_default_trust)
void EnableDigestVerification(bool in_on_or_off)
void EnableTrustVerification(bool in_on_or_off)
void EnableModificationVerification(bool in_on_or_off)