pub struct SignerHandle { /* private fields */ }Expand description
Handle to a signing backend. Obtained from create_signer().
Multi-key: each method takes a label parameter. The factory
initializes the backend and ensures the default_key_label exists.
Implementations§
Source§impl SignerHandle
impl SignerHandle
Sourcepub fn generate_key(&self, label: &str, policy: AccessPolicy) -> Result<Vec<u8>>
pub fn generate_key(&self, label: &str, policy: AccessPolicy) -> Result<Vec<u8>>
Generate a new P-256 signing key. Returns uncompressed SEC1 public key.
§Errors
Error::DuplicateLabelif a key with this label already exists.Error::InvalidLabelif the label is empty, too long, or contains illegal characters.Error::PolicyNotSupportedif the backend cannot enforce the requestedAccessPolicy.Error::RequiresSigningifpolicyrequires a code-signed binary.Error::KeyOperationfor underlying hardware or I/O failures.
Sourcepub fn public_key(&self, label: &str) -> Result<Vec<u8>>
pub fn public_key(&self, label: &str) -> Result<Vec<u8>>
Return the uncompressed SEC1 public key for an existing key.
Sourcepub fn sign(&self, label: &str, data: &[u8]) -> Result<Vec<u8>>
pub fn sign(&self, label: &str, data: &[u8]) -> Result<Vec<u8>>
Sign data (SHA-256 applied internally). Returns a DER-encoded ECDSA
P-256 signature.
§Errors
Error::KeyNotFoundif no key with this label exists.Error::AuthDeniedif the keychain ACL denies access to the wrapping key.Error::AuthRequiredif the device is locked or the GUI session is absent.Error::UserCancelledif the user dismissed a biometric prompt.Error::SignFailedfor underlying hardware or crypto failures.
Sourcepub fn sign_with_presence(
&self,
label: &str,
data: &[u8],
opts: &PresenceOptions,
) -> Result<Vec<u8>>
pub fn sign_with_presence( &self, label: &str, data: &[u8], opts: &PresenceOptions, ) -> Result<Vec<u8>>
Sign data with an optional user-presence prompt.
PresenceMode::Stricton a platform wherepresence_available()is false returnsError::PresenceNotAvailable.PresenceMode::CachedorPresenceMode::Nonealways falls through to a plain sign on non-macOS platforms (no error).
§Errors
Error::PresenceNotAvailableifopts.modeisStrictand the platform has no user-presence support.Error::KeyNotFoundif no key with this label exists.Error::AuthDeniedif the keychain ACL denies access to the wrapping key.Error::AuthRequiredif the device is locked or the GUI session is absent.Error::UserCancelledif the user dismissed a biometric prompt.Error::SignFailedfor underlying hardware or crypto failures.
Sourcepub fn presence_available(&self) -> bool
pub fn presence_available(&self) -> bool
True when the current platform supports presence prompting.
Sourcepub fn delete_key(&self, label: &str) -> Result<()>
pub fn delete_key(&self, label: &str) -> Result<()>
Permanently delete a signing key and its metadata.
Sourcepub fn key_exists(&self, label: &str) -> Result<bool>
pub fn key_exists(&self, label: &str) -> Result<bool>
Return true if a key with this label exists.
Sourcepub fn rename_key(&self, old_label: &str, new_label: &str) -> Result<()>
pub fn rename_key(&self, old_label: &str, new_label: &str) -> Result<()>
Atomically rename a signing key.
Sourcepub fn evict_presence_cache(&self, label: &str)
pub fn evict_presence_cache(&self, label: &str)
Evict the cached wrapping-key / LAContext for label, forcing the next sign to
re-authenticate. Has no effect on platforms without presence caching.
Sourcepub fn backend_kind(&self) -> BackendKind
pub fn backend_kind(&self) -> BackendKind
Which hardware security backend backs this handle.