Technical Article

ISO/TS 32002 ECDSA and EdDSA Policy Checks in PDFium Delphi

A P-256 key can sign a SHA-512 digest and the math will not object. ECDSA truncates the hash to the leftmost 256 bits, the signature verifies, and a CMS verifier reports the signature value as intact. ISO/TS 32002, the PDF 2.0 extension that brought elliptic-curve and EdDSA signatures into PDF, does not permit that pairing, because it binds each curve to the digest widths it may carry. The same signed invoice can therefore pass a cryptographic check on one machine and fail on a validator that applies the PDF 2.0 algorithm profile, and both verdicts are correct about the question each one asked

Which curve and digest pairs ISO/TS 32002 accepts

ISO/TS 32002 accepts six ECDSA curves and two EdDSA schemes. The PDFium Component checks every PDF signature against that profile and reports the verdict in TPadesSignatureValidation.AlgorithmPolicyStatus, keyed by the curve OID in the signer certificate. The NIST curves are strict: the digest must have the same bit width as the curve, from either the SHA-2 or the SHA-3 family. The Brainpool r1 curves are looser and accept their own width or anything wider:

  • P-256 (1.2.840.10045.3.1.7): SHA-256 or SHA3-256 only
  • P-384 (1.3.132.0.34): SHA-384 or SHA3-384 only
  • P-521 (1.3.132.0.35): SHA-512 or SHA3-512 only
  • brainpoolP256r1 (1.3.36.3.3.2.8.1.1.7): any SHA-2 or SHA-3 digest from 256 to 512 bits
  • brainpoolP384r1 (1.3.36.3.3.2.8.1.1.11): 384- or 512-bit SHA-2 / SHA-3
  • brainpoolP512r1 (1.3.36.3.3.2.8.1.1.13): SHA-512 or SHA3-512 only
Matrix of the ISO TS 32002 algorithm profile in PDFium Component: P-256, P-384 and P-521 accept only matching digest widths, brainpoolP256r1 accepts 256 to 512 bits, brainpoolP384r1 accepts 384 and 512, Ed25519 and Ed448 declare SHA-512 and SHAKE256 with length 512, and mismatches raise ppeiSignatureAlgorithmMismatch while outside-profile curves return pcsUnsupported
Six ECDSA curves and two EdDSA schemes can pass, and each curve is tied to the digest widths it may carry; everything else is invalid or unsupported, never silently accepted

The asymmetry catches signing tools that pick one digest and reuse it for every key. SHA-512 everywhere looks like the cautious choice, and on brainpoolP256r1 it is accepted. On P-256 the identical configuration produces pcsInvalid: the curve is in the profile, the digest is strong, and the pairing is still outside the table. A key on a curve the profile never names, such as brainpoolP160r1 (1.3.36.3.3.2.8.1.1.1) or secp256k1 (1.3.132.0.10), lands in a different bucket. As long as its declared digest and signature algorithm agree, it gets pcsUnsupported

EdDSA leaves no choices, only encoding rules

Ed25519 and Ed448 have no curve parameter and no digest option, so every rule the PDFium Component applies to them concerns how the CMS declares the algorithm. RFC 8419 fixes the digest. An Ed25519 SignerInfo declares SHA-512 (2.16.840.1.101.3.4.2.3) as its digestAlgorithm with the parameters field absent. An Ed448 SignerInfo that carries signed attributes, which every PAdES signature does, declares id-shake256-len (2.16.840.1.101.3.4.2.18) with an INTEGER parameter of exactly 512. RFC 8410 adds that the signature AlgorithmIdentifier (1.3.101.112 for Ed25519, 1.3.101.113 for Ed448) and the certificate public key AlgorithmIdentifier carry no parameters at all

Many ASN.1 encoders append an explicit NULL to every algorithm OID because RSA identifiers have always had one, and the habit survives when someone bolts Ed25519 onto an existing signing path. The key is fine. The signature value is fine. The encoding is not, and the PDFium Component returns pcsInvalid when a parameters field is present on either identifier, when the Ed25519 digest is anything other than parameter-free SHA-512, or when the Ed448 digest is not id-shake256-len with 512. A certificate whose key OID belongs to the other EdDSA scheme, or to some other algorithm, also yields pcsInvalid

Reading the algorithm triple out of the CMS

The PDFium engine reads the signature dictionary, but its public API neither verifies the CMS nor exposes the curve of the signer certificate. The PAdES inspection layer built on PDFium therefore parses the CMS SignedData (RFC 5652) on its own. InspectPadesSignatureAlgorithm reads the digestAlgorithm and signatureAlgorithm of the first SignerInfo, locates the signer certificate in the certificates set, and reads the key algorithm and curve from its SubjectPublicKeyInfo. Digest, signature algorithm, key plus curve: those three values are what the policy judges

