Skip to main content

PassphraseProvider

Trait PassphraseProvider 

Source
pub trait PassphraseProvider: Send + Sync {
    // Required method
    fn get_passphrase(
        &self,
        prompt_message: &str,
    ) -> Result<Zeroizing<String>, AgentError>;

    // Provided method
    fn on_incorrect_passphrase(&self, _prompt_message: &str) { ... }
}
Expand description

A trait for components that can securely provide a passphrase when requested.

This allows the core signing logic to request a passphrase without knowing whether it’s coming from a terminal prompt, a GUI dialog, or another source. Implementors should handle secure input and potential user cancellation.

Required Methods§

Source

fn get_passphrase( &self, prompt_message: &str, ) -> Result<Zeroizing<String>, AgentError>

Securely obtains a passphrase, potentially by prompting the user.

Args:

  • prompt_message: A message to display to the user indicating why the passphrase is needed.

Usage:

let passphrase = provider.get_passphrase("Enter passphrase for key 'main':")?;

Provided Methods§

Source

fn on_incorrect_passphrase(&self, _prompt_message: &str)

Notifies the provider that the passphrase returned for prompt_message was wrong.

The default implementation is a no-op. Caching providers override this to evict the stale entry so subsequent calls prompt the user again rather than replaying a known-bad passphrase.

Args:

  • prompt_message: The prompt for which the bad passphrase was cached.

Implementors§