Giter Club home page Giter Club logo

Comments (12)

akakou avatar akakou commented on June 2, 2024

Now I'm implementing the test code of TPM2_Commit, but not work.
Do you have any idea to solve this error?

go test -run TestCommit
--- FAIL: TestCommit (0.01s)
    commit_test.go:102: could not commit: TPM_RC_AUTH_MISSING: command requires an authorization session for handle and it is not present.
FAIL
exit status 1
FAIL    github.com/google/go-tpm/direct/tpm2    0.012s

https://github.com/akakou/go-tpm/blob/tpm2-commit/direct/tpm2/commit_test.go

from go-tpm.

chrisfenner avatar chrisfenner commented on June 2, 2024

Can you try removing the space between the comma-separated type annotations at https://github.com/akakou/go-tpm/blob/dafdbfea0c93185d68e8afe8eccf4c520fa48456/direct/tpm2/tpm2.go#L625? I.e.,

	SignHandle handle `gotpm:"handle,auth"`

from go-tpm.

akakou avatar akakou commented on June 2, 2024

Thank you! It's one of the bugs and I fixed it.
But it has never worked still...and panic with the error following:

--- FAIL: TestCommit (0.00s)
    commit_test.go:102: could not commit: TPM_RC_SIZE (handle 0): structure is the wrong size
FAIL
exit status 1
FAIL    github.com/google/go-tpm/direct/tpm2    0.008s

Do you have any idea?

from go-tpm.

akakou avatar akakou commented on June 2, 2024

I added to create a key that is not the primary key because the basic sample program needs to run TPM2_Create.
(But I don't know why it is needed.)

However, the program has the same error as before...

from go-tpm.

chrisfenner avatar chrisfenner commented on June 2, 2024
TPM_RC_SIZE (handle 0): structure is the wrong size

looks like an ill-formed error code to me. Handle indices start at 1, so "handle 0" doesn't make a lot of sense. I'm assuming the test code got back raw error code 0x95, but we should investigate whether there's a bug in the error interpretation stack. Filed #290 to follow up on our side.

Confession: I still don't understand ECDAA. Please correct me where my crypto veers astray 😅

P1: tpm2b.ECCPoint{
	Point: tpms.ECCPoint{
		X: tpm2b.ECCParameter{
			Buffer: []byte{
				0x1, 0x1,
			},
		},
		Y: tpm2b.ECCParameter{
			Buffer: []byte{0x1, 0x1},
		},
	},
	Size: 8,
},

P1 doesn't look like a real ECC point to me. Is 0x0101,0x0101 a legitimate BNP256 point?

Second issue, looks like you added TPM2B_ECC_Point but there is some subtlety about marshalling I need to point out:

// TPM2BECCPoint represents a TPM2B_ECC_POINT.
// See definition in Part 2: Structures, section 11.2.5.3.
type TPM2BECCPoint struct {
	Size  uint16
	Point TPMSECCPoint
}

In go-tpm tpmdirect, sized 2Bs' sizes are never passed in by the user. Instead they are computed on the fly. Can you fix this to

// TPM2BECCPoint represents a TPM2B_ECC_POINT.
// See definition in Part 2: Structures, section 11.2.5.3.
type TPM2BECCPoint struct {
	Point TPMSECCPoint `gotpm:"sized"`
}

The sized type annotation instructs the marshalling/unmarshlaling

from go-tpm.

akakou avatar akakou commented on June 2, 2024

Thank you! You are right and I fixed them.

Specifically, I fixed them as:

  1. Set x=0x1, y=0x2 to P1.
  2. Use annotation to express the size of TPM2B_ECC_POINT

from go-tpm.

akakou avatar akakou commented on June 2, 2024

But the program calls the same error...

from go-tpm.

akakou avatar akakou commented on June 2, 2024

I compared worked TPM2_Commit(tpm2-tools) and this library.
Mainly, I compared what binaries each library sent to TPM.

These are the binaries:

go-tpm

\x80\x02\x00\x00\x00\x40\x00\x00\x01\x91\x40\x00\x00\x01\x00\x00\x00\x09\x40\x00\x00\x09\x00\x00\x00\x00\x00\x00\x07\x00\x03\x00\x01\x03\x00\x00\x00\x1a\x00\x23\x00\x04\x00\x04\x00\x72\x00\x00\x00\x10\x00\x1a\x00\x0b\x00\x00\x00\x10\x00\x10\x00\x00\x00\x00

tpm2-tools

\x80\x02\x00\x00\x00\x65\x00\x00\x01\x8b\x80\xff\xff\xff\x00\x00\x00\x49\x02\x00\x00\x00\x00\x20\x14\xe2\x02\x60\x66\x57\x5f\x9c\xab\x50\x13\x21\x36\x37\xc3\xfd\x24\x86\xf8\xae\x9f\xa1\x0b\x62\x3e\x4a\x00\xa8\x91\x8d\xf3\x10\x01\x00\x20\x2f\xc0\x53\x68\x30\xa0\x0b\xc3\x88\x5f\x43\xed\x73\x00\xa8\x79\x87\xae\x96\x5a\x78\xa3\xe1\xda\x40\xa4\xa0\x0d\xae\x11\x4f\xca\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00

from go-tpm.

akakou avatar akakou commented on June 2, 2024

Sorry...I had added the unnecessary parameter to the request of TPM2_Commit.
Specifically, we should not add the count to the request.

from go-tpm.

akakou avatar akakou commented on June 2, 2024

@chrisfenner

So I fixed it and it works.
Could you check the PR (#296) and merge it?

from go-tpm.

akakou avatar akakou commented on June 2, 2024

#296 (comment)

from go-tpm.

akakou avatar akakou commented on June 2, 2024

It is implemented at #296, so I closed this issue.

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.