A CMS certificate set is unordered and usually holds the signer certificate next to its issuing CA, and both can be EC keys on different curves, so taking the first EC certificate would let the CA decide which curve the signer supposedly used. The PDFium Component matches the issuer and serial number from issuerAndSerialNumber byte for byte, examines at most 64 certificates, and falls back to "the only certificate there is" only when the set holds exactly one parseable certificate. Any other outcome leaves the key fields of the record empty

How the PDFium Component inspects a PDF signature algorithm triple: InspectPadesSignatureAlgorithm reads the digestAlgorithm and signatureAlgorithm of the first SignerInfo in the CMS, pins the signer certificate through an exact issuerAndSerialNumber match among at most 64 candidates, reads the SubjectPublicKeyInfo for the curve, and EvaluatePadesSignatureAlgorithm returns the AlgorithmPolicyStatus
PDFium itself neither verifies the CMS nor exposes the signer curve, so the PAdES layer parses the SignedData and keeps every raw OID in the record for an explainable rejection

TPdf.ValidatePades runs the policy during its compliance pass, first against the certificate found inside the CMS. It then verifies the signature with the CMS verifier for the platform: Windows CryptoAPI by default on Windows, or an OpenSSL or macOS Keychain verifier registered through ConfigureSslCmsVerifier or ConfigureKeychainCmsVerifier. When the verifier reports which certificate it actually used, the policy runs again on that certificate and its result replaces the first one. TPdf.ValidatePadesTrust in the Enterprise edition follows the same order while also building the chain and, on request, checking revocation. The raw inputs end up in TPadesSignatureAlgorithmInfo, which this listing prints for every signature in a file:

uses
  PDFium, FPdfPades;

const
  StatusNames: array[TPadesCryptoStatus] of string =
    ('not checked', 'valid', 'invalid', 'unsupported', 'indeterminate');

var
  Pdf: TPdf;
  R: TPadesValidationResult;
  A: TPadesSignatureAlgorithmInfo;
  I: Integer;
begin
  Pdf := TPdf.Create(nil);
  try
    Pdf.FileName := 'invoice-ecdsa-signed.pdf';
    Pdf.Active := True;
    R := Pdf.ValidatePades;
    for I := 0 to Length(R.Signatures) - 1 do
    begin
      A := R.Signatures[I].AlgorithmInfo;
      Writeln('Signature ', I);
      Writeln('  digestAlgorithm    : ', string(A.DigestAlgorithmOid),
        '  params=', A.DigestParametersPresent, ' bits=', A.DigestParameterBits);
      Writeln('  signatureAlgorithm : ', string(A.SignatureAlgorithmOid),
        '  params=', A.SignatureParametersPresent);
      Writeln('  public key / curve : ', string(A.PublicKeyAlgorithmOid),
        ' / ', string(A.CurveOid),
        '  namedCurve=', A.PublicKeyParametersAreNamedCurve);
      Writeln('  policy             : ',
        StatusNames[R.Signatures[I].AlgorithmPolicyStatus]);
    end;
    if ppeiSignatureAlgorithmMismatch in R.Issues then
      Writeln('At least one signature violates the ISO/TS 32002 profile');
  finally
    Pdf.Free;
  end;
end;

Those flags usually explain a rejection before anyone opens an ASN.1 dump. DigestParameterBits shows the Ed448 length, SignatureParametersPresent exposes the stray NULL, and PublicKeyParametersAreNamedCurve covers the curve encoding discussed in the next section. An empty PublicKeyAlgorithmOid means the signer certificate was never pinned down

Why does a P-256 signature with SHA3-256 fail the policy?

A P-256 signature with SHA3-256 fails whenever the CMS digestAlgorithm says SHA3-256 while the signatureAlgorithm says ecdsa-with-SHA256. Each half is acceptable for P-256 on its own; together they disagree about which hash was signed. EvaluatePadesSignatureAlgorithm maps each ECDSA signature OID, from ecdsa-with-SHA256 through ecdsa-with-SHA3-512, to the digest it implies, compares that with the declared digestAlgorithm, and returns pcsInvalid on any difference before it looks at the curve table. A signing tool that moves its hash to SHA3-256 but keeps a hard-coded signature identifier produces exactly this file, and a conforming verifier has no consistent way to read it

EvaluatePadesSignatureAlgorithm is public and takes a plain record, so the matrix can be pinned in a unit test without building a PDF. The Assert calls below are your own test checks:

var
  Info: TPadesSignatureAlgorithmInfo;
