@@ -78,7 +78,6 @@ impl Pkcs11Impl {
7878#[ derive( Debug ) ]
7979pub struct Pkcs11 {
8080 pub ( crate ) impl_ : Pkcs11Impl ,
81- initialized : RwLock < bool > ,
8281}
8382
8483impl Pkcs11 {
@@ -133,7 +132,6 @@ impl Pkcs11 {
133132 _pkcs11_lib : pkcs11_lib,
134133 function_list : FunctionList :: V3_2 ( * list32_ptr) ,
135134 } ,
136- initialized : RwLock :: new ( false ) ,
137135 } ) ;
138136 }
139137 let list30_ptr: * mut cryptoki_sys:: CK_FUNCTION_LIST_3_0 =
@@ -143,7 +141,6 @@ impl Pkcs11 {
143141 _pkcs11_lib : pkcs11_lib,
144142 function_list : FunctionList :: V3_0 ( v30tov32 ( * list30_ptr) ) ,
145143 } ,
146- initialized : RwLock :: new ( false ) ,
147144 } ) ;
148145 }
149146 /* fall back to the 2.* API */
@@ -159,22 +156,12 @@ impl Pkcs11 {
159156 _pkcs11_lib : pkcs11_lib,
160157 function_list : FunctionList :: V2 ( v2tov3 ( * list_ptr) ) ,
161158 } ,
162- initialized : RwLock :: new ( false ) ,
163159 } )
164160 }
165161
166162 /// Initialize the PKCS11 library
167163 pub fn initialize ( & self , init_args : CInitializeArgs ) -> Result < ( ) > {
168- let mut init_lock = self . initialized . write ( ) . expect ( "lock not to be poisoned" ) ;
169- if * init_lock {
170- Err ( Error :: AlreadyInitialized ) ?
171- }
172- initialize ( self , init_args) . map ( |_| * init_lock = true )
173- }
174-
175- /// Check whether the PKCS11 library has been initialized
176- pub fn is_initialized ( & self ) -> bool {
177- * self . initialized . read ( ) . expect ( "lock not to be poisoned" )
164+ initialize ( self , init_args)
178165 }
179166
180167 /// Finalize the PKCS11 library. Indicates that the application no longer needs to use PKCS11.
0 commit comments