Struct cms::builder::SignerInfoBuilder
source · pub struct SignerInfoBuilder<'s, S> { /* private fields */ }
builder
only.Expand description
Collect info needed for creating a SignerInfo
.
Calling build()
on this struct will
- calculate the correct
CMSVersion
(depends onsid
) - calculate the signature
- set the signing time attribute
- create a
SignerInfo
object
Implementations§
source§impl<'s, S> SignerInfoBuilder<'s, S>where
S: Keypair + DynSignatureAlgorithmIdentifier,
impl<'s, S> SignerInfoBuilder<'s, S>where
S: Keypair + DynSignatureAlgorithmIdentifier,
sourcepub fn new(
signer: &'s S,
sid: SignerIdentifier,
digest_algorithm: AlgorithmIdentifierOwned,
encapsulated_content_info: &'s EncapsulatedContentInfo,
external_message_digest: Option<&'s [u8]>
) -> Result<Self, Error>
pub fn new( signer: &'s S, sid: SignerIdentifier, digest_algorithm: AlgorithmIdentifierOwned, encapsulated_content_info: &'s EncapsulatedContentInfo, external_message_digest: Option<&'s [u8]> ) -> Result<Self, Error>
Create a new SignerInfoBuilder
. This is used for adding SignerInfo
s to SignedData
structures.
The content to be signed can be stored externally. In this case eContent
in
encapsulated_content_info
must be None
and the message digest must be passed with
external_message_digest
. digest_algorithm
must match the used digest algorithm.
sourcepub fn add_signed_attribute(
&mut self,
signed_attribute: Attribute
) -> Result<&mut Self, Error>
pub fn add_signed_attribute( &mut self, signed_attribute: Attribute ) -> Result<&mut Self, Error>
Add a “signed” attribute. The attribute will be signed together with the other “signed”
attributes, when build()
is called.
sourcepub fn add_unsigned_attribute(
&mut self,
unsigned_attribute: Attribute
) -> Result<&mut Self, Error>
pub fn add_unsigned_attribute( &mut self, unsigned_attribute: Attribute ) -> Result<&mut Self, Error>
Add an unsigned attribute.
sourcepub fn version(&self) -> CmsVersion
pub fn version(&self) -> CmsVersion
Calculate the CMSVersion of the signer info.
Intended to be called during building the SignerInfo
.
RFC 5652 § 5.3: version is the syntax version number. If the SignerIdentifier is
the CHOICE issuerAndSerialNumber, then the version MUST be 1. If
the SignerIdentifier is subjectKeyIdentifier, then the version MUST be 3.
Trait Implementations§
source§impl<'s, S> Builder for SignerInfoBuilder<'s, S>where
S: Keypair + DynSignatureAlgorithmIdentifier,
impl<'s, S> Builder for SignerInfoBuilder<'s, S>where
S: Keypair + DynSignatureAlgorithmIdentifier,
source§fn finalize(&mut self) -> Result<Vec<u8>>
fn finalize(&mut self) -> Result<Vec<u8>>
Calculate the data to be signed
RFC 5652 § 5.4
If an external_message_digest
is passed in, it is assumed, that we are signing external
content (see RFC 5652 § 5.2). In this case, the eContent
in EncapsulatedContentInfo
must be None
.