Information about a signature field returned by SignDocDocument::verifySignature() or SignDocDocument::verifySignature2(). More...
#include <SignDocSDK-cpp.h>
Public Types | |
enum | ReturnCode { rc_ok = SignDocDocument::rc_ok, rc_invalid_argument = SignDocDocument::rc_invalid_argument, rc_not_supported = SignDocDocument::rc_not_supported, rc_not_verified = SignDocDocument::rc_not_verified, rc_property_not_found = SignDocDocument::rc_property_not_found, rc_no_biometric_data = SignDocDocument::rc_no_biometric_data, rc_unexpected_error = SignDocDocument::rc_unexpected_error } |
Return codes. More... | |
enum | SignatureState { ss_unmodified, ss_document_extended, ss_document_modified, ss_unsupported_signature, ss_invalid_certificate, ss_empty } |
State of a signature. More... | |
enum | ModificationState { ms_unmodified, ms_allowed, ms_prohibited } |
Modification state of the document for a certain signature. More... | |
enum | TimeStampState { tss_valid, tss_missing, tss_invalid } |
State of the RFC 3161 time stamp. More... | |
enum | CertificateChainState { ccs_ok, ccs_broken_chain, ccs_untrusted_root, ccs_critical_extension, ccs_not_time_valid, ccs_path_length, ccs_invalid, ccs_error } |
Certificate chain state for verifyCertificateChain() and verifyTimeStampCertificateChain(). More... | |
enum | CertificateRevocationState { crs_ok, crs_not_checked, crs_offline, crs_revoked, crs_error } |
Certificate revocation state for getCertificateRevocationState() and getTimeStampCertificateRevocationState(). More... | |
Public Member Functions | |
SignDocVerificationResult () | |
Constructor. | |
~SignDocVerificationResult () | |
Destructor. | |
ReturnCode | getState (SignatureState &aOutput) |
Get the signature state. | |
ReturnCode | getModificationState (ModificationState &aOutput) |
Get the modification state of a PDF document. | |
ReturnCode | getMethod (SignDocSignatureParameters::Method &aOutput) |
Get the signing method. | |
int | getDocMDP () |
Get the DocMDP P value of a certification signature. | |
int | getLockMDP () |
Get the lock MDP value of the signature. | |
ReturnCode | getDigestAlgorithm (std::string &aOutput) |
Get the message digest algorithm of the signature. | |
ReturnCode | getCertificates (std::vector< std::vector< unsigned char > > &aOutput) |
Get the certificates of the signature. | |
ReturnCode | verifyCertificateChain (const SignDocVerificationParameters *aParameters, CertificateChainState &aOutput) |
Verify the certificate chain of the signature's certificate. | |
ReturnCode | getCertificateRevocationState (CertificateRevocationState &aOutput) |
Get the revocation state of the certificate chain of the signature's certificate. | |
ReturnCode | verifyCertificateSimplified (const SignDocVerificationParameters *aParameters) |
Simplified verification of the certificate chain and revocation status of the signature's certificate. | |
ReturnCode | getCertificateChainLength (int &aOutput) |
Get the certificate chain length. | |
ReturnCode | getSignatureString (Encoding aEncoding, const std::string &aName, std::string &aOutput) |
Get a string parameter from the signature field. | |
ReturnCode | getSignatureBlob (const std::string &aName, std::vector< unsigned char > &aOutput) |
Get a blob property from the signature field. | |
ReturnCode | getBiometricData (const unsigned char *aKeyPtr, size_t aKeySize, const wchar_t *aKeyPath, const char *aPassphrase, std::vector< unsigned char > &aOutput) |
Get the biometric data of the field. | |
ReturnCode | getBiometricData (Encoding aEncoding, const unsigned char *aKeyPtr, size_t aKeySize, const char *aKeyPath, const char *aPassphrase, std::vector< unsigned char > &aOutput) |
Get the biometric data of the field. | |
ReturnCode | getEncryptedBiometricData (std::vector< unsigned char > &aOutput) |
Get the encrypted biometric data of the field. | |
ReturnCode | getBiometricEncryption (SignDocSignatureParameters::BiometricEncryption &aOutput) |
Get the encryption method used for biometric data of the signature field. | |
ReturnCode | checkBiometricHash (const unsigned char *aBioPtr, size_t aBioSize, bool &aOutput) |
Check the hash of the biometric data. | |
ReturnCode | getTimeStampState (TimeStampState &aOutput) |
Get the state of the RFC 3161 time stamp. | |
ReturnCode | getTimeStampDigestAlgorithm (std::string &aOutput) |
Get the message digest algorithm of the RFC 3161 time stamp. | |
ReturnCode | verifyTimeStampCertificateChain (const SignDocVerificationParameters *aParameters, CertificateChainState &aOutput) |
Verify the certificate chain of the RFC 3161 time stamp. | |
ReturnCode | getTimeStampCertificateRevocationState (CertificateRevocationState &aOutput) |
Get the revocation state of the certificate chain of the RFC 3161 time stamp. | |
ReturnCode | verifyTimeStampCertificateSimplified (const SignDocVerificationParameters *aParameters) |
Simplified verification of the certificate chain and revocation status of the RFC 3161 time stamp. | |
ReturnCode | getTimeStamp (std::string &aOutput) |
Get the value of the RFC 3161 time stamp. | |
ReturnCode | getTimeStampCertificates (std::vector< std::vector< unsigned char > > &aOutput) |
Get the certificates of the RFC 3161 time stamp. | |
const char * | getErrorMessage (Encoding aEncoding) const |
Get an error message for the last function call. | |
const wchar_t * | getErrorMessageW () const |
Get an error message for the last function call. | |
SignDocVerificationResult (SIGNDOC_VerificationResult *aP) | |
Internal function. | |
SIGNDOC_VerificationResult * | getImpl () |
Internal function. | |
const SIGNDOC_VerificationResult * | getImpl () const |
Internal function. | |
void | setImpl (SIGNDOC_VerificationResult *aP) |
Internal function. |
Information about a signature field returned by SignDocDocument::verifySignature() or SignDocDocument::verifySignature2().
The SignDocDocument object must live longer than any SignDocVerificationResult objects returned by its verifySignature() and verifySignature2() functions.
Certificate chain state for verifyCertificateChain() and verifyTimeStampCertificateChain().
Certificate revocation state for getCertificateRevocationState() and getTimeStampCertificateRevocationState().
Return codes.
Do not forget to update de/softpro/doc/SignDocException.java!
rc_ok |
No error. |
rc_invalid_argument |
Invalid argument. |
rc_not_supported |
Operation not supported. |
rc_not_verified |
SignDocDocument::verifySignature() has not been called. |
rc_property_not_found |
Property not found. |
rc_no_biometric_data |
No biometric data (or hash) available. |
rc_unexpected_error |
Unexpected error. |
State of a signature.
de::softpro::doc::SignDocVerificationResult::SignDocVerificationResult | ( | ) | [inline] |
Constructor.
de::softpro::doc::SignDocVerificationResult::~SignDocVerificationResult | ( | ) | [inline] |
Destructor.
de::softpro::doc::SignDocVerificationResult::SignDocVerificationResult | ( | SIGNDOC_VerificationResult * | aP ) | [inline] |
Internal function.
ReturnCode de::softpro::doc::SignDocVerificationResult::checkBiometricHash | ( | const unsigned char * | aBioPtr, |
size_t | aBioSize, | ||
bool & | aOutput | ||
) | [inline] |
Check the hash of the biometric data.
This function fails for document time stamps, see getMethod().
[in] | aBioPtr | Pointer to unencrypted biometric data, typically retrieved by getBiometricData(). |
[in] | aBioSize | Size of unencrypted biometric data in octets. |
[out] | aOutput | Result of the operation: true if the hash is OK, false if the hash doesn't match (the document has been tampered with). |
ReturnCode de::softpro::doc::SignDocVerificationResult::getBiometricData | ( | const unsigned char * | aKeyPtr, |
size_t | aKeySize, | ||
const wchar_t * | aKeyPath, | ||
const char * | aPassphrase, | ||
std::vector< unsigned char > & | aOutput | ||
) | [inline] |
Get the biometric data of the field.
Use getBiometricEncryption() to find out what parameters need to be passed:
This function fails for document time stamps, see getMethod().
[in] | aKeyPtr | Pointer to the first octet of the key (must be NULL if aKeyPath is not NULL). |
[in] | aKeySize | Size of the key pointed to by aKeyPtr (must be 0 if aKeyPath is not NULL). |
[in] | aKeyPath | Pathname of the file containing the key (must be NULL if aKeyPtr is not NULL). See Using SignDoc SDK in Windows Store apps for restrictions on pathnames in Windows Store apps. |
[in] | aPassphrase | Passphrase for decrypting the key contained in the file named by aKeyPath. If this argument is NULL or points to the empty string, it will be assumed that the key file is not protected by a passphrase. aPassphrase is used only when reading the key from a file for SignDocSignatureParameters::be_rsa. The passphrase must contain ASCII characters only. |
[out] | aOutput | The decrypted biometric data will be stored here. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getBiometricData | ( | Encoding | aEncoding, |
const unsigned char * | aKeyPtr, | ||
size_t | aKeySize, | ||
const char * | aKeyPath, | ||
const char * | aPassphrase, | ||
std::vector< unsigned char > & | aOutput | ||
) | [inline] |
Get the biometric data of the field.
Use getBiometricEncryption() to find out what parameters need to be passed:
This function fails for document time stamps, see getMethod().
[in] | aEncoding | The encoding of the string pointed to by aKeyPath. |
[in] | aKeyPtr | Pointer to the first octet of the key (must be NULL if aKeyPath is not NULL). |
[in] | aKeySize | Size of the key pointed to by aKeyPtr (must be 0 if aKeyPath is not NULL). |
[in] | aKeyPath | Pathname of the file containing the key (must be NULL if aKeyPtr is not NULL). See Using SignDoc SDK in Windows Store apps for restrictions on pathnames in Windows Store apps. |
[in] | aPassphrase | Passphrase for decrypting the key contained in the file named by aKeyPath. If this argument is NULL or points to the empty string, it will be assumed that the key file is not protected by a passphrase. aPassphrase is used only when reading the key from a file for SignDocSignatureParameters::be_rsa. The passphrase must contain ASCII characters only. |
[out] | aOutput | The decrypted biometric data will be stored here. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getBiometricEncryption | ( | SignDocSignatureParameters::BiometricEncryption & | aOutput ) | [inline] |
Get the encryption method used for biometric data of the signature field.
This function fails for document time stamps, see getMethod().
[out] | aOutput | The encryption method. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getCertificateChainLength | ( | int & | aOutput ) | [inline] |
Get the certificate chain length.
verifyCertificateChain() or verifyCertificateSimplified() must have been called successfully.
This function fails for document time stamps, see getMethod() and getTimeStampCertificates().
[out] | aOutput | The chain length will be stored here if this function is successful. If the signature was performed with a self-signed certificate, the chain length will be 1. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getCertificateRevocationState | ( | CertificateRevocationState & | aOutput ) | [inline] |
Get the revocation state of the certificate chain of the signature's certificate.
verifyCertificateChain() must have been called successfully.
getErrorMessage() will return an error message if this function fails (return value not rc_ok) or the verification result returned in aOutput is not crs_ok.
If vf_check_revocation was not set in integer parameter "VerificationFlags" for the most recent call to verifyCertificateChain(), this function will return crs_not_checked in aOutput.
This function fails for document time stamps, see getMethod() and getTimeStampCertificateRevocationState().
[out] | aOutput | The result of the certificate revocation check. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getCertificates | ( | std::vector< std::vector< unsigned char > > & | aOutput ) | [inline] |
Get the certificates of the signature.
This function fails for document time stamps, see getMethod() and getTimeStampCertificates().
[out] | aOutput | The ASN.1-encoded X.509 certificates will be stored here. If there are multiple certificates, the first one (at index 0) is the signing certificate. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getDigestAlgorithm | ( | std::string & | aOutput ) | [inline] |
Get the message digest algorithm of the signature.
Note that the values returned by this functions are different from the Digest values used by SignDocField::getSeedValueDigestMethod() and friends:
DigestMethod | getDigestAlgorithm() | DetachedHashAlgorithm |
---|---|---|
n/a | "MD5" | n/a |
"RIPEMD160" | "RIPEMD-160" | SignDocSignatureParameters::dha_ripemd160 |
"SHA1" | "SHA-1" | SignDocSignatureParameters::dha_sha1 |
- | "SHA-224" | SignDocSignatureParameters::dha_sha224 |
"SHA256" | "SHA-256" | SignDocSignatureParameters::dha_sha256 |
"SHA384" | "SHA-384" | SignDocSignatureParameters::dha_sha384 |
"SHA512" | "SHA-512" | SignDocSignatureParameters::dha_sha512 |
[out] | aOutput | The message digest algorithm (such as "SHA-1") will be stored here. If the message digest algorithm is unsupported, an empty string will be stored. |
int de::softpro::doc::SignDocVerificationResult::getDocMDP | ( | ) | [inline] |
Get the DocMDP P value of a certification signature.
The DocMDP P value specifies what modifications to the document are allowed by the certification signature.
ReturnCode de::softpro::doc::SignDocVerificationResult::getEncryptedBiometricData | ( | std::vector< unsigned char > & | aOutput ) | [inline] |
Get the encrypted biometric data of the field.
Use this function if you cannot use getBiometricData() for decrypting the biometric data (for instance, because the private key is stored in an HSM).
In the following description of the format of the encrypted data retrieved by this function, all numbers are stored in little-endian format (however, RSA uses big-endian format):
If the version number is 1, the encryption method is SignDocSignatureParameters::be_rsa with a 2048-bit key and the body has this format:
If the version number is 2, the body has this format:
If the version number is 3, the encryption method is SignDocSignatureParameters::be_rsa with a key longer than 2048 bits and the body has this format:
This function fails for document time stamps, see getMethod().
[out] | aOutput | The decrypted biometric data will be stored here. See above for the format. |
const char* de::softpro::doc::SignDocVerificationResult::getErrorMessage | ( | Encoding | aEncoding ) | const [inline] |
Get an error message for the last function call.
[in] | aEncoding | The encoding to be used for the error message. |
const wchar_t* de::softpro::doc::SignDocVerificationResult::getErrorMessageW | ( | ) | const [inline] |
Get an error message for the last function call.
SIGNDOC_VerificationResult* de::softpro::doc::SignDocVerificationResult::getImpl | ( | ) | [inline] |
Internal function.
const SIGNDOC_VerificationResult* de::softpro::doc::SignDocVerificationResult::getImpl | ( | ) | const [inline] |
Internal function.
int de::softpro::doc::SignDocVerificationResult::getLockMDP | ( | ) | [inline] |
Get the lock MDP value of the signature.
The lock MDP value specifies what modifications to the document are allowed by the signature.
ReturnCode de::softpro::doc::SignDocVerificationResult::getMethod | ( | SignDocSignatureParameters::Method & | aOutput ) | [inline] |
Get the signing method.
If the output is SignDocSignatureParameters::m_digsig_cades_rfc3161, the signature is a document time stamp. Use verifyTimeStampCertificateChain() etc. instead of verifyCertificateChain() etc. for document time stamps.
[out] | aOutput | The signing method, see SignDocSignatureParameters::Method. SignDocSignatureParameters::m_default is never returned. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getModificationState | ( | ModificationState & | aOutput ) | [inline] |
Get the modification state of a PDF document.
Use this function to find out if the modifications applied to a PDF document after adding a signature are allowed by that signature.
As there is no specification for the modifications allowed or prohibited by a signature, this function tries to mimic the behavior of Adobe Reader.
For TIFF documents, the output is computed directly from the output of getState().
[out] | aOutput | The modification state. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getSignatureBlob | ( | const std::string & | aName, |
std::vector< unsigned char > & | aOutput | ||
) | [inline] |
Get a blob property from the signature field.
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_BiometricData", and "Prop_Build", which are reserved), see SignDocSignatureParameters::setBlob().
[in] | aName | The name of the parameter. |
[out] | aOutput | The blob retrieved from the signature field. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getSignatureString | ( | Encoding | aEncoding, |
const std::string & | aName, | ||
std::string & | aOutput | ||
) | [inline] |
Get a string parameter from the signature field.
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_BiometricData", and "Prop_Build", which are reserved), see SignDocSignatureParameters::setString().
The following parameters are not available for document time stamps, see getMethod(): ContactInfo, Location, Reason, and Signer.
[in] | aEncoding | The encoding to be used for aOutput. |
[in] | aName | The name of the parameter. |
[out] | aOutput | The string retrieved from the signature field. If flag SignDocDocument::f_keep_escape_sequences is set, the string may contain escape sequences for selecting natural languages. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getState | ( | SignatureState & | aOutput ) | [inline] |
Get the signature state.
Use this function to find out if the document is still identical to the signed document, or has been updated since signed, or has been tampered with.
If the state is ss_unsupported_signature or ss_invalid_certificate, getErrorMessage() will provide additional information.
If the state is ss_document_extended, getModificationState() will provide additional information.
Use verifyCertificateChain() to find out if you can trust the identity of the signer.
If the output is ss_document_extended for a PDF document, you should call getModificationState() to get additional information.
[out] | aOutput | The signature state. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getTimeStamp | ( | std::string & | aOutput ) | [inline] |
Get the value of the RFC 3161 time stamp.
You must call verifyTimeStampCertificateChain() and getTimeStampCertificateRevocationState() to find out whether the time stamp can be trusted. If either of these functions report a problem, the time stamp should not be displayed.
A signature has either an RFC 3161 time stamp (returned by this function) or a time stamp stored as string parameter (returned by getSignatureString().
[out] | aOutput | The RFC 3161 time stamp in ISO 8601 format: "yyyy-mm-ddThh:mm:ssZ" (without milliseconds). |
ReturnCode de::softpro::doc::SignDocVerificationResult::getTimeStampCertificateRevocationState | ( | CertificateRevocationState & | aOutput ) | [inline] |
Get the revocation state of the certificate chain of the RFC 3161 time stamp.
verifyTimeStampCertificateChain() must have been called successfully.
getErrorMessage() will return an error message if this function fails (return value not rc_ok) or the verification result returned in aOutput is not crs_ok.
If vf_check_revocation was not set in integer parameter "VerificationFlags" for the most recent call to verifyTimeStampCertificateChain(), this function will return crs_not_checked in aOutput.
[out] | aOutput | The result of the certificate revocation check. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getTimeStampCertificates | ( | std::vector< std::vector< unsigned char > > & | aOutput ) | [inline] |
Get the certificates of the RFC 3161 time stamp.
[out] | aOutput | The ASN.1-encoded X.509 certificates will be stored here. If there are multiple certificates, the first one (at index 0) is the signing certificate. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getTimeStampDigestAlgorithm | ( | std::string & | aOutput ) | [inline] |
Get the message digest algorithm of the RFC 3161 time stamp.
The following table shows the supported digest algorithms and the respective value of integer parameter "TimeStampHashAlgorithm":
getTimeStampDigestAlgorithm() | TimeStampHashAlgorithm |
---|---|
"MD5" | n/a |
"RIPEMD-160" | n/a |
"SHA-1" | SignDocSignatureParameters::tsha_sha1 |
"SHA-256" | SignDocSignatureParameters::tsha_sha256 |
"SHA-384" | SignDocSignatureParameters::tsha_sha384 |
"SHA-512" | SignDocSignatureParameters::tsha_sha512 |
[out] | aOutput | The message digest algorithm (such as "SHA-1") will be stored here. If the message digest algorithm is unsupported, an empty string will be stored. |
ReturnCode de::softpro::doc::SignDocVerificationResult::getTimeStampState | ( | TimeStampState & | aOutput ) | [inline] |
Get the state of the RFC 3161 time stamp.
[out] | aOutput | The state of the RFC 3161 time stamp. |
void de::softpro::doc::SignDocVerificationResult::setImpl | ( | SIGNDOC_VerificationResult * | aP ) | [inline] |
Internal function.
ReturnCode de::softpro::doc::SignDocVerificationResult::verifyCertificateChain | ( | const SignDocVerificationParameters * | aParameters, |
CertificateChainState & | aOutput | ||
) | [inline] |
Verify the certificate chain of the signature's certificate.
getErrorMessage() will return an error message if this function fails (return value not rc_ok) or the verification result returned in aOutput is not ccs_ok.
Call getCertificateRevocationState() after this function to get the revocation state.
This function fails for document time stamps, see getMethod() and verifyTimeStampCertificateChain().
[in] | aParameters | A pointer to an object containing Verification parameters or NULL for default parameters. |
[out] | aOutput | The result of the certificate chain verification. |
ReturnCode de::softpro::doc::SignDocVerificationResult::verifyCertificateSimplified | ( | const SignDocVerificationParameters * | aParameters ) | [inline] |
Simplified verification of the certificate chain and revocation status of the signature's certificate.
This function just returns a good / not good value according to policies defined by the arguments. It does not tell the caller what exactly is wrong. However, getErrorMessage() will return an error message if this function fails. Do not attempt to base decisions on that error message, please use verifyCertificateChain() instead of this function if you need details about the failure.
This function fails for document time stamps, see getMethod() and verifyTimeStampCertificateSimplified().
[in] | aParameters | Verification parameters or NULL for default parameters. |
ReturnCode de::softpro::doc::SignDocVerificationResult::verifyTimeStampCertificateChain | ( | const SignDocVerificationParameters * | aParameters, |
CertificateChainState & | aOutput | ||
) | [inline] |
Verify the certificate chain of the RFC 3161 time stamp.
getErrorMessage() will return an error message if this function fails (return value not rc_ok) or the verification result returned in aOutput is not ccs_ok.
Call getTimeStampCertificateRevocationState() after this function to get the revocation state.
[in] | aParameters | Verification parameters or NULL for default parameters. |
[out] | aOutput | The result of the certificate chain verification. |
ReturnCode de::softpro::doc::SignDocVerificationResult::verifyTimeStampCertificateSimplified | ( | const SignDocVerificationParameters * | aParameters ) | [inline] |
Simplified verification of the certificate chain and revocation status of the RFC 3161 time stamp.
This function just returns a good / not good value according to policies defined by the verification parameters. It does not tell the caller what exactly is wrong. However, getErrorMessage() will return an error message if this function fails. Do not attempt to base decisions on that error message, please use verifyTimeStampCertificateChain() and getTimeStampCertificateRevocationState() instead of this function if you need details about the failure.
For integer parameter "CertificateChainVerificationPolicy", ccvp_accept_self_signed_with_bio and ccvp_accept_self_signed_with_rsa_bio are treated like ccvp_accept_self_signed.
[in] | aParameters | Verification parameters or NULL for default parameters. |