begin
  Info := Default(TPadesSignatureAlgorithmInfo);
  Info.Family := psafEcdsa;
  Info.PublicKeyAlgorithmOid := '1.2.840.10045.2.1';       // id-ecPublicKey
  Info.PublicKeyParametersPresent := True;
  Info.PublicKeyParametersAreNamedCurve := True;
  Info.CurveOid := '1.2.840.10045.3.1.7';                  // P-256
  Info.DigestAlgorithmOid := '2.16.840.1.101.3.4.2.8';     // SHA3-256
  Info.SignatureAlgorithmOid := '2.16.840.1.101.3.4.3.10'; // ecdsa-with-SHA3-256
  Assert(EvaluatePadesSignatureAlgorithm(Info) = pcsValid);

  Info.SignatureAlgorithmOid := '1.2.840.10045.4.3.2';     // ecdsa-with-SHA256
  Assert(EvaluatePadesSignatureAlgorithm(Info) = pcsInvalid);  // digest mismatch

  Info.DigestAlgorithmOid := '2.16.840.1.101.3.4.2.3';     // SHA-512
  Info.SignatureAlgorithmOid := '1.2.840.10045.4.3.4';     // ecdsa-with-SHA512
  Assert(EvaluatePadesSignatureAlgorithm(Info) = pcsInvalid);  // congruent, but not for P-256

  Info.CurveOid := '1.3.36.3.3.2.8.1.1.1';                 // brainpoolP160r1
  Assert(EvaluatePadesSignatureAlgorithm(Info) = pcsUnsupported); // curve outside the profile

  Info.CurveOid := '1.2.840.10045.3.1.7';
  Info.PublicKeyParametersAreNamedCurve := False;          // explicit curve parameters
  Assert(EvaluatePadesSignatureAlgorithm(Info) = pcsInvalid);

  Info.PublicKeyAlgorithmOid := '';                        // signer certificate not found
  Assert(EvaluatePadesSignatureAlgorithm(Info) = pcsIndeterminate);
end;

The fifth case is about how the certificate encodes its curve. RFC 5480 §2.1.1 lets ECParameters be a named curve OID, an implicit curve (NULL) or a full explicit parameter set, and the same section restricts PKIX certificates to the named form. The PDFium Component returns pcsInvalid for an id-ecPublicKey certificate with missing, implicit or explicit parameters. Explicit parameters spell out the prime, coefficients and base point, which lets an attacker describe a curve that merely resembles a standard one, and a checker that accepted them would have to prove the numbers match a named curve before trusting anything else

Invalid, unsupported and indeterminate are three different answers

The three non-valid values of AlgorithmPolicyStatus carry different meanings, and collapsing them into one "failed" bucket throws away the information an auditor needs. pcsInvalid means a recognised algorithm combination is malformed or mismatched. It adds ppeiSignatureAlgorithmMismatch to TPadesValidationResult.Issues and drives the aggregate IntegrityStatus to pcsInvalid, so IsCryptographicallyValid returns False even when the CMS signature value checks out

pcsUnsupported means the curve or digest is outside what the profile names. That is a capability result, and it leaves IntegrityStatus alone. pcsIndeterminate means the PDFium Component refused to guess: the signer certificate could not be pinned, typically a certificate set with several candidates and no exact issuerAndSerialNumber match, or the SignerInfo could not be parsed far enough to read its algorithms. On the RSA side the same value marks a digest that current suites no longer accept for new validations, covered in the last section

EdDSA shows why the policy status and the cryptographic status live in separate fields. On a system whose CMS verifier cannot check Ed25519 or Ed448, CmsSignatureStatus comes back pcsUnsupported while AlgorithmPolicyStatus can still be pcsValid, computed from the certificate found in the CMS. The encoding was correct; only the verifier was missing. Merging the two would force a choice between calling a well-formed signature broken and calling an unchecked one good

Decision path of EvaluatePadesSignatureAlgorithm in PDFium Component: a digest mismatch sets pcsInvalid and ppeiSignatureAlgorithmMismatch, a named curve outside the ISO TS 32002 profile such as brainpoolP160r1 sets pcsUnsupported, a signer certificate that cannot be pinned sets pcsIndeterminate, and the RSA branch applies the ETSI TS 119 312 digest suites, with the key size still left to the application
The three non-valid statuses mean different things: invalid is proof of a broken combination, unsupported is a capability result, and indeterminate means the code refused to guess

For an intake pipeline, reject automatically on pcsInvalid and nothing else. Treating pcsUnsupported as a rejection turns a curve your policy never listed into an accusation of tampering, and the sender has no way to fix what was never broken. Send unsupported and indeterminate results to a person, with the OIDs from AlgorithmInfo attached:

