Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some example binaries #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chrisccoulson
Copy link
Collaborator

This adds some example binaries which are useful for manual testing:

  • activate-volume: An example that makes use of ActivateVolumeWithTPMSealedKey
    and ActivateVolumeWithRecoveryKey.
  • change-pin: An example that makes use of ChangePIN.
  • provision-status: An example that makes use of ProvisionStatus.
  • provision-tpm: An example that makes use of ProvistionTPM.
  • seal-key: An example that makes use of SealKeyToTPM to seal a key to PCR7
    on Ubuntu classic systems.
  • unseal-key: An example that makes use of SealedKeyObject.UnsealFromTPM.

This adds some example binaries which are useful for manual testing:

- activate-volume: An example that makes use of ActivateVolumeWithTPMSealedKey
and ActivateVolumeWithRecoveryKey.
- change-pin: An example that makes use of ChangePIN.
- provision-status: An example that makes use of ProvisionStatus.
- provision-tpm: An example that makes use of ProvistionTPM.
- seal-key: An example that makes use of SealKeyToTPM to seal a key to PCR7
on Ubuntu classic systems.
- unseal-key: An example that makes use of SealedKeyObject.UnsealFromTPM.
Copy link
Member

@cmatsuoka cmatsuoka left a comment

Choose a reason for hiding this comment

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

Thanks Chris. It's always nice to have examples for the most important operations. I left a few notes and comments but all the example files are functional and accomplish their goals (even if the fprintf/return 1 pattern feels a bit C-ish). There's also a question about the expected value of the provisioning status after a TPM clear since my Lenovo machine and swtpm behave differently in this situation.

"github.com/snapcore/secboot"
)

func run() int {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be more idiomatic to return an error instead of the OS error code directly, printing the error message and exiting with the appropriate code in main().

recoveryTries := 1
var activateOptions []string

if len(args) >= 5 && args[4] != "" && args[4] != "-" && args[4] != "none" {
Copy link
Member

Choose a reason for hiding this comment

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

This command line argument parsing looks familiar, possibly the same one used in the old unlock utility? :)

authReader = f
}

if !forceRecovery {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of the if/else we could invert the test, process the forced recovery and exit, leaving the non-forced in the normal execution flow.

fmt.Println("** ERROR: TPM does not have a valid EK **")
}

if status&secboot.AttrDAParamsOK > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I noticed that on my Lenovo test machine the DA parameters stay configured after clearing the TPM, or at least its status attribute is the only one that remains enabled. Is that a normal/expected TPM behavior? In swtpm all attributes are unset.

args := flag.Args()

if requestClear {
if err := secboot.RequestTPMClearUsingPPI(); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

In the Lenovo test machine we see a "Press F12 to clear the TPM" message in the next boot. I wonder how embedded headless systems handle this request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants