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

Enable different key sizes and curves for EK and AK #846

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

THS-on
Copy link
Member

@THS-on THS-on commented Oct 1, 2024

This implements a selection of the different key sizes for RSA and curves for ECC for EK and AK using the backported changes in rust-tss-esapi.

Further this then also enables us to use EK certs for non default key types.

Note this is currently blocked until parallaxsecond/rust-tss-esapi#546 gets merged and we have a new release.

@THS-on
Copy link
Member Author

THS-on commented Oct 1, 2024

Note that this now outputs in the quote rsa2048 instead of rsa, so we would probably need to update also something on the server side.

Edit: decided to make the string encoding for RSA 2024 just rsa

@THS-on THS-on force-pushed the ecc-ek-cert branch 4 times, most recently from cde261e to fdbdb4a Compare October 3, 2024 09:25
Copy link

codecov bot commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 59.83607% with 49 lines in your changes missing coverage. Please review.

Project coverage is 60.78%. Comparing base (2f7b3ad) to head (5219bae).
Report is 86 commits behind head on master.

Files with missing lines Patch % Lines
keylime/src/algorithms.rs 50.00% 26 Missing ⚠️
keylime/src/tpm.rs 68.65% 21 Missing ⚠️
keylime-agent/src/main.rs 33.33% 2 Missing ⚠️
Additional details and impacted files
Flag Coverage Δ
e2e-testsuite 60.78% <59.83%> (+3.19%) ⬆️
upstream-unit-tests 60.78% <59.83%> (+9.77%) ⬆️

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

Files with missing lines Coverage Δ
keylime-agent/src/agent_handler.rs 57.44% <ø> (ø)
keylime-agent/src/common.rs 67.94% <ø> (ø)
keylime-agent/src/main.rs 24.18% <33.33%> (-1.83%) ⬇️
keylime/src/tpm.rs 72.04% <68.65%> (+5.85%) ⬆️
keylime/src/algorithms.rs 65.69% <50.00%> (-6.84%) ⬇️

... and 8 files with indirect coverage changes

@THS-on
Copy link
Member Author

THS-on commented Oct 17, 2024

This is now mostly blocked on a new stable release of the tss-esapi create.

There is also the issue that the parsing of the EK TPM structure goes somewhere wrong, as the verifier says that the EK public key in the TSS structure and the one in the EK certificate don't match. I'll investigate where this goes wrong.

@THS-on
Copy link
Member Author

THS-on commented Oct 21, 2024

This PR is also blocked on parallaxsecond/rust-tss-esapi#552 being backported, otherwise the EK verification will always fail.

@THS-on
Copy link
Member Author

THS-on commented Nov 12, 2024

@ansasaki this is now fully working. We still need to wait for a new release of tss-esapi bindings to actually use it.

@THS-on THS-on force-pushed the ecc-ek-cert branch 2 times, most recently from 823df43 to f3d69ba Compare December 19, 2024 13:21
Signed-off-by: Thore Sommer <[email protected]>
@THS-on THS-on force-pushed the ecc-ek-cert branch 2 times, most recently from 2c4ee14 to 9a9506e Compare December 23, 2024 13:42
@THS-on
Copy link
Member Author

THS-on commented Dec 23, 2024

Registration and EK verification using swtpm with the Nist384 curve works. Unfortunatly something with is broken when trying to verify the actual quote:

2024-12-23 16:16:17.166 - keylime.tpm - ERROR - Error verifying quote: 
2024-12-23 16:16:17.166 - keylime.tpm - ERROR - 
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/keylime/tpm/tpm_main.py", line 176, in _tpm2_checkquote
    pcrs_dict = tpm_util.checkquote(aikFromRegistrar, nonce, sigblob, quoteblob, pcrblob, hash_alg)
  File "/usr/local/lib/python3.13/site-packages/keylime/tpm/tpm_util.py", line 249, in checkquote
    verify(pubkey, signature, quote_digest, hashfunc)
    ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/keylime/tpm/tpm_util.py", line 82, in verify
    pubkey.verify(sig, digest, ec.ECDSA(Prehashed(hashfunc)))
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cryptography.exceptions.InvalidSignature
2024-12-23 16:16:17.167 - keylime.tpm - WARNING - Quote for agent d432fbb3-d2f1-4a97-9ef7-75bd81c00000 does not contain any PCRs. Make sure that the TPM supports sha256 PCR banks
2024-12-23 16:16:17.167 - keylime.tpm - ERROR - Binding PCR #16 was not included in the quote (from agent d432fbb3-d2f1-4a97-9ef7-75bd81c00000), but is required
2024-12-23 16:16:17.167 - keylime.tenant - ERROR - TPM Quote from Agent d432fbb3-d2f1-4a97-9ef7-75bd81c00000 (127.0.0.1:9002) is invalid for nonce: aY76KkOhWwK53FlNocI1

Might be an padding issue or something else that we missed.

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.

4 participants