pub struct HsmContext {
pub context: Pkcs11Context,
pub provider: HsmProvider,
/* private fields */
}Expand description
High-level HSM context wrapping PKCS#11 initialization and provider config.
Used by AppState to hold the HSM connection for the server lifetime.
When fully initialized, holds a logged-in PKCS#11 session for signing.
Fields§
§context: Pkcs11Context§provider: HsmProviderImplementations§
Source§impl HsmContext
impl HsmContext
Sourcepub fn new(
context: Pkcs11Context,
provider: HsmProvider,
slot: HsmSlot,
session: Session,
) -> Self
pub fn new( context: Pkcs11Context, provider: HsmProvider, slot: HsmSlot, session: Session, ) -> Self
Create a new HSM context with a logged-in session ready for signing.
pub fn placeholder() -> Self
Sourcepub fn health_check(&self) -> HsmResult<()>
pub fn health_check(&self) -> HsmResult<()>
Check that the HSM session is initialized and the mutex is healthy.
Returns Ok(()) if a PKCS#11 session exists and the lock is
acquirable. Used by health probes to verify HSM availability
without performing a signing operation.
Sourcepub fn tls_key_label(&self, uri: &str) -> HsmResult<String>
pub fn tls_key_label(&self, uri: &str) -> HsmResult<String>
Resolve a strict RFC 7512 key selector against the configured token.
Sourcepub fn sign_tls(
&self,
key_label: &str,
data: &[u8],
scheme: SignatureScheme,
) -> HsmResult<Vec<u8>>
pub fn sign_tls( &self, key_label: &str, data: &[u8], scheme: SignatureScheme, ) -> HsmResult<Vec<u8>>
Sign the TLS transcript with the selected scheme and wire encoding.
pub fn sign_data( &self, key_label: &str, data: &[u8], hash_algorithm: &str, ) -> HsmResult<Vec<u8>>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for HsmContext
impl RefUnwindSafe for HsmContext
impl Unpin for HsmContext
impl UnsafeUnpin for HsmContext
impl UnwindSafe for HsmContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more