pub struct SignerInfo { /* private fields */ }
Expand description

Represents a CMS SignerInfo structure.

This is a high-level interface to the SignerInfo ASN.1 type. It supports performing common operations against that type.

Instances of this type are logically equivalent to a single signed assertion within a SignedData payload. There can be multiple signers per SignedData, which is why this type exists on its own.

Implementations

Obtain the signing X.509 certificate’s issuer name and its serial number.

The returned value can be used to locate the certificate so verification can be performed.

Obtain the message digest algorithm used by this signer.

Obtain the cryptographic signing algorithm used by this signer.

Obtain the raw bytes constituting the cryptographic signature.

This is the signature that should be verified.

Obtain the SignedAttributes attached to this instance.

Obtain the UnsignedAttributes attached to this instance.

Verifies the signature defined by this signer given a SignedData instance.

This function will perform cryptographic verification that the signature contained within this SignerInfo instance is valid for the content that was signed. The content that was signed is the encapsulated content from the SignedData instance (its .signed_data() value) combined with the SignedAttributes attached to this instance.

IMPORTANT SECURITY LIMITATIONS

This method only performs signature verification. It:

  • DOES NOT verify the digest hash embedded within SignedAttributes (if present).
  • DOES NOT validate the signing certificate in any way.
  • DOES NOT validate that the cryptography used is appropriate.
  • DOES NOT verify the time stamp token, if present.

See the crate’s documentation for more on the security implications.

Verifies the signature defined by this signer given a SignedData and signed content.

This function will perform cryptographic verification that the signature contained within this SignerInfo is valid for signed_content. Unlike Self::verify_signature_with_signed_data(), the content that was signed is passed in explicitly instead of derived from SignedData.

This method only performs cryptographic signature verification. It is therefore subject to the same limitations as Self::verify_signature_with_signed_data().

Verifies the digest stored in signed attributes matches that of content in a SignedData.

If signed attributes are present on this instance, they must contain a message-digest attribute defining the digest of data that was signed. The specification says this digested data should come from the encapsulated content within SignedData (SignedData.signed_content()).

Note that some utilities of CMS will not store a computed digest in message-digest that came from SignedData or is using the digest algorithm indicated by this SignerInfo. This is strictly in violation of the specification but it does occur.

IMPORTANT SECURITY LIMITATIONS

This method only performs message digest verification. It:

  • DOES NOT verify the signature over the signed data or anything about the signer.
  • DOES NOT validate that the digest algorithm is strong/appropriate.
  • DOES NOT compare the digests in a manner that is immune to timing side-channels.

See the crate’s documentation for more on the security implications.

Verifies the message digest stored in signed attributes using explicit encapsulated content.

Typically, the digest is computed over content stored in the SignedData instance. However, it is possible for the signed content to be external. This function allows you to define the source of that external content.

Behavior is very similar to SignerInfo::verify_message_digest_with_signed_data except the original content that was digested is explicitly passed in. This content is appended with the signed attributes data on this SignerInfo.

The security limitations from SignerInfo::verify_message_digest_with_signed_data apply to this function as well.

Obtain an entity for validating the signature described by this instance.

This will attempt to locate the certificate used by this signing info structure in the passed iterable of certificates and then construct a signature verifier that can be used to verify content integrity.

If the certificate referenced by this signing info could not be found, an error occurs.

If the signing key’s algorithm or signature algorithm aren’t supported, an error occurs.

Resolve the time-stamp token SignedData for this signer.

The time-stamp token is a SignedData ASN.1 structure embedded as an unsigned attribute. This is a convenience method to extract it and turn it into a SignedData.

Returns Ok(Some) on success, Ok(None) if there is no time-stamp token, and Err if there is a parsing error.

Verify the time-stamp token in this instance.

The time-stamp token is a SignedData ASN.1 structure embedded as an unsigned attribute. So this method reconstructs that data structure and effectively calls SignerInfo::verify_signature_with_signed_data and SignerInfo::verify_message_digest_with_signed_data.

Returns Ok(None) if there is no time-stamp token and Ok(Some(())) if there is and the token validates. Err occurs on any parse or verification error.

Obtain the raw bytes of content that was signed given a SignedData.

This joins the encapsulated content from SignedData with SignedAttributes on this instance to produce a new blob. This new blob is the message that is signed and whose signature is embedded in SignerInfo instances.

Obtain the raw bytes of content that were digested and signed.

The returned value is the message that was signed and whose signature of which needs to be verified.

The optional content argument is the encapContentInfo eContent field, typically the value of SignedData.signed_content().

Obtain the raw bytes constituting SignerInfo.signedAttrs as encoded for signatures.

Cryptographic signatures in the SignerInfo ASN.1 type are made from the digest of the EXPLICIT SET OF DER encoding of SignerInfo.signedAttrs, if signed attributes are present. This function resolves the raw bytes that are used for digest computation and later signing.

This should always be Some if the instance was constructed from an ASN.1 value that had signed attributes.

Compute a message digest using a SignedData instance.

This will obtain the encapsulated content blob from a SignedData and digest it using the algorithm configured on this instance.

The resulting digest is typically stored in the message-digest attribute of SignedData.

Compute a message digest using the configured algorithm.

This method calls into compute_digest_with_algorithm() using the digest algorithm stored in this instance.

Compute a message digest using an explicit digest algorithm.

This will compute the hash/digest of the passed in content.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more