{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TSS.MSR/issues/4","repository_url":"https://api.github.com/repos/Microsoft/TSS.MSR","labels_url":"https://api.github.com/repos/Microsoft/TSS.MSR/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TSS.MSR/issues/4/comments","events_url":"https://api.github.com/repos/Microsoft/TSS.MSR/issues/4/events","html_url":"https://github.com/Microsoft/TSS.MSR/issues/4","id":174395083,"number":4,"title":"TSS.CPP Tpm2::NV_DefineSpace errors with code TPM_RC::BAD_AUTH (0xA2) for TpmTbsDevice","user":{"login":"AdditionalPylons","id":1009039,"avatar_url":"https://avatars.githubusercontent.com/u/1009039?v=3","gravatar_id":"","url":"https://api.github.com/users/AdditionalPylons","html_url":"https://github.com/AdditionalPylons","followers_url":"https://api.github.com/users/AdditionalPylons/followers","following_url":"https://api.github.com/users/AdditionalPylons/following{/other_user}","gists_url":"https://api.github.com/users/AdditionalPylons/gists{/gist_id}","starred_url":"https://api.github.com/users/AdditionalPylons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdditionalPylons/subscriptions","organizations_url":"https://api.github.com/users/AdditionalPylons/orgs","repos_url":"https://api.github.com/users/AdditionalPylons/repos","events_url":"https://api.github.com/users/AdditionalPylons/events{/privacy}","received_events_url":"https://api.github.com/users/AdditionalPylons/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-31T22:32:50Z","updated_at":"2016-09-01T23:20:34Z","closed_at":"2016-09-01T23:20:34Z","body":"I have the following simple code:\r\n\r\n``` \r\nauto device = TpmTbsDevice();\r\n\r\n\tif(!device.Connect())\r\n\t{\r\n\t\treturn 1;\r\n\t}\r\n\r\n\tTpm2 tpm(device);\r\n\r\n\tByteVec nvAuth = { '1', '2', '3', '4' };\r\n\r\n\tTPM_HANDLE nvHandle = TPM_HANDLE::NVHandle(100);\r\n\r\n\tByteVec policy = {};\r\n\r\n\tTPMS_NV_PUBLIC nvTemplate(nvHandle, TPM_ALG_ID::SHA256, TPMA_NV::AUTHWRITE, policy, 20);\r\n\r\n\tTPM_HANDLE ownerHandle = TPM_HANDLE::FromReservedHandle(TPM_RH::OWNER);\r\n\t// ownerHandle.setAuth(...)\r\n\t\r\n\ttry\r\n\t{\r\n\t\ttpm.NV_DefineSpace(ownerHandle, nvAuth, nvTemplate);\r\n\t} \r\n\tcatch(system_error e)\r\n\t{\r\n\t\t\r\n\t}\r\n```\r\n\r\nYet it fails with return code BAD_AUTH, indicating a failure when trying to authorize the command.\r\n\r\nI've tried two ways of setting the Owner Authorization: First by retrieving it from Tbsi_Get_OwnerAuth, and second by changing the password to something trivial, such as \"12345678\" and setting the auth to that string. Both yield the same error.\r\n\r\nI've even tried crafting my own command buffer and calling Tbsip_Submit_Command directly, which also gives me the same error. \r\n\r\nAm I setting the auth incorrectly? \r\n\r\nI'm testing this on Windows Server 2012 R2, with a TPM 2.0 family chip. The reported Manufacturer name is \"IFX v5.50\" from the TPM management console.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TSS.MSR/issues/comments/244241410","html_url":"https://github.com/Microsoft/TSS.MSR/issues/4#issuecomment-244241410","issue_url":"https://api.github.com/repos/Microsoft/TSS.MSR/issues/4","id":244241410,"user":{"login":"AdditionalPylons","id":1009039,"avatar_url":"https://avatars.githubusercontent.com/u/1009039?v=3","gravatar_id":"","url":"https://api.github.com/users/AdditionalPylons","html_url":"https://github.com/AdditionalPylons","followers_url":"https://api.github.com/users/AdditionalPylons/followers","following_url":"https://api.github.com/users/AdditionalPylons/following{/other_user}","gists_url":"https://api.github.com/users/AdditionalPylons/gists{/gist_id}","starred_url":"https://api.github.com/users/AdditionalPylons/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdditionalPylons/subscriptions","organizations_url":"https://api.github.com/users/AdditionalPylons/orgs","repos_url":"https://api.github.com/users/AdditionalPylons/repos","events_url":"https://api.github.com/users/AdditionalPylons/events{/privacy}","received_events_url":"https://api.github.com/users/AdditionalPylons/received_events","type":"User","site_admin":false},"created_at":"2016-09-01T23:20:34Z","updated_at":"2016-09-01T23:20:34Z","body":"It seems you have to fetch the StorageOwnerAuth from HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Services\\TPM\\WMI\\Admin\r\n To authorize commands. There is probably a way to get it from an API but I'm not sure where it is yet, or if it's even available publicly."}}
{"actor":{"display_login":"AdditionalPylons"}}