Trait gmime::CryptoContextExt [−][src]
pub trait CryptoContextExt {
fn decrypt<'a, P: Into<Option<&'a str>>, Q: IsA<Stream>, R: IsA<Stream>>(
&self,
flags: DecryptFlags,
session_key: P,
istream: &Q,
ostream: &R
) -> Result<DecryptResult, Error>;
fn digest_id(&self, name: &str) -> DigestAlgo;
fn digest_name(&self, digest: DigestAlgo) -> Option<String>;
fn export_keys<P: IsA<Stream>>(
&self,
keys: &str,
ostream: &P
) -> Result<i32, Error>;
fn get_encryption_protocol(&self) -> Option<String>;
fn get_key_exchange_protocol(&self) -> Option<String>;
fn get_signature_protocol(&self) -> Option<String>;
fn import_keys<P: IsA<Stream>>(&self, istream: &P) -> Result<i32, Error>;
fn sign<P: IsA<Stream>, Q: IsA<Stream>>(
&self,
detach: bool,
userid: &str,
istream: &P,
ostream: &Q
) -> Result<i32, Error>;
fn verify<'a, 'b, P: IsA<Stream>, Q: IsA<Stream> + 'a, R: Into<Option<&'a Q>>, S: IsA<Stream> + 'b, T: Into<Option<&'b S>>>(
&self,
flags: VerifyFlags,
istream: &P,
sigstream: R,
ostream: T
) -> Result<Option<SignatureList>, Error>;
}Required Methods
fn decrypt<'a, P: Into<Option<&'a str>>, Q: IsA<Stream>, R: IsA<Stream>>(
&self,
flags: DecryptFlags,
session_key: P,
istream: &Q,
ostream: &R
) -> Result<DecryptResult, Error>
&self,
flags: DecryptFlags,
session_key: P,
istream: &Q,
ostream: &R
) -> Result<DecryptResult, Error>
Decrypts the ciphertext input stream and writes the resulting cleartext to the output stream.
When non-None, session_key should be a None-terminated string,
such as the one returned by DecryptResultExt::get_session_key
from a previous decryption. If the session_key is not valid, decryption
will fail.
If the encrypted input stream was also signed, the returned
DecryptResult will have a non-None list of signatures, each with a
SignatureStatus (among other details about each signature).
On success, the returned DecryptResult will contain a list of
certificates, one for each recipient, that the original encrypted stream
was encrypted to.
Note: It may be possible to maliciously design an encrypted stream such that recursively decrypting it will result in an endless loop, causing a denial of service attack on your application.
flags
a set of DecryptFlags
session_key
the session key to use or None
istream
input/ciphertext stream
ostream
output/cleartext stream
Returns
a DecryptResult on success or None
on error.
fn digest_id(&self, name: &str) -> DigestAlgo
Gets the digest id based on the digest name.
name
digest name
Returns
the equivalent digest id or DigestAlgo::Default on fail.
fn digest_name(&self, digest: DigestAlgo) -> Option<String>
Gets the digest name based on the digest id digest.
digest
digest id
Returns
the equivalent digest name or None on fail.
fn export_keys<P: IsA<Stream>>(
&self,
keys: &str,
ostream: &P
) -> Result<i32, Error>
&self,
keys: &str,
ostream: &P
) -> Result<i32, Error>
Exports the keys/certificates in keys to the stream ostream from
the key/certificate database controlled by self.
If keys is None or contains only a None element, then all keys
will be exported.
keys
an array of key ids, terminated by a None element
ostream
output stream
Returns
0 on success or %-1 on fail.
fn get_encryption_protocol(&self) -> Option<String>
Gets the encryption protocol for the crypto context.
Returns
the encryption protocol or None if not supported.
fn get_key_exchange_protocol(&self) -> Option<String>
Gets the key exchange protocol for the crypto context.
Returns
the key exchange protocol or None if not supported.
fn get_signature_protocol(&self) -> Option<String>
Gets the signature protocol for the crypto context.
Returns
the signature protocol or None if not supported.
fn import_keys<P: IsA<Stream>>(&self, istream: &P) -> Result<i32, Error>
Imports a stream of keys/certificates contained within istream
into the key/certificate database controlled by self.
istream
input stream (containing keys)
Returns
the total number of keys imported on success or %-1 on fail.
fn sign<P: IsA<Stream>, Q: IsA<Stream>>(
&self,
detach: bool,
userid: &str,
istream: &P,
ostream: &Q
) -> Result<i32, Error>
&self,
detach: bool,
userid: &str,
istream: &P,
ostream: &Q
) -> Result<i32, Error>
Signs the input stream and writes the resulting signature to the output stream.
detach
true if ostream should be the detached signature; otherwise, false
userid
private key to use to sign the stream
istream
input stream
ostream
output stream
Returns
the DigestAlgo used on success or %-1 on fail.
fn verify<'a, 'b, P: IsA<Stream>, Q: IsA<Stream> + 'a, R: Into<Option<&'a Q>>, S: IsA<Stream> + 'b, T: Into<Option<&'b S>>>(
&self,
flags: VerifyFlags,
istream: &P,
sigstream: R,
ostream: T
) -> Result<Option<SignatureList>, Error>
&self,
flags: VerifyFlags,
istream: &P,
sigstream: R,
ostream: T
) -> Result<Option<SignatureList>, Error>
Verifies the signature. If istream is a clearsigned stream, you
should pass None as the sigstream parameter and may wish to
provide an ostream argument for GMime to output the original
plaintext into. Otherwise sigstream is assumed to be the signature
stream and is used to verify the integirity of the istream.
flags
a VerifyFlags
istream
input stream
sigstream
detached-signature stream
ostream
output stream for use with encapsulated signature input streams
Returns
a SignatureList object containing
the status of each signature or None on error.
Implementors
impl<O: IsA<CryptoContext>> CryptoContextExt for O