Skip to main content

CmsContentInfo

Struct CmsContentInfo 

Source
pub struct CmsContentInfo { /* private fields */ }
Expand description

An owned CMS_ContentInfo* — the top-level CMS container.

Implementations§

Source§

impl CmsContentInfo

Source

pub fn from_der(data: &[u8]) -> Result<Self, ErrorStack>

Decode a DER-encoded CMS_ContentInfo structure.

§Errors

Returns Err if data is not valid CMS DER.

Source

pub fn from_der_in(ctx: &Arc<LibCtx>, data: &[u8]) -> Result<Self, ErrorStack>

Decode a DER-encoded CMS_ContentInfo using an explicit library context.

Allocates the container with CMS_ContentInfo_new_ex(ctx) first, then decodes into it so that any internal algorithm fetches use ctx’s provider set.

§Errors
Source

pub fn to_der(&self) -> Result<Vec<u8>, ErrorStack>

DER-encode this CMS_ContentInfo.

§Errors
Source

pub fn content_type_oid(&self) -> Oid

Return the content-type OID (the outer contentType field).

For SignedData this is OID 1.2.840.113549.1.7.2.

§Panics

Panics if OpenSSL fails to allocate memory for the OID copy.

Source

pub fn econtent_type_oid(&self) -> Oid

Return the encapsulated content type OID (eContentType).

For ordinary SignedData carrying arbitrary data this is typically data (OID 1.2.840.113549.1.7.1); PKINIT uses its own OIDs (id-pkinit-authData, id-pkinit-DHKeyData, etc.).

§Panics

Panics if OpenSSL fails to allocate memory for the OID copy.

Source

pub fn is_detached(&self) -> bool

Return true if the content is detached (not embedded in the structure).

Source

pub fn content(&self) -> Option<Vec<u8>>

Return the raw encapsulated content bytes, or None if absent or detached.

Source

pub fn signers(&self) -> Vec<CmsSignerInfo<'_>>

Return the list of signer infos (borrowed from this CmsContentInfo).

Source

pub fn certs(&self) -> Vec<X509>

Return the certificates embedded in this CMS_ContentInfo.

CMS_get1_certs increments the reference count of each returned certificate; each X509 in the returned Vec owns an independent ref.

Source

pub fn crls(&self) -> Vec<X509Crl>

Return the CRLs embedded in this CMS_ContentInfo.

Source

pub fn verify( &self, store: &X509Store, certs: &[X509], flags: CmsVerifyFlags, ) -> Result<Vec<u8>, ErrorStack>

Verify the CMS SignedData, returning the encapsulated content on success.

  • store — trust anchor store.
  • certs — additional untrusted certificates to include in chain building.
  • flags — verification control flags (see CmsVerifyFlags).
§Errors

Returns Err if signature verification fails, the chain cannot be built, or the content is missing or malformed.

Source

pub fn sign( cert: &X509, key: &Pkey<Private>, extra_certs: &[X509], content: &[u8], flags: CmsSignFlags, ) -> Result<Self, ErrorStack>

Create a CMS SignedData wrapping content.

  • cert — signer certificate.
  • key — corresponding private key.
  • extra_certs — additional certificates to embed in the SignedData (e.g. intermediate CA certificates for chain building).
  • content — the payload to sign.
  • flags — sign control flags (see CmsSignFlags).
§Errors
Source

pub fn sign_in( ctx: &Arc<LibCtx>, cert: &X509, key: &Pkey<Private>, extra_certs: &[X509], content: &[u8], flags: CmsSignFlags, ) -> Result<Self, ErrorStack>

Create a CMS SignedData using an explicit library context.

Calls CMS_sign_ex so all algorithm fetches use ctx’s provider set.

§Errors

Trait Implementations§

Source§

impl Drop for CmsContentInfo

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for CmsContentInfo

Source§

impl Sync for CmsContentInfo

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.