![]() |
SignDoc SDK (C++)
5.0.0
|
Parameters for signing a document. More...
#include <SignDocSDK-cpp.h>
Public Types | |
enum | Type { t_undefined = 0, t_integer = 2, t_string = 4, t_color = 5, t_blob = 8, t_length = 9 } |
Return values of getType(). More... | |
enum | Method { m_default, m_digsig_pkcs1, m_digsig_pkcs7_detached, m_digsig_pkcs7_sha1, m_hash, m_digsig_cades_detached, m_digsig_cades_rfc3161 } |
Signing methods. More... | |
enum | AddCertificates { ac_all, ac_none, ac_trusted } |
Values for integer parameter "AddCertificates". More... | |
enum | AddRevocationInfo { ari_add = 0x01 } |
Flags for integer parameter "AddRevocationInfo". More... | |
enum | RemoveXFA { rx_always, rx_if_allowed, rx_never } |
Values for integer parameter "RemoveXFA". More... | |
enum | Optimize { o_optimize, o_dont_optimize, o_if_possible } |
Optimization of document before signing. More... | |
enum | PDFAButtons { pb_freeze, pb_dont_freeze, pb_auto } |
Fix appearance streams of check boxes and radio buttons for PDF/A-1 without Technical Corrigendum 2. More... | |
enum | BiometricEncryption { be_rsa, be_fixed, be_binary, be_passphrase, be_dont_store } |
Select how to encrypt the biometric data. More... | |
enum | BiometricHashLocation { bhl_attr, bhl_contents } |
Select where to store the message digest computed over the document hash and the unencrypted biometric data. More... | |
enum | HAlignment { ha_left, ha_center, ha_right, ha_justify, ha_auto, ha_default = -1 } |
Horizontal alignment. More... | |
enum | VAlignment { va_top, va_center, va_bottom } |
Vertical alignment. More... | |
enum | TextPosition { tp_overlay, tp_below, tp_underlay, tp_right_of, tp_above, tp_left_of } |
enum | ValueType { vt_abs, vt_field_height, vt_field_width } |
Indicate how measurements are specified. More... | |
enum | TextGroup { tg_primary, tg_secondary, tg_master = tg_primary, tg_slave = tg_secondary } |
Text groups. More... | |
enum | TextItemDirection { tid_ltr = 0x1000, tid_rtl = 0x2000, tid_default_ltr = 0x4000, tid_default_rtl = 0x8000 } |
Paragraph direction of a text item. More... | |
enum | IgnoreSeedValues { isv_SubFilter = 0x01, isv_DigestMethod = 0x02 } |
Flags for ignoring mandatory requirements specified by the signature seed value dictionary. More... | |
enum | CertificateSelectionFlags { csf_software = 0x01, csf_hardware = 0x02, csf_use_certificate_seed_values = 0x10, csf_ask_if_ambiguous = 0x20, csf_never_ask = 0x40, csf_create_self_signed = 0x80 } |
Flags for selecting certificates. More... | |
enum | RenderSignatureFlags { rsf_bw = 0x01, rsf_gray = 0x02, rsf_antialias = 0x04, rsf_limit_size = 0x08 } |
Flags for rendering the signature. More... | |
enum | ImageTransparency { it_opaque, it_brightest } |
Transparency of signature image. More... | |
Public Member Functions | |
SignDocSignatureParameters () | |
Constructor. More... | |
~SignDocSignatureParameters () | |
Destructor. More... | |
ReturnCode | setString (Encoding aEncoding, const std::string &aName, const std::string &aValue) |
Set a string parameter. More... | |
ReturnCode | setString (const std::string &aName, const wchar_t *aValue) |
Set a string parameter. More... | |
ReturnCode | setInteger (const std::string &aName, int aValue) |
Set an integer parameter. More... | |
ReturnCode | setBlob (const std::string &aName, const unsigned char *aData, size_t aSize) |
Set a blob parameter. More... | |
ReturnCode | setLength (const std::string &aName, ValueType aType, double aValue) |
Set a length parameter. More... | |
ReturnCode | setColor (const std::string &aName, const SignDocColor &aValue) |
Set a color parameter. More... | |
ReturnCode | addTextItem (const std::string &aItem, TextGroup aGroup) |
Add another string to be displayed, top down. More... | |
ReturnCode | addTextItem2 (const std::string &aItem, TextGroup aGroup, HAlignment aHAlignment, int aDirection) |
Add another string to be displayed, top down, with paragraph direction. More... | |
ReturnCode | clearTextItems () |
Remove all strings that were to be displayed. More... | |
ReturnCode | setTextItemDirection (const std::string &aItem, HAlignment aHAlignment, int aDirection) |
Set the paragraph direction of text items. More... | |
ReturnCode | setPKCS7 (SignPKCS7 *aPKCS7) |
Set an object which will create a PKCS #7 or CAdES signature. More... | |
ReturnCode | setRSA (SignRSA *aRSA) |
Set an object which will compute an RSA signature. More... | |
ReturnCode | setECDSA (SignECDSA *aECDSA) |
Set an object which will compute an ECDSA signature. More... | |
int | getAvailableMethods () |
Get a bitset indicating which signing methods are available for this signature field. More... | |
ReturnCode | getTemplate (std::vector< unsigned char > &aOutput) |
Get an XML document specifying the current layout. More... | |
const char * | getErrorMessage (Encoding aEncoding) const |
Get an error message for the last function call. More... | |
const wchar_t * | getErrorMessageW () const |
Get an error message for the last function call. More... | |
SignDocSignatureParameters (SIGNDOC_SignatureParameters *aP) | |
Internal function. More... | |
SIGNDOC_SignatureParameters * | getImpl () |
Internal function. More... | |
const SIGNDOC_SignatureParameters * | getImpl () const |
Internal function. More... | |
void | setImpl (SIGNDOC_SignatureParameters *aP) |
Internal function. More... | |
Static Public Member Functions | |
static Type | getType (const std::string &aName) |
Get the type of a parameter. More... | |
Parameters for signing a document.
Use getErrorMessage() to get more information after a function call failed.
The available parameters depend both on the document type and on the signature field for which the SignDocSignatureParameters object has been created.
SignDocDocument::addSignature() may fail due to invalid parameters even if all setters reported success as the setters do not check if there are conflicts between parameters.
Which certificates are acceptable may be restricted by the application (by using csf_software and csf_hardware of integer parameter "SelectCertificate", blob parameters "FilterCertificatesByIssuerCertificate" and "FilterCertificatesBySubjectCertificate", and string parameters "FilterCertificatesByPolicy" and "FilterCertificatesBySubjectDN") and by the PDF document (certificate seed value dictionary). If no matching certificate is available (for instance, because integer parameter "SelectCertificate" is zero), SignDocDocument::addSignature() will fail with error ReturnCode::rc_no_certificate. If more than one matching certificate is available but csf_never_ask is specified in integer parameter "SelectCertificate"), SignDocDocument::addSignature() will fail with error ReturnCode::rc_ambiguous_certificate.
To make the signature maximally meaningful, integer parameter "AddCertificates" should be ac_all (which is the default value) and integer parameter "AddRevocationInfo" should include ari_add.
Unless you need a specific signing method, you should leave integer parameter "Method" at its default value m_default. If you select a specific signing method and that method is not allowed by the signature field's seed values, signing will fail.
Unless you need a specific digest algorithm, you should leave string parameter "DetachedHashAlgorithm" at its default value "default". If you select a specific digest algorithm and that algorithm is not allowed by the signature field's seed values, signing will fail.
The interaction between some parameters is quite complex; the following section tries to summarize the signing methods for PDF documents.
Additionally:
For TIFF documents, an additional, simplified signing method is available:
The following parameters control the signing method and related aspects of the signature:
The following parameters control the private key used for signing:
The following parameters control rendering of the signature image from biometric data:
The following parameters put additional data into the signature:
The following parameters provide texts for the appearance of a signature in PDF documents:
The following parameters control how a signed signature field in a PDF document will look like (parameters marked with * can be overridden with blob parameter "Template"):
The following parameters control the signing certificate:
The following parameters are used for generating a self-signed certificate on the fly (you also need to set at least one parameter for the private key):
The following parameters are used for putting biometric data (handwritten signature) into the signature:
The following parameters control the certificate selection dialog:
The following parameters control RFC 3161 timestamps:
The following parameters put additional certificates and revocation information into the signature:
The following parameters do not fall into the above categories:
enum AddCertificates |
Values for integer parameter "AddCertificates".
enum AddRevocationInfo |
Flags for integer parameter "AddRevocationInfo".
enum BiometricEncryption |
Select how to encrypt the biometric data.
Used for integer parameter "BiometricEncryption". The biometric data to be encrypted is specified by blob parameter "BiometricData".
Enumerator | |
---|---|
be_rsa |
Random session key encrypted with public RSA key. Either blob parameter "BiometricKey" (see setBlob()) or string parameter "BiometricKeyPath" (see setString()) must be set.
|
be_fixed |
Fixed key (no security). |
be_binary |
Binary 256-bit key. Blob parameter "BiometricKey" (see setBlob()) must be set. |
be_passphrase |
Passphrase that will be hashed to a 256-bit key. String parameter "BiometricPassphrase" (see setString()) must be set. |
be_dont_store |
The biometric data won't be stored in the document. Use this value if you want to use the biometric data for generating the signature image only. Note that using an automatically generated self-signed certificate is secure only if biometric data is stored in the document using asymmetric encryption. |
Select where to store the message digest computed over the document hash and the unencrypted biometric data.
Used for integer parameter "BiometricHashLocation".
Enumerator | |
---|---|
bhl_attr |
If possible, store the biometric hash as unauthenticated attribute in the PKCS #7 (or CMS) message. For method m_digsig_pkcs1, the biometric hash will stored in the Contents entry of the signature dictionary (see bhl_contents). For all other methods, the biometric hash will stored as unauthenticated attribute in the PKCS #7 (or CMS) message. |
bhl_contents |
Store the message digest in the Contents entry of the signature dictionary. This is what SignDoc SDK 4.1 and older did; it violates a constraint of most PDF specifications. |
Flags for selecting certificates.
Used for integer parameter "SelectCertificate".
Enumerator | |
---|---|
csf_software |
Include certificates with software-based private keys. As software-based private keys and hardware-based private keys cannot be reliably distinguished, you should always set both csf_software and csf_hardware. If neither csf_ask_if_ambiguous nor csf_never_ask is included, the certificate selection dialog will be displayed. |
csf_hardware |
Include certificates with hardware-based private keys. As software-based private keys and hardware-based private keys cannot be reliably distinguished, you should always set both csf_software and csf_hardware. If neither csf_ask_if_ambiguous nor csf_never_ask is included, the certificate selection dialog will be displayed. |
csf_use_certificate_seed_values |
Include only certificates allowed by the PDF document's certificate seed value dictionary. |
csf_ask_if_ambiguous |
Ask the user to select a certificate if there is more than one matching certificate. |
csf_never_ask |
Never ask the user to select a certificate; exactly one certificate must match. |
csf_create_self_signed |
Offer to create a self-signed certificate (cannot be used with csf_never_ask and csf_ask_if_ambiguous). |
enum HAlignment |
Horizontal alignment.
Used for integer parameters "ImageHAlignment" and "TextHAlignment" and for addTextItem2().
Enumerator | |
---|---|
ha_left |
Align left. |
ha_center |
Center. |
ha_right |
Align right. |
ha_justify |
Justify (align both and right, expanding white space).
|
ha_auto |
Align left if the text begins with an LTR run, align right if the text begins with an RTL run. |
ha_default |
addTextItem2(): use integer parameter "TextHAlignment". |
enum IgnoreSeedValues |
Flags for ignoring mandatory requirements specified by the signature seed value dictionary.
Used for integer parameter "IgnoreSeedValues".
Enumerator | |
---|---|
isv_SubFilter |
Ignore SubFilter (signing method). If this flag is not set signing will fail if the signing method specified by integer parameter "Method" is neither m_default nor listed in the SubFilter entry of the signature field seed value dictionary. If this flag is set, you can override the SubFilter entry of the signature field seed value dictionary with integer parameter "Method" without risking failure of signing due to a conflict between "Method" and SubFilter. |
isv_DigestMethod |
Ignore DigestMethod (hash algorithm). If this flag is not set, signing will fail if a hash algorithm is requested that is not listed in the DigestMethod entry of the signature field seed value dictionary. The hash algorithnm is specified by string parameter "DetachedHashAlgorithm" (if the value of that parameter is not "default"). It can also be implied by integer parameter "Method". If this flag is set, you can override the DigestMethod entry of the signature field seed value dictionary with string parameter "DetachedHashAlgorithm" and/or integer parameter "Method" without risking failure of signing due to a conflict with DigestMethod. |
enum ImageTransparency |
Transparency of signature image.
Used for integer parameter "ImageTransparency".
If the image has an alpha channel (or if its palette contains a transparent color), the image's transparency will be used no matter what value is set for "ImageTransparency".
Transparency is not supported for JPEG images and JPEG-compressed TIFF images. Signature images created from biometric data (according to the "RenderSignature" integer parameter) don't have an alpha channel.
enum Method |
Signing methods.
Used for integer parameter "Method" and by SignDocVerificationResult::getMethod().
Enumerator | |
---|---|
m_default |
Default method. For signature parameters created by SignDocDocument::createSignatureParametersForTimeStamp(), this value is treated as m_digsig_cades_rfc3161. Use the method specified by the SubFilter values of the signature field seed value dictionary or, if not present, m_digsig_pkcs7_detached. This is the recommended method unless you need an ETSI CAdES signature (m_digsig_cades_detached). |
m_digsig_pkcs1 |
PKCS #1 (RSA keys only). Not allowed for PDF/A-2 and PDF/A-3. |
m_digsig_pkcs7_detached |
Detached PKCS #7. |
m_digsig_pkcs7_sha1 | |
m_hash | |
m_digsig_cades_detached | |
m_digsig_cades_rfc3161 |
enum Optimize |
Optimization of document before signing.
Used for integer parameter "Optimize".
enum PDFAButtons |
Fix appearance streams of check boxes and radio buttons for PDF/A-1 without Technical Corrigendum 2.
Used for integer parameter "PDFAButtons".
Using pb_freeze (or pb_auto, if the document claims to conform with PDF/A-1 and has no signed signature fields) is equivalent to saving the document with SignDocDocument::sf_pdfa_buttons before signing.
enum RemoveXFA |
Values for integer parameter "RemoveXFA".
Enumerator | |
---|---|
rx_always |
Always remove XFA. Use this value if you intend to call SignDocDocument::setField() or SignDocDocument::addField() after signing. Adding the signature will fail if the document prohibits removal of XFA. |
rx_if_allowed |
Remove XFA if possible. XFA will be removed unless the document prohibits removal of XFA. SignDocDocument::addField() and SignDocDocument::setField() will fail if XFA is still present after signing. |
rx_never |
Do not remove XFA. SignDocDocument::addField() and SignDocDocument::setField() will fail if XFA is still present after signing. |
enum RenderSignatureFlags |
Flags for rendering the signature.
Used for integer parameter "RenderSignature".
rsf_bw, rsf_gray, and rsf_antialias are mutually exclusive.
enum TextGroup |
Text groups.
One font size is used per group and is chosen such that the text fits horizontally. The maximum font size is specified by length parameter "FontSize". The font size of the secondary group cannot be greater than the font size of the primary group, that is, long text in the secondary group won't reduce the font size of the primary group.
There must be at least one primary text item if there is a secondary text item.
Enumerator | |
---|---|
tg_primary |
Primary group. |
tg_secondary |
Secondary group. |
tg_master | |
tg_slave |
enum TextItemDirection |
Paragraph direction of a text item.
enum TextPosition |
Position of the text block w.r.t. to the image.
Used for integer parameter "TextPosition".
enum Type |
Return values of getType().
Enumerator | |
---|---|
t_undefined |
The specified parameter is not defined. |
t_integer |
Integer.
|
t_string |
String.
|
t_color |
Color.
|
t_blob |
Blob.
|
t_length |
Length.
|
enum VAlignment |
Vertical alignment.
Used for integer parameters "ImageVAlignment" and "TextVAlignment" (see setInteger()).
Enumerator | |
---|---|
va_top |
Align top. |
va_center |
Center. |
va_bottom |
Align bottom. |
enum ValueType |
Indicate how measurements are specified.
Enumerator | |
---|---|
vt_abs |
aValue is the value to be used (units of document coordinates). See Coordinate Systems. |
vt_field_height |
Multiply aValue by the field height. |
vt_field_width |
Multiply aValue by the field width. |
|
inline |
Constructor.
Use SignDocDocument::createSignatureParameters() or SignDocDocument::createSignatureParametersForTimeStamp() instead.
|
inline |
Destructor.
Overwrites this object's copies of the private key and biometric data.
|
inline |
Internal function.
|
inline |
Add another string to be displayed, top down.
For DigSig signature fields, this function adds another string to the appearance stream of PDF documents. The first call clears any default strings. The default values depend on the profile passed to SignDocDocument::createSignatureParameters():
Profile | Value |
---|---|
"" | "Signer"/tg_primary, "SignTime"/tg_primary |
"image" | (empty) |
The paragraph direction is 0 which is treated like tid_ltr.
See also blob parameter "Template".
[in] | aItem | Select the string to be added:
|
[in] | aGroup | The string's group for font size computation. |
|
inline |
Add another string to be displayed, top down, with paragraph direction.
For DigSig signature fields, this function adds another string to the appearance stream of PDF documents. The first call clears any default strings. The default values depend on the profile passed to SignDocDocument::createSignatureParameters():
Profile | Value |
---|---|
"" | "Signer"/tg_primary, "SignTime"/tg_primary |
"image" | (empty) |
See also blob parameter "Template".
[in] | aItem | Select the string to be added:
|
[in] | aGroup | The string's group for font size computation. |
[in] | aHAlignment | Horizontal alignment. This value overrides integer parameter "TextHAlignment" unless it is ha_default. |
[in] | aDirection | The paragraph direction, see enum TextItemDirection. 0 is treated like tid_ltr. |
|
inline |
Remove all strings that were to be displayed.
addTextItem() cannot remove the default strings without adding a new string. This function does.
See also blob parameter "Template".
|
inline |
Get a bitset indicating which signing methods are available for this signature field.
|
inline |
Get an error message for the last function call.
[in] | aEncoding | The encoding to be used for the error message. |
|
inline |
Get an error message for the last function call.
|
inline |
Internal function.
|
inline |
Internal function.
|
inline |
Get an XML document specifying the current layout.
This function can be used for debugging and for reporting bugs. This function will fail if the "Template" blob parameter is invalid.
[out] | aOutput | The XML document will be stored here. |
|
inlinestatic |
Get the type of a parameter.
[in] | aName | The name of the parameter (case-sensitive). |
|
inline |
Set a blob parameter.
Available blob parameters are:
Additionally, you can store your own blobs in the signature by using a name starting with "Prop_", except for "Prop_AuthTime", "Prop_AuthType", "Prop_Build", and any name starting with "Prop_BiometricData", see SignDocVerificationResult::getSignatureBlob(). The name shall contain the following characters only: 0-9, a-z, A-Z, '-', and '_'.
[in] | aName | The name of the parameter (case-sensitive). |
[in] | aData | A pointer to the first octet of the value. |
[in] | aSize | Size of the blob (number of octets). |
|
inline |
Set a color parameter.
Available color parameters are:
[in] | aName | The name of the parameter (case-sensitive). |
[in] | aValue | The value of the parameter. |
|
inline |
Set an object which will compute an ECDSA signature.
By default, ECDSA signatures are computed internally which means that the private key must be available on this machine.
Requirements for string parameters:
Requirements for integer parameters:
Requirements for blob parameters:
setRSA() and setPKCS7() must not have been called
[in] | aECDSA | The object that will compute the ECDSA signature. This function does not take ownership of that object. It must still be alive when addSignature() is called. |
|
inline |
Internal function.
|
inline |
Set an integer parameter.
Available integer parameters are:
Profile | Value |
---|---|
"" | ha_center |
"image" | ha_center |
Profile | Value |
---|---|
"" | va_top |
"image" | va_center |
Profile | Value |
---|---|
"" | ha_center |
"image" | ha_center |
Profile | Value |
---|---|
"" | tp_below |
"image" | tp_overlay |
Profile | Value |
---|---|
"" | va_bottom |
"image" | va_center |
[in] | aName | The name of the parameter (case-sensitive). |
[in] | aValue | The value of the parameter. |
|
inline |
Set a length parameter.
Available length parameters are:
Profile | Value |
---|---|
"" | vt_field_height and 0.1 |
"image" | vt_field_height and 0.1 |
Profile | Value |
---|---|
"" | vt_abs and 1.0 |
"image" | vt_abs and 1.0 |
Profile | Value |
---|---|
"" | vt_field_height and 0.1 |
"image" | vt_field_height and 0.1 |
[in] | aName | The name of the parameter (case-sensitive). |
[in] | aType | Define how the length is specified. |
[in] | aValue | The value of the parameter. |
|
inline |
Set an object which will create a PKCS #7 or CAdES signature.
By default, PKCS #7 and CAdES signatures are handled internally which means that the private key must be available on this machine.
Requirements for string parameters:
Requirements for integer parameters:
Requirements for blob parameters:
setRSA() and setECDSA() must not have been called
The SignPKCS7 interface is quite hard to use, please use setRSA() and the SignRSA interface or setECDSA() and the SignECDSA interface instead.
[in] | aPKCS7 | The object that will create the PKCS #7 or CAdES signature. This function does not take ownership of that object. It must still be alive when addSignature() is called. |
|
inline |
Set an object which will compute an RSA signature.
By default, RSA signatures are computed internally which means that the private key must be available on this machine.
Requirements for string parameters:
Requirements for integer parameters:
Requirements for blob parameters:
setECDSA() and setPKCS7() must not have been called
[in] | aRSA | The object that will compute the RSA signature. This function does not take ownership of that object. It must still be alive when addSignature() is called. |
|
inline |
Set a string parameter.
Available string parameters are:
Additionally, you can store your own strings in the signature by using a name starting with "Prop_", except for "Prop_AuthTime", "Prop_AuthType", "Prop_Build", and any name starting with "Prop_BiometricData", see SignDocVerificationResult::getSignatureString(). The name shall contain the following characters only: 0-9, a-z, A-Z, '-', and '_'. The length of the value is restricted for PDF documents and depends on the characters being used; the value encoded as PDF text string shall not exceed 32767 octets.
[in] | aEncoding | The encoding used for aValue. |
[in] | aName | The name of the parameter (case-sensitive). |
[in] | aValue | The value of the parameter. The encoding is specified by aEncoding. |
|
inline |
Set a string parameter.
See setString(Encoding aEncoding, const std::string &aName, const std::string &aValue) for a list of available string parameters.
[in] | aName | The name of the parameter (case-sensitive). |
[in] | aValue | The value of the parameter. |
|
inline |
Set the paragraph direction of text items.
This function sets the paragraph direction of all existing text items matching aItem.
See also blob parameter "Template".
[in] | aItem | Select the text items:
|
[in] | aHAlignment | Horizontal alignment. This value overrides integer parameter "TextHAlignment" unless it is ha_default. |
[in] | aDirection | The paragraph direction, see enum TextItemDirection. 0 is treated like tid_ltr. |