Struct openssl::pkcs7::Pkcs7

source ·
pub struct Pkcs7(/* private fields */);
Expand description

A PKCS#7 structure.

Contains signed and/or encrypted data.

Implementations§

source§

impl Pkcs7

source

pub fn from_pem(pem: &[u8]) -> Result<Pkcs7, ErrorStack>

Deserializes a PEM-encoded PKCS#7 signature

The input should have a header of -----BEGIN PKCS7-----.

This corresponds to PEM_read_bio_PKCS7.

source

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

Deserializes a DER-encoded PKCS#7 signature

This corresponds to d2i_PKCS7.

source

pub fn from_smime(input: &[u8]) -> Result<(Pkcs7, Option<Vec<u8>>), ErrorStack>

Parses a message in S/MIME format.

Returns the loaded signature, along with the cleartext message (if available).

This corresponds to SMIME_read_PKCS7.

source

pub fn encrypt( certs: &StackRef<X509>, input: &[u8], cipher: Cipher, flags: Pkcs7Flags ) -> Result<Pkcs7, ErrorStack>

Creates and returns a PKCS#7 envelopedData structure.

certs is a list of recipient certificates. input is the content to be encrypted. cipher is the symmetric cipher to use. flags is an optional set of flags.

This corresponds to PKCS7_encrypt.

source

pub fn sign<PT>( signcert: &X509Ref, pkey: &PKeyRef<PT>, certs: &StackRef<X509>, input: &[u8], flags: Pkcs7Flags ) -> Result<Pkcs7, ErrorStack>where PT: HasPrivate,

Creates and returns a PKCS#7 signedData structure.

signcert is the certificate to sign with, pkey is the corresponding private key. certs is an optional additional set of certificates to include in the PKCS#7 structure (for example any intermediate CAs in the chain).

This corresponds to PKCS7_sign.

Methods from Deref<Target = Pkcs7Ref>§

source

pub fn to_smime( &self, input: &[u8], flags: Pkcs7Flags ) -> Result<Vec<u8>, ErrorStack>

Converts PKCS#7 structure to S/MIME format

This corresponds to SMIME_write_PKCS7.

source

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

Serializes the data into a PEM-encoded PKCS#7 structure.

The output will have a header of -----BEGIN PKCS7-----.

This corresponds to PEM_write_bio_PKCS7.

source

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

Serializes the data into a DER-encoded PKCS#7 structure.

This corresponds to i2d_PKCS7.

source

pub fn decrypt<PT>( &self, pkey: &PKeyRef<PT>, cert: &X509Ref, flags: Pkcs7Flags ) -> Result<Vec<u8>, ErrorStack>where PT: HasPrivate,

Decrypts data using the provided private key.

pkey is the recipient’s private key, and cert is the recipient’s certificate.

Returns the decrypted message.

This corresponds to PKCS7_decrypt.

source

pub fn verify( &self, certs: &StackRef<X509>, store: &X509StoreRef, indata: Option<&[u8]>, out: Option<&mut Vec<u8>>, flags: Pkcs7Flags ) -> Result<(), ErrorStack>

Verifies the PKCS#7 signedData structure contained by &self.

certs is a set of certificates in which to search for the signer’s certificate. store is a trusted certificate store (used for chain verification). indata is the signed data if the content is not present in &self. The content is written to out if it is not None.

This corresponds to PKCS7_verify.

source

pub fn signers( &self, certs: &StackRef<X509>, flags: Pkcs7Flags ) -> Result<Stack<X509>, ErrorStack>

Retrieve the signer’s certificates from the PKCS#7 structure without verifying them.

This corresponds to PKCS7_get0_signers.

source

pub fn type_(&self) -> Option<&Asn1ObjectRef>

Return the type of a PKCS#7 structure as an Asn1Object

source

pub fn signed(&self) -> Option<&Pkcs7SignedRef>

Get the signed data of a PKCS#7 structure of type PKCS7_SIGNED

Trait Implementations§

source§

impl AsRef<Pkcs7Ref> for Pkcs7

source§

fn as_ref(&self) -> &Pkcs7Ref

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<Pkcs7Ref> for Pkcs7

source§

fn borrow(&self) -> &Pkcs7Ref

Immutably borrows from an owned value. Read more
source§

impl Deref for Pkcs7

§

type Target = Pkcs7Ref

The resulting type after dereferencing.
source§

fn deref(&self) -> &Pkcs7Ref

Dereferences the value.
source§

impl DerefMut for Pkcs7

source§

fn deref_mut(&mut self) -> &mut Pkcs7Ref

Mutably dereferences the value.
source§

impl Drop for Pkcs7

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl ForeignType for Pkcs7

§

type CType = PKCS7

The raw C type.
§

type Ref = Pkcs7Ref

The type representing a reference to this type.
source§

unsafe fn from_ptr(ptr: *mut PKCS7) -> Pkcs7

Constructs an instance of this type from its raw type.
source§

fn as_ptr(&self) -> *mut PKCS7

Returns a raw pointer to the wrapped value.
source§

impl Send for Pkcs7

source§

impl Sync for Pkcs7

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.