Skip to content
DemoSampleAPI ReferenceFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

Algorithms and Certificate Formats ​

This guide applies to version 3.2.1 of the native ComPDF SDK for iOS, which requires iOS 15 or later. Choose your workflow based on who holds the private key and what the signer returns:

  • Your app has the private key: Use local PKCS#12 signing with a .p12 or .pfx file and its password.
  • An external service holds the private key: Use two-step signing. With CPDFDeferredSignSession, prepare the PDF, pass the prepared digest to the signer, and fill the result into the same prepared PDF. Pass a raw signature value as signatureValue for the SDK to build the CMS container, or pass a complete detached CMS container as containerDER to embed it. Use DocumentDigest mode for the complete-container path. SignedAttributes mode requires the raw-signature path.

Signature Algorithms ​

Signature algorithmLocal PKCS#12 signingTwo-step: raw signature valueTwo-step: complete CMSTest certificate generation
RSA-PKCS#1 v1.5SupportedSupportedEmbed the signer's detached CMSRSA-2048
ECDSA P-256 with SHA-256 (SHA256WithECDSA)Confirmed in the core library; not confirmed with the iOS 3.2.1 release packageConfirmed in the core library; pass a DER signature value. Not confirmed with the iOS 3.2.1 release packageEmbed the signer's detached CMS; iOS 3.2.1 release-package verification is unconfirmedNot available for ECC
RSA-PSSNot supportedNot supportedContainer embedding is not RSA-PSS support; verification is unconfirmedNot available

ECDSA P-256: For local signing, supply a PKCS#12 file with the P-256 certificate and matching private key. For raw-signature fill, the iOS API contract requires an ASN.1 DER-encoded SEQUENCE { r, s }, not the fixed-width r‖s format (IEEE P1363). This DER encoding is for the signature value, not the certificate or the CMS container. The core-library confirmation is for P-256 with SHA-256; it does not establish support for other ECDSA curves or digest combinations.

RSA-PSS: Do not select RSA-PSS for local signing or two-step raw-signature assembly. An RSA-PSS enum in the external signing API, or successful embedding of a CMS container, does not establish that iOS can create or verify an RSA-PSS signature.

Test certificates: CPDFSignature.generatePKCS12Cert generates an RSA-2048 PKCS#12 test identity. It cannot generate an ECC test identity. See Create Digital Certificates.

Digest Algorithms ​

The digest algorithm hashes the input; the signature algorithm uses a private key to sign. For two-step signing, use the digest algorithm selected during preparation for the signature value or detached CMS returned by the signer. hashToSign is already a binary digest; do not hash it again.

Digest algorithmLocal PKCS#12 signingTwo-step preparation and fillRFC 3161 timestamp request
SHA-256SupportedSupported (default)Supported (default)
SHA-384Not supportedSupportedSupported
SHA-512Not supportedSupportedSupported

The two-step column describes digest selection for the raw-signature and complete-container paths, not every combination of digest, signature algorithm, and key type. The timestamp column describes the message imprint sent via CPDFTimestampService and CPDFTimestampOptions.digestAlgorithm, not the algorithm the TSA uses to sign its response, nor the digest of a local PKCS#12 signature. See Timestamped Signatures.

Certificate and Signature Inputs ​

InputWhere to use it
PKCS#12 (.p12, .pfx)Local signing: pass the file containing the signing certificate and its private key, plus the password.
A single DER-encoded X.509 certificateTwo-step raw-signature fill: use signerCertificateDER. Supply it during preparation in SignedAttributes mode; in DocumentDigest mode, you can supply it at fill time if it was not provided during preparation.
X.509 certificate chain in DERFor raw-signature assembly, pass certificateChainDER as a list with one DER certificate per entry. Convert PEM certificates to binary DER for both DER properties. An embedded chain helps build a chain but does not make it trusted.
Detached CMS/PKCS#7 in DERFor complete-container fill, pass the DER SignedData container in containerDER. The signer supplies the CMS signature and relevant certificates. Do not pass a bare certificate, a PKCS#12 identity, or a raw signature here.
Raw signature valueFor raw-signature fill, pass signatureValue: a modulus-sized byte block for RSA-PKCS#1 v1.5 or a DER SEQUENCE { r, s } for ECDSA. Provide certificates separately.
Trust anchors for validationFor the structured validation report, set CPDFSignatureValidationOptions.trustedCertificatePath to a PEM bundle or an OpenSSL-style hashed certificate directory. When building a chain separately, CPDFCertificateStore accepts DER bytes via addTrustedCertificateDER: or a PEM/DER certificate file via addTrustedCertificateFileAtPath:. These inputs do not contain a signing private key.

Verification and Test Coverage ​

Always verify the output PDF after signing or embedding a container. Check signature integrity and signed-content coverage separately from certificate-chain trust. A successful fill, even one that checks the CMS messageDigest attribute, is not a substitute for signature verification.

An earlier iOS simulator smoke test covered RSA-PKCS#1 v1.5 two-step signing and reopening the PDF to verify it: SHA-256 raw-signature and complete-container paths, and SHA-384/SHA-512 raw-signature paths. This was not a test of the iOS 3.2.1 release package and does not establish certificate-chain trust. ECDSA P-256 support above is based on core-library confirmation and the iOS API contract, not an iOS end-to-end test. The timestamp digest options are exposed by the SDK; a TSA round trip has not been confirmed with the iOS 3.2.1 release package. Do not assume verification support for ECDSA, RSA-PSS, or arbitrary third-party CMS containers from the signing matrix.