[][src]Enum pgp::composed::message::Message

pub enum Message {
    Literal(LiteralData),
    Compressed(CompressedData),
    Signed {
        message: Option<Box<Message>>,
        one_pass_signature: Option<OnePassSignature>,
        signature: Signature,
    },
    Encrypted {
        esk: Vec<Esk>,
        edata: Vec<Edata>,
    },
}

A PGP message https://tools.ietf.org/html/rfc4880.html#section-11.3

Variants

Literal(LiteralData)
Compressed(CompressedData)
Signed

Fields of Signed

message: Option<Box<Message>>

nested message

one_pass_signature: Option<OnePassSignature>

for signature packets that contain a one pass message

signature: Signature
Encrypted

Fields of Encrypted

esk: Vec<Esk>edata: Vec<Edata>

Methods

impl Message[src]

pub fn new_literal(file_name: &str, data: &str) -> Self[src]

pub fn new_literal_bytes(file_name: &str, data: &[u8]) -> Self[src]

pub fn compress(&self, alg: CompressionAlgorithm) -> Result<Self>[src]

Compresses the message.

pub fn decompress(self) -> Result<Self>[src]

Decompresses the data if compressed.

pub fn encrypt_to_keys<R: CryptoRng + Rng>(
    &self,
    rng: &mut R,
    alg: SymmetricKeyAlgorithm,
    pkeys: &[&impl PublicKeyTrait]
) -> Result<Self>
[src]

Encrypt the message to the list of passed in public keys.

pub fn encrypt_with_password<R, F>(
    &self,
    rng: &mut R,
    s2k: StringToKey,
    alg: SymmetricKeyAlgorithm,
    msg_pw: F
) -> Result<Self> where
    R: Rng + CryptoRng,
    F: FnOnce() -> String + Clone
[src]

Encrytp the message using the given password.

pub fn sign<F>(
    self,
    key: &impl SecretKeyTrait,
    key_pw: F,
    hash_algorithm: HashAlgorithm
) -> Result<Self> where
    F: FnOnce() -> String
[src]

Sign this message using the provided key.

pub fn into_signature(self) -> StandaloneSignature[src]

Convert the message to a standalone signature according to the cleartext framework.

pub fn verify(&self, key: &impl PublicKeyTrait) -> Result<()>[src]

Verify this message. For signed messages this verifies the signature and for compressed messages they are decompressed and checked for signatures to verify.

pub fn get_recipients(&self) -> Vec<&KeyId>[src]

Returns a list of KeyIds that the message is encrypted to. For non encrypted messages this list is empty.

pub fn decrypt<'a, F, G>(
    &'a self,
    msg_pw: F,
    key_pw: G,
    keys: &[&SignedSecretKey]
) -> Result<(MessageDecrypter<'a>, Vec<KeyId>)> where
    F: FnOnce() -> String + Clone,
    G: FnOnce() -> String + Clone
[src]

Decrypt the message using the given key. Returns a message decrypter, and a list of KeyIds that are valid recipients of this message.

pub fn decrypt_with_password<'a, F>(
    &'a self,
    msg_pw: F
) -> Result<MessageDecrypter<'a>> where
    F: FnOnce() -> String + Clone
[src]

Decrypt the message using the given key. Returns a message decrypter, and a list of KeyIds that are valid recipients of this message.

pub fn is_one_pass_signed(&self) -> bool[src]

Check if this message is a signature, that was signed with a one pass signature.

pub fn is_literal(&self) -> bool[src]

pub fn get_literal(&self) -> Option<&LiteralData>[src]

pub fn get_content(&self) -> Result<Option<Vec<u8>>>[src]

Returns the underlying content and None if the message is encrypted.

pub fn to_armored_writer(
    &self,
    writer: &mut impl Write,
    headers: Option<&BTreeMap<String, String>>
) -> Result<()>
[src]

pub fn to_armored_bytes(
    &self,
    headers: Option<&BTreeMap<String, String>>
) -> Result<Vec<u8>>
[src]

pub fn to_armored_string(
    &self,
    headers: Option<&BTreeMap<String, String>>
) -> Result<String>
[src]

Trait Implementations

impl Deserializable for Message[src]

fn from_packets<'a>(
    packets: impl Iterator<Item = Packet> + 'a
) -> Box<dyn Iterator<Item = Result<Self>> + 'a>
[src]

Parse a composed message. Ref: https://tools.ietf.org/html/rfc4880#section-11.3

impl Serialize for Message[src]

impl Clone for Message[src]

impl Eq for Message[src]

impl PartialEq<Message> for Message[src]

impl Debug for Message[src]

Auto Trait Implementations

impl Send for Message

impl Sync for Message

impl Unpin for Message

impl UnwindSafe for Message

impl RefUnwindSafe for Message

Blanket Implementations

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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.

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

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

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