google / go-tpm

Apache License 2.0
562 stars 161 forks source link

Support As(TPMRC) for format-1 errors. #340

Open chrisfenner opened 1 year ago

chrisfenner commented 1 year ago

Ideally this always gives a canonical code, even if the error is a TPM format-1 error code (bearing handle and other metadata):

_, err := tpm2.SomeCommand{}.Execute(tpm)
var rc tpm2.TPMRC
if errors.As(err, &rc) {
  fmt.Printf("TPM canonical code: %v\n", rc)
}