pub struct SignedDataBuilder<'a> { /* private fields */ }
Expand description
Entity for incrementally deriving a SignedData primitive.
Use this type for generating an RFC 5652 payload for signed data.
By default, the encapsulated content to sign is empty. Call Self::content_inline() or Self::content_external() to define encapsulated content.
Implementations§
Source§impl<'a> SignedDataBuilder<'a>
impl<'a> SignedDataBuilder<'a>
Sourcepub fn content_inline(self, content: Vec<u8>) -> Self
pub fn content_inline(self, content: Vec<u8>) -> Self
Define encapsulated content that will be stored inline in the produced signature.
Sourcepub fn content_external(self, content: Vec<u8>) -> Self
pub fn content_external(self, content: Vec<u8>) -> Self
Define encapsulated content that won’t be present in the produced signature.
The content will be digested and that digest conveyed in the built signature. But the content itself won’t be present in the signature. RFC 5652 refers to this as an external signature.
Sourcepub fn signer(self, signer: SignerBuilder<'a>) -> Self
pub fn signer(self, signer: SignerBuilder<'a>) -> Self
Add a signer.
The signer is the thing generating the cryptographic signature over data to be signed.
Sourcepub fn certificate(self, cert: CapturedX509Certificate) -> Self
pub fn certificate(self, cert: CapturedX509Certificate) -> Self
Add a certificate defined by our crate’s Certificate type.
Sourcepub fn certificates(
self,
certs: impl Iterator<Item = CapturedX509Certificate>,
) -> Self
pub fn certificates( self, certs: impl Iterator<Item = CapturedX509Certificate>, ) -> Self
Add multiple certificates to the certificates chain.
Sourcepub fn content_type(self, oid: Oid) -> Self
pub fn content_type(self, oid: Oid) -> Self
Force the OID for the ContentInfo.contentType
field.
Sourcepub fn signing_time(self, time: UtcTime) -> Self
pub fn signing_time(self, time: UtcTime) -> Self
Specify the signing time to use in signatures.
If not called, current time at struct construction will be used.
Sourcepub fn build_signed_data(&self) -> Result<SignedData, CmsError>
pub fn build_signed_data(&self) -> Result<SignedData, CmsError>
Construct a SignedData
object from the parameters received so far.
Sourcepub fn build_der(&self) -> Result<Vec<u8>, CmsError>
pub fn build_der(&self) -> Result<Vec<u8>, CmsError>
Construct a DER-encoded ASN.1 document containing a SignedData
object.
RFC 5652 says SignedData
is BER encoded. However, DER is a stricter subset
of BER. DER encodings are valid BER. So producing DER encoded data is perfectly
valid. We choose to go with the more well-defined encoding format.