pub struct Pkcs11 { /* private fields */ }
Expand description
Main PKCS11 context. Should usually be unique per application.
Implementations§
source§impl Pkcs11
impl Pkcs11
sourcepub fn open_ro_session(&self, slot_id: Slot) -> Result<Session>
pub fn open_ro_session(&self, slot_id: Slot) -> Result<Session>
Open a new Read-Only session
For a Read-Write session, use open_rw_session
Note: No callback is set when opening the session.
sourcepub fn open_rw_session(&self, slot_id: Slot) -> Result<Session>
pub fn open_rw_session(&self, slot_id: Slot) -> Result<Session>
Open a new Read/Write session
Note: No callback is set when opening the session.
source§impl Pkcs11
impl Pkcs11
sourcepub fn get_slots_with_token(&self) -> Result<Vec<Slot>>
pub fn get_slots_with_token(&self) -> Result<Vec<Slot>>
Get all slots available with a token
sourcepub fn get_all_slots(&self) -> Result<Vec<Slot>>
pub fn get_all_slots(&self) -> Result<Vec<Slot>>
Get all slots
sourcepub fn get_slots_with_initialized_token(&self) -> Result<Vec<Slot>>
pub fn get_slots_with_initialized_token(&self) -> Result<Vec<Slot>>
Get all slots available with a token
sourcepub fn init_token(&self, slot: Slot, pin: &AuthPin, label: &str) -> Result<()>
pub fn init_token(&self, slot: Slot, pin: &AuthPin, label: &str) -> Result<()>
Initialize a token
Currently will use an empty label for all tokens.
sourcepub fn get_slot_info(&self, slot: Slot) -> Result<SlotInfo>
pub fn get_slot_info(&self, slot: Slot) -> Result<SlotInfo>
Returns the slot info
sourcepub fn get_token_info(&self, slot: Slot) -> Result<TokenInfo>
pub fn get_token_info(&self, slot: Slot) -> Result<TokenInfo>
Returns information about a specific token
sourcepub fn get_mechanism_list(&self, slot: Slot) -> Result<Vec<MechanismType>>
pub fn get_mechanism_list(&self, slot: Slot) -> Result<Vec<MechanismType>>
Get all mechanisms support by a slot
sourcepub fn get_mechanism_info(
&self,
slot: Slot,
type_: MechanismType
) -> Result<MechanismInfo>
pub fn get_mechanism_info( &self, slot: Slot, type_: MechanismType ) -> Result<MechanismInfo>
Get detailed information about a mechanism for a slot
sourcepub fn wait_for_slot_event(&self) -> Result<Slot>
pub fn wait_for_slot_event(&self) -> Result<Slot>
Wait for slot events (insertion or removal of a token)
sourcepub fn get_slot_event(&self) -> Result<Option<Slot>>
pub fn get_slot_event(&self) -> Result<Option<Slot>>
Get the latest slot event (insertion or removal of a token)
source§impl Pkcs11
impl Pkcs11
sourcepub fn new<P>(filename: P) -> Result<Self>
pub fn new<P>(filename: P) -> Result<Self>
Instantiate a new context from the path of a PKCS11 dynamic library implementation.
sourcepub fn initialize(&self, init_args: CInitializeArgs) -> Result<()>
pub fn initialize(&self, init_args: CInitializeArgs) -> Result<()>
Initialize the PKCS11 library
sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check whether the PKCS11 library has been initialized
sourcepub fn finalize(self)
pub fn finalize(self)
Finalize the PKCS11 library. Indicates that the application no longer needs to use PKCS11. The library is also automatically finalized on drop.
sourcepub fn get_library_info(&self) -> Result<Info>
pub fn get_library_info(&self) -> Result<Info>
Returns the information about the library
sourcepub fn is_fn_supported(&self, function: Function) -> bool
pub fn is_fn_supported(&self, function: Function) -> bool
Check whether a given PKCS11 spec-defined function is supported by this implementation