Struct sequoia_gpg_agent::KeyPair
source · pub struct KeyPair { /* private fields */ }
Expand description
A cryptographic key pair.
A KeyPair
is a combination of public and secret key. This
particular implementation does not have the secret key, but
diverges the cryptographic operations to gpg-agent
.
This provides a convenient, synchronous interface for use with the low-level Sequoia crate.
Implementations§
source§impl KeyPair
impl KeyPair
sourcepub fn new_for_gnupg_context<R>(
ctx: &Context,
key: &Key<PublicParts, R>
) -> Result<KeyPair>where
R: KeyRole,
pub fn new_for_gnupg_context<R>(
ctx: &Context,
key: &Key<PublicParts, R>
) -> Result<KeyPair>where
R: KeyRole,
Returns a KeyPair
for key
with the secret bits managed by
the agent.
This provides a convenient, synchronous interface for use with the low-level Sequoia crate.
sourcepub fn new_for_socket<P, R>(
agent_socket: P,
key: &Key<PublicParts, R>
) -> Result<KeyPair>
pub fn new_for_socket<P, R>( agent_socket: P, key: &Key<PublicParts, R> ) -> Result<KeyPair>
Returns a KeyPair
for key
with the secret bits managed by
the agent.
If you have a Agent
, then you should create a KeyPair
using Agent::keypair
.
sourcepub fn with_cert(self, cert: &ValidCert<'_>) -> Self
pub fn with_cert(self, cert: &ValidCert<'_>) -> Self
Changes the password prompt to include information about the cert.
Use this function to give more context to the user when she is prompted for a password. This function will generate a prompt that is very similar to the prompts that GnuPG generates.
To set an arbitrary password prompt, use
KeyPair::with_password_prompt
.
sourcepub fn with_password(self, password: Password) -> Self
pub fn with_password(self, password: Password) -> Self
Supplies a password to unlock the secret key.
This will be used when the secret key operation is performed, e.g. when signing or decrypting a message.
Note: This is the equivalent of GnuPG’s
--pinentry-mode=loopback
and requires explicit opt-in in the
gpg-agent configuration using the allow-loopback-pinentry
option. If this is not enabled in the agent, the secret key
operation will fail. It is likely only useful during testing.
sourcepub fn set_pinentry_mode(self, mode: PinentryMode) -> Self
pub fn set_pinentry_mode(self, mode: PinentryMode) -> Self
Overrides the pinentry mode.
sourcepub fn suppress_pinentry(self) -> Self
pub fn suppress_pinentry(self) -> Self
Disables gpg’s pinentry.
Changes the pinentry mode to PinEntryMode::Error
, which
configures the agent to not ask for a password.
sourcepub fn with_password_prompt(self, prompt: String) -> Self
pub fn with_password_prompt(self, prompt: String) -> Self
Changes the password prompt.
Use this function to give more context to the user when she is prompted for a password.
To set an password prompt that uses information from the
OpenPGP certificate, use KeyPair::with_cert
.
source§impl KeyPair
impl KeyPair
sourcepub async fn sign_async(
&mut self,
hash_algo: HashAlgorithm,
digest: &[u8]
) -> Result<Signature>
pub async fn sign_async( &mut self, hash_algo: HashAlgorithm, digest: &[u8] ) -> Result<Signature>
Signs a message.
An async implementation of
sequoia_openpgp::crypto::Signer::sign
.
source§impl KeyPair
impl KeyPair
sourcepub async fn decrypt_async(
&mut self,
ciphertext: &Ciphertext,
plaintext_len: Option<usize>
) -> Result<SessionKey>
pub async fn decrypt_async( &mut self, ciphertext: &Ciphertext, plaintext_len: Option<usize> ) -> Result<SessionKey>
Decrypts a message.
An async implementation of
sequoia_openpgp::crypto::Decryptor::decrypt
.
Trait Implementations§
source§impl Decryptor for KeyPair
impl Decryptor for KeyPair
source§fn public(&self) -> &Key<PublicParts, UnspecifiedRole>
fn public(&self) -> &Key<PublicParts, UnspecifiedRole>
source§fn decrypt(
&mut self,
ciphertext: &Ciphertext,
plaintext_len: Option<usize>
) -> Result<SessionKey>
fn decrypt( &mut self, ciphertext: &Ciphertext, plaintext_len: Option<usize> ) -> Result<SessionKey>
ciphertext
, returning the plain session key.source§impl Signer for KeyPair
impl Signer for KeyPair
source§fn public(&self) -> &Key<PublicParts, UnspecifiedRole>
fn public(&self) -> &Key<PublicParts, UnspecifiedRole>
source§fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8]) -> Result<Signature>
fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8]) -> Result<Signature>
digest
produced by hash_algo
.