question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Identity quote failure when using TPM devices with manufacturer certificates signed by ECC keys

See original GitHub issue

Environment

  • OS / version: OpenBMC Yocto “phosphor”, Ubuntu 20.04, Ubuntu 22.04
  • Processor architecture: ARM cortex A7, AMD x86_64 (mostly irrelevant)
  • TPM Manufacturer: Nuvoton TPM signed by NUVO_1111.pem, but reproducible with swtpm.
  • Keylime version: 6.4.0, but problem is reproducible with current master branch (Aug 8 2022)

Description

During the initial identity quote at the start of attestation the function tpm_main.verify_ek() is invoked by the keylime tenant to ensure that the TPM device on the agent is genuine. The process involves listing all the manufacturer certificates in the tpm_cert_store directory, finding one that has an Issuer that matches the EK cert’s, and then running verify().

When the manufacturer certificate signature algorithm is EC(*) the verify() function call fails, resulting in attestation failure.

Expected behavior vs. actual behavior

  • Expected behavior: a Nuvoton device certified by the file keylime/tmp_cert_store/NUVO0_1111.pem should work.
  • Actual behavior: said Nuvoton TPM device will never result in successful attestation, because the NUVO_1111.pem file is signed with an ECC key. The following error is generated during the identity quote phase by the tenant:
2022-08-09 14:43:15.313 - keylime.tpm - ERROR - verify() takes 4 positional arguments but 5 were given
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/keylime-6.4.0-py3.9.egg/keylime/tpm/tpm_main.py", line 857, in verify_ek
    signcert.public_key().verify(
TypeError: verify() takes 4 positional arguments but 5 were given

Steps to reproduce problem

1A. Install keylime attestation on any system with a Nuvoton chip that is certified by the NUVO_1111.pem file. 1B. Alternatively, create a swtpm instance in which the manufacturer cert is signed by an ECC key. 2. Start the keylime agent and let it register. Registration should execute normally. 3. Attempt to start attestation with the keylime_tenant -c add command. Expect the error message above to show up.

Root cause analysis

The problem is with the following sequence in the TPM code (keylime/tpm/tpm_main.py):

                    signcert.public_key().verify(
                        ek509.signature,
                        ek509.tbs_certificate_bytes,
                        padding.PKCS1v15(),
                        ek509.signature_hash_algorithm,
                    )

The call to the verify() method makes an assumption that (including “self”) 5 arguments are needed. But on elliptic curve public keys only 4 arguments are expected (there is no padding).

This discrepancy causes the problem.

Proposed (tentative) fix

Insert an if statement to handle the different verify() method signatures in python cryptography.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
sergio-correiacommented, Nov 11, 2022

@THS-on: yep. @kkaarreell is adding a test for this in #1175

0reactions
THS-oncommented, Nov 10, 2022

@sergio-correia is this now fully fixed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TPM 2.0 Keys for Device Identity and Attestation
A certificate includes a public key (or “key” as described above), data about the “subject” (identity) conveyed and a signature over the entire ......
Read more >
TPM Key Attestation | Microsoft Learn
A user certificate with a TPM-attested key provides higher security assurance, backed up by non-exportability, anti-hammering, and isolation of ...
Read more >
Keys | SpringerLink
USE CASE: CERTIFYING A TPM QUOTE KEY​​ A signing key is used for attestation: for example, to quote (sign) a set of PCR...
Read more >
draft-ietf-rats-yang-tpm-charra-10
This RPC allows a Verifier to request signed TPM PCRs (TPM Quote ... using the TPM key identified by sig-key-id) </quote-signature> ...
Read more >
Protection Profile PC Client Specific TPM TCG Published
on specification licensing through membership agreements. ... Key, Platform Keys and corresponding Platform Certificates.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found