Blog | G5 Cyber Security

TPM EK Hash as Device Fingerprint

TL;DR

Yes, the hash of a TPM’s Endorsement Key (EK) public key can be used to fingerprint a device. However, it’s not foolproof and has limitations. It’s a good starting point but shouldn’t be relied upon as the sole identifier.

How to Use a TPM EK Hash for Device Fingerprinting

  1. Understand the Endorsement Key (EK)
  • Extract the EK Public Key
  • You’ll need tools that can communicate with the TPM. Common options include:

    Using tpm2-tools, you can extract the EK public key with:

    tpm2_getpublic -g EK

    This command will output the EK public key in a specific format (usually X.509 or raw bytes).

  • Hash the Public Key
  • To create a fingerprint, you need to hash the EK public key using a cryptographic hash function like SHA-256.

    openssl dgst -sha256 < /path/to/ek_public_key | awk '{print $2}'

    This command uses openssl to calculate the SHA-256 hash of the EK public key file and then extracts just the hash value.

  • Store and Compare Hashes
  • Important Considerations & Limitations

    1. TPM Replacement: If a TPM is replaced, the EK hash will change, invalidating the fingerprint. This is the biggest limitation.
    2. Firmware Updates: Some firmware updates *might* alter the EK, though this is rare. Always verify after major firmware changes.
    3. Platform Configuration Registers (PCRs): PCRs store hashes of boot components. While not directly the EK hash, they provide a more robust attestation mechanism as they are harder to spoof than just relying on the EK. Consider using PCR values in conjunction with the EK hash for stronger identification.
    4. Privacy: Be mindful of privacy implications when storing and sharing device fingerprints.
    5. EKSR (Endorsement Key Signing Key): Some TPMs have an EKSR, which can be used to sign data. While less common for fingerprinting, it's another potential identifier.

    Example Scenario

    Imagine you’re building a secure boot process. You could:

    1. Extract the EK hash during initial device setup.
    2. Store this hash in a trusted database.
    3. During each boot, recalculate the EK hash and compare it to the stored value. If they match, you can proceed with booting; otherwise, signal an error (potential tampering).

    cyber security Best Practices

    Always combine the EK hash with other attestation methods like PCR measurements for a more secure device identification solution. Regularly review your implementation and update it based on new cyber security threats.

    Exit mobile version