@@ -21,6 +21,7 @@ const DEVICE: &str = "device";
2121const  MSSIM :  & str  = "mssim" ; 
2222const  SWTPM :  & str  = "swtpm" ; 
2323const  TABRMD :  & str  = "tabrmd" ; 
24+ const  LIBTPMS :  & str  = "libtpms" ; 
2425
2526/// TCTI Context created via a TCTI Loader Library. 
2627/// Wrapper around the TSS2_TCTI_CONTEXT structure. 
@@ -139,6 +140,8 @@ pub enum TctiNameConf {
139140/// 
140141/// For more information about configuration, see [this page](https://www.mankier.com/3/Tss2_Tcti_Mssim_Init) 
141142Swtpm ( TpmSimulatorConfig ) , 
143+     /// Connect to a TPM (simulator) available as a library 
144+ LibTpms , 
142145    /// Connect to a TPM through an Access Broker/Resource Manager daemon 
143146/// 
144147/// For more information about configuration, see [this page](https://www.mankier.com/3/Tss2_Tcti_Tabrmd_Init) 
@@ -174,6 +177,7 @@ impl TryFrom<TctiNameConf> for CString {
174177            TctiNameConf :: Mssim ( ..)  => MSSIM , 
175178            TctiNameConf :: Swtpm ( ..)  => SWTPM , 
176179            TctiNameConf :: Tabrmd ( ..)  => TABRMD , 
180+             TctiNameConf :: LibTpms  => LIBTPMS , 
177181        } ; 
178182
179183        let  tcti_conf = match  tcti { 
@@ -204,6 +208,7 @@ impl TryFrom<TctiNameConf> for CString {
204208            TctiNameConf :: Tabrmd ( config)  => { 
205209                format ! ( "bus_name={},bus_type={}" ,  config. bus_name,  config. bus_type) 
206210            } 
211+             TctiNameConf :: LibTpms  => String :: new ( ) , 
207212        } ; 
208213
209214        if  tcti_conf. is_empty ( )  { 
@@ -247,6 +252,11 @@ impl FromStr for TctiNameConf {
247252            ) ?) ) ; 
248253        } 
249254
255+         let  libtpms_pattern = Regex :: new ( r"^libtpms$" ) . unwrap ( ) ;  //should not fail 
256+         if  let  Some ( _captures)  = libtpms_pattern. captures ( config_str)  { 
257+             return  Ok ( TctiNameConf :: LibTpms ) ; 
258+         } 
259+ 
250260        Err ( Error :: WrapperError ( WrapperErrorKind :: InvalidParam ) ) 
251261    } 
252262} 
0 commit comments