Skip to content

Commit bc05e83

Browse files
Adds a TBS TctiNameConf.
When parallaxsecond#477 got merged it became possible to build using a path to the ```tpm2-tss``` installation instead of depending on ```pkg-config```. This made it possible to build under Windows. To further increase the support for the windows platform this commit moves the option for TBS TCTI that is being introduced in parallaxsecond#523 into a separate commit. This commit also updates the documentation regarding building using an installation folder. Co-authored-by: Thomas Epperson <[email protected]> Signed-off-by: Jesper Brynolf <[email protected]>
1 parent 1d8337c commit bc05e83

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tss-esapi-sys/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,26 @@ wrapper script around `pkg-config` can be seen
6262
Be advised that in some cases the linker used might need to be set manually in
6363
`.cargo/config`.
6464

65+
## Locally built tpm2-tss
66+
It is now possible to specify an installation path when building the crate. This will
67+
make the build process trying to find all the libraries and header files it needs from
68+
installation path instead of using `pkg-config`.
69+
70+
The `TPM2_TSS_PATH` environment variable name is used to specify the path to the installation.
71+
The installation is required to have a specific layout.
72+
73+
```md
74+
Installation folder
75+
├── bin (Optional)
76+
│ ├── tss2-*.dll (Windows)
77+
├── include (Required)
78+
│ ├── tss2
79+
│ │ ├── tss2_*.h
80+
├── lib (Required)
81+
│ ├── tss2-*.lib (Windows)
82+
│ ├── tss2-*.so (Nix)
83+
│ ├── tss2-*.pdb (Windows)
84+
└── VERSION (Required)
85+
```
86+
6587
*Copyright 2021 Contributors to the Parsec project.*

tss-esapi/src/tcti_ldr.rs

+15
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const MSSIM: &str = "mssim";
2222
const SWTPM: &str = "swtpm";
2323
const TABRMD: &str = "tabrmd";
2424
const LIBTPMS: &str = "libtpms";
25+
const TBS: &str = "tbs";
2526

2627
/// TCTI Context created via a TCTI Loader Library.
2728
/// Wrapper around the TSS2_TCTI_CONTEXT structure.
@@ -148,6 +149,10 @@ pub enum TctiNameConf {
148149
///
149150
/// For more information about configuration, see [this page](https://www.mankier.com/3/Tss2_Tcti_Tabrmd_Init)
150151
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,
151156
}
152157

153158
impl TctiNameConf {
@@ -180,6 +185,7 @@ impl TryFrom<TctiNameConf> for CString {
180185
TctiNameConf::Swtpm(..) => SWTPM,
181186
TctiNameConf::Tabrmd(..) => TABRMD,
182187
TctiNameConf::LibTpms { .. } => LIBTPMS,
188+
TctiNameConf::Tbs => TBS,
183189
};
184190

185191
let tcti_conf = match tcti {
@@ -213,6 +219,7 @@ impl TryFrom<TctiNameConf> for CString {
213219
TctiNameConf::LibTpms { state } => {
214220
state.map(|s| s.display().to_string()).unwrap_or_default()
215221
}
222+
TctiNameConf::Tbs => String::new(),
216223
};
217224

218225
if tcti_conf.is_empty() {
@@ -265,6 +272,10 @@ impl FromStr for TctiNameConf {
265272
});
266273
}
267274

275+
if config_str.trim() == TBS {
276+
return Ok(TctiNameConf::Tbs);
277+
}
278+
268279
Err(Error::WrapperError(WrapperErrorKind::InvalidParam))
269280
}
270281
}
@@ -356,6 +367,10 @@ fn validate_from_str_tcti() {
356367

357368
let tcti = TctiNameConf::from_str("libtpms").unwrap();
358369
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);
359374
}
360375

361376
/// Configuration for a Device TCTI context

0 commit comments

Comments
 (0)