Struct cryptoki::context::Pkcs11

source ·
pub struct Pkcs11 { /* private fields */ }
Expand description

Main PKCS11 context. Should usually be unique per application.

Implementations§

source§

impl Pkcs11

source

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.

source

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

source

pub fn get_slots_with_token(&self) -> Result<Vec<Slot>>

Get all slots available with a token

source

pub fn get_all_slots(&self) -> Result<Vec<Slot>>

Get all slots

source

pub fn get_slots_with_initialized_token(&self) -> Result<Vec<Slot>>

Get all slots available with a token

source

pub fn init_token(&self, slot: Slot, pin: &AuthPin, label: &str) -> Result<()>

Initialize a token

Currently will use an empty label for all tokens.

source

pub fn get_slot_info(&self, slot: Slot) -> Result<SlotInfo>

Returns the slot info

source

pub fn get_token_info(&self, slot: Slot) -> Result<TokenInfo>

Returns information about a specific token

source

pub fn get_mechanism_list(&self, slot: Slot) -> Result<Vec<MechanismType>>

Get all mechanisms support by a slot

source

pub fn get_mechanism_info( &self, slot: Slot, type_: MechanismType ) -> Result<MechanismInfo>

Get detailed information about a mechanism for a slot

source

pub fn wait_for_slot_event(&self) -> Result<Slot>

Wait for slot events (insertion or removal of a token)

source

pub fn get_slot_event(&self) -> Result<Option<Slot>>

Get the latest slot event (insertion or removal of a token)

source§

impl Pkcs11

source

pub fn new<P>(filename: P) -> Result<Self>
where P: AsRef<Path>,

Instantiate a new context from the path of a PKCS11 dynamic library implementation.

source

pub fn initialize(&self, init_args: CInitializeArgs) -> Result<()>

Initialize the PKCS11 library

source

pub fn is_initialized(&self) -> bool

Check whether the PKCS11 library has been initialized

source

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.

source

pub fn get_library_info(&self) -> Result<Info>

Returns the information about the library

source

pub fn is_fn_supported(&self, function: Function) -> bool

Check whether a given PKCS11 spec-defined function is supported by this implementation

Trait Implementations§

source§

impl Clone for Pkcs11

source§

fn clone(&self) -> Pkcs11

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Pkcs11

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Pkcs11

§

impl Send for Pkcs11

§

impl Sync for Pkcs11

§

impl Unpin for Pkcs11

§

impl !UnwindSafe for Pkcs11

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.