PoDoFo 1.2.0
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
PoDoFo::PdfSignerCms Class Reference

This class computes a CMS signature according to RFC 5652. More...

#include <PdfSignerCms.h>

Inherits PoDoFo::PdfSigner.

Public Member Functions

 PdfSignerCms (const bufferview &cert, const bufferview &pkey, const PdfSignerCmsParams &parameters={ })
 Load X.509 certificate and supply a ASN.1 DER encoded private key.
 
 PdfSignerCms (const bufferview &cert, const PdfSignerCmsParams &parameters={ })
 Load a X.509 certificate without supplying a private key.
 
void ValidateSignatureDate (const nullable< PdfDate > &date) override
 Validate the signature date against the certificate validity period.
 
void AppendData (const bufferview &data) override
 
void ComputeSignature (charbuff &buffer, bool dryrun) override
 
void FetchIntermediateResult (charbuff &result) override
 
void ComputeSignatureDeferred (const bufferview &processedResult, charbuff &contents, bool dryrun) override
 
void Reset () override
 
std::string GetSignatureFilter () const override
 
std::string GetSignatureSubFilter () const override
 
std::string GetSignatureType () const override
 
bool SkipBufferClear () const override
 
void AddAttribute (const std::string_view &nid, const bufferview &attr, PdfSignatureAttributeFlags flags=PdfSignatureAttributeFlags::None)
 Add a signature attribute with given identifier from the input.
 
void SetTrustedTimestamp (const bufferview &timeStamp)
 Set the RFC 3161 timestamp of the signature as the unsigned attribute id-aa-timeStampToken (1.2.840.113549.1.9.16.2.14), replacing the existing one.
 
void ReserveAttributeSize (unsigned attrSize)
 Reserve some size in the final signature.
 
unsigned GetSignedHashSize () const
 
const PdfSignerCmsParams & GetParameters () const
 

Friends

class PdfSigningContext
 

Detailed Description

This class computes a CMS signature according to RFC 5652.

Constructor & Destructor Documentation

◆ PdfSignerCms() [1/2]

PdfSignerCms::PdfSignerCms ( const bufferview &  cert,
const bufferview &  pkey,
const PdfSignerCmsParams &  parameters = { } 
)

Load X.509 certificate and supply a ASN.1 DER encoded private key.

Parameters
certASN.1 DER encoded X.509 certificate
pkeyASN.1 DER encoded private key (PKCS#1 or PKCS#8) formats. It can be empty. In that case signing can be supplied by a signing service, or performing a deferred signing

◆ PdfSignerCms() [2/2]

PdfSignerCms::PdfSignerCms ( const bufferview &  cert,
const PdfSignerCmsParams &  parameters = { } 
)

Load a X.509 certificate without supplying a private key.

Parameters
certASN.1 DER encoded X.509 certificate
Remarks
signing can be supplied by a signing service, or performing a deferred signing

Member Function Documentation

◆ AddAttribute()

void PdfSignerCms::AddAttribute ( const std::string_view &  nid,
const bufferview &  attr,
PdfSignatureAttributeFlags  flags = PdfSignatureAttributeFlags::None 
)

Add a signature attribute with given identifier from the input.

Parameters
nidthe numerical identifier
attrthe attribute bytes. By default, the bytes are parsed for valid ASN.1 input

◆ ReserveAttributeSize()

void PdfSignerCms::ReserveAttributeSize ( unsigned  attrSize)

Reserve some size in the final signature.

It is used in dry-runs to enlarge the signature buffer

Remarks
the total reserved size is reset on Reset()

◆ SetTrustedTimestamp()

void PdfSignerCms::SetTrustedTimestamp ( const bufferview &  timeStamp)

Set the RFC 3161 timestamp of the signature as the unsigned attribute id-aa-timeStampToken (1.2.840.113549.1.9.16.2.14), replacing the existing one.

Parameters
timeStampthe DER encoded TimeStampResp or TimeStampToken, with the message imprint computed on the signed hash as described in RFC 3161 Appendix A
Remarks
Unless PdfSignerCmsFlags::SkipVerification is set, the message imprint is verified against the signed hash when the signature is computed, as the signed hash may be still unknown at this point (eg. in deferred signing). In dry runs, when a valid timestamp is not available, some space must be reserved using ReserveAttributeSize() instead

◆ ValidateSignatureDate()

void PdfSignerCms::ValidateSignatureDate ( const nullable< PdfDate > &  date)
override

Validate the signature date against the certificate validity period.

Parameters
datethe date of the signature field. A missing date makes the validation fail
Remarks
it does nothing when PdfSignerCmsFlags::SkipDateValidation is set

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