SignedDataVerifier

Verifies a CMS SignedData that carries its own content, which is the shape of an RFC 3161 timestamp token. It resolves the signer certificate from the ones the message embeds, checks the content-type and message-digest signed attributes against the encapsulated content, and verifies the signature over the DER SET OF signed attributes (RFC 5652 section 5.4).

Namespace: Com\Tecnick\Pdf\Sign\Cms

Final: Yes

File: SignedDataVerifier.php line 51

Verifies a CMS SignedData that carries its own content, which is the shape of an RFC 3161 timestamp token. It resolves the signer certificate from the ones the message embeds, checks the content-type and message-digest signed attributes against the encapsulated content, and verifies the signature over the DER SET OF signed attributes (RFC 5652 section 5.4).

eContentType sits outside the signature, so it is compared with the signed content-type attribute (RFC 5652 sections 5.3 and 11.1). An ESS signing-certificate attribute is checked when present, which binds the signature to that certificate rather than to its key alone (RFC 5035); a caller whose profile requires the attribute passes $requireSigningCertificate.

The result establishes that the message was signed by the key in the certificate it names and has not been altered since. Whether that certificate is trusted stays the host’s question.

Tags

Constants

LEGACY_DIGESTS

File: SignedDataVerifier.php line 58

public array<string, string> LEGACY_DIGESTS = ['1.3.14.3.2.26' => 'sha1']

Methods

__construct()

File: SignedDataVerifier.php line 75

public __construct([Asn1|null $asn1 = null ][, Certificate|null $certificate = null ][, SignatureVerifier|null $verifier = null ][, bool $allowSha1 = false ][, bool $requireSigningCertificate = false ]) : mixed

Parameters

  • $asn1 : Asn1|null = null
  • $certificate : Certificate|null = null
  • $verifier : SignatureVerifier|null = null
  • $allowSha1 : bool = false: Accept SHA-1 for the message-digest attribute, the ESS certificate hash, and the signature algorithm.
  • $requireSigningCertificate : bool = false: Refuse a SignerInfo that carries no ESS signing-certificate attribute. Off by default, the attribute being optional in CMS at large; the codecs reading a timestamp token turn it on, as RFC 3161 section 2.4.2 requires it there.

verify()

File: SignedDataVerifier.php line 104

public verify(string $cmsDer[, string|null $detachedContent = null ]) : string

Parameters

  • $cmsDer : string: DER-encoded CMS ContentInfo.
  • $detachedContent : string|null = null: Content a detached signature covers, which is the ByteRange-covered document bytes for the CMS Builder emits. Given one, the message must carry no eContent of its own and these octets are what the message-digest attribute is checked against. Omitted, the message has to carry its own content, which is the shape of an RFC 3161 timestamp token.

Tags

  • throws: Exception If the message is malformed, embeds no usable signer certificate, or the signature or the message digest does not check out.

Return values

string —

DER of the certificate the signature was verified against.