pub trait SigningProvider: Send + Sync {
Show 17 methods
// Required methods
fn name(&self) -> &str;
fn is_available(&self) -> bool;
fn generate_key(&self, label: &str) -> HsmResult<KeyId>;
fn import_key(
&self,
label: &str,
secret_key: &SecretKey,
) -> HsmResult<KeyId>;
fn get_public_key(&self, key_id: &KeyId) -> HsmResult<PublicKey>;
fn sign(&self, key_id: &KeyId, message: &[u8]) -> HsmResult<SignatureBytes>;
fn list_keys(&self) -> HsmResult<Vec<KeyMetadata>>;
fn delete_key(&self, key_id: &KeyId) -> HsmResult<()>;
fn key_exists(&self, key_id: &KeyId) -> bool;
// Provided methods
fn verify(
&self,
public_key: &PublicKey,
message: &[u8],
signature: &SignatureBytes,
) -> HsmResult<()> { ... }
fn export_key(&self, key_id: &KeyId) -> HsmResult<SecretKey> { ... }
fn get_key_metadata(&self, key_id: &KeyId) -> HsmResult<KeyMetadata> { ... }
fn update_key_state(
&self,
key_id: &KeyId,
state: KeyLifecycleState,
) -> HsmResult<()> { ... }
fn health_check(&self) -> HsmResult<HealthStatus> { ... }
fn batch_sign(
&self,
key_id: &KeyId,
messages: &[&[u8]],
) -> HsmResult<Vec<SignatureBytes>> { ... }
fn get_audit_log(&self, limit: usize) -> HsmResult<Vec<AuditEntry>> { ... }
fn rotate_key(&self, key_id: &KeyId, new_label: &str) -> HsmResult<KeyId> { ... }
}Expand description
Trait for cryptographic signing providers.
This trait abstracts over different key storage backends, allowing the same code to work with software keys, HSMs, or TPMs.
Required Methods§
Sourcefn is_available(&self) -> bool
fn is_available(&self) -> bool
Check if the provider is available and initialized.
Sourcefn generate_key(&self, label: &str) -> HsmResult<KeyId>
fn generate_key(&self, label: &str) -> HsmResult<KeyId>
Generate a new key pair and return its identifier.
Sourcefn import_key(&self, label: &str, secret_key: &SecretKey) -> HsmResult<KeyId>
fn import_key(&self, label: &str, secret_key: &SecretKey) -> HsmResult<KeyId>
Import an existing secret key.
Sourcefn get_public_key(&self, key_id: &KeyId) -> HsmResult<PublicKey>
fn get_public_key(&self, key_id: &KeyId) -> HsmResult<PublicKey>
Get the public key for a key identifier.
Sourcefn sign(&self, key_id: &KeyId, message: &[u8]) -> HsmResult<SignatureBytes>
fn sign(&self, key_id: &KeyId, message: &[u8]) -> HsmResult<SignatureBytes>
Sign a message using the specified key.
Sourcefn list_keys(&self) -> HsmResult<Vec<KeyMetadata>>
fn list_keys(&self) -> HsmResult<Vec<KeyMetadata>>
List all key identifiers.
Sourcefn delete_key(&self, key_id: &KeyId) -> HsmResult<()>
fn delete_key(&self, key_id: &KeyId) -> HsmResult<()>
Delete a key.
Sourcefn key_exists(&self, key_id: &KeyId) -> bool
fn key_exists(&self, key_id: &KeyId) -> bool
Check if a key exists.
Provided Methods§
Sourcefn verify(
&self,
public_key: &PublicKey,
message: &[u8],
signature: &SignatureBytes,
) -> HsmResult<()>
fn verify( &self, public_key: &PublicKey, message: &[u8], signature: &SignatureBytes, ) -> HsmResult<()>
Verify a signature (can use public key directly).
Sourcefn export_key(&self, key_id: &KeyId) -> HsmResult<SecretKey>
fn export_key(&self, key_id: &KeyId) -> HsmResult<SecretKey>
Export secret key (if allowed by key policy).
Sourcefn get_key_metadata(&self, key_id: &KeyId) -> HsmResult<KeyMetadata>
fn get_key_metadata(&self, key_id: &KeyId) -> HsmResult<KeyMetadata>
Get key metadata including lifecycle state and usage stats.
Sourcefn update_key_state(
&self,
key_id: &KeyId,
state: KeyLifecycleState,
) -> HsmResult<()>
fn update_key_state( &self, key_id: &KeyId, state: KeyLifecycleState, ) -> HsmResult<()>
Update key lifecycle state.
Sourcefn health_check(&self) -> HsmResult<HealthStatus>
fn health_check(&self) -> HsmResult<HealthStatus>
Perform health check and return status.
Sourcefn batch_sign(
&self,
key_id: &KeyId,
messages: &[&[u8]],
) -> HsmResult<Vec<SignatureBytes>>
fn batch_sign( &self, key_id: &KeyId, messages: &[&[u8]], ) -> HsmResult<Vec<SignatureBytes>>
Batch sign multiple messages.
Sourcefn get_audit_log(&self, limit: usize) -> HsmResult<Vec<AuditEntry>>
fn get_audit_log(&self, limit: usize) -> HsmResult<Vec<AuditEntry>>
Get audit log entries (if supported).