{"action":"created","issue":{"url":"https://api.github.com/repos/tpm2-software/tpm2-tss/issues/720","repository_url":"https://api.github.com/repos/tpm2-software/tpm2-tss","labels_url":"https://api.github.com/repos/tpm2-software/tpm2-tss/issues/720/labels{/name}","comments_url":"https://api.github.com/repos/tpm2-software/tpm2-tss/issues/720/comments","events_url":"https://api.github.com/repos/tpm2-software/tpm2-tss/issues/720/events","html_url":"https://github.com/tpm2-software/tpm2-tss/issues/720","id":288183646,"number":720,"title":"TPMU_NAME marshalling","user":{"login":"flihp","id":1550813,"avatar_url":"https://avatars2.githubusercontent.com/u/1550813?v=4","gravatar_id":"","url":"https://api.github.com/users/flihp","html_url":"https://github.com/flihp","followers_url":"https://api.github.com/users/flihp/followers","following_url":"https://api.github.com/users/flihp/following{/other_user}","gists_url":"https://api.github.com/users/flihp/gists{/gist_id}","starred_url":"https://api.github.com/users/flihp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flihp/subscriptions","organizations_url":"https://api.github.com/users/flihp/orgs","repos_url":"https://api.github.com/users/flihp/repos","events_url":"https://api.github.com/users/flihp/events{/privacy}","received_events_url":"https://api.github.com/users/flihp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"tstruk","id":1063257,"avatar_url":"https://avatars0.githubusercontent.com/u/1063257?v=4","gravatar_id":"","url":"https://api.github.com/users/tstruk","html_url":"https://github.com/tstruk","followers_url":"https://api.github.com/users/tstruk/followers","following_url":"https://api.github.com/users/tstruk/following{/other_user}","gists_url":"https://api.github.com/users/tstruk/gists{/gist_id}","starred_url":"https://api.github.com/users/tstruk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tstruk/subscriptions","organizations_url":"https://api.github.com/users/tstruk/orgs","repos_url":"https://api.github.com/users/tstruk/repos","events_url":"https://api.github.com/users/tstruk/events{/privacy}","received_events_url":"https://api.github.com/users/tstruk/received_events","type":"User","site_admin":false},"assignees":[{"login":"tstruk","id":1063257,"avatar_url":"https://avatars0.githubusercontent.com/u/1063257?v=4","gravatar_id":"","url":"https://api.github.com/users/tstruk","html_url":"https://github.com/tstruk","followers_url":"https://api.github.com/users/tstruk/followers","following_url":"https://api.github.com/users/tstruk/following{/other_user}","gists_url":"https://api.github.com/users/tstruk/gists{/gist_id}","starred_url":"https://api.github.com/users/tstruk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tstruk/subscriptions","organizations_url":"https://api.github.com/users/tstruk/orgs","repos_url":"https://api.github.com/users/tstruk/repos","events_url":"https://api.github.com/users/tstruk/events{/privacy}","received_events_url":"https://api.github.com/users/tstruk/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/tpm2-software/tpm2-tss/milestones/24","html_url":"https://github.com/tpm2-software/tpm2-tss/milestone/24","labels_url":"https://api.github.com/repos/tpm2-software/tpm2-tss/milestones/24/labels","id":3031805,"number":24,"title":"2.0 bugs","description":"bugs that must be fixed before 2.0 release","creator":{"login":"flihp","id":1550813,"avatar_url":"https://avatars2.githubusercontent.com/u/1550813?v=4","gravatar_id":"","url":"https://api.github.com/users/flihp","html_url":"https://github.com/flihp","followers_url":"https://api.github.com/users/flihp/followers","following_url":"https://api.github.com/users/flihp/following{/other_user}","gists_url":"https://api.github.com/users/flihp/gists{/gist_id}","starred_url":"https://api.github.com/users/flihp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flihp/subscriptions","organizations_url":"https://api.github.com/users/flihp/orgs","repos_url":"https://api.github.com/users/flihp/repos","events_url":"https://api.github.com/users/flihp/events{/privacy}","received_events_url":"https://api.github.com/users/flihp/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2018-01-12T16:34:00Z","updated_at":"2018-01-12T17:00:04Z","due_on":"2018-02-28T08:00:00Z","closed_at":null},"comments":5,"created_at":"2018-01-12T17:00:04Z","updated_at":"2018-02-01T19:19:09Z","closed_at":null,"author_association":"OWNER","body":"See the discussion here: #719 \r\n\r\nThe `TPMU_NAME` marshalling and unmarshalling functions are special cases. There is no selector defined for this type. Instead part 2 of the spec [1] describes (in section 10.5.3) how the selector should be determined. It uses the size of the `TPMU_NAME` as indicated by the `size` field in the `TPM2B_NAME` structure. This is mentioned in a note in the marshalling spec. Thus our selector is effectively the size field where acceptable size values are:\r\n4 (aka sizeof (UINT32)) -> selects TPMU_NAME->handle and does marshalling for a handle\r\n0 -> no name value present (marshal / unmarshal no-op)\r\nsizeof (hash) -> hash specific marshal / unmarshal (one for each supported hash function)\r\n\r\nThe marshalling spec requires that `TSS2_MU_RC_BAD_VALUE` be returned for invalid selector values so all other size values should produce this RC.\r\n\r\nThe thing that's bothering me is that [1] defines the TPM2B_NAME structure in table 84 as:\r\n\r\n|Parameter | Type | Description|\r\n|-----------|-------|-------------|\r\n|size|UINT16|size of the name structure|\r\n|name[size]{:sizeof(TPMU_NAME)}|BYTE|the Name structure|\r\n\r\nThis seems wrong to me though since the `name` field cannot be treated as a BYTE array when it's a handle. Treating it as one will result in the handle being marshalled in network byte order. The text in the spec: `If size is four, then the Name is a handle.` clarifies this but it makes me wonder if there are other structures that suffer from this similar issue.\r\n\r\n@tstruk : Interested in your thoughts on this whole thing. Likely it's something you've thought a great deal about while doing the implementation.\r\n\r\n[1] - https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf\r\n[2] - https://trustedcomputinggroup.org/wp-content/uploads/TSS_Marshaling_Unmarshaling_API_Version-1.0_Revision-04_review_ENDS030918.pdf"},"comment":{"url":"https://api.github.com/repos/tpm2-software/tpm2-tss/issues/comments/362372618","html_url":"https://github.com/tpm2-software/tpm2-tss/issues/720#issuecomment-362372618","issue_url":"https://api.github.com/repos/tpm2-software/tpm2-tss/issues/720","id":362372618,"user":{"login":"flihp","id":1550813,"avatar_url":"https://avatars2.githubusercontent.com/u/1550813?v=4","gravatar_id":"","url":"https://api.github.com/users/flihp","html_url":"https://github.com/flihp","followers_url":"https://api.github.com/users/flihp/followers","following_url":"https://api.github.com/users/flihp/following{/other_user}","gists_url":"https://api.github.com/users/flihp/gists{/gist_id}","starred_url":"https://api.github.com/users/flihp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flihp/subscriptions","organizations_url":"https://api.github.com/users/flihp/orgs","repos_url":"https://api.github.com/users/flihp/repos","events_url":"https://api.github.com/users/flihp/events{/privacy}","received_events_url":"https://api.github.com/users/flihp/received_events","type":"User","site_admin":false},"created_at":"2018-02-01T19:19:09Z","updated_at":"2018-02-01T19:19:09Z","author_association":"OWNER","body":"Not sure I follow your bit about the context. Marshalling based on size really just means the size tells you what's being marshalled. So if it's 4 bytes then it's a handle, if it's one of the supported hash algorithm sizes (https://github.com/tpm2-software/tpm2-tss/blob/master/include/sapi/tss2_tpm2_types.h#L56) then it's marshalled as a hash. At least that seems to be the most simple reading of it and it seems logical to me. Agree / Disagree?"}}
{"actor":{"display_login":"flihp"}}