Giter Site home page Giter Site logo

Comments (2)

ElMostafaIdrassi avatar ElMostafaIdrassi commented on May 19, 2024

From the spec, a TPM2_PCR_Read command only returns 1 single TPML_DIGEST. Knowing that a TPML_DIGEST can contain at most 8 digests, I think it is safe to say that the TPM can at most return 8 PCRs Digests per TPM2_PCR_Read command.

go-tpm/tpm2/tpm2.go

Lines 180 to 191 in ac5b427

func ReadPCRs(rw io.ReadWriter, sel PCRSelection) (map[int][]byte, error) {
Cmd, err := encodeTPMLPCRSelection(sel)
if err != nil {
return nil, err
}
resp, err := runCommand(rw, TagNoSessions, CmdPCRRead, tpmutil.RawBytes(Cmd))
if err != nil {
return nil, err
}
return decodeReadPCRs(resp)
}

As you can see, the current implementation only runs the command once and expects the TPM to return all the selected PCRs. This works fine when you select up to 8 PCRs, but will return only the first 8 PCRs digests if you select more, as explained above.

In order to fix this, a similar approach to what tpm2-tools does is needed, that is, in the first call, send the whole TPML_PCR_SELECTION with all the wanted PCR bits set. After getting and parsing the first response, null out the bits of the PCRs we just retrieved in the TPML_PCR_SELECTION, check that it is not all zeroed out, then call TPM2_PCR_READ once more on the new TPML_PCR_SELECTION, etc...

from go-tpm.

twitchy-jsonp avatar twitchy-jsonp commented on May 19, 2024

As @ElMostafaIdrassi explained, a single call to read PCRs can only read a few PCRs at a time. In go-attestation, we read all the PCRs using a loop, like this:

https://github.com/google/go-attestation/blob/2453c8f39a4ff46009f6a9db6fb7c6cca789d9a1/attest/tpm.go#L232

from go-tpm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.