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

tests: Add script to generate IAK and IDevID certificates #883

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

ansasaki
Copy link
Contributor

@ansasaki ansasaki commented Dec 4, 2024

The script generates a test root CA and intermediate CA keys and certificates. The output directory can be set via the --output option, and the CA password with the --pwd option. If an output directory is not set, a temporary directory is created and the certificates are placed there.

Then, the script generates the IDevID and IAK keys inside the TPM and respective certificates.

The script requires the tpm2-openssl provider to access the keys inside the TPM.

It is recommended to setup the TCTI, TPM2TOOLS_TCTI, and TPM2OPENSSL_TCTI environment variables to select the TPM to use. If not set, the default /dev/tpmrm0 will be used instead.

This also modifies the tests/setup_swtpm.sh and tests/run.sh to configure the TPM2OPENSSL_TCTI to use the swtpm with the tpm2-openssl provider.

This is based on the test contributed by @Isaac-Matthews on https://github.com/RedHat-SP-Security/keylime-tests

@ansasaki ansasaki force-pushed the improve_tpm_testing branch 3 times, most recently from 82c1f6c to 89cff6e Compare December 5, 2024 09:13
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.19%. Comparing base (2f7b3ad) to head (47dc78d).
Report is 79 commits behind head on master.

Additional details and impacted files
Flag Coverage Δ
e2e-testsuite 59.19% <ø> (+1.61%) ⬆️
upstream-unit-tests 59.19% <ø> (+8.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 11 files with indirect coverage changes

Copy link
Contributor

@Isaac-Matthews Isaac-Matthews left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@sergio-correia sergio-correia left a comment

Choose a reason for hiding this comment

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

Thanks, it looks good to me. I would run it through shellcheck and work on the "double quote to prevent globbing and word splitting" warnings, as they usually make sense for at least for paths.

@ansasaki
Copy link
Contributor Author

ansasaki commented Dec 6, 2024

Thanks, it looks good to me. I would run it through shellcheck and work on the "double quote to prevent globbing and word splitting" warnings, as they usually make sense for at least for paths.

Fixed the issues reported by shellcheck. Thanks for the review!

The script generates a test root CA and intermediate CA keys and
certificates. The output directory can be set via the --output option,
and the CA password with the --pwd option.  If an output directory is
not set, a temporary directory is created and the certificates are
placed there.

Then, the script generates the IDevID and IAK keys inside the TPM and
respective certificates.

The script requires the tpm2-openssl provider to access the keys inside
the TPM.

It is recommended to set the TCTI, TPM2TOOLS_TCTI, and TPM2OPENSSL_TCTI
environment variables to set which TPM to use when running the script.
If these variables are not set, the default value `device:/dev/tpmrm0`
is used instead.

This also modifies the tests/setup_swtpm.sh and tests/run.sh to
configure the TPM2OPENSSL_TCTI to use the swtpm with the tpm2-openssl
provider.

Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
@ansasaki ansasaki force-pushed the improve_tpm_testing branch from c1cf781 to 47dc78d Compare December 6, 2024 16:10
@ansasaki ansasaki merged commit 2a91d66 into keylime:master Dec 9, 2024
10 checks passed
@ansasaki ansasaki deleted the improve_tpm_testing branch December 9, 2024 08:24
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.

8 participants