@@ -22,6 +22,7 @@ const MSSIM: &str = "mssim";
22
22
const SWTPM : & str = "swtpm" ;
23
23
const TABRMD : & str = "tabrmd" ;
24
24
const LIBTPMS : & str = "libtpms" ;
25
+ const TBS : & str = "tbs" ;
25
26
26
27
/// TCTI Context created via a TCTI Loader Library.
27
28
/// Wrapper around the TSS2_TCTI_CONTEXT structure.
@@ -148,6 +149,10 @@ pub enum TctiNameConf {
148
149
///
149
150
/// For more information about configuration, see [this page](https://www.mankier.com/3/Tss2_Tcti_Tabrmd_Init)
150
151
Tabrmd ( TabrmdConfig ) ,
152
+ /// Connect to the tpm using the Trusted Platform Module (TPM) Base Services (TBS) on Windows.
153
+ ///
154
+ /// For more information about TBS, see [this page](https://learn.microsoft.com/en-us/windows/win32/tbs/about-tbs)
155
+ Tbs ,
151
156
}
152
157
153
158
impl TctiNameConf {
@@ -180,6 +185,7 @@ impl TryFrom<TctiNameConf> for CString {
180
185
TctiNameConf :: Swtpm ( ..) => SWTPM ,
181
186
TctiNameConf :: Tabrmd ( ..) => TABRMD ,
182
187
TctiNameConf :: LibTpms { .. } => LIBTPMS ,
188
+ TctiNameConf :: Tbs => TBS ,
183
189
} ;
184
190
185
191
let tcti_conf = match tcti {
@@ -213,6 +219,7 @@ impl TryFrom<TctiNameConf> for CString {
213
219
TctiNameConf :: LibTpms { state } => {
214
220
state. map ( |s| s. display ( ) . to_string ( ) ) . unwrap_or_default ( )
215
221
}
222
+ TctiNameConf :: Tbs => String :: new ( ) ,
216
223
} ;
217
224
218
225
if tcti_conf. is_empty ( ) {
@@ -265,6 +272,10 @@ impl FromStr for TctiNameConf {
265
272
} ) ;
266
273
}
267
274
275
+ if config_str. trim ( ) == TBS {
276
+ return Ok ( TctiNameConf :: Tbs ) ;
277
+ }
278
+
268
279
Err ( Error :: WrapperError ( WrapperErrorKind :: InvalidParam ) )
269
280
}
270
281
}
@@ -356,6 +367,10 @@ fn validate_from_str_tcti() {
356
367
357
368
let tcti = TctiNameConf :: from_str ( "libtpms" ) . unwrap ( ) ;
358
369
assert_eq ! ( tcti, TctiNameConf :: LibTpms { state: None } ) ;
370
+
371
+ let tcti_tbs = TctiNameConf :: from_str ( "tbs" )
372
+ . expect ( "It should be possible to convert the string 'tbs' into a TctiNameConf object." ) ;
373
+ assert_eq ! ( tcti_tbs, TctiNameConf :: Tbs ) ;
359
374
}
360
375
361
376
/// Configuration for a Device TCTI context
0 commit comments