Struct gpgme::context::Context[][src]

pub struct Context(_);
Expand description

A context for cryptographic operations.

Upstream documentation: gpgme_ctx_t

Implementations

Creates a new context and initializes it to work with the specified protocol.

Upstream documentation: gpgme_new and gpgme_set_protocol

Upstream documentation: gpgme_get_protocol

Upstream documentation: gpgme_get_armor

Upstream documentation: gpgme_set_armor

Upstream documentation: gpgme_get_textmode

Upstream documentation: gpgme_set_textmode

Upstream documentation: gpgme_get_offline

Upstream documentation: gpgme_set_offline

Upstream documentation: gpgme_get_ctx_flag

Upstream documentation: gpgme_get_ctx_flag

Upstream documentation: gpgme_set_ctx_flag

Upstream documentation: gpgme_ctx_get_engine_info

Upstream documentation: gpgme_ctx_set_engine_info

Upstream documentation: gpgme_get_pinentry_mode

Upstream documentation: gpgme_set_pinentry_mode

Upstream documentation: gpgme_set_passphrase_cb

Upstream documentation: gpgme_set_passphrase_cb

Uses the specified provider to handle passphrase requests for the duration of the closure.

Upstream documentation: gpgme_set_passphrase_cb

Examples

use std::io::prelude::*;

use gpgme::{Context, PassphraseRequest, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp)?;
ctx.with_passphrase_provider(|_: PassphraseRequest, out: &mut dyn Write| {
    out.write_all(b"some passphrase")?;
    Ok(())
}, |mut ctx| {
    // Do something with ctx requiring a passphrase, for example decryption
});

Upstream documentation: gpgme_set_progress_cb

Upstream documentation: gpgme_set_progress_cb

Upstream documentation: gpgme_set_progress_cb

👎 Deprecated since 0.9.2:

use with_progress_reporter instead

Upstream documentation: gpgme_set_progress_cb

Upstream documentation: gpgme_set_status_cb

Upstream documentation: gpgme_set_status_cb

Upstream documentation: gpgme_set_status_cb

Upstream documentation: gpgme_get_keylist_mode

Adds all flags set in the provided key listing mode to the Context’s current mode.

Upstream documentation: gpgme_set_keylist_mode

Upstream documentation: gpgme_set_keylist_mode

Returns an iterator over all public keys available in the keyring.

Returns an iterator over all secret keys available in the keyring.

Returns an updated version of the provided key.

Returns the public key with the specified fingerprint, if such a key can be found. Otherwise, an error is returned.

Upstream documentation: gpgme_get_key

Returns the secret key with the specified fingerprint, if such a key can be found. Otherwise, an error is returned.

Upstream documentation: gpgme_get_key

👎 Deprecated since 0.8.0:

use get_key instead

Upstream documentation: gpgme_get_key

👎 Deprecated since 0.8.0:

use get_secret_key instead

Upstream documentation: gpgme_get_key

Returns an iterator over a list of all public keys matching one or more of the specified patterns.

Upstream documentation: gpgme_op_keylist_ext_start

Returns an iterator over a list of all secret keys matching one or more of the specified patterns.

Upstream documentation: gpgme_op_keylist_ext_start

Returns an iterator over the keys encoded in the specified source.

Upstream documentation: gpgme_op_keylist_from_data_start

Examples

use gpgme::{Context, Data, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp)?;
let mut keyring = Data::load("somefile")?;
for key in ctx.read_keys(&mut keyring)? {
    println!("{:?}", key);
}

Upstream documentation: gpgme_op_genkey

Creates a new OpenPGP key.

Upstream documentation: gpgme_op_createkey

Examples

use gpgme::{Context, Data, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp)?;
let result = ctx.create_key("Example User <example@example.com>", "default", Default::default())?;
println!("Key Fingerprint: {}", result.fingerprint().unwrap());

Upstream documentation: gpgme_op_createkey

Upstream documentation: gpgme_op_createsubkey

Upstream documentation: gpgme_op_createsubkey

Upstream documentation: gpgme_op_setexpire

Upstream documentation: gpgme_op_setexpire

Upstream documentation: gpgme_op_adduid

Upstream documentation: gpgme_op_revuid

Upstream documentation: gpgme_op_set_uid_flag

Signs the given key with the default signing key, or the keys specified via add_signer.

Upstream documentation: gpgme_op_keysign

Signs the given key with the default signing key, or the keys specified via add_signer.

Upstream documentation: gpgme_op_keysign

Upstream documentation: gpgme_op_revsig

Upstream documentation: gpgme_op_tofu_policy

Upstream documentation: gpgme_op_passwd

👎 Deprecated since 0.9.2:

use interact instead

Upstream documentation: gpgme_op_edit

👎 Deprecated since 0.9.2:

use interact_with_card instead

Upstream documentation: gpgme_op_card_edit

👎 Deprecated since 0.9.2:

