-
Notifications
You must be signed in to change notification settings - Fork 52
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
Windows TCTI/TBS support #421
Comments
When I do development I use WSL on windows. So that works. Well I have never tried it with a real tpm in WSL don't know if the TPM seen in the WSL might just be a virtual one. I think the points that you stated are correct those are the basic things needed in order to for this to work on windows. If I am not mistaken some of the APIs that might be blocked on windows that might cause some additional problems. |
Since Windows 7(?) a TPM is managed by TPM Base Services (TBS) https://learn.microsoft.com/en-us/windows/win32/tbs/tpm-base-services-portal - which coordinates applications' access to the TPM. One never gets direct TPM access? On Linux one can access /dev/tpm0 directly, and with V2 now the /dev/tpmrm0 service multiplexes applications. I have not found a similar service for Windows, so I suspect the TBS does what tpmrm0 does on Linux? It would make sense that some commands don't work therefor on Windows. Still, Rust is very portable, high-level TPM code should be portable, only the above mentioned low-level plumbing to attach to TBS is missing? Unfortunately, I don't run Windows and have no Win development experience - but it would be nice to just recompile and have a Windows binary for friends/colleagues that do. Hm..... |
Yes, the TBS on windows is some kind of resource access manager. I think it serves the role that arbmd had before it was possible to multiplex access to the TPM device on linux. So if you could use some kind of TCTI based on TBS it should probably work. |
Would you mind to check whether WSDL uses the hardware tpm? |
The computer I use is so old that it does not have a physical TPM. Not even a 1.2 one. |
I'd like to help and might try to tackle this in the future if no one's done it by then, but I have limited bandwidth for now. I'd be more than glad to accept a patch if someone can share a proof of concept, could try it out on my PC. Will try out the TPM2 tools idea from WSL, I'll let you know how that goes when I get to it :) |
As Rust code is very portable, it would be nice to have Rust code that uses the TPM under Linux, and also work the same under Windows. By my first investigation this looks quite possible, if the missing bindings/config are filled-in. Although the official C-based TSS does seem to be less loved on Windows (see their README: "Windows dlls built [...] are currently prototypes"). Unfortunately, I don't have a Windows machine (borrowed one for testing) or Windows dev experience... (hmm... maybe use a Win VM?) |
I tried to build the lib natively on a windows machine. It did not work I got the following error:
But it is interesting to see how much tinkering it will require to get it to build properly. |
That is expected, see my first post, the windows targets are not implemented. However, the more interesting question is which route is easiest to get something running? |
Not sure. This was just me trying to get the build chain up on windows and see what would happen. I will have to look into how to generate bindings next when I have the time. |
Right now I built the tpm2-tss(4.0.1) using Visual Studio 2022 on Windows 11. It required some minor modifications:
|
When I tried (see in my first post: "the included VS solutions seems a bit outdated and needs some tweaks"), I used current git snapshot and had to do 3-5, but I not 1-2 as far as I remember. Hm... probably current git already fixed this? |
I am not sure why I had to do all that but it did not matter to because what I was more intressted in was to try to modify the build.rs in the sys crate in order to recognise the header files on windows. Without pkg I was struggling with how to pass version values. Because no version information is built into the lib or dll files. |
Hey guys, are the windows targets implemented yet? |
No, I have written a little bit of code to try to get it running. But it is experimental in tpm2-tss and my code is not really working yet. |
So this is my progress so far:
|
I need to get this in #471 then I might have something that actually builds. But I have no idea how to test it. Does any one know how to use the Microsoft simulator? |
I have incorporated the latest changes so it now builds under windows. But I have no idea how to test it under windows so if any one have any ideas please provide them so I can see if I can setup some kind of CI for it. |
I'm trying to build this on Windows following the comments above. I addition to LIBCLANG_PATH, I also had to define BINDGEN_EXTRA_CLANG_ARGS with additional -isystem paths for all the system header files. It didn't seem to find them on there own. The clang call seems to pass now, but I'm getting a fatal error from bindgen:
(I'm building with main branch of this repo) Any thoughts about this error? |
What feature flags are you using when building? |
|
Did you build it using powershell or what shell did you use? And how did your build command look like? |
With powershell I did like this:
<C:\Program Files\tpm2-tss-Win64> = The directory where I manually setup the tpm2-tss installation. And the latest from master builds fine for me. |
This is not working for me. How did you install tpm2-tss? Is it a binary install? What version? |
So the I realize that my first description might not have been so easy to understand. This is how the directory should look like. ├── tpm2-tss-Win64
│ ├── include
│ │ ├── tss2
│ │ ├── tss2_*.h
│ ├── lib
│ │ ├── tss2-*.lib
│ │ ├── tss2-*.dll
│ │ ├── tss2-*.pdb
│ └── VERSION |
Yes, I had done that properly. I've tried to match your setup. So I have: Without adding any extra include path, my result was:
I then added an extra include path:
With that my result is:
|
When I am trying to use tpm2-tss master I get the same error. I updated bindgen to 0.69.4. And now it builds fine. |
Confirmed, it is working for me as well with that change. Thank you! |
Reading through this bug (and related bugs) some seem to have succeeded, however I havn't figured it out myself yet. Now... how do I build this project under native Windows, generate the tss-esapi-sys bindings and use the HW TPM? Thank you! |
Currently there is no released version tss-esapi that can build natively on Windows. So you will have to use master if you want to try it out. |
Hello, let context = Context::new(
TctiNameConf::from_environment_variable()
.expect("Failed to get TCTI / TPM2TOOLS_TCTI from environment. Try `export TCTI=device:/dev/tpmrm0`"),
)
.expect("Failed to create Context"); |
On windows you have to use the TBS TCTI. And you are right it seems as it has not been added. And that is being added #523. |
Good new, I hope that #523 will be merged soon ! |
The main branch now have support for the TBS TCTI but the |
I was wondering how this crate would also work on Windows platforms. I found:
The official tpm2-tss project https://github.com/tpm2-software/tpm2-tss contains a tcti-tbs.c driver and the included INSTALL mentions Windows in one paragraph (the description does not sound enthusiastic). The project indeed does compile to DLLs on Windows (the included VS solutions seems a bit outdated and needs some tweaks). I have no knowledge if it is feasible to compile it (easier?) without VS (e.g. under WSL with a Makefile?)
This crate generates the TSS bindings for 4 platforms: aarch64-unknown-linux-gnu, arm-unknown-linux-gnueabi, x86_64-unknown-darwin and x86_64-unknown-linux.gnu, so no Windows bindings, and does not implement Windows TBS as connection option.
Q: What is missing for this crate to work on Windows, too?
...or are there some fundamental issues/structures to implement/rework to make this work?
The text was updated successfully, but these errors were encountered: