Debian Codegraph @

attest/tpm_fake.go

raw symbols SCIP
1 package attestscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/"
5 "encoding/binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/"
6 "ioscip-go gomod github.com/golang/go/src go1.24.0 io/"
7 )
8
9 // fakeCmdChannel returns a fake TPM command channel that
10 // returns a measurement log with the algorithms that are present in the PCR banks.
11 type fakeCmdChannelscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/fakeCmdChannel# struct {
12 ioscip-go gomod github.com/golang/go/src go1.24.0 io/.ReadWriteCloserscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/fakeCmdChannel#ReadWriteCloser.
13 }
14
15 // MeasurementLog implements CommandChannelTPM20.
16 func (cc *fakeCmdChannelscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/fakeCmdChannel#) MeasurementLogscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/fakeCmdChannel#MeasurementLog().() ([]byte, error) {
17 algs, err := pcrbanksscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/pcrbanks().(cc.ReadWriteCloserscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/fakeCmdChannel#ReadWriteCloser.)
18 if err != nil {
19 return nil, err
20 }
21 return generateMeasurementLogscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/generateMeasurementLog().(algs), nil
22 }
23
24 func generateMeasurementLogscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/generateMeasurementLog().(algs []HashAlgscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/HashAlg#) []byte {
25 specIDEventHeader := generateSpecIDEventHeaderscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/generateSpecIDEventHeader().(algs)
26 raw := rawEventHeaderscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/rawEventHeader#{
27 PCRIndexscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/rawEventHeader#PCRIndex.: 0,
28 Typescip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/rawEventHeader#Type.: eventTypeNoActionscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/eventTypeNoAction.,
29 Digestscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/rawEventHeader#Digest.: [20]byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
30 EventSizescip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/rawEventHeader#EventSize.: uint32(len(specIDEventHeader)),
31 }
32 var rawBytes bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer#
33
34 if err := binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.Writescip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/Write().(&rawBytes, binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.LittleEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/LittleEndian., &raw); err != nil {
35 panic(err)
36 }
37 if err := binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.Writescip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/Write().(&rawBytes, binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.LittleEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/LittleEndian., specIDEventHeader); err != nil {
38 panic(err)
39 }
40 return rawBytes.Bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer#Bytes().()
41 }
42
43 func generateSpecIDEventHeaderscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/generateSpecIDEventHeader().(algs []HashAlgscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/HashAlg#) []byte {
44 specIDEventHeader := specIDEventHeaderscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/specIDEventHeader#{
45 NumAlgsscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/specIDEventHeader#NumAlgs.: uint32(len(algs)),
46 Signaturescip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/specIDEventHeader#Signature.: wantSignaturescip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/wantSignature.,
47 VersionMajorscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/specIDEventHeader#VersionMajor.: wantMajorscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/wantMajor.,
48 VersionMinorscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/specIDEventHeader#VersionMinor.: wantMinorscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/wantMinor.,
49 Erratascip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/specIDEventHeader#Errata.: wantErratascip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/wantErrata.,
50 UintnSizescip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/specIDEventHeader#UintnSize.: 0,
51 PlatformClassscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/specIDEventHeader#PlatformClass.: 0,
52 }
53
54 // Write out the header.
55 var specIDEventHeaderBytes bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer#
56 if err := binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.Writescip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/Write().(&specIDEventHeaderBytes, binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.LittleEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/LittleEndian., &specIDEventHeader); err != nil {
57 panic(err)
58 }
59 // Write out the Algs.
60 for _, alg := range algs {
61 var specAlg specAlgSizescip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/specAlgSize#
62 specAlg.IDscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/specAlgSize#ID. = uint16(alg)
63 hash, err := alg.cryptoHashscip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/HashAlg#cryptoHash().()
64 if err != nil {
65 panic(err)
66 }
67 specAlg.Sizescip-go gomod github.com/google/go-attestation . `github.com/google/go-attestation/attest`/specAlgSize#Size. = uint16(hash.Sizescip-go gomod github.com/golang/go/src go1.24.0 crypto/Hash#Size().())
68 if err := binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.Writescip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/Write().(&specIDEventHeaderBytes, binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.LittleEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/LittleEndian., &specAlg); err != nil {
69 panic(err)
70 }
71 }
72 // No vendor info.
73 vendorInfoSize := uint8(0)
74 if err := binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.Writescip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/Write().(&specIDEventHeaderBytes, binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.LittleEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/LittleEndian., &vendorInfoSize); err != nil {
75 panic(err)
76 }
77
78 return specIDEventHeaderBytes.Bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer#Bytes().()
79 }