Struct cryptoki::types::session::Session[][src]

pub struct Session<'a> { /* fields omitted */ }

Type that identifies a session

It will automatically get closed (and logout) on drop. Session does not implement Sync to prevent the same Session instance to be used from multiple threads. A Session needs to be created in its own thread or to be passed by ownership to another thread.

Implementations

impl<'a> Session<'a>[src]

pub fn decrypt(
    &self,
    mechanism: &Mechanism,
    key: ObjectHandle,
    encrypted_data: &[u8]
) -> Result<Vec<u8>>
[src]

Single-part decryption operation

impl<'a> Session<'a>[src]

pub fn encrypt(
    &self,
    mechanism: &Mechanism,
    key: ObjectHandle,
    data: &[u8]
) -> Result<Vec<u8>>
[src]

Single-part encryption operation

impl<'a> Session<'a>[src]

pub fn generate_key_pair(
    &self,
    mechanism: &Mechanism,
    pub_key_template: &[Attribute],
    priv_key_template: &[Attribute]
) -> Result<(ObjectHandle, ObjectHandle)>
[src]

Generate a public/private key pair

impl<'a> Session<'a>[src]

pub fn find_objects(&self, template: &[Attribute]) -> Result<Vec<ObjectHandle>>[src]

Search for session objects matching a template

pub fn create_object(&self, template: &[Attribute]) -> Result<ObjectHandle>[src]

Create a new object

pub fn destroy_object(&self, object: ObjectHandle) -> Result<()>[src]

Destroy an object

pub fn get_attribute_info(
    &self,
    object: ObjectHandle,
    attributes: &[AttributeType]
) -> Result<Vec<AttributeInfo>>
[src]

Get the attribute info of an object: if the attribute is present and its size.

pub fn get_attributes(
    &self,
    object: ObjectHandle,
    attributes: &[AttributeType]
) -> Result<Vec<Attribute>>
[src]

Get the attributes values of an object. Ignore the unavailable one. One has to call the get_attribute_info method to check which ones are unavailable.

impl<'a> Session<'a>[src]

pub fn close(&self)[src]

Close a session This will be called on drop as well.

pub fn login(&self, user_type: UserType) -> Result<()>[src]

Log a session in

Do not fail if the user is already logged in. It happens if another session on the same slot has already called the log in operation. Record the login call and only log out when there aren’t anymore sessions requiring log in state.

pub fn logout(&self) -> Result<()>[src]

Log a session out

Will also be called on drop.

impl<'a> Session<'a>[src]

pub fn sign(
    &self,
    mechanism: &Mechanism,
    key: ObjectHandle,
    data: &[u8]
) -> Result<Vec<u8>>
[src]

Sign data in single-part

pub fn verify(
    &self,
    mechanism: &Mechanism,
    key: ObjectHandle,
    data: &[u8],
    signature: &[u8]
) -> Result<()>
[src]

Verify data in single-part

impl<'a> Session<'a>[src]

pub fn init_pin(&self, pin: &str) -> Result<()>[src]

Initialize the normal user’s pin for a token

Trait Implementations

impl<'a> Debug for Session<'a>[src]

impl Drop for Session<'_>[src]

impl<'a> Send for Session<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Session<'a>

impl<'a> !Sync for Session<'a>

impl<'a> Unpin for Session<'a>

impl<'a> !UnwindSafe for Session<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.