Fix lints; run gofmt (#293)

$ gofmt -s -w .
This commit is contained in:
Brandon Weeks 2022-11-01 12:19:57 -07:00 committed by GitHub
parent 17f9c05652
commit 438907edb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 42 deletions

View File

@ -383,7 +383,7 @@ func (a *AKPublic) validate20Quote(quote Quote, pcrs []PCR, nonce []byte) error
sigHash.Write(digest) sigHash.Write(digest)
} }
for index, _ := range pcrByIndex { for index := range pcrByIndex {
if _, exists := quotePCRs[index]; !exists { if _, exists := quotePCRs[index]; !exists {
return fmt.Errorf("provided PCR %d was not included in quote", index) return fmt.Errorf("provided PCR %d was not included in quote", index)
} }

View File

@ -81,7 +81,7 @@ func (k *windowsKey12) quote(tb tpmBase, nonce []byte, alg HashAlg) (*Quote, err
} }
selectedPCRs := make([]int, 24) selectedPCRs := make([]int, 24)
for pcr, _ := range selectedPCRs { for pcr := range selectedPCRs {
selectedPCRs[pcr] = pcr selectedPCRs[pcr] = pcr
} }

View File

@ -369,8 +369,8 @@ func (h *winPCP) Close() error {
return closeNCryptObject(h.hProv) return closeNCryptObject(h.hProv)
} }
// DeleteKey permanently removes the key with the given handle // DeleteKey permanently removes the key with the given handle from the system,
// from the system, and frees its handle. // and frees its handle.
func (h *winPCP) DeleteKey(kh uintptr) error { func (h *winPCP) DeleteKey(kh uintptr) error {
r, _, msg := nCryptDeleteKey.Call(kh, 0) r, _, msg := nCryptDeleteKey.Call(kh, 0)
if r != 0 { if r != 0 {

View File

@ -11,7 +11,6 @@ import (
// Generated using the following command: // Generated using the following command:
// //
// openssl genrsa 2048|openssl rsa -outform PEM -pubout // openssl genrsa 2048|openssl rsa -outform PEM -pubout
//
var testRSAKey = mustParseRSAKey(`-----BEGIN PUBLIC KEY----- var testRSAKey = mustParseRSAKey(`-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq8zyTXCjVALZzjS8wgNH MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq8zyTXCjVALZzjS8wgNH
nAVdt4ZGM3N450xOnLplx/RbCVwXyu83SWh0B3Ka+92aocqcHzo+j6e6Urppre/I nAVdt4ZGM3N450xOnLplx/RbCVwXyu83SWh0B3Ka+92aocqcHzo+j6e6Urppre/I

View File

@ -31,7 +31,7 @@ func TestParseWinEvents(t *testing.T) {
CodeIntegrityEnabled: TernaryTrue, CodeIntegrityEnabled: TernaryTrue,
BitlockerUnlocks: []BitlockerStatus{0, 0}, BitlockerUnlocks: []BitlockerStatus{0, 0},
LoadedModules: map[string]WinModuleLoad{ LoadedModules: map[string]WinModuleLoad{
"0fdce7d71936f79445e7d2c84cbeb97c948d3730e0b839166b0a4e625c2d4547": WinModuleLoad{ "0fdce7d71936f79445e7d2c84cbeb97c948d3730e0b839166b0a4e625c2d4547": {
FilePath: `\Windows\System32\drivers\vioscsi.sys`, FilePath: `\Windows\System32\drivers\vioscsi.sys`,
ImageBase: []uint64{81416192}, ImageBase: []uint64{81416192},
ImageSize: uint64(86016), ImageSize: uint64(86016),
@ -49,7 +49,7 @@ func TestParseWinEvents(t *testing.T) {
}, },
AuthenticodeHash: []byte{15, 220, 231, 215, 25, 54, 247, 148, 69, 231, 210, 200, 76, 190, 185, 124, 148, 141, 55, 48, 224, 184, 57, 22, 107, 10, 78, 98, 92, 45, 69, 71}, AuthenticodeHash: []byte{15, 220, 231, 215, 25, 54, 247, 148, 69, 231, 210, 200, 76, 190, 185, 124, 148, 141, 55, 48, 224, 184, 57, 22, 107, 10, 78, 98, 92, 45, 69, 71},
}, },
"055a36a9921b98cc04042ca95249c7eca655536868dafcec7508947ebe5e71f4": WinModuleLoad{ "055a36a9921b98cc04042ca95249c7eca655536868dafcec7508947ebe5e71f4": {
FilePath: `\Windows\System32\Drivers\ksecpkg.sys`, FilePath: `\Windows\System32\Drivers\ksecpkg.sys`,
ImageBase: []uint64{82952192}, ImageBase: []uint64{82952192},
ImageSize: uint64(204800), ImageSize: uint64(204800),
@ -67,7 +67,7 @@ func TestParseWinEvents(t *testing.T) {
}, },
AuthenticodeHash: []byte{5, 90, 54, 169, 146, 27, 152, 204, 4, 4, 44, 169, 82, 73, 199, 236, 166, 85, 83, 104, 104, 218, 252, 236, 117, 8, 148, 126, 190, 94, 113, 244}, AuthenticodeHash: []byte{5, 90, 54, 169, 146, 27, 152, 204, 4, 4, 44, 169, 82, 73, 199, 236, 166, 85, 83, 104, 104, 218, 252, 236, 117, 8, 148, 126, 190, 94, 113, 244},
}, },
"2bedd1589410b6fa13c82f35db735025b6a160595922750248771f5abd0fee58": WinModuleLoad{ "2bedd1589410b6fa13c82f35db735025b6a160595922750248771f5abd0fee58": {
FilePath: `\Windows\System32\drivers\volmgrx.sys`, FilePath: `\Windows\System32\drivers\volmgrx.sys`,
ImageBase: []uint64{80875520}, ImageBase: []uint64{80875520},
ImageSize: uint64(405504), ImageSize: uint64(405504),
@ -87,7 +87,7 @@ func TestParseWinEvents(t *testing.T) {
}, },
}, },
ELAM: map[string]WinELAM{ ELAM: map[string]WinELAM{
"Windows Defender": WinELAM{Measured: []byte{0x06, 0x7d, 0x5b, 0x9d, 0xc5, 0x62, 0x7f, 0x97, 0xdc, 0xf3, 0xfe, 0xff, 0x60, 0x2a, 0x34, 0x2e, 0xd6, 0x98, 0xd2, 0xcc}}, "Windows Defender": {Measured: []byte{0x06, 0x7d, 0x5b, 0x9d, 0xc5, 0x62, 0x7f, 0x97, 0xdc, 0xf3, 0xfe, 0xff, 0x60, 0x2a, 0x34, 0x2e, 0xd6, 0x98, 0xd2, 0xcc}},
}, },
} }
@ -121,7 +121,7 @@ func TestParseWinEvents(t *testing.T) {
"055a36a9921b98cc04042ca95249c7eca655536868dafcec7508947ebe5e71f4": true, "055a36a9921b98cc04042ca95249c7eca655536868dafcec7508947ebe5e71f4": true,
"2bedd1589410b6fa13c82f35db735025b6a160595922750248771f5abd0fee58": true, "2bedd1589410b6fa13c82f35db735025b6a160595922750248771f5abd0fee58": true,
} }
for k, _ := range winState.LoadedModules { for k := range winState.LoadedModules {
if _, keep := keep[k]; !keep { if _, keep := keep[k]; !keep {
delete(winState.LoadedModules, k) delete(winState.LoadedModules, k)
} }

View File

@ -161,14 +161,14 @@ type validity struct {
} }
// RFC 5280 4.2.1.4 // RFC 5280 4.2.1.4
type NoticeReference struct { type noticeReference struct {
Organization string Organization string
NoticeNumbers []int NoticeNumbers []int
} }
// RFC 5280 4.2.1.4 // RFC 5280 4.2.1.4
type userNotice struct { type userNotice struct {
NoticeRef NoticeReference `asn1:"optional"` NoticeRef noticeReference `asn1:"optional"`
ExplicitText string `asn1:"optional"` ExplicitText string `asn1:"optional"`
} }

View File

@ -42,6 +42,9 @@ func marshalOtherName(typeID asn1.ObjectIdentifier, value interface{}) (asn1.Raw
return asn1.RawValue{FullBytes: bytes}, nil return asn1.RawValue{FullBytes: bytes}, nil
} }
// PermanentIdentifier represents an ASN.1 encoded "permanent identifier" as
// defined by RFC4043.
//
// PermanentIdentifier ::= SEQUENCE { // PermanentIdentifier ::= SEQUENCE {
// identifierValue UTF8String OPTIONAL, // identifierValue UTF8String OPTIONAL,
// assigner OBJECT IDENTIFIER OPTIONAL // assigner OBJECT IDENTIFIER OPTIONAL