1 // Copyright 2020 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef PUBLIC_FPDF_SIGNATURE_H_ 6 #define PUBLIC_FPDF_SIGNATURE_H_ 7 8 // NOLINTNEXTLINE(build/include) 9 #include "fpdfview.h" 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif // __cplusplus 14 15 // Experimental API. 16 // Function: FPDF_GetSignatureCount 17 // Get total number of signatures in the document. 18 // Parameters: 19 // document - Handle to document. Returned by FPDF_LoadDocument(). 20 // Return value: 21 // Total number of signatures in the document on success, -1 on error. 22 FPDF_EXPORT int FPDF_CALLCONV FPDF_GetSignatureCount(FPDF_DOCUMENT document); 23 24 // Experimental API. 25 // Function: FPDF_GetSignatureObject 26 // Get the Nth signature of the document. 27 // Parameters: 28 // document - Handle to document. Returned by FPDF_LoadDocument(). 29 // index - Index into the array of signatures of the document. 30 // Return value: 31 // Returns the handle to the signature, or NULL on failure. The caller 32 // does not take ownership of the returned FPDF_SIGNATURE. Instead, it 33 // remains valid until FPDF_CloseDocument() is called for the document. 34 FPDF_EXPORT FPDF_SIGNATURE FPDF_CALLCONV 35 FPDF_GetSignatureObject(FPDF_DOCUMENT document, int index); 36 37 // Experimental API. 38 // Function: FPDFSignatureObj_GetContents 39 // Get the contents of a signature object. 40 // Parameters: 41 // signature - Handle to the signature object. Returned by 42 // FPDF_GetSignatureObject(). 43 // buffer - The address of a buffer that receives the contents. 44 // length - The size, in bytes, of |buffer|. 45 // Return value: 46 // Returns the number of bytes in the contents on success, 0 on error. 47 // 48 // For public-key signatures, |buffer| is either a DER-encoded PKCS#1 binary or 49 // a DER-encoded PKCS#7 binary. If |length| is less than the returned length, or 50 // |buffer| is NULL, |buffer| will not be modified. 51 FPDF_EXPORT unsigned long FPDF_CALLCONV 52 FPDFSignatureObj_GetContents(FPDF_SIGNATURE signature, 53 void* buffer, 54 unsigned long length); 55 56 // Experimental API. 57 // Function: FPDFSignatureObj_GetByteRange 58 // Get the byte range of a signature object. 59 // Parameters: 60 // signature - Handle to the signature object. Returned by 61 // FPDF_GetSignatureObject(). 62 // buffer - The address of a buffer that receives the 63 // byte range. 64 // length - The size, in ints, of |buffer|. 65 // Return value: 66 // Returns the number of ints in the byte range on 67 // success, 0 on error. 68 // 69 // |buffer| is an array of pairs of integers (starting byte offset, 70 // length in bytes) that describes the exact byte range for the digest 71 // calculation. If |length| is less than the returned length, or 72 // |buffer| is NULL, |buffer| will not be modified. 73 FPDF_EXPORT unsigned long FPDF_CALLCONV 74 FPDFSignatureObj_GetByteRange(FPDF_SIGNATURE signature, 75 int* buffer, 76 unsigned long length); 77 78 // Experimental API. 79 // Function: FPDFSignatureObj_GetSubFilter 80 // Get the encoding of the value of a signature object. 81 // Parameters: 82 // signature - Handle to the signature object. Returned by 83 // FPDF_GetSignatureObject(). 84 // buffer - The address of a buffer that receives the encoding. 85 // length - The size, in bytes, of |buffer|. 86 // Return value: 87 // Returns the number of bytes in the encoding name (including the 88 // trailing NUL character) on success, 0 on error. 89 // 90 // The |buffer| is always encoded in 7-bit ASCII. If |length| is less than the 91 // returned length, or |buffer| is NULL, |buffer| will not be modified. 92 FPDF_EXPORT unsigned long FPDF_CALLCONV 93 FPDFSignatureObj_GetSubFilter(FPDF_SIGNATURE signature, 94 char* buffer, 95 unsigned long length); 96 97 // Experimental API. 98 // Function: FPDFSignatureObj_GetReason 99 // Get the reason (comment) of the signature object. 100 // Parameters: 101 // signature - Handle to the signature object. Returned by 102 // FPDF_GetSignatureObject(). 103 // buffer - The address of a buffer that receives the reason. 104 // length - The size, in bytes, of |buffer|. 105 // Return value: 106 // Returns the number of bytes in the reason on success, 0 on error. 107 // 108 // Regardless of the platform, the |buffer| is always in UTF-16LE encoding. The 109 // string is terminated by a UTF16 NUL character. If |length| is less than the 110 // returned length, or |buffer| is NULL, |buffer| will not be modified. 111 FPDF_EXPORT unsigned long FPDF_CALLCONV 112 FPDFSignatureObj_GetReason(FPDF_SIGNATURE signature, 113 void* buffer, 114 unsigned long length); 115 116 // Experimental API. 117 // Function: FPDFSignatureObj_GetTime 118 // Get the time of signing of a signature object. 119 // Parameters: 120 // signature - Handle to the signature object. Returned by 121 // FPDF_GetSignatureObject(). 122 // buffer - The address of a buffer that receives the time. 123 // length - The size, in bytes, of |buffer|. 124 // Return value: 125 // Returns the number of bytes in the encoding name (including the 126 // trailing NUL character) on success, 0 on error. 127 // 128 // The |buffer| is always encoded in 7-bit ASCII. If |length| is less than the 129 // returned length, or |buffer| is NULL, |buffer| will not be modified. 130 // 131 // The format of time is expected to be D:YYYYMMDDHHMMSS+XX'YY', i.e. it's 132 // percision is seconds, with timezone information. This value should be used 133 // only when the time of signing is not available in the (PKCS#7 binary) 134 // signature. 135 FPDF_EXPORT unsigned long FPDF_CALLCONV 136 FPDFSignatureObj_GetTime(FPDF_SIGNATURE signature, 137 char* buffer, 138 unsigned long length); 139 140 // Experimental API. 141 // Function: FPDFSignatureObj_GetDocMDPPermission 142 // Get the DocMDP permission of a signature object. 143 // Parameters: 144 // signature - Handle to the signature object. Returned by 145 // FPDF_GetSignatureObject(). 146 // Return value: 147 // Returns the permission (1, 2 or 3) on success, 0 on error. 148 FPDF_EXPORT unsigned int FPDF_CALLCONV 149 FPDFSignatureObj_GetDocMDPPermission(FPDF_SIGNATURE signature); 150 151 #ifdef __cplusplus 152 } // extern "C" 153 #endif // __cplusplus 154 155 #endif // PUBLIC_FPDF_SIGNATURE_H_ 156