var
  Pdf: TPdf;
  Options: TPadesTrustValidationOptions;
  R: TPadesValidationResult;
  S: TPadesSignatureValidation;
  I: Integer;
begin
  Pdf := TPdf.Create(nil);
  try
    Pdf.FileName := 'invoice-ecdsa-signed.pdf';
    Pdf.Active := True;
    Options := TPadesTrustValidationOptions.Default; // offline, no revocation
    R := Pdf.ValidatePadesTrust(Options);
    for I := 0 to Length(R.Signatures) - 1 do
    begin
      S := R.Signatures[I];
      if S.IsDocumentTimeStamp then
        Continue;
      case S.AlgorithmPolicyStatus of
        pcsInvalid:       Writeln(I, ': reject, algorithm combination is invalid');
        pcsUnsupported:   Writeln(I, ': manual review, algorithm outside the profile: ',
                            string(S.AlgorithmInfo.SignatureAlgorithmOid), ' / ',
                            string(S.AlgorithmInfo.CurveOid));
        pcsIndeterminate: Writeln(I, ': manual review, signer not identified or digest no longer accepted');
        pcsValid:
          if S.AlgorithmInfo.Family = psafRsa then
            Writeln(I, ': RSA digest suite accepted, check key size yourself')
          else
            Writeln(I, ': EC/EdDSA profile satisfied');
      end;
      if (S.CmsSignatureStatus = pcsUnsupported) and
         (S.AlgorithmPolicyStatus = pcsValid) then
        Writeln(I, ': encoding conforms, but no verifier here can check this algorithm');
    end;
    Writeln('Cryptographically valid: ', R.IsCryptographicallyValid);
  finally
    Pdf.Free;
  end;
end;

If the rejection comes from Adobe Acrobat or a DSS-based validator rather than from this check, the guide to why validators reject PAdES signatures walks through the other common causes, from ByteRange gaps to a malformed /M signing time

What does pcsValid leave to you?

AlgorithmPolicyStatus = pcsValid certifies the algorithm profile and nothing more: an approved curve with a congruent, correctly encoded digest for ECDSA and EdDSA, or a digest from a current suite for RSA. For RSA signatures EvaluatePadesSignatureAlgorithm applies the ETSI TS 119 312 suites. MD2, MD4 and MD5 are pcsInvalid. SHA-1 and the 112-bit digests (SHA-224, SHA-512/224, SHA3-224) are pcsIndeterminate, the outcome EN 319 102-1 uses when an algorithm is no longer considered reliable and no proof of earlier existence was evaluated, so a SHA-1 signature keeps its integrity result and goes to review. A digestAlgorithm that differs from the digest fixed by the signature OID, such as sha256WithRSAEncryption over a SHA-1 digest, is pcsInvalid, and so is an RSA signature algorithm on a non-RSA signer key. A missing signer certificate gives pcsIndeterminate, and unknown digests or non-signature OIDs from the PKCS #1 arc give pcsUnsupported

RSASSA-PSS signatures get a parameter check on top: the PSS parameters must be present and well formed, their hash must equal the declared digestAlgorithm, the trailer field must be 1, and a PSS-restricted certificate key must agree with them. The RFC 4055 RSASSA-PSS-params article covers how those parameters are encoded on the signing side. Modulus length is outside the policy, so an application that wants a 3072-bit floor enforces it itself. SHA-1 or MD5 in the digestAlgorithm also raises the separate ppeiBadDigestAlgorithm issue. When the signed attributes carry the RFC 6211 cms-algorithm-protection attribute, its two identifiers are compared with the SignerInfo values byte for byte, and a difference raises ppeiCmsAlgorithmProtectionMismatch and fails integrity; VerifyCmsAlgorithmProtection runs that comparison on a raw CMS blob

The signature math, the certificate chain and revocation stay with CmsSignatureStatus, CertificateTrustStatus and RevocationStatus, which come from the CMS verifier. Read pcsValid as "the algorithm profile holds" and never as "this key is strong enough". For a Delphi application that accepts signed invoices, contracts or archive packages, the whole setup fits in a few lines: run ValidatePadesTrust, reject on ppeiSignatureAlgorithmMismatch, route pcsUnsupported and pcsIndeterminate to a reviewer, and apply your own RSA key-size floor

The same library that runs these checks also produces PAdES signatures, so a team can sign with P-384 or Ed25519 and confirm that its own output satisfies the ISO/TS 32002 profile before it ever reaches a customer. Editions, platform support and the signing pipeline are described on the PDFium Component for Delphi and Lazarus product page