# Struct openssl::pkcs7::Pkcs7 [−] [src]

    pub struct Pkcs7(_);

A PKCS#7 structure.

Contains signed and/or encrypted data.

## Implementations

### `impl Pkcs7` [src]

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

Deserializes a PEM-encoded PKCS#7 signature

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

This corresponds to `PEM_read_bio_PKCS7`.

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

Deserializes a DER-encoded PKCS#7 signature

This corresponds to `d2i_PKCS7`.

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

Parses a message in S/MIME format.

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

This corresponds to `SMIME_read_PKCS7`.

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

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`.

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

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>

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

Converts PKCS#7 structure to S/MIME format

This corresponds to `SMIME_write_PKCS7`.

#### `pub fn to_pem(&self) -> Result<Vec<u8>, ErrorStack>` [src]

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`.

#### `pub fn to_der(&self) -> Result<Vec<u8>, ErrorStack>` [src]

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

This corresponds to `i2d_PKCS7`.

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

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`.

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

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`.

## Trait Implementations

### `impl AsRef<Pkcs7Ref> for Pkcs7` [src]

#### `fn as_ref(&self) -> &Pkcs7Ref` [src]

Performs the conversion.

### `impl Borrow<Pkcs7Ref> for Pkcs7` [src]

#### `fn borrow(&self) -> &Pkcs7Ref` [src]

Immutably borrows from an owned value. Read more

### `impl Deref for Pkcs7` [src]

#### `type Target = Pkcs7Ref`

The resulting type after dereferencing.

#### `fn deref(&self) -> &Pkcs7Ref` [src]

Dereferences the value.

### `impl DerefMut for Pkcs7` [src]

#### `fn deref_mut(&mut self) -> &mut Pkcs7Ref` [src]

Mutably dereferences the value.

### `impl Drop for Pkcs7` [src]

#### `fn drop(&mut self)` [src]

Executes the destructor for this type. Read more

### `impl ForeignType for Pkcs7` [src]

#### `type CType = PKCS7`

The raw C type.

#### `type Ref = Pkcs7Ref`

The type representing a reference to this type.

#### `unsafe fn from_ptr(ptr: *mut PKCS7) -> Pkcs7` [src]

Constructs an instance of this type from its raw type.

#### `fn as_ptr(&self) -> *mut PKCS7` [src]

Returns a raw pointer to the wrapped value.

### `impl Send for Pkcs7` [src]

### `impl Sync for Pkcs7` [src]

## Auto Trait Implementations

### `impl RefUnwindSafe for Pkcs7`

### `impl Unpin for Pkcs7`

### `impl UnwindSafe for Pkcs7`

## Blanket Implementations

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `pub fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T` [src]

#### `pub fn from(t: T) -> T` [src]

Performs the conversion.

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `pub fn into(self) -> U` [src]

Performs the conversion.

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>` [src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

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

The type returned in the event of a conversion error.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.