Signatures
The PKI SDK allows customization and creation of PDF signatures in the PAdES standard (ETSI TS 102 778), signatures PKCS#7/CMS in the standard CADES (ETSI TS 101 733) and simple signatures XmlDSig and also as standard XADES (ETSI TS 101 903).
In the example below we will make a basic CAdES siganture in order to present and exercise the concepts and properties of this subscriber:
// We instantiate the signer object that is responsible for creating the signature
var signer = new CadesSigner();
// We set the main parameters
signer.SetSigningCertificate(signingCert); // signer certificate with associated private key
signer.SetDataToSign(toSign); // bytes or stream of the document to be signed
signer.SetPolicy(policy); // sigantures policy
signer.ComputeSignature(); // creates attributes and reaps signature from signatory
var cadesSig = signer.GetSignature(); // assembles the signature package and returns the bytes with DER encoding
In the example below we will make a basic PAdES signature in order to present and exercise the concepts and properties of this subscriber:
// We instantiate the signer object that is responsible for creating the signature
var signer = new PadesSigner();
// We set the main parameters
signer.SetSigningCertificate(signingCert); // signer certificate with associated private key
signer.SetPdfToSign(pdfBytes); // PDF bytes to be signed
signer.SetPolicy(policy); // signatures policy
signer.ComputeSignature(); // creates reaps signature of signatory
var signedPdf = signer.GetPdfBytes(); // returns the bytes of the signed PDF