Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a TBS TctiNameConf. #545

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tss-esapi-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,26 @@ wrapper script around `pkg-config` can be seen
Be advised that in some cases the linker used might need to be set manually in
`.cargo/config`.

## Locally built tpm2-tss
It is now possible to specify an installation path when building the crate. This will
make the build process trying to find all the libraries and header files it needs from
installation path instead of using `pkg-config`.

The `TPM2_TSS_PATH` environment variable name is used to specify the path to the installation.
The installation is required to have a specific layout.

```md
Installation folder
├── bin (Optional)
│ ├── tss2-*.dll (Windows)
├── include (Required)
│ ├── tss2
│ │ ├── tss2_*.h
├── lib (Required)
│ ├── tss2-*.lib (Windows)
│ ├── tss2-*.so (Nix)
│ ├── tss2-*.pdb (Windows)
└── VERSION (Required)
```

*Copyright 2021 Contributors to the Parsec project.*
15 changes: 15 additions & 0 deletions tss-esapi/src/tcti_ldr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const MSSIM: &str = "mssim";
const SWTPM: &str = "swtpm";
const TABRMD: &str = "tabrmd";
const LIBTPMS: &str = "libtpms";
const TBS: &str = "tbs";

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

impl TctiNameConf {
Expand Down Expand Up @@ -180,6 +185,7 @@ impl TryFrom<TctiNameConf> for CString {
TctiNameConf::Swtpm(..) => SWTPM,
TctiNameConf::Tabrmd(..) => TABRMD,
TctiNameConf::LibTpms { .. } => LIBTPMS,
TctiNameConf::Tbs => TBS,
};

let tcti_conf = match tcti {
Expand Down Expand Up @@ -213,6 +219,7 @@ impl TryFrom<TctiNameConf> for CString {
TctiNameConf::LibTpms { state } => {
state.map(|s| s.display().to_string()).unwrap_or_default()
}
TctiNameConf::Tbs => String::new(),
};

if tcti_conf.is_empty() {
Expand Down Expand Up @@ -265,6 +272,10 @@ impl FromStr for TctiNameConf {
});
}

if config_str.trim() == TBS {
return Ok(TctiNameConf::Tbs);
}

Err(Error::WrapperError(WrapperErrorKind::InvalidParam))
}
}
Expand Down Expand Up @@ -356,6 +367,10 @@ fn validate_from_str_tcti() {

let tcti = TctiNameConf::from_str("libtpms").unwrap();
assert_eq!(tcti, TctiNameConf::LibTpms { state: None });

let tcti_tbs = TctiNameConf::from_str("tbs")
.expect("It should be possible to convert the string 'tbs' into a TctiNameConf object.");
assert_eq!(tcti_tbs, TctiNameConf::Tbs);
}

/// Configuration for a Device TCTI context
Expand Down
Loading