inherits from Exception
(no public members)
tPdfSignatureInfo - what ExtractPdfSignature(s) reports about one signature of a signed document; used by verification and the tests.
fByteRange: array [0..3] of Int64;
fContents: OctetString;
fSubFilter: string;
fFieldName: OctetString;
fSignedBytes: OctetString;
fCoversWholeFile: Boolean;
fGapIsContentsString: Boolean;
fDocMDPLevel: Integer;
tPdfValidationMaterial - the certificates and revocation data that a PAdES B-LT document embeds so the signature stays verifiable after the signer certificate expires or its responder disappears. Every entry is a raw DER blob: a Certificate, an OCSPResponse, or a CertificateList (CRL). Fill it with PdfAddCert / PdfAddOcsp / PdfAddCrl.
fCerts: array of OctetString;
fOcsps: array of OctetString;
fCrls: array of OctetString;
inherits from TComponent
TstPdfSigner
Drop-in signing component (the TstMPSignedData branch of the library). Assign KeysAndCerts, then call SignData/SignFile with the signer certificate (which must be resolvable to a private key by the manager, exactly as for TstMPSignedData.SignData). On True the destination holds the signed document; on False LastError says why.
constructor Create(aOwner: TComponent); override;
function SignData(aCert: iCertificate; aSource, aDest: TStream): Boolean;
function SignFile(aCert: iCertificate; const aSourceFile, aDestFile: string): Boolean;
property LastError: string read fLastError;
property KeysAndCerts: TstCertificateManager read fKeysAndCerts write SetKeysAndCerts;
property ContentDigestAlg: tHashAlgorithm read fContentDigestAlg write fContentDigestAlg default haSHA256;
property ContentsSize: Integer read fContentsSize write fContentsSize default 16384;
property SubFilter: tPdfSubFilter read fSubFilter write fSubFilter default psfAdbePkcs7Detached;
property FieldName: string read fFieldName write fFieldName;
property Reason: string read fReason write fReason;
property Location: string read fLocation write fLocation;
property ContactInfo: string read fContactInfo write fContactInfo;
property TimeStampURL: string read fTimeStampURL write fTimeStampURL;
property VisibleLeft: Double read fVisibleLeft write fVisibleLeft;
property VisibleBottom: Double read fVisibleBottom write fVisibleBottom;
property VisibleRight: Double read fVisibleRight write fVisibleRight;
property VisibleTop: Double read fVisibleTop write fVisibleTop;
property VisibleText: string read fVisibleText write fVisibleText;
function ExtendToLT(aSource, aDest: TStream; const aMaterial: tPdfValidationMaterial): Boolean;
function ExtendToLTFile(const aSourceFile, aDestFile: string; const aMaterial: tPdfValidationMaterial): Boolean;
function AddDocumentTimestamp(aSource, aDest: TStream): Boolean;
function AddDocumentTimestampFile(const aSourceFile, aDestFile: string): Boolean;
function ExtendToLTA(aSource, aDest: TStream; const aMaterial: tPdfValidationMaterial): Boolean;
function ExtendToLTAFile(const aSourceFile, aDestFile: string; const aMaterial: tPdfValidationMaterial): Boolean;
property Certify: Boolean read fCertify write fCertify default False;
property CertifyLevel: Integer read fCertifyLevel write fCertifyLevel default 2;
property ExtKeyUsagePolicy: tExtKeyUsagePolicy read fExtKeyUsagePolicy write fExtKeyUsagePolicy default ekupIgnore;
inherits from TComponent
TstPdfVerifier
Basic verification counterpart of TstPdfSigner: locates the first signature, checks the ByteRange geometry (including detection of content appended AFTER signing - the incremental-update surface every PDF validator must report), and verifies the detached CMS over the signed spans through TstCustomMPSignedData with the assigned KeysAndCerts (the manager's configuration decides trust, exactly as for CMS verification; an embedded RFC 3161 signature time-stamp is verified along the way and surfaced through LastTimeStampTime). Deeper PAdES policy - DocMDP, permitted-change analysis of post-signing updates, LTV - is later work.
Certificates embedded in the signature are imported automatically by the CMS layer, but the key manager only STORES a certificate that chains correctly under its filters and indexes, and that requires a trust anchor of the chain to be present in the manager's root store (plus a storage willing to accept it). So configure KeysAndCerts with the trusted root(s) before verifying; a signature whose chain has no anchor there is reported pssInvalid with "signer certificate could not be resolved/trusted", not silently accepted.
function VerifyData(aSource: TStream): tPdfSignatureStatus;
function VerifyFile(const aFile: string): tPdfSignatureStatus;
property LastError: string read fLastError;
property LastInfo: tPdfSignatureInfo read fLastInfo;
property SignatureCount: Integer read get_SignatureCount;
property Signatures[aIndex: Integer]: tPdfSignatureInfo read get_Signatures;
property StatusOf[aIndex: Integer]: tPdfSignatureStatus read get_StatusOf;
property ModificationOf[aIndex: Integer]: tPdfModificationClass read get_ModificationOf;
property ErrorOf[aIndex: Integer]: string read get_ErrorOf;
property LastModificationClass: tPdfModificationClass read get_LastModificationClass;
property LastTimeStampTime: TDateTime read fLastTimeStampTime;
property LastTimeStampError: string read fLastTimeStampError;
property KeysAndCerts: TstCertificateManager read fKeysAndCerts write SetKeysAndCerts;
property ExtKeyUsagePolicy: tExtKeyUsagePolicy read fExtKeyUsagePolicy write fExtKeyUsagePolicy default ekupIgnore;
property OnKeyUsageRejected: tPdfKeyUsageEvent read fOnKeyUsageRejected write fOnKeyUsageRejected;
tPdfSubFilter - the signature encoding named in /SubFilter.
tPdfModificationClass - what an incremental update appended AFTER a signature actually did. PDF permits appending (that is how a second signature is added), so "modified" alone is not a verdict; what matters is WHICH objects the later revision superseded.
tPdfSignatureStatus - the verdict of TstPdfVerifier.
tPdfKeyUsageEvent - last word on a signer certificate that the verifier's ExtKeyUsagePolicy has REJECTED. It is raised only on that path, so an unassigned handler can never weaken the policy, and the accepting path costs nothing. Set aAccept True to overrule the rejection - the place to honour, say, a legacy CA that marks document signing with its own OID.