blob: 9a075e5f8429bc63d61d3ae2f33a1edbf8c7bc41 [file] [log] [blame]
K. Moon832a6942022-10-31 20:11:31 +00001// Copyright 2020 The PDFium Authors
Miklos Vajna2b76bf92020-06-25 21:35:26 +00002// 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
12extern "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.
22FPDF_EXPORT int FPDF_CALLCONV FPDF_GetSignatureCount(FPDF_DOCUMENT document);
23
Miklos Vajna0ab17242020-06-30 22:17:11 +000024// 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.
34FPDF_EXPORT FPDF_SIGNATURE FPDF_CALLCONV
35FPDF_GetSignatureObject(FPDF_DOCUMENT document, int index);
36
Miklos Vajna57445f22020-07-17 19:15:48 +000037// 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.
51FPDF_EXPORT unsigned long FPDF_CALLCONV
52FPDFSignatureObj_GetContents(FPDF_SIGNATURE signature,
53 void* buffer,
54 unsigned long length);
55
Miklos Vajna9e1fc052020-07-22 14:22:23 +000056// 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.
73FPDF_EXPORT unsigned long FPDF_CALLCONV
74FPDFSignatureObj_GetByteRange(FPDF_SIGNATURE signature,
75 int* buffer,
76 unsigned long length);
77
Miklos Vajna1fc751f2020-07-28 06:35:27 +000078// 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.
92FPDF_EXPORT unsigned long FPDF_CALLCONV
93FPDFSignatureObj_GetSubFilter(FPDF_SIGNATURE signature,
94 char* buffer,
95 unsigned long length);
96
Miklos Vajnaf8935042020-08-03 18:08:56 +000097// 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.
111FPDF_EXPORT unsigned long FPDF_CALLCONV
112FPDFSignatureObj_GetReason(FPDF_SIGNATURE signature,
113 void* buffer,
114 unsigned long length);
115
Miklos Vajna571febd2020-08-12 19:18:14 +0000116// 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.
135FPDF_EXPORT unsigned long FPDF_CALLCONV
136FPDFSignatureObj_GetTime(FPDF_SIGNATURE signature,
137 char* buffer,
138 unsigned long length);
139
Miklos Vajnaf63c9652020-11-03 16:32:12 +0000140// 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.
148FPDF_EXPORT unsigned int FPDF_CALLCONV
149FPDFSignatureObj_GetDocMDPPermission(FPDF_SIGNATURE signature);
150
Miklos Vajna2b76bf92020-06-25 21:35:26 +0000151#ifdef __cplusplus
152} // extern "C"
153#endif // __cplusplus
154
155#endif // PUBLIC_FPDF_SIGNATURE_H_