SignDoc SDK (C)  5.0.0
SIGNDOC_SignPKCS7 Class Reference

Interface for creating a PKCS #7 or CAdES signature. More...

#include <SignDocSDK-c.h>

Public Types

typedef SIGNDOC_Boolean(* SIGNDOC_SignPKCS7_sign) (void *aClosure, struct SIGNDOC_Source *aSource, SIGNDOC_Boolean aDetached, const char *aHashAlgorithm, struct SIGNDOC_TimeStamper *aTimeStamper, struct SIGNDOC_ByteArray *aOutput)
 Callback: Sign data, producing a PKCS #7 or CAdES signature. More...
 
typedef size_t(* SIGNDOC_SignPKCS7_getSignatureSize) (void *aClosure, SIGNDOC_Boolean aDetached, const char *aHashAlgorithm)
 Callback: Compute the size of the signature produced by SIGNDOC_SignPKCS7_sign(). More...
 
typedef SIGNDOC_Boolean(* SIGNDOC_SignPKCS7_getSubjectCommonName) (void *aClosure, char **aOutput)
 Callback: Get the common name (CN) of the certificate's subject. More...
 
typedef const char *(* SIGNDOC_SignPKCS7_getErrorMessage) (void *aClosure)
 Callback: Get an error message for the last operation. More...
 

Public Member Functions

struct SIGNDOC_SignPKCS7SIGNDOC_SignPKCS7_new (struct SIGNDOC_Exception **aEx, void *aClosure, SIGNDOC_SignPKCS7_sign aSign, SIGNDOC_SignPKCS7_getSignatureSize aGetSignatureSize, SIGNDOC_SignPKCS7_getSubjectCommonName aGetSubjectCommonName, SIGNDOC_SignPKCS7_getErrorMessage aGetErrorMessage)
 SIGNDOC_SignPKCS7 constructor. More...
 
void SIGNDOC_SignPKCS7_delete (struct SIGNDOC_SignPKCS7 *aObj)
 SIGNDOC_SignPKCS7 destructor. More...
 

Detailed Description

Interface for creating a PKCS #7 or CAdES signature.

Selection of the certificate, including intermediate certifcatse, and implementing CAdES is up to the implementation.

This interface is quite hard to use, please use SIGNDOC_SignRSA and SIGNDOC_SignECDSA instead.

Member Typedef Documentation

typedef const char*( * SIGNDOC_SignPKCS7_getErrorMessage) (void *aClosure)

Callback: Get an error message for the last operation.

After any function pointer of the SIGNDOC_SignPKCS7 object has been called, this function shall return an error message (possibly empty if the most recently called function pointer didn't fail).

Parameters
[in]aClosureA pointer to user-defined object.
Returns
A pointer to the error message. The caller assumes that the pointer may bcome invalid as soon as any function pointer of the SIGNDOC_SignPKCS7 object is called or that object is destroyed.
typedef size_t( * SIGNDOC_SignPKCS7_getSignatureSize) (void *aClosure, SIGNDOC_Boolean aDetached, const char *aHashAlgorithm)

Callback: Compute the size of the signature produced by SIGNDOC_SignPKCS7_sign().

Parameters
[in]aClosureA pointer to user-defined object.
[in]aDetachedSIGNDOC_TRUE for a detached signature, SIGNDOC_FALSE for an encapsulated signature.
[in]aHashAlgorithmHash algorithm to be used for the signature. This parameter also determines the size of encapsulated data (e.g., 20 octets for "SHA-1") if aDetached is false. You might want to ignore this value for ECDSA signatures as it might come from the DigestMethod seed value, which is to be used for RSA only. The following values are defined:
  • "MD5"
  • "RIPEMD-160"
  • "SHA-1"
  • "SHA-224"
  • "SHA-256"
  • "SHA-384"
  • "SHA-512"
Returns
A positive number which is an upper limit to the number of octets required for the ASN.1-encoded signature (excluding any RFC 3161 timestamp) zero on error.
typedef SIGNDOC_Boolean( * SIGNDOC_SignPKCS7_getSubjectCommonName) (void *aClosure, char **aOutput)

Callback: Get the common name (CN) of the certificate's subject.

Parameters
[in]aClosureA pointer to user-defined object.
[out]aOutputA pointer to the common name shall be stored here (UTF-8). The string must be allocated with SIGNDOC_alloc() or SIGNDOC_strdup() as the caller will free it with SIGNDOC_free().
Returns
SIGNDOC_TRUE if successful, SIGNDOC_FALSE on error.
typedef SIGNDOC_Boolean( * SIGNDOC_SignPKCS7_sign) (void *aClosure, struct SIGNDOC_Source *aSource, SIGNDOC_Boolean aDetached, const char *aHashAlgorithm, struct SIGNDOC_TimeStamper *aTimeStamper, struct SIGNDOC_ByteArray *aOutput)

Callback: Sign data, producing a PKCS #7 or CAdES signature.

Parameters
[in]aClosureA pointer to user-defined object.
[in]aSourceAn object providing data to be hashed and signed. If aDetached is SIGNDOC_FALSE, all the data shall be encapsulated in the PKCS #7 message.
[in]aDetachedSIGNDOC_TRUE for a detached signature, SIGNDOC_FALSE for an encapsulated signature.
[in]aHashAlgorithmHash algorithm to be used for the signature. You might want to ignore this value for ECDSA signatures as it might come from the DigestMethod seed value, which is to be used for RSA only. The following values are defined:
  • "MD5"
  • "RIPEMD-160"
  • "SHA-1"
  • "SHA-224"
  • "SHA-256"
  • "SHA-384"
  • "SHA-512"
[in]aTimeStamperNon-NULL to use a time-stamp server.
[in,out]aOutputThe ASN.1-encoded PKCS #7 or CAdES signature shall be stored here.
Returns
SIGNDOC_TRUE if successful, SIGNDOC_FALSE on error.

Member Function Documentation

void SIGNDOC_SignPKCS7_delete ( struct SIGNDOC_SignPKCS7 aObj)

SIGNDOC_SignPKCS7 destructor.

Parameters
[in]aObjA pointer to the SIGNDOC_SignPKCS7 object.
struct SIGNDOC_SignPKCS7 * SIGNDOC_SignPKCS7_new ( struct SIGNDOC_Exception **  aEx,
void *  aClosure,
SIGNDOC_SignPKCS7_sign  aSign,
SIGNDOC_SignPKCS7_getSignatureSize  aGetSignatureSize,
SIGNDOC_SignPKCS7_getSubjectCommonName  aGetSubjectCommonName,
SIGNDOC_SignPKCS7_getErrorMessage  aGetErrorMessage 
)

SIGNDOC_SignPKCS7 constructor.

Parameters
[out]aExAny exception will be returned in the object pointed to by this parameter.
[in]aClosureA pointer to user-defined object that will be passed to the callbacks.
[in]aSignPointer to function implementing sign().
[in]aGetSignatureSizePointer to function implementing getSignatureSize().
[in]aGetSubjectCommonNamePointer to function implementing getSubjectCommonName().
[in]aGetErrorMessagePointer to function implementing getErrorMessage().
Returns
A pointer to a new SIGNDOC_SignPKCS7 object.
See also
SIGNDOC_SignPKCS7_delete()

The documentation for this class was generated from the following file: