diff --git a/attest/attest_simulated_tpm20_test.go b/attest/attest_simulated_tpm20_test.go index 29c9ac4..8743f7d 100644 --- a/attest/attest_simulated_tpm20_test.go +++ b/attest/attest_simulated_tpm20_test.go @@ -114,7 +114,7 @@ func TestSimTPM20ActivateCredential(t *testing.T) { ap := ActivationParameters{ TPMVersion: TPMVersion20, - AK: ak.AttestationParameters(), + AK: ak.AttestationParameters(), EK: ek, } secret, challenge, err := ap.Generate() diff --git a/attest/attest_tpm12_test.go b/attest/attest_tpm12_test.go index 35e92c8..b3db566 100644 --- a/attest/attest_tpm12_test.go +++ b/attest/attest_tpm12_test.go @@ -150,7 +150,7 @@ func TestTPMActivateCredential(t *testing.T) { ap := ActivationParameters{ TPMVersion: TPMVersion12, - AK: ak.AttestationParameters(), + AK: ak.AttestationParameters(), EK: ek, } secret, challenge, err := ap.Generate() diff --git a/attest/eventlog_fuzz.go b/attest/eventlog_fuzz.go index 94566aa..84c829f 100644 --- a/attest/eventlog_fuzz.go +++ b/attest/eventlog_fuzz.go @@ -16,6 +16,8 @@ package attest +// FuzzParseEventLog is an exported entrypoint for fuzzers to test the eventlog +// parser. This method should not be used for any other purpose. func FuzzParseEventLog(data []byte) int { _, err := ParseEventLog(data) if err != nil { diff --git a/attest/eventlog_test.go b/attest/eventlog_test.go index 169aa60..c0572f5 100644 --- a/attest/eventlog_test.go +++ b/attest/eventlog_test.go @@ -161,7 +161,7 @@ func TestParseSpecIDEvent(t *testing.T) { data: append( []byte("Spec ID Event03"), 0x0, 0x0, 0x0, 0x0, 0x0, // platform class - 0x0, // verison minor + 0x0, // version minor 0x2, // version major 0x0, // errata 0x8, // uintn size @@ -178,7 +178,7 @@ func TestParseSpecIDEvent(t *testing.T) { data: append( []byte("Spec ID Event03"), 0x0, 0x0, 0x0, 0x0, 0x0, // platform class - 0x0, // verison minor + 0x0, // version minor 0x2, // version major 0x0, // errata 0x8, // uintn size @@ -197,7 +197,7 @@ func TestParseSpecIDEvent(t *testing.T) { data: append( []byte("Spec ID Event03"), 0x0, 0x0, 0x0, 0x0, 0x0, // platform class - 0x2, // verison minor + 0x2, // version minor 0x1, // version major 0x0, // errata 0x8, // uintn size @@ -216,7 +216,7 @@ func TestParseSpecIDEvent(t *testing.T) { data: append( []byte("Spec ID Event03"), 0x0, 0x0, 0x0, 0x0, 0x0, // platform class - 0x0, // verison minor + 0x0, // version minor 0x2, // version major 0x0, // errata 0x8, // uintn size diff --git a/attest/example_test.go b/attest/example_test.go index 0c3b9dd..057a237 100644 --- a/attest/example_test.go +++ b/attest/example_test.go @@ -72,7 +72,7 @@ func ExampleAK_credentialActivation() { activation := attest.ActivationParameters{ TPMVersion: tpm.Version(), EK: ek[0].Public, - AK: ap, + AK: ap, } secret, challenge, err := activation.Generate() if err != nil { diff --git a/attest/tpm.go b/attest/tpm.go index 182f807..5a6721f 100644 --- a/attest/tpm.go +++ b/attest/tpm.go @@ -100,18 +100,18 @@ var ( ) func cryptoHash(h tpm2.Algorithm) (crypto.Hash, error) { - switch h { - case tpm2.AlgSHA1: - return crypto.SHA1, nil - case tpm2.AlgSHA256: - return crypto.SHA256, nil - case tpm2.AlgSHA384: - return crypto.SHA384, nil - case tpm2.AlgSHA512: - return crypto.SHA512, nil - default: - return crypto.Hash(0), fmt.Errorf("unsupported signature digest: %v", h) - } + switch h { + case tpm2.AlgSHA1: + return crypto.SHA1, nil + case tpm2.AlgSHA256: + return crypto.SHA256, nil + case tpm2.AlgSHA384: + return crypto.SHA384, nil + case tpm2.AlgSHA512: + return crypto.SHA512, nil + default: + return crypto.Hash(0), fmt.Errorf("unsupported signature digest: %v", h) + } } type tpm20Info struct { diff --git a/attest/tpm_other.go b/attest/tpm_other.go index ca914f5..ce743ca 100644 --- a/attest/tpm_other.go +++ b/attest/tpm_other.go @@ -20,17 +20,17 @@ import ( "errors" ) -var unsupportedError = errors.New("tpm operations not supported from given build parameters") +var errUnsupported = errors.New("tpm operations not supported from given build parameters") type platformTPM struct { } func probeSystemTPMs() ([]probedTPM, error) { - return nil, unsupportedError + return nil, errUnsupported } func openTPM(tpm probedTPM) (*TPM, error) { - return nil, unsupportedError + return nil, errUnsupported } func (t *platformTPM) tpmVersion() TPMVersion { @@ -39,29 +39,29 @@ func (t *platformTPM) tpmVersion() TPMVersion { func (t *platformTPM) close() error { - return unsupportedError + return errUnsupported } func (t *platformTPM) info() (*TPMInfo, error) { - return nil, unsupportedError + return nil, errUnsupported } func (t *platformTPM) loadAK(opaqueBlob []byte) (*AK, error) { - return nil, unsupportedError + return nil, errUnsupported } func (t *platformTPM) eks() ([]EK, error) { - return nil, unsupportedError + return nil, errUnsupported } func (t *platformTPM) newAK(opts *AKConfig) (*AK, error) { - return nil, unsupportedError + return nil, errUnsupported } func (t *platformTPM) pcrs(alg HashAlg) ([]PCR, error) { - return nil, unsupportedError + return nil, errUnsupported } func (t *platformTPM) measurementLog() ([]byte, error) { - return nil, unsupportedError + return nil, errUnsupported }