Skip to content

Commit 3c02ff8

Browse files
committed
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-author: Thomas Thomas Epperson <[email protected]> Signed-off-by: Jesper Brynolf <[email protected]>
1 parent 8ec8381 commit 3c02ff8

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
@@ -21,6 +21,7 @@ const DEVICE: &str = "device";
2121
const MSSIM: &str = "mssim";
2222
const SWTPM: &str = "swtpm";
2323
const TABRMD: &str = "tabrmd";
24+
const TBS: &str = "tbs";
2425

2526
/// TCTI Context created via a TCTI Loader Library.
2627
/// Wrapper around the TSS2_TCTI_CONTEXT structure.
@@ -143,6 +144,10 @@ pub enum TctiNameConf {
143144
///
144145
/// For more information about configuration, see [this page](https://www.mankier.com/3/Tss2_Tcti_Tabrmd_Init)
145146
Tabrmd(TabrmdConfig),
147+
/// Connect to the tpm using the Trusted Platform Module (TPM) Base Services (TBS) on Windows.
148+
///
149+
/// For more information about TBS, see [this page](https://learn.microsoft.com/en-us/windows/win32/tbs/about-tbs)
150+
Tbs,
146151
}
147152

148153
impl TctiNameConf {
@@ -174,6 +179,7 @@ impl TryFrom<TctiNameConf> for CString {
174179
TctiNameConf::Mssim(..) => MSSIM,
175180
TctiNameConf::Swtpm(..) => SWTPM,
176181
TctiNameConf::Tabrmd(..) => TABRMD,
182+
TctiNameConf::Tbs => TBS,
177183
};
178184

179185
let tcti_conf = match tcti {
@@ -204,6 +210,7 @@ impl TryFrom<TctiNameConf> for CString {
204210
TctiNameConf::Tabrmd(config) => {
205211
format!("bus_name={},bus_type={}", config.bus_name, config.bus_type)
206212
}
213+
TctiNameConf::Tbs => String::new(),
207214
};
208215

209216
if tcti_conf.is_empty() {
@@ -247,6 +254,10 @@ impl FromStr for TctiNameConf {
247254
)?));
248255
}
249256

257+
if config_str.trim() == TBS {
258+
return Ok(TctiNameConf::Tbs);
259+
}
260+
250261
Err(Error::WrapperError(WrapperErrorKind::InvalidParam))
251262
}
252263
}
@@ -327,6 +338,10 @@ fn validate_from_str_tcti() {
327338

328339
let tcti = TctiNameConf::from_str("tabrmd").unwrap();
329340
assert_eq!(tcti, TctiNameConf::Tabrmd(Default::default()));
341+
342+
let tcti_tbs = TctiNameConf::from_str("tbs")
343+
.expect("It should be possible to convert the string 'tbs' into a TctiNameConf object.");
344+
assert_eq!(tcti_tbs, TctiNameConf::Tbs);
330345
}
331346

332347
/// Configuration for a Device TCTI context

0 commit comments

Comments
 (0)