Created
July 6, 2022 15:03
-
-
Save chrisccoulson/c57a3af290ee79f7d12a7cf0b8daa5d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/canonical/go-tpm2" | |
"github.com/canonical/go-tpm2/linux" | |
) | |
func run() error { | |
tcti, err := linux.OpenDevice("/dev/tpm0") | |
if err != nil { | |
return fmt.Errorf("cannot open TPM device: %v", err) | |
} | |
tpm := tpm2.NewTPMContext(tcti) | |
defer tpm.Close() | |
v, err := tpm.GetCapabilityTPMProperty(tpm2.PropertyLockoutCounter) | |
if err != nil { | |
return fmt.Errorf("cannot obtain lockout counter value: %v", err) | |
} | |
if v != 0 { | |
return fmt.Errorf("lockout counter is non-zero (%d)", v) | |
} | |
return nil | |
} | |
func main() { | |
if err := run(); err != nil { | |
fmt.Fprintln(os.Stderr, err) | |
os.Exit(1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment