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 sign_data(
&self,
key_label: &str,
data: &[u8],
hash_algorithm: &str,
) -> HsmResult<Vec<u8>>
pub fn sign_data( &self, key_label: &str, data: &[u8], hash_algorithm: &str, ) -> HsmResult<Vec<u8>>
Sign data using the HSM key identified by label.
Uses CKM_SHA256_RSA_PKCS for RSA keys (the mechanism hashes
and signs in one operation, so data is the raw TBS bytes).
§Arguments
key_label- CKA_LABEL of the private key in the tokendata- data to sign (raw TBS certificate bytes)hash_algorithm- hash algorithm name (“sha256”, “sha384”, “sha512”)
Trait Implementations§
impl Send for HsmContext
impl Sync for HsmContext
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