use interact instead

Upstream documentation: gpgme_op_edit

👎 Deprecated since 0.9.2:

use interact_with_card instead

Upstream documentation: gpgme_op_card_edit

Upstream documentation: gpgme_op_interact

Upstream documentation: gpgme_op_interact

Upstream documentation: gpgme_op_delete

Upstream documentation: gpgme_op_delete

Upstream documentation: gpgme_op_delete_ext

Upstream documentation: gpgme_op_import

Upstream documentation: gpgme_op_import_keys

Upstream documentation: gpgme_op_export_ext

Upstream documentation: gpgme_op_export_ext

Upstream documentation: gpgme_op_export_ext

Upstream documentation: gpgme_op_export_ext

Upstream documentation: gpgme_op_export_keys

Upstream documentation: gpgme_op_export_keys

Upstream documentation: gpgme_set_sender

Upstream documentation: gpgme_set_sender

Upstream documentation: gpgme_get_sender

Upstream documentation: gpgme_get_sender

Upstream documentation: gpgme_signers_clear

Upstream documentation: gpgme_signers_add

Upstream documentation: gpgme_signers_enum

Upstream documentation: gpgme_sig_notation_clear

Upstream documentation: gpgme_sig_notation_add

Upstream documentation: gpgme_sig_notation_add

Upstream documentation: gpgme_sig_notation_get

Upstream documentation: gpgme_sig_notation_get

Upstream documentation: gpgme_sig_notation_get

Creates a clear text signature.

Upstream documentation: gpgme_op_sign

Creates a detached signature.

Upstream documentation: gpgme_op_sign

Creates a normal signature.

Upstream documentation: gpgme_op_sign

Creates a signature for the text stored in the data object plaintext and writes it to the data object signature.

The type of the signature created is determined by the ASCII armor (or, if that is not set, by the encoding specified for sig), the text mode attributes set for the context and the requested signature mode.

Information about the results of the operation are returned in the SigningResult structure.

Upstream documentation: gpgme_op_sign

Upstream documentation: gpgme_op_verify

Upstream documentation: gpgme_op_verify

Encrypts a message for the specified recipients.

Upstream documentation: gpgme_op_encrypt

Examples

use gpgme::{Context, Data, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp)?;
let key = ctx.find_key("[some key fingerprint]")?;
let (plaintext, mut ciphertext) = ("Hello, World!", Vec::new());
ctx.encrypt(Some(&key), plaintext, &mut ciphertext)?;

Upstream documentation: gpgme_op_encrypt

Upstream documentation: gpgme_op_encrypt

Upstream documentation: gpgme_op_encrypt

Encrypts and signs a message for the specified recipients.

Upstream documentation: gpgme_op_encrypt_sign

Examples

use gpgme::{Context, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp)?;
let key = ctx.find_key("[some key fingerprint]")?;
let (plaintext, mut ciphertext) = ("Hello, World!", Vec::new());
ctx.sign_and_encrypt(Some(&key), plaintext, &mut ciphertext)?;

Upstream documentation: gpgme_op_encrypt_sign

Decrypts a message.

Upstream documentation: gpgme_op_decrypt

Examples

use gpgme::{Context, Data, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp)?;
let mut cipher = Data::load("some file")?;
let mut plain = Vec::new();
ctx.decrypt(&mut cipher, &mut plain)?;

Upstream documentation: gpgme_op_decrypt_ext

Decrypts and verifies a message.

Upstream documentation: gpgme_op_decrypt_verify

Examples

use gpgme::{Context, Data, Protocol};

let mut ctx = Context::from_protocol(Protocol::OpenPgp)?;
let mut cipher = Data::load("some file")?;
let mut plain = Vec::new();
ctx.decrypt_and_verify(&mut cipher, &mut plain)?;

Upstream documentation: gpgme_op_decrypt_ext

Upstream documentation: gpgme_op_query_swdb

Upstream documentation: gpgme_op_getauditlog

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

The error type produced by a failed conversion.

Convert the given value into an approximately equivalent representation.

The error type produced by a failed conversion.

Convert the subject into an approximately equivalent representation.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Approximate the subject with the default scheme.

Approximate the subject with a specific scheme.

Approximate the subject to a given type with the default scheme.

Approximate the subject to a given type with a specific scheme.

Convert the subject to a given type.

Attempt to convert the subject to a given type.

Attempt a value conversion of the subject to a given type.

Performs the conversion.

Performs the conversion.

The error type produced by a failed conversion.

Convert the given value into the subject type.

The type returned in the event of a conversion error.

Performs the conversion.

The error type produced by a failed conversion.

Convert the subject into the destination type.

The type returned in the event of a conversion error.

Performs the conversion.

The error type produced by a failed conversion.

Convert the given value into an exactly equivalent representation.

The error type produced by a failed conversion.

Convert the subject into an exactly equivalent representation.