TPDFNativeSigningIdentity
security and signatures
Description
TPDFNativeSigningIdentity owns one loaded signing identity and produces CMS signatures through the native provider. Open it from a PKCS #12 blob with OpenPKCS12, or adopt a PKCS #11 token with OpenPKCS11; the instance then signs detached, attached or CAdES CMS blobs and, for token identities, OCSP requests.
Signing methods take and return byte strings and never touch a PDF document, so one open instance can serve several signatures. The type is available only on non-Windows Free Pascal targets: on Windows the constructor raises ENotSupportedException.
Syntax
Delphi
TPDFNativeSigningIdentity = class
Public
constructor Create(const LibraryName: AnsiString = '');
destructor Destroy; override;
function OpenPKCS12(const Data, Password: AnsiString;
out ErrorText: WideString): Boolean;
function OpenPKCS11(Client: TPDFlibExternalSigningKey;
const Chain: array of AnsiString; out ErrorText: WideString): Boolean;
function SignDetached(const Data: AnsiString; DigestAlgorithm: Integer;
CAdES: Boolean; out Signature: AnsiString;
out ErrorText: WideString): Boolean;
function SignDetachedEx(const Data: AnsiString; DigestAlgorithm: Integer;
CAdES: Boolean;
const CommitmentTypeDER, SignaturePolicyDER, RevocationInfoDER: AnsiString;
out Signature: AnsiString; out ErrorText: WideString): Boolean;
function SignAttached(const Data: AnsiString; DigestAlgorithm: Integer;
out Signature: AnsiString; out ErrorText: WideString): Boolean;
function SignOCSPRequest(const RequestDER: AnsiString;
out SignedRequest: AnsiString; out ErrorText: WideString): Boolean;
property CertificateDER: AnsiString read FCertificateDER;
property RSAPSSPadding: Boolean read FRSAPSSPadding write FRSAPSSPadding;
end;Fields
| Create | Creates the identity and loads the OpenSSL 3 signing library; LibraryName optionally overrides the library name or path, and a library that cannot be loaded raises ENotSupportedException |
|---|---|
| OpenPKCS12 | Opens one PFX blob with its password; empty or oversized data, an embedded NUL in the password, trailing bytes and a key that does not match the certificate are rejected |
| OpenPKCS11 | Adopts an RSA, ECDSA or EdDSA token identity from a client; the client is referenced, not owned, and the complete certificate plus chain must stay under 64 KiB with fewer than 1024 chain entries |
| SignDetached | Produces a detached CMS signature; CAdES selects the PAdES baseline attribute set, which drops the signing-time attribute |
| SignDetachedEx | Detached CMS signature plus optional commitment type, signature policy and revocation info signed attributes |
| SignAttached | Attached CMS signature that carries the signed data; no CAdES attributes are added |
| SignOCSPRequest | Signs one complete unsigned OCSP request and returns the signed request together with the identity certificates |
| CertificateDER | DER bytes of the open certificate; empty until an identity is opened |
| RSAPSSPadding | Forces RSASSA-PSS instead of PKCS #1 v1.5; requires a detached profile and an RSA key, and is implied for RSA-PSS keys |
Remarks
Digest selectors follow TPDFlibDigestAlgorithm: 0 auto, 1 SHA-1, 2 SHA-256, 3 SHA-384, 4 SHA-512 and 5 to 7 for SHA-3. The native signer resolves 0 to SHA-256 and rejects selector 8 (daSM3) as unsupported.
Custom signed attributes must each be one complete bounded DER sequence and together at most 16 MiB. Commitment type and signature policy apply to detached CAdES signatures, revocation info to detached non-CAdES; any other combination fails before the provider is called.
RSA-PSS requires a detached signature and an RSA key, and is selected automatically for an RSA-PSS key even when RSAPSSPadding is False.
Size bounds are 16 MiB for a PKCS #12 blob, 256 MiB for signed data, and 64 KiB for an OCSP request or the signed request produced from it.
OpenPKCS12 releases the current identity before parsing, so a failed open leaves the instance empty; OpenPKCS11 swaps the identity only after all of its checks pass. Destroy releases whatever is still open.
See also
OpenPKCS12, OpenPKCS11, TPDFlibExternalSigningKey, TPDFlibPKCS11Client, NativeOCSPSignedRequests, SignDetached, SignDetachedEx