diff --git a/cryptoki-rustcrypto/src/lib.rs b/cryptoki-rustcrypto/src/lib.rs index aae154cc..de5a3d47 100644 --- a/cryptoki-rustcrypto/src/lib.rs +++ b/cryptoki-rustcrypto/src/lib.rs @@ -5,7 +5,8 @@ use cryptoki::{ error::Result, mechanism::Mechanism, object::{Attribute, AttributeType, ObjectHandle}, - session::Session, + session::{Session, UserType}, + types::AuthPin, }; pub use cryptoki; @@ -23,8 +24,17 @@ pub trait SessionLike { object: ObjectHandle, attributes: &[AttributeType], ) -> Result>; + fn update_attributes(&self, object: ObjectHandle, template: &[Attribute]) -> Result<()>; fn sign(&self, mechanism: &Mechanism, key: ObjectHandle, data: &[u8]) -> Result>; fn generate_random_slice(&self, random_data: &mut [u8]) -> Result<()>; + fn wrap_key( + &self, + mechanism: &Mechanism, + wrapping_key: ObjectHandle, + key: ObjectHandle, + ) -> Result>; + fn login(&self, user_type: UserType, pin: Option<&AuthPin>) -> Result<()>; + fn logout(&self) -> Result<()>; } impl SessionLike for Session { @@ -41,12 +51,30 @@ impl SessionLike for Session { ) -> Result> { Session::get_attributes(self, object, attributes) } + fn update_attributes(&self, object: ObjectHandle, template: &[Attribute]) -> Result<()> { + Session::update_attributes(self, object, template) + } + fn sign(&self, mechanism: &Mechanism, key: ObjectHandle, data: &[u8]) -> Result> { Session::sign(self, mechanism, key, data) } fn generate_random_slice(&self, random_data: &mut [u8]) -> Result<()> { Session::generate_random_slice(self, random_data) } + fn wrap_key( + &self, + mechanism: &Mechanism, + wrapping_key: ObjectHandle, + key: ObjectHandle, + ) -> Result> { + Session::wrap_key(self, mechanism, wrapping_key, key) + } + fn login(&self, user_type: UserType, pin: Option<&AuthPin>) -> Result<()> { + Session::login(self, user_type, pin) + } + fn logout(&self) -> Result<()> { + Session::logout(self) + } } impl<'s> SessionLike for &'s Session { @@ -63,12 +91,30 @@ impl<'s> SessionLike for &'s Session { ) -> Result> { Session::get_attributes(self, object, attributes) } + fn update_attributes(&self, object: ObjectHandle, template: &[Attribute]) -> Result<()> { + Session::update_attributes(self, object, template) + } + fn sign(&self, mechanism: &Mechanism, key: ObjectHandle, data: &[u8]) -> Result> { Session::sign(self, mechanism, key, data) } fn generate_random_slice(&self, random_data: &mut [u8]) -> Result<()> { Session::generate_random_slice(self, random_data) } + fn wrap_key( + &self, + mechanism: &Mechanism, + wrapping_key: ObjectHandle, + key: ObjectHandle, + ) -> Result> { + Session::wrap_key(self, mechanism, wrapping_key, key) + } + fn login(&self, user_type: UserType, pin: Option<&AuthPin>) -> Result<()> { + Session::login(self, user_type, pin) + } + fn logout(&self) -> Result<()> { + Session::logout(self) + } } pub trait CryptokiImport {