@@ -5,7 +5,8 @@ use cryptoki::{
55 error:: Result ,
66 mechanism:: Mechanism ,
77 object:: { Attribute , AttributeType , ObjectHandle } ,
8- session:: Session ,
8+ session:: { Session , UserType } ,
9+ types:: AuthPin ,
910} ;
1011
1112pub use cryptoki;
@@ -23,8 +24,17 @@ pub trait SessionLike {
2324 object : ObjectHandle ,
2425 attributes : & [ AttributeType ] ,
2526 ) -> Result < Vec < Attribute > > ;
27+ fn update_attributes ( & self , object : ObjectHandle , template : & [ Attribute ] ) -> Result < ( ) > ;
2628 fn sign ( & self , mechanism : & Mechanism , key : ObjectHandle , data : & [ u8 ] ) -> Result < Vec < u8 > > ;
2729 fn generate_random_slice ( & self , random_data : & mut [ u8 ] ) -> Result < ( ) > ;
30+ fn wrap_key (
31+ & self ,
32+ mechanism : & Mechanism ,
33+ wrapping_key : ObjectHandle ,
34+ key : ObjectHandle ,
35+ ) -> Result < Vec < u8 > > ;
36+ fn login ( & self , user_type : UserType , pin : Option < & AuthPin > ) -> Result < ( ) > ;
37+ fn logout ( & self ) -> Result < ( ) > ;
2838}
2939
3040impl SessionLike for Session {
@@ -41,12 +51,30 @@ impl SessionLike for Session {
4151 ) -> Result < Vec < Attribute > > {
4252 Session :: get_attributes ( self , object, attributes)
4353 }
54+ fn update_attributes ( & self , object : ObjectHandle , template : & [ Attribute ] ) -> Result < ( ) > {
55+ Session :: update_attributes ( self , object, template)
56+ }
57+
4458 fn sign ( & self , mechanism : & Mechanism , key : ObjectHandle , data : & [ u8 ] ) -> Result < Vec < u8 > > {
4559 Session :: sign ( self , mechanism, key, data)
4660 }
4761 fn generate_random_slice ( & self , random_data : & mut [ u8 ] ) -> Result < ( ) > {
4862 Session :: generate_random_slice ( self , random_data)
4963 }
64+ fn wrap_key (
65+ & self ,
66+ mechanism : & Mechanism ,
67+ wrapping_key : ObjectHandle ,
68+ key : ObjectHandle ,
69+ ) -> Result < Vec < u8 > > {
70+ Session :: wrap_key ( self , mechanism, wrapping_key, key)
71+ }
72+ fn login ( & self , user_type : UserType , pin : Option < & AuthPin > ) -> Result < ( ) > {
73+ Session :: login ( self , user_type, pin)
74+ }
75+ fn logout ( & self ) -> Result < ( ) > {
76+ Session :: logout ( self )
77+ }
5078}
5179
5280impl < ' s > SessionLike for & ' s Session {
@@ -63,12 +91,30 @@ impl<'s> SessionLike for &'s Session {
6391 ) -> Result < Vec < Attribute > > {
6492 Session :: get_attributes ( self , object, attributes)
6593 }
94+ fn update_attributes ( & self , object : ObjectHandle , template : & [ Attribute ] ) -> Result < ( ) > {
95+ Session :: update_attributes ( self , object, template)
96+ }
97+
6698 fn sign ( & self , mechanism : & Mechanism , key : ObjectHandle , data : & [ u8 ] ) -> Result < Vec < u8 > > {
6799 Session :: sign ( self , mechanism, key, data)
68100 }
69101 fn generate_random_slice ( & self , random_data : & mut [ u8 ] ) -> Result < ( ) > {
70102 Session :: generate_random_slice ( self , random_data)
71103 }
104+ fn wrap_key (
105+ & self ,
106+ mechanism : & Mechanism ,
107+ wrapping_key : ObjectHandle ,
108+ key : ObjectHandle ,
109+ ) -> Result < Vec < u8 > > {
110+ Session :: wrap_key ( self , mechanism, wrapping_key, key)
111+ }
112+ fn login ( & self , user_type : UserType , pin : Option < & AuthPin > ) -> Result < ( ) > {
113+ Session :: login ( self , user_type, pin)
114+ }
115+ fn logout ( & self ) -> Result < ( ) > {
116+ Session :: logout ( self )
117+ }
72118}
73119
74120pub trait CryptokiImport {
0 commit comments