Skip to content

Windows TPM enrollment support#25801

Merged
strideynet merged 41 commits intomasterfrom
strideynet/windows-tpm-enrollment
May 22, 2023
Merged

Windows TPM enrollment support#25801
strideynet merged 41 commits intomasterfrom
strideynet/windows-tpm-enrollment

Conversation

@strideynet
Copy link
Copy Markdown
Contributor

@strideynet strideynet commented May 8, 2023

As per https://github.com/gravitational/teleport.e/pull/911
Closes https://github.com/gravitational/teleport.e/issues/1163
Associated with https://github.com/gravitational/teleport.e/pull/1159 .
image

DeviceCollectedData {
  "collect_time": "2023-05-11T15:29:03.305882500Z",
  "os_type": "OS_TYPE_WINDOWS",
  "serial_number": "winaia_1337",
  "model_identifier": "21J50013US",
  "os_version": "10.0.22621",
  "os_username": "LAPTOP-LS1NN4BK\\noahstride",
  "reported_asset_tag": "winaia_1337",
  "system_serial_number": "PF47WND6",
  "base_board_serial_number": "L1HF2CM03ZT"
}

@strideynet strideynet force-pushed the strideynet/windows-tpm-enrollment branch from a5cafe7 to 2c958ba Compare May 10, 2023 11:45
@strideynet strideynet marked this pull request as ready for review May 15, 2023 11:41
@github-actions github-actions Bot requested review from codingllama and lxea May 15, 2023 11:42
@strideynet strideynet requested a review from codingllama May 17, 2023 12:20
Copy link
Copy Markdown
Contributor

@codingllama codingllama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, the vast majority of comments are inconsequential.

Apologies for the delay and thanks for splitting the other parts.

Comment thread lib/devicetrust/enroll/enroll.go
Comment thread lib/devicetrust/enroll/enroll.go Outdated
Comment thread lib/devicetrust/native/api.go Outdated
Comment thread lib/devicetrust/native/device_darwin.go Outdated
Comment thread lib/devicetrust/native/device_windows.go Outdated
Comment thread lib/devicetrust/enroll/enroll_test.go Outdated
Comment thread lib/devicetrust/enroll/enroll_test.go Outdated
Comment thread lib/devicetrust/enroll/enroll_test.go Outdated
Comment thread lib/devicetrust/enroll/enroll_test.go Outdated
Comment thread lib/devicetrust/enroll/enroll_test.go Outdated
Copy link
Copy Markdown
Contributor

@codingllama codingllama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, the vast majority of comments are inconsequential.

Apologies for the delay and thanks for splitting the other parts.

@strideynet strideynet requested a review from codingllama May 22, 2023 07:59
@strideynet
Copy link
Copy Markdown
Contributor Author

@codingllama ready for you to take another look 🦦

Comment thread lib/devicetrust/testenv/fake_device_service.go Outdated
Comment thread lib/devicetrust/enroll/enroll.go Outdated
Comment thread lib/devicetrust/native/device_windows.go
}
}

// getDeviceSerial returns the serial number of the device using PowerShell to
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed explanation, sounds good.

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from lxea May 22, 2023 16:43
@strideynet strideynet added this pull request to the merge queue May 22, 2023
Merged via the queue into master with commit 13dfbbc May 22, 2023
@strideynet strideynet deleted the strideynet/windows-tpm-enrollment branch May 22, 2023 17:08
@public-teleport-github-review-bot
Copy link
Copy Markdown

@strideynet See the table below for backport results.

Branch Result
branch/v13 Failed

Comment thread lib/devicetrust/native/device_windows.go
if os.IsNotExist(err) {
// If it doesn't exist, we can create it and return as we know
// the perms are correct as we created it.
if err := os.Mkdir(deviceStateDirPath, 700); err != nil {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about MkdirAll?

}
}

// getDeviceSerial returns the serial number of the device using PowerShell to
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @probakowski who has some experience calling win32 APIs via syscall. Przemko, do you think that would make sense here?

// PF47WND6
out, err := cmd.Output()
if err != nil {
return "", trace.Wrap(err)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it helpful to include out in the error message here, otherwise when this fails you'll just get an error message about a non-zero exit code and have no idea what went wrong.

Comment thread lib/devicetrust/native/device_windows.go
strideynet added a commit that referenced this pull request May 22, 2023
* Start implementation of Windows TPM enrollment

* Basic device data collection for windows

* Add AK get/creatiom

* Add helpers for converting tpm protos

* Don't create AK in inappropriate circumstances

* Furhter simplify AK load/create

* Add tests for proto/attest conversions

* Ensure that digestalg varies between test cases

* More accurate proto field name

* Missing license header

* Add credential fingerprinting function

* Add getDeviceCredential implementation for windows

* Add dependencies so this builds

* Fix generation of credential id

* Introduce AKPublic field

* Collect other key data

* Add some additional debug logging

* Add more specific serial number fields to dcd

* Use faster powershell call for determining OS version

* Fix missing field in DeviceFromResource

* Add link to to-do issue

* Add packages necessary for enterprise submodule

* Fix import orders

* bump go-tpm-tools to latest versions

* Tidy up returned errors

* Add failure case test for Linux enrollment

* move linux device fake to lib/devicetrust/testenv

* Add test to exercise `RunCeremony`

* Tidier assertion messages

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Further simplifcations of test assertions/errors

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Apply suggestions from code review

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* Further fixes as per the llama's suggestions

* Further simplification and header on logs

* Use BadParameter rather than platform unsupported

* Add further notes on RSAness of `go-attestation`

* Minor adjustments to comments

* Unused import removed

* License headers

* rename `mustRandomBytes` -> `randomBytes`

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
strideynet added a commit that referenced this pull request May 23, 2023
* Start implementation of Windows TPM enrollment

* Basic device data collection for windows

* Add AK get/creatiom

* Add helpers for converting tpm protos

* Don't create AK in inappropriate circumstances

* Furhter simplify AK load/create

* Add tests for proto/attest conversions

* Ensure that digestalg varies between test cases

* More accurate proto field name

* Missing license header

* Add credential fingerprinting function

* Add getDeviceCredential implementation for windows

* Add dependencies so this builds

* Fix generation of credential id

* Introduce AKPublic field

* Collect other key data

* Add some additional debug logging

* Add more specific serial number fields to dcd

* Use faster powershell call for determining OS version

* Fix missing field in DeviceFromResource

* Add link to to-do issue

* Add packages necessary for enterprise submodule

* Fix import orders

* bump go-tpm-tools to latest versions

* Tidy up returned errors

* Add failure case test for Linux enrollment

* move linux device fake to lib/devicetrust/testenv

* Add test to exercise `RunCeremony`

* Tidier assertion messages



* Further simplifcations of test assertions/errors



* Apply suggestions from code review



* Further fixes as per the llama's suggestions

* Further simplification and header on logs

* Use BadParameter rather than platform unsupported

* Add further notes on RSAness of `go-attestation`

* Minor adjustments to comments

* Unused import removed

* License headers

* rename `mustRandomBytes` -> `randomBytes`

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
@r0mant r0mant mentioned this pull request Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants