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

Make TCTI configurable and force the tests to use the simulator #18

Merged
merged 4 commits into from
Apr 24, 2019

Conversation

diabonas
Copy link
Member

@diabonas diabonas commented Apr 24, 2019

This PR makes allows configuring the TCTI to be used with

  • an additional TSS2_TCTI_CONTEXT argument (can be NULL) for the library functions and
  • the new -T/--tcti option or the environment variable TPM2TOTP_TCTI for the tpm2-totp command.

The syntax and the implementation for the command option/environment variable follow the implementations in tpm2-tools (tpm2-software/tpm2-tools#765, tpm2_options.c and tpm2_tcti_ldr.c) and tpm2-tss-engine (tpm2-software/tpm2-tss-engine#62, tpm2-tss-engine-tcti.c).

Using these configuration options, we can force the tests to use the TPM simulator, enabling the possibility to run the tests (in parallel) on systems with existing hardware TPMs. The implementation is adapted from tpm2-tss-engine (tpm2-software/tpm2-tss-engine#107, sh_log_compiler.sh).

Closes #7.

Signed-off-by: Jonas Witschel <diabonas@gmx.de>
The tcti context can be set using this option or via the environment
variable TPM2TOTP_TCTI. The syntax follows the one from tpm2-tools and
tpm2-tss-engine.

The code is implemented in a separate file so that it can be reused in
the integration tests.

Signed-off-by: Jonas Witschel <diabonas@gmx.de>
@codecov
Copy link

codecov bot commented Apr 24, 2019

Codecov Report

Merging #18 into master will decrease coverage by 3.8%.
The diff coverage is 65.8%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #18      +/-   ##
==========================================
- Coverage   84.34%   80.53%   -3.81%     
==========================================
  Files           3        4       +1     
  Lines         658      745      +87     
==========================================
+ Hits          555      600      +45     
- Misses        103      145      +42
Impacted Files Coverage Δ
src/libtpm2-totp.c 84.66% <100%> (ø) ⬆️
src/tpm2-totp-tcti.c 52.23% <52.23%> (ø)
src/tpm2-totp.c 81.06% <68.18%> (-1.59%) ⬇️
test/libtpm2-totp.c 81.25% <79.41%> (-8.23%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8dba9e8...bde2981. Read the comment docs.

Currently the integration tests use the first TPM they find on the system.
This commit starts a TPM simulator for every integration test and
configures the TCTI environment variable to use it, allowing parallel
execution of the tests.

The test harness is adapted from the one in tpm2-tss-engine.

Signed-off-by: Jonas Witschel <diabonas@gmx.de>
This is possible after the preceeding changes to the integration test
harness.

Signed-off-by: Jonas Witschel <diabonas@gmx.de>
Copy link
Member

@AndreasFuchsTPM AndreasFuchsTPM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the effort.

I'll merge it for now, but before the next release, I want to get rid of the static tcti variable.

However, I'd wait for https://github.com/tpm2-software/tpm2-tss/wiki/TCTI-loader-library to be done and then it should be easy to switch over, given all the existing work already done.

@AndreasFuchsTPM AndreasFuchsTPM merged commit 7196820 into tpm2-software:master Apr 24, 2019
@AndreasFuchsTPM AndreasFuchsTPM mentioned this pull request Apr 24, 2019
@diabonas
Copy link
Member Author

Awesome, tss2-tctildr will indeed make things much easier 👍

@diabonas diabonas deleted the tcti-config branch April 24, 2019 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make TCTI configurable
